diff --git a/js/ui/appDisplay.js b/js/ui/appDisplay.js index ab06c3549..9ec427f1a 100644 --- a/js/ui/appDisplay.js +++ b/js/ui/appDisplay.js @@ -797,12 +797,12 @@ AppIconMenu.prototype = { _updateHighlight: function (item) { if (this._highlightedItem) { - this._highlightedItem.set_style_pseudo_class(null); + this._highlightedItem.remove_style_pseudo_class('hover'); this.emit('highlight-window', null); } this._highlightedItem = item; if (this._highlightedItem) { - item.set_style_pseudo_class('hover'); + item.add_style_pseudo_class('hover'); let window = this._highlightedItem._window; if (window) this.emit('highlight-window', window); diff --git a/js/ui/dash.js b/js/ui/dash.js index e36bd2d95..3d5ab4aef 100644 --- a/js/ui/dash.js +++ b/js/ui/dash.js @@ -359,7 +359,10 @@ SearchResult.prototype = { }, setSelected: function(selected) { - this._content.set_style_pseudo_class(selected ? 'selected' : null); + if (selected) + this._content.add_style_pseudo_class('selected'); + else + this._content.remove_style_pseudo_class('selected'); }, activate: function() { @@ -630,10 +633,10 @@ MoreLink.prototype = { setPane: function (pane) { this._pane = pane; this._pane.connect('open-state-changed', Lang.bind(this, function(pane, isOpen) { - if (!isOpen) - this._expander.style_class = 'more-link-expander'; + if (isOpen) + this._expander.add_style_class_name('open'); else - this._expander.style_class = 'more-link-expander open'; + this._expander.remove_style_class_name('open'); })); } }; diff --git a/js/ui/genericDisplay.js b/js/ui/genericDisplay.js index 102c681b4..219e92c17 100644 --- a/js/ui/genericDisplay.js +++ b/js/ui/genericDisplay.js @@ -105,7 +105,10 @@ GenericDisplayItem.prototype = { // Highlights the item by setting a different background color than the default // if isSelected is true, removes the highlighting otherwise. markSelected: function(isSelected) { - this.actor.set_style_pseudo_class(isSelected ? "selected" : null); + if (iSelected) + this.actor.add_style_pseudo_class('selected'); + else + this.actor.remove_style_pseudo_class('selected'); }, /* diff --git a/js/ui/lookingGlass.js b/js/ui/lookingGlass.js index c5d5051c5..89c9f3e8a 100644 --- a/js/ui/lookingGlass.js +++ b/js/ui/lookingGlass.js @@ -84,7 +84,7 @@ Notebook.prototype = { if (this._selectedIndex < 0) return; let tabData = this._tabs[this._selectedIndex]; - tabData.labelBox.set_style_pseudo_class(null); + tabData.labelBox.remove_style_pseudo_class('selected'); tabData.scrollView.hide(); this._selectedIndex = -1; }, @@ -98,7 +98,7 @@ Notebook.prototype = { return; } let tabData = this._tabs[index]; - tabData.labelBox.set_style_pseudo_class('selected'); + tabData.labelBox.add_style_pseudo_class('selected'); tabData.scrollView.show(); this._selectedIndex = index; this.emit('selection', tabData.child); diff --git a/js/ui/workspacesView.js b/js/ui/workspacesView.js index 47886b99e..5712509e3 100644 --- a/js/ui/workspacesView.js +++ b/js/ui/workspacesView.js @@ -484,7 +484,10 @@ NewWorkspaceArea.prototype = { }, setStyle: function(isHover) { - this._child1.set_style_pseudo_class(isHover ? 'hover' : null); + if (isHover) + this._child1.add_style_pseudo_class('hover'); + else + this._child1.remove_style_pseudo_class('hover'); } }; diff --git a/src/Makefile-st.am b/src/Makefile-st.am index 51593e240..706c58840 100644 --- a/src/Makefile-st.am +++ b/src/Makefile-st.am @@ -161,6 +161,6 @@ libst_1_0_la_LDFLAGS = $(LDADD) noinst_PROGRAMS += test-theme test_theme_CPPFLAGS = $(st_cflags) -test_theme_LDADD = libst-1.0.la +test_theme_LDADD = libst-1.0.la libbig-1.0.la test_theme_SOURCES = st/test-theme.c diff --git a/src/st/st-button.c b/src/st/st-button.c index ae53021ec..2b8d7574e 100644 --- a/src/st/st-button.c +++ b/src/st/st-button.c @@ -133,21 +133,13 @@ st_button_style_changed (StWidget *widget) static void st_button_real_pressed (StButton *button) { - st_widget_set_style_pseudo_class ((StWidget*) button, "active"); + st_widget_add_style_pseudo_class ((StWidget*) button, "active"); } static void st_button_real_released (StButton *button) { - StButtonPrivate *priv = button->priv; - - if (priv->is_checked) - st_widget_set_style_pseudo_class ((StWidget*) button, "checked"); - else if (!priv->is_hover) - st_widget_set_style_pseudo_class ((StWidget*) button, NULL); - else - st_widget_set_style_pseudo_class ((StWidget*) button, "hover"); - + st_widget_remove_style_pseudo_class ((StWidget*) button, "active"); } static gboolean @@ -212,8 +204,7 @@ st_button_enter (ClutterActor *actor, { StButton *button = ST_BUTTON (actor); - if (!button->priv->is_checked) - st_widget_set_style_pseudo_class ((StWidget*) button, "hover"); + st_widget_add_style_pseudo_class ((StWidget*) button, "hover"); button->priv->is_hover = 1; @@ -240,10 +231,7 @@ st_button_leave (ClutterActor *actor, klass->released (button); } - if (button->priv->is_checked) - st_widget_set_style_pseudo_class ((StWidget*) button, "checked"); - else - st_widget_set_style_pseudo_class ((StWidget*) button, NULL); + st_widget_remove_style_pseudo_class ((StWidget*) button, "hover"); return CLUTTER_ACTOR_CLASS (st_button_parent_class)->leave_event (actor, event); } @@ -558,12 +546,9 @@ st_button_set_checked (StButton *button, button->priv->is_checked = checked; if (checked) - st_widget_set_style_pseudo_class ((StWidget*) button, "checked"); + st_widget_add_style_pseudo_class ((StWidget*) button, "checked"); else - if (button->priv->is_hover) - st_widget_set_style_pseudo_class ((StWidget*) button, "hover"); - else - st_widget_set_style_pseudo_class ((StWidget*) button, NULL); + st_widget_remove_style_pseudo_class ((StWidget*) button, "checked"); } g_object_notify (G_OBJECT (button), "checked"); diff --git a/src/st/st-clickable.c b/src/st/st-clickable.c index bc5ad4994..ee52e3738 100644 --- a/src/st/st-clickable.c +++ b/src/st/st-clickable.c @@ -42,9 +42,15 @@ static guint st_clickable_signals [LAST_SIGNAL] = { 0 }; static void sync_pseudo_class (StClickable *self) { - st_widget_set_style_pseudo_class (ST_WIDGET (self), - (self->priv->pressed || self->priv->active) ? "pressed" : - (self->priv->hover ? "hover" : NULL)); + if (self->priv->pressed || self->priv->active) + st_widget_add_style_pseudo_class (ST_WIDGET (self), "pressed"); + else + st_widget_remove_style_pseudo_class (ST_WIDGET (self), "pressed"); + + if (self->priv->hover) + st_widget_add_style_pseudo_class (ST_WIDGET (self), "hover"); + else + st_widget_remove_style_pseudo_class (ST_WIDGET (self), "hover"); } static void diff --git a/src/st/st-entry.c b/src/st/st-entry.c index 147640d7e..c78317996 100644 --- a/src/st/st-entry.c +++ b/src/st/st-entry.c @@ -391,7 +391,8 @@ clutter_text_focus_in_cb (ClutterText *text, clutter_text_set_text (text, ""); } - st_widget_set_style_pseudo_class (ST_WIDGET (actor), "focus"); + st_widget_remove_style_pseudo_class (ST_WIDGET (actor), "indeterminate"); + st_widget_add_style_pseudo_class (ST_WIDGET (actor), "focus"); clutter_text_set_cursor_visible (text, TRUE); } @@ -401,17 +402,15 @@ clutter_text_focus_out_cb (ClutterText *text, { StEntryPrivate *priv = ST_ENTRY_PRIV (actor); + st_widget_remove_style_pseudo_class (ST_WIDGET (actor), "focus"); + /* add a hint if the entry is empty */ if (priv->hint && !strcmp (clutter_text_get_text (text), "")) { priv->hint_visible = TRUE; clutter_text_set_text (text, priv->hint); - st_widget_set_style_pseudo_class (ST_WIDGET (actor), "indeterminate"); - } - else - { - st_widget_set_style_pseudo_class (ST_WIDGET (actor), NULL); + st_widget_add_style_pseudo_class (ST_WIDGET (actor), "indeterminate"); } clutter_text_set_cursor_visible (text, FALSE); } @@ -586,7 +585,7 @@ st_entry_enter_event (ClutterActor *actor, if (priv->hint && priv->hint_visible) { - st_widget_set_style_pseudo_class (ST_WIDGET (actor), "hover"); + st_widget_add_style_pseudo_class (ST_WIDGET (actor), "hover"); } return CLUTTER_ACTOR_CLASS (st_entry_parent_class)->enter_event (actor, event); @@ -596,16 +595,7 @@ static gboolean st_entry_leave_event (ClutterActor *actor, ClutterCrossingEvent *event) { - StEntryPrivate *priv = ST_ENTRY_PRIV (actor); - - if (priv->hint && priv->hint_visible) - { - st_widget_set_style_pseudo_class (ST_WIDGET (actor), "indeterminate"); - } - else - { - st_widget_set_style_pseudo_class (ST_WIDGET (actor), "focus"); - } + st_widget_remove_style_pseudo_class (ST_WIDGET (actor), "hover"); return CLUTTER_ACTOR_CLASS (st_entry_parent_class)->leave_event (actor, event); } @@ -782,14 +772,11 @@ st_entry_set_text (StEntry *entry, { text = priv->hint; priv->hint_visible = TRUE; - st_widget_set_style_pseudo_class (ST_WIDGET (entry), "indeterminate"); + st_widget_add_style_pseudo_class (ST_WIDGET (entry), "indeterminate"); } else { - if (HAS_FOCUS (priv->entry)) - st_widget_set_style_pseudo_class (ST_WIDGET (entry), "focus"); - else - st_widget_set_style_pseudo_class (ST_WIDGET (entry), NULL); + st_widget_remove_style_pseudo_class (ST_WIDGET (entry), "indeterminate"); priv->hint_visible = FALSE; } @@ -845,7 +832,7 @@ st_entry_set_hint_text (StEntry *entry, priv->hint_visible = TRUE; clutter_text_set_text (CLUTTER_TEXT (priv->entry), priv->hint); - st_widget_set_style_pseudo_class (ST_WIDGET (entry), "indeterminate"); + st_widget_add_style_pseudo_class (ST_WIDGET (entry), "indeterminate"); } } diff --git a/src/st/st-scroll-bar.c b/src/st/st-scroll-bar.c index 3c6bbb7bc..526432032 100644 --- a/src/st/st-scroll-bar.c +++ b/src/st/st-scroll-bar.c @@ -723,7 +723,7 @@ handle_capture_event_cb (ClutterActor *trough, ((ClutterButtonEvent*) event)->y); if (target != bar->priv->handle) { - st_widget_set_style_pseudo_class ((StWidget*) bar->priv->handle, NULL); + st_widget_remove_style_pseudo_class ((StWidget*) bar->priv->handle, "hover"); } diff --git a/src/st/st-widget.c b/src/st/st-widget.c index ea4db0144..8a3b03406 100644 --- a/src/st/st-widget.c +++ b/src/st/st-widget.c @@ -1354,34 +1354,165 @@ st_widget_get_theme (StWidget *actor) return actor->priv->theme; } +static const gchar * +find_class_name (const gchar *class_list, + const gchar *class_name) +{ + gint len = strlen (class_name); + const gchar *match; + + if (!class_list) + return NULL; + + for (match = strstr (class_list, class_name); match; match = strstr (match + 1, class_name)) + { + if ((match == class_list || g_ascii_isspace (match[-1])) && + (match[len] == '\0' || g_ascii_isspace (match[len]))) + return match; + } + + return NULL; +} + +static gboolean +set_class_list (gchar **class_list, + const gchar *new_class_list) +{ + if (g_strcmp0 (*class_list, new_class_list) != 0) + { + g_free (*class_list); + *class_list = g_strdup (new_class_list); + return TRUE; + } + else + return FALSE; +} + +static gboolean +add_class_name (gchar **class_list, + const gchar *class_name) +{ + gchar *new_class_list; + + if (*class_list) + { + if (find_class_name (*class_list, class_name)) + return FALSE; + + new_class_list = g_strdup_printf ("%s %s", *class_list, class_name); + g_free (*class_list); + *class_list = new_class_list; + } + else + *class_list = g_strdup (class_name); + + return TRUE; +} + +static gboolean +remove_class_name (gchar **class_list, + const gchar *class_name) +{ + const gchar *match, *end; + gchar *new_class_list; + + if (!*class_list) + return FALSE; + + if (strcmp (*class_list, class_name) == 0) + { + g_free (*class_list); + *class_list = NULL; + return TRUE; + } + + match = find_class_name (*class_list, class_name); + if (!match) + return FALSE; + end = match + strlen (class_name); + + /* Adjust either match or end to include a space as well. + * (One or the other must be possible at this point.) + */ + if (match != *class_list) + match--; + else + end++; + + new_class_list = g_strdup_printf ("%.*s%s", match - *class_list, + *class_list, end); + g_free (*class_list); + *class_list = new_class_list; + + return TRUE; +} + /** * st_widget_set_style_class_name: * @actor: a #StWidget - * @style_class: a new style class string + * @style_class_list: (allow-none): a new style class list string * - * Set the style class name + * Set the style class name list. @style_class_list can either be + * %NULL, for no classes, or a space-separated list of style class + * names. See also st_widget_add_style_class_name() and + * st_widget_remove_style_class_name(). */ void st_widget_set_style_class_name (StWidget *actor, - const gchar *style_class) + const gchar *style_class_list) { - StWidgetPrivate *priv = actor->priv; - g_return_if_fail (ST_IS_WIDGET (actor)); - priv = actor->priv; - - if (g_strcmp0 (style_class, priv->style_class)) + if (set_class_list (&actor->priv->style_class, style_class_list)) { - g_free (priv->style_class); - priv->style_class = g_strdup (style_class); - st_widget_style_changed (actor); - g_object_notify (G_OBJECT (actor), "style-class"); } } +/** + * st_widget_add_style_class_name: + * @actor: a #StWidget + * @style_class: a style class name string + * + * Adds @style_class to @actor's style class name list, if it is not + * already present. + */ +void +st_widget_add_style_class_name (StWidget *actor, + const gchar *style_class) +{ + g_return_if_fail (ST_IS_WIDGET (actor)); + g_return_if_fail (style_class != NULL); + + if (add_class_name (&actor->priv->style_class, style_class)) + { + st_widget_style_changed (actor); + g_object_notify (G_OBJECT (actor), "style-class"); + } +} + +/** + * st_widget_remove_style_class_name: + * @actor: a #StWidget + * @style_class: a style class name string + * + * Removes @style_class from @actor's style class name, if it is + * present. + */ +void +st_widget_remove_style_class_name (StWidget *actor, + const gchar *style_class) +{ + g_return_if_fail (ST_IS_WIDGET (actor)); + g_return_if_fail (style_class != NULL); + + if (remove_class_name (&actor->priv->style_class, style_class)) + { + st_widget_style_changed (actor); + g_object_notify (G_OBJECT (actor), "style-class"); + } +} /** * st_widget_get_style_class_name: @@ -1400,14 +1531,37 @@ st_widget_get_style_class_name (StWidget *actor) return actor->priv->style_class; } +/** + * st_widget_has_style_class_name: + * @actor: a #StWidget + * @style_class: a style class string + * + * Tests if @actor's style class list includes @style_class. + * + * Returns: whether or not @actor's style class list includes + * @style_class. + */ +gboolean +st_widget_has_style_class_name (StWidget *actor, + const gchar *style_class) +{ + g_return_val_if_fail (ST_IS_WIDGET (actor), FALSE); + + return find_class_name (actor->priv->style_class, style_class) != NULL; +} + /** * st_widget_get_style_pseudo_class: * @actor: a #StWidget * - * Get the current style pseudo class + * Get the current style pseudo class list. * - * Returns: the pseudo class string. The string is owned by the #StWidget and - * should not be modified or freed. + * Note that an actor can have multiple pseudo classes; if you just + * want to test for the presence of a specific pseudo class, use + * st_widget_has_style_pseudo_class(). + * + * Returns: the pseudo class list string. The string is owned by the + * #StWidget and should not be modified or freed. */ const gchar* st_widget_get_style_pseudo_class (StWidget *actor) @@ -1417,30 +1571,87 @@ st_widget_get_style_pseudo_class (StWidget *actor) return actor->priv->pseudo_class; } +/** + * st_widget_has_style_pseudo_class: + * @actor: a #StWidget + * @pseudo_class: a pseudo class string + * + * Tests if @actor's pseudo class list includes @pseudo_class. + * + * Returns: whether or not @actor's pseudo class list includes + * @pseudo_class. + */ +gboolean +st_widget_has_style_pseudo_class (StWidget *actor, + const gchar *pseudo_class) +{ + g_return_val_if_fail (ST_IS_WIDGET (actor), FALSE); + + return find_class_name (actor->priv->pseudo_class, pseudo_class) != NULL; +} + /** * st_widget_set_style_pseudo_class: * @actor: a #StWidget - * @pseudo_class: (allow-none): a new pseudo class string + * @pseudo_class_list: (allow-none): a new pseudo class list string * - * Set the style pseudo class + * Set the style pseudo class list. @pseudo_class_list can either be + * %NULL, for no classes, or a space-separated list of pseudo class + * names. See also st_widget_add_style_pseudo_class() and + * st_widget_remove_style_pseudo_class(). */ void st_widget_set_style_pseudo_class (StWidget *actor, - const gchar *pseudo_class) + const gchar *pseudo_class_list) { - StWidgetPrivate *priv; - g_return_if_fail (ST_IS_WIDGET (actor)); - priv = actor->priv; - - if (g_strcmp0 (pseudo_class, priv->pseudo_class)) + if (set_class_list (&actor->priv->pseudo_class, pseudo_class_list)) { - g_free (priv->pseudo_class); - priv->pseudo_class = g_strdup (pseudo_class); - st_widget_style_changed (actor); + g_object_notify (G_OBJECT (actor), "pseudo-class"); + } +} +/** + * st_widget_add_style_pseudo_class: + * @actor: a #StWidget + * @pseudo_class: a pseudo class string + * + * Adds @pseudo_class to @actor's pseudo class list, if it is not + * already present. + */ +void +st_widget_add_style_pseudo_class (StWidget *actor, + const gchar *pseudo_class) +{ + g_return_if_fail (ST_IS_WIDGET (actor)); + g_return_if_fail (pseudo_class != NULL); + + if (add_class_name (&actor->priv->pseudo_class, pseudo_class)) + { + st_widget_style_changed (actor); + g_object_notify (G_OBJECT (actor), "pseudo-class"); + } +} + +/** + * st_widget_remove_style_pseudo_class: + * @actor: a #StWidget + * @pseudo_class: a pseudo class string + * + * Removes @pseudo_class from @actor's pseudo class, if it is present. + */ +void +st_widget_remove_style_pseudo_class (StWidget *actor, + const gchar *pseudo_class) +{ + g_return_if_fail (ST_IS_WIDGET (actor)); + g_return_if_fail (pseudo_class != NULL); + + if (remove_class_name (&actor->priv->pseudo_class, pseudo_class)) + { + st_widget_style_changed (actor); g_object_notify (G_OBJECT (actor), "pseudo-class"); } } diff --git a/src/st/st-widget.h b/src/st/st-widget.h index bfe22320c..660c5e584 100644 --- a/src/st/st-widget.h +++ b/src/st/st-widget.h @@ -84,11 +84,25 @@ struct _StWidgetClass GType st_widget_get_type (void) G_GNUC_CONST; void st_widget_set_style_pseudo_class (StWidget *actor, + const gchar *pseudo_class_list); +void st_widget_add_style_pseudo_class (StWidget *actor, + const gchar *pseudo_class); +void st_widget_remove_style_pseudo_class (StWidget *actor, const gchar *pseudo_class); G_CONST_RETURN gchar *st_widget_get_style_pseudo_class (StWidget *actor); +gboolean st_widget_has_style_pseudo_class (StWidget *actor, + const gchar *pseudo_class); + void st_widget_set_style_class_name (StWidget *actor, + const gchar *style_class_list); +void st_widget_add_style_class_name (StWidget *actor, + const gchar *style_class); +void st_widget_remove_style_class_name (StWidget *actor, const gchar *style_class); G_CONST_RETURN gchar *st_widget_get_style_class_name (StWidget *actor); +gboolean st_widget_has_style_class_name (StWidget *actor, + const gchar *style_class); + void st_widget_set_style (StWidget *actor, const gchar *style); G_CONST_RETURN gchar *st_widget_get_style (StWidget *actor); diff --git a/src/st/test-theme.c b/src/st/test-theme.c index f39471aef..425fc5773 100644 --- a/src/st/test-theme.c +++ b/src/st/test-theme.c @@ -3,9 +3,11 @@ #include #include "st-theme.h" #include "st-theme-context.h" +#include "st-label.h" #include #include +static ClutterActor *stage; static StThemeNode *root; static StThemeNode *group1; static StThemeNode *text1; @@ -322,12 +324,72 @@ test_font (void) static void test_pseudo_class (void) { + StWidget *label; + StThemeNode *labelNode; + test = "pseudo_class"; /* text4 has :visited and :hover pseudo-classes, so should pick up both of these */ assert_foreground_color (text4, "text4", 0x888888ff); assert_text_decoration (text4, "text4", ST_TEXT_DECORATION_UNDERLINE); /* :hover pseudo-class matches, but class doesn't match */ assert_text_decoration (group3, "group3", 0); + + /* Test the StWidget add/remove pseudo_class interfaces */ + label = st_label_new ("foo"); + clutter_container_add_actor (CLUTTER_CONTAINER (stage), CLUTTER_ACTOR (label)); + + labelNode = st_widget_get_theme_node (label); + assert_foreground_color (labelNode, "label", 0x000000ff); + assert_text_decoration (labelNode, "label", 0); + assert_length ("label", "border-width", 0., + st_theme_node_get_border_width (labelNode, ST_SIDE_TOP)); + + st_widget_add_style_pseudo_class (label, "visited"); + g_assert (st_widget_has_style_pseudo_class (label, "visited")); + labelNode = st_widget_get_theme_node (label); + assert_foreground_color (labelNode, "label", 0x888888ff); + assert_text_decoration (labelNode, "label", 0); + assert_length ("label", "border-width", 0., + st_theme_node_get_border_width (labelNode, ST_SIDE_TOP)); + + st_widget_add_style_pseudo_class (label, "hover"); + g_assert (st_widget_has_style_pseudo_class (label, "hover")); + labelNode = st_widget_get_theme_node (label); + assert_foreground_color (labelNode, "label", 0x888888ff); + assert_text_decoration (labelNode, "label", ST_TEXT_DECORATION_UNDERLINE); + assert_length ("label", "border-width", 0., + st_theme_node_get_border_width (labelNode, ST_SIDE_TOP)); + + st_widget_remove_style_pseudo_class (label, "visited"); + g_assert (!st_widget_has_style_pseudo_class (label, "visited")); + g_assert (st_widget_has_style_pseudo_class (label, "hover")); + labelNode = st_widget_get_theme_node (label); + assert_foreground_color (labelNode, "label", 0x000000ff); + assert_text_decoration (labelNode, "label", ST_TEXT_DECORATION_UNDERLINE); + assert_length ("label", "border-width", 0., + st_theme_node_get_border_width (labelNode, ST_SIDE_TOP)); + + st_widget_add_style_pseudo_class (label, "boxed"); + labelNode = st_widget_get_theme_node (label); + assert_foreground_color (labelNode, "label", 0x000000ff); + assert_text_decoration (labelNode, "label", ST_TEXT_DECORATION_UNDERLINE); + assert_length ("label", "border-width", 1., + st_theme_node_get_border_width (labelNode, ST_SIDE_TOP)); + + st_widget_remove_style_pseudo_class (label, "hover"); + labelNode = st_widget_get_theme_node (label); + assert_foreground_color (labelNode, "label", 0x000000ff); + assert_text_decoration (labelNode, "label", 0); + assert_length ("label", "border-width", 1., + st_theme_node_get_border_width (labelNode, ST_SIDE_TOP)); + + st_widget_remove_style_pseudo_class (label, "boxed"); + g_assert (st_widget_get_style_pseudo_class (label) == NULL); + labelNode = st_widget_get_theme_node (label); + assert_foreground_color (labelNode, "label", 0x000000ff); + assert_text_decoration (labelNode, "label", 0); + assert_length ("label", "border-width", 0., + st_theme_node_get_border_width (labelNode, ST_SIDE_TOP)); } static void @@ -351,7 +413,8 @@ main (int argc, char **argv) theme = st_theme_new ("st/test-theme.css", NULL, NULL); - context = st_theme_context_new (); + stage = clutter_stage_get_default (); + context = st_theme_context_get_for_stage (CLUTTER_STAGE (stage)); st_theme_context_set_theme (context, theme); st_theme_context_set_resolution (context, 96.); st_theme_context_set_font (context, diff --git a/src/st/test-theme.css b/src/st/test-theme.css index b2fad3699..77ae34c19 100644 --- a/src/st/test-theme.css +++ b/src/st/test-theme.css @@ -64,10 +64,14 @@ stage > #text2 { border-radius: 10px 10px 0px 0px; } -ClutterText:hover { +ClutterText:hover, StLabel:hover { text-decoration: underline; } -ClutterText:visited { +ClutterText:visited, StLabel:visited { color: #888888; } + +StLabel:boxed { + border: 1px; +}