[gnome-shell] Implement "text-align"
- From: Florian Müllner <fmuellner src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-shell] Implement "text-align"
- Date: Fri, 25 Jun 2010 20:49:42 +0000 (UTC)
commit 97f883b10eed82ec665d2aafe2cb42a4c893e2c1
Author: Giovanni Campagna <scampa giovanni gmail com>
Date: Tue Jun 22 22:04:45 2010 +0200
Implement "text-align"
"text-align" allows setting the alignment of text, with respect to
other lines and allocated space, without requiring a reference to
the ClutterText (which is private for most widgets).
If not specified, all text is left-aligned.
https://bugzilla.gnome.org/show_bug.cgi?id=622447
data/theme/gnome-shell.css | 1 +
js/ui/appDisplay.js | 1 -
src/st/st-private.c | 10 +++++++++
src/st/st-theme-node.c | 47 ++++++++++++++++++++++++++++++++++++++++++++
src/st/st-theme-node.h | 9 ++++++++
5 files changed, 67 insertions(+), 1 deletions(-)
---
diff --git a/data/theme/gnome-shell.css b/data/theme/gnome-shell.css
index 6669845..24ac579 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 98dfb2f..3a9e4c5 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 1ebadf6..248c703 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 08a9357..a9d33af 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 dadff59..97f8e83 100644
--- a/src/st/st-theme-node.h
+++ b/src/st/st-theme-node.h
@@ -59,6 +59,13 @@ typedef enum {
} 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,
ST_GRADIENT_HORIZONTAL,
@@ -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,
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]