diff options
author | Matthias Clasen <mclasen@redhat.com> | 2015-11-18 11:38:59 -0500 |
---|---|---|
committer | Matthias Clasen <mclasen@redhat.com> | 2015-11-25 22:19:33 -0500 |
commit | b2c94a56a4ad57c5d77280718164503b8c5d2538 (patch) | |
tree | 2ab8a4f974b5f722a3a1def0f13ccdb656b031f2 | |
parent | 74e95093a36dd30311e619141de4b1e0a33f19a2 (diff) | |
download | glade-b2c94a56a4ad57c5d77280718164503b8c5d2538.tar.gz |
GladeDesignLayout: Avoid GTK+ warnings
GTK+ warns nowadays if the state passed to gtk_style_context_get_*
does not match the state of the context. Avoid this by setting
the state beforehand. This is just a bandaid fix; the drawing
should be redone in terms of gtk_render_ APIs instead of poking
at colors.
https://bugzilla.gnome.org/show_bug.cgi?id=758296
-rw-r--r-- | gladeui/glade-design-layout.c | 14 |
1 files changed, 9 insertions, 5 deletions
diff --git a/gladeui/glade-design-layout.c b/gladeui/glade-design-layout.c index 5cc37746..d16f18ae 100644 --- a/gladeui/glade-design-layout.c +++ b/gladeui/glade-design-layout.c @@ -2210,12 +2210,16 @@ _glade_design_layout_get_colors (GtkStyleContext *context, GdkRGBA *c3, GdkRGBA *c4) { gfloat off; - - gtk_style_context_get_background_color (context, GTK_STATE_FLAG_NORMAL, c1); - gtk_style_context_get_color (context, GTK_STATE_FLAG_NORMAL, c2); - gtk_style_context_get_background_color (context, GTK_STATE_FLAG_SELECTED | GTK_STATE_FLAG_FOCUSED, c3); - gtk_style_context_get_color (context, GTK_STATE_FLAG_SELECTED | GTK_STATE_FLAG_FOCUSED, c4); + gtk_style_context_save (context); + gtk_style_context_set_state (context, GTK_STATE_FLAG_NORMAL); + gtk_style_context_get_background_color (context, gtk_style_context_get_state (context), c1); + gtk_style_context_get_color (context, gtk_style_context_get_state (context), c2); + + gtk_style_context_set_state (context, gtk_style_context_get_state (context) | GTK_STATE_FLAG_SELECTED | GTK_STATE_FLAG_FOCUSED); + gtk_style_context_get_background_color (context, gtk_style_context_get_state (context), c3); + gtk_style_context_get_color (context, gtk_style_context_get_state (context), c4); + gtk_style_context_restore (context); off = ((c1->red + c1->green + c1->blue)/3 < .5) ? .16 : -.16; |