[gcr] ui: Suppress CSS warnings for GTK+ 3.20



commit 5db6fe1571c4887dead533c0a1b319e62e0abbff
Author: Daiki Ueno <dueno src gnome org>
Date:   Fri Mar 11 11:58:43 2016 +0900

    ui: Suppress CSS warnings for GTK+ 3.20
    
    If STATE argument of gtk_style_context_get*() doesn't match with the
    CONTEXT's state, it shows warnings like:
    
      State 36 for GcrDisplayView 0xd62540 doesn't match state 160 set via
      gtk_style_context_set_state ()
    
    To suppress those warnings, add gtk_style_context_save() and _restore()
    around the calls.  Based on the information from:
    http://feaneron.com/2016/01/04/quick-guide-to-port-an-app-for-gtk-3-20/
    
    https://bugzilla.gnome.org/show_bug.cgi?id=763488

 ui/gcr-display-view.c |   10 ++++++++--
 1 files changed, 8 insertions(+), 2 deletions(-)
---
diff --git a/ui/gcr-display-view.c b/ui/gcr-display-view.c
index 2b4db51..bc97c2e 100644
--- a/ui/gcr-display-view.c
+++ b/ui/gcr-display-view.c
@@ -254,7 +254,10 @@ style_display_item (GtkWidget *widget, GcrDisplayItem *item)
        gtk_style_context_save (style);
 
        gtk_style_context_add_class (style, GTK_STYLE_CLASS_VIEW);
-       gtk_style_context_get_background_color (style, GTK_STATE_FLAG_NORMAL, &color);
+       gtk_style_context_set_state (style, GTK_STATE_FLAG_NORMAL);
+       gtk_style_context_get_background_color (style,
+                                               gtk_style_context_get_state (style),
+                                               &color);
 
        gtk_style_context_restore (style);
 
@@ -494,9 +497,12 @@ paint_item_border (GcrDisplayView *self,
 
        ensure_text_height (self);
 
+       gtk_style_context_save (context);
+       gtk_style_context_set_state (context, GTK_STATE_FLAG_SELECTED | GTK_STATE_FLAG_FOCUSED);
        gtk_style_context_get_background_color (context,
-                                               GTK_STATE_FLAG_SELECTED | GTK_STATE_FLAG_FOCUSED,
+                                               gtk_style_context_get_state (context),
                                                &color);
+       gtk_style_context_restore (context);
 
        gtk_text_view_get_iter_location (view, &iter, &location);
 


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