[glade/wip/matthiasc/shortcuts: 2/6] GladeDesignLayout: Avoid GTK+ warnings



commit ff4275e542a60cf7f04410a17ebfb5817db10947
Author: Matthias Clasen <mclasen redhat com>
Date:   Wed Nov 18 11:38:59 2015 -0500

    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

 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 5cc3774..d16f18a 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;
    


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]