[glade] signal editor: Avoid GTK+ warnings



commit 3604a2a9fc2ce36e09c0d6a2d26ef8aeaec0c179
Author: Matthias Clasen <mclasen redhat com>
Date:   Wed Nov 18 11:50:55 2015 -0500

    signal editor: 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=758299

 gladeui/glade-signal-editor.c |   37 +++++++++++++++++++++++++------------
 1 files changed, 25 insertions(+), 12 deletions(-)
---
diff --git a/gladeui/glade-signal-editor.c b/gladeui/glade-signal-editor.c
index 0bec933..407251f 100644
--- a/gladeui/glade-signal-editor.c
+++ b/gladeui/glade-signal-editor.c
@@ -973,17 +973,21 @@ glade_signal_editor_handler_cell_data_func (GtkTreeViewColumn *column,
       dummy = glade_signal_is_dummy (signal);
       if (dummy)
        {
-         gtk_style_context_get_color (context, 
-                                      GTK_STATE_FLAG_INSENSITIVE, &color);
+          gtk_style_context_save (context);
+          gtk_style_context_set_state (context, gtk_style_context_get_state (context) | 
GTK_STATE_FLAG_INSENSITIVE);
+         gtk_style_context_get_color (context,
+                                       gtk_style_context_get_state (context),
+                                       &color);
          g_object_set (renderer, 
                        "style", PANGO_STYLE_ITALIC,
                        "foreground-rgba", &color,
                        NULL);
+          gtk_style_context_restore (context);
        }
       else
        {
-         gtk_style_context_get_color (context, 
-                                      GTK_STATE_FLAG_NORMAL,
+         gtk_style_context_get_color (context,
+                                      gtk_style_context_get_state (context),
                                       &color);
          g_object_set (renderer,
                        "style", PANGO_STYLE_NORMAL,
@@ -1030,17 +1034,21 @@ glade_signal_editor_detail_cell_data_func (GtkTreeViewColumn *column,
       dummy = glade_signal_is_dummy (signal);
       if (dummy || !glade_signal_get_detail (signal))
        {
-         gtk_style_context_get_color (context, 
-                                      GTK_STATE_FLAG_INSENSITIVE, &color);
+          gtk_style_context_save (context);
+          gtk_style_context_set_state (context, gtk_style_context_get_state (context) | 
GTK_STATE_FLAG_INSENSITIVE);
+         gtk_style_context_get_color (context,
+                                      gtk_style_context_get_state (context),
+                                       &color);
          g_object_set (renderer,
                        "style", PANGO_STYLE_ITALIC,
                        "foreground-rgba", &color,
                        NULL);
+          gtk_style_context_restore (context);
        }
       else
        {
-         gtk_style_context_get_color (context, 
-                                      GTK_STATE_FLAG_NORMAL,
+         gtk_style_context_get_color (context,
+                                      gtk_style_context_get_state (context),
                                       &color);
          g_object_set (renderer,
                        "style", PANGO_STYLE_NORMAL,
@@ -1096,17 +1104,22 @@ glade_signal_editor_data_cell_data_func (GtkTreeViewColumn *column,
 
          if (dummy || !glade_signal_get_userdata (signal))
            {
-             gtk_style_context_get_color (context, GTK_STATE_FLAG_INSENSITIVE, &color);
+              gtk_style_context_save (context);
+              gtk_style_context_set_state (context, gtk_style_context_get_state (context) | 
GTK_STATE_FLAG_INSENSITIVE);
+             gtk_style_context_get_color (context,
+                                           gtk_style_context_get_state (context),
+                                           &color);
              g_object_set (renderer, 
                            "style", PANGO_STYLE_ITALIC,
                            "foreground-rgba", &color,
                            NULL);
+              gtk_style_context_restore (context);
            }
          else
            {
-             gtk_style_context_get_color (context, 
-                                          GTK_STATE_FLAG_NORMAL,
-                                          &color);
+             gtk_style_context_get_color (context,
+                                           gtk_style_context_get_state (context),
+                                           &color);
              g_object_set (renderer,
                            "style", PANGO_STYLE_NORMAL,
                            "foreground-rgba", &color,


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