diff options
author | Paolo Borelli <pborelli@gnome.org> | 2012-02-21 23:42:39 +0100 |
---|---|---|
committer | Paolo Borelli <pborelli@gnome.org> | 2012-02-24 08:16:55 +0100 |
commit | 4a6658b0faf1ece6183dad8578af880badee98ba (patch) | |
tree | 4e5af83f5c7b4763d3e9c11b0ac1e387cf33b9f9 /gtk/gtkinfobar.c | |
parent | 86ffa06f018f2f760c6d466c724e792d51375cc4 (diff) | |
download | gtk+-4a6658b0faf1ece6183dad8578af880badee98ba.tar.gz |
Set infobar css classes permanently
The message-type css classes must be in the widget context all the time,
not only when drawing, otherwise they are not propagated to the
children, for instance a label in the InfoBar must inherit the
color. Add a corresponding reftest.
https://bugzilla.gnome.org/show_bug.cgi?id=670555
Diffstat (limited to 'gtk/gtkinfobar.c')
-rw-r--r-- | gtk/gtkinfobar.c | 34 |
1 files changed, 18 insertions, 16 deletions
diff --git a/gtk/gtkinfobar.c b/gtk/gtkinfobar.c index 88d6046fce..528625f86b 100644 --- a/gtk/gtkinfobar.c +++ b/gtk/gtkinfobar.c @@ -290,13 +290,6 @@ gtk_info_bar_draw (GtkWidget *widget, cairo_t *cr) { GtkInfoBarPrivate *priv = GTK_INFO_BAR (widget)->priv; - const char* type_class[] = { - GTK_STYLE_CLASS_INFO, - GTK_STYLE_CLASS_WARNING, - GTK_STYLE_CLASS_QUESTION, - GTK_STYLE_CLASS_ERROR, - NULL - }; if (priv->message_type != GTK_MESSAGE_OTHER) { @@ -304,20 +297,12 @@ gtk_info_bar_draw (GtkWidget *widget, context = gtk_widget_get_style_context (widget); - gtk_style_context_save (context); - - if (type_class[priv->message_type]) - gtk_style_context_add_class (context, - type_class[priv->message_type]); - gtk_render_background (context, cr, 0, 0, gtk_widget_get_allocated_width (widget), gtk_widget_get_allocated_height (widget)); gtk_render_frame (context, cr, 0, 0, gtk_widget_get_allocated_width (widget), gtk_widget_get_allocated_height (widget)); - - gtk_style_context_restore (context); } if (GTK_WIDGET_CLASS (gtk_info_bar_parent_class)->draw) @@ -1091,7 +1076,6 @@ gtk_info_bar_set_message_type (GtkInfoBar *info_bar, GtkMessageType message_type) { GtkInfoBarPrivate *priv; - AtkObject *atk_obj; g_return_if_fail (GTK_IS_INFO_BAR (info_bar)); @@ -1099,6 +1083,21 @@ gtk_info_bar_set_message_type (GtkInfoBar *info_bar, if (priv->message_type != message_type) { + GtkStyleContext *context; + AtkObject *atk_obj; + const char *type_class[] = { + GTK_STYLE_CLASS_INFO, + GTK_STYLE_CLASS_WARNING, + GTK_STYLE_CLASS_QUESTION, + GTK_STYLE_CLASS_ERROR, + NULL + }; + + context = gtk_widget_get_style_context (GTK_WIDGET (info_bar)); + + if (type_class[priv->message_type]) + gtk_style_context_remove_class (context, type_class[priv->message_type]); + priv->message_type = message_type; gtk_widget_queue_draw (GTK_WIDGET (info_bar)); @@ -1144,6 +1143,9 @@ gtk_info_bar_set_message_type (GtkInfoBar *info_bar, } } + if (type_class[priv->message_type]) + gtk_style_context_add_class (context, type_class[priv->message_type]); + g_object_notify (G_OBJECT (info_bar), "message-type"); } } |