diff --git a/data/theme/gnome-shell.css b/data/theme/gnome-shell.css index 66698457c..24ac5798f 100644 --- a/data/theme/gnome-shell.css +++ b/data/theme/gnome-shell.css @@ -553,6 +553,7 @@ StTooltip { height: 70px; font-size: 10px; transition-duration: 100; + text-align: center; } .app-well-app.running { diff --git a/js/ui/appDisplay.js b/js/ui/appDisplay.js index 98dfb2f65..3a9e4c5a0 100644 --- a/js/ui/appDisplay.js +++ b/js/ui/appDisplay.js @@ -456,7 +456,6 @@ AppIcon.prototype = { box.add(this.icon, { expand: true, x_fill: false, y_fill: false }); this._name = new St.Label({ text: this.app.get_name() }); - this._name.clutter_text.line_alignment = Pango.Alignment.CENTER; box.add_actor(this._name); } }; diff --git a/src/st/st-private.c b/src/st/st-private.c index 1ebadf654..248c703d2 100644 --- a/src/st/st-private.c +++ b/src/st/st-private.c @@ -280,6 +280,7 @@ _st_set_text_from_style (ClutterText *text, PangoAttrList *attribs; const PangoFontDescription *font; gchar *font_string; + StTextAlign align; st_theme_node_get_foreground_color (theme_node, &color); clutter_text_set_color (text, &color); @@ -309,6 +310,15 @@ _st_set_text_from_style (ClutterText *text, clutter_text_set_attributes (text, attribs); pango_attr_list_unref (attribs); + + align = st_theme_node_get_text_align (theme_node); + if(align == ST_TEXT_ALIGN_JUSTIFY) { + clutter_text_set_justify (text, TRUE); + clutter_text_set_line_alignment (text, PANGO_ALIGN_LEFT); + } else { + clutter_text_set_justify (text, FALSE); + clutter_text_set_line_alignment (text, (PangoAlignment) align); + } } gboolean diff --git a/src/st/st-theme-node.c b/src/st/st-theme-node.c index 08a9357ab..a9d33afc3 100644 --- a/src/st/st-theme-node.c +++ b/src/st/st-theme-node.c @@ -1761,6 +1761,53 @@ st_theme_node_get_text_decoration (StThemeNode *node) return 0; } +StTextAlign +st_theme_node_get_text_align(StThemeNode *node) +{ + int i; + + ensure_properties(node); + + for (i = node->n_properties - 1; i >= 0; i--) + { + CRDeclaration *decl = node->properties[i]; + + if (strcmp(decl->property->stryng->str, "text-align") == 0) + { + CRTerm *term = decl->value; + + if (term->type != TERM_IDENT || term->next) + continue; + + if (strcmp(term->content.str->stryng->str, "inherit") == 0) + { + if (node->parent_node) + return st_theme_node_get_text_align(node->parent_node); + return ST_TEXT_ALIGN_LEFT; + } + else if (strcmp(term->content.str->stryng->str, "left") == 0) + { + return ST_TEXT_ALIGN_LEFT; + } + else if (strcmp(term->content.str->stryng->str, "right") == 0) + { + return ST_TEXT_ALIGN_RIGHT; + } + else if (strcmp(term->content.str->stryng->str, "center") == 0) + { + return ST_TEXT_ALIGN_CENTER; + } + else if (strcmp(term->content.str->stryng->str, "justify") == 0) + { + return ST_TEXT_ALIGN_JUSTIFY; + } + } + } + if(node->parent_node) + return st_theme_node_get_text_align(node->parent_node); + return ST_TEXT_ALIGN_LEFT; +} + static gboolean font_family_from_terms (CRTerm *term, char **family) diff --git a/src/st/st-theme-node.h b/src/st/st-theme-node.h index dadff5974..97f8e835c 100644 --- a/src/st/st-theme-node.h +++ b/src/st/st-theme-node.h @@ -58,6 +58,13 @@ typedef enum { ST_TEXT_DECORATION_BLINK = 1 << 3 } StTextDecoration; +typedef enum { + ST_TEXT_ALIGN_LEFT = PANGO_ALIGN_LEFT, + ST_TEXT_ALIGN_CENTER = PANGO_ALIGN_CENTER, + ST_TEXT_ALIGN_RIGHT = PANGO_ALIGN_RIGHT, + ST_TEXT_ALIGN_JUSTIFY +} StTextAlign; + typedef enum { ST_GRADIENT_NONE, ST_GRADIENT_VERTICAL, @@ -149,6 +156,8 @@ int st_theme_node_get_transition_duration (StThemeNode *node); StTextDecoration st_theme_node_get_text_decoration (StThemeNode *node); +StTextAlign st_theme_node_get_text_align (StThemeNode *node); + /* Font rule processing is pretty complicated, so we just hardcode it * under the standard font/font-family/font-size/etc names. This means * you can't have multiple separate styled fonts for a single item,