[hitori] interface: Use state from GtkStyleContext



commit 1a8a1698debdd4534a42307106179ae05157cf01
Author: Philip Withnall <philip tecnocode co uk>
Date:   Wed Mar 9 00:21:59 2016 +0000

    interface: Use state from GtkStyleContext
    
    Instead of assuming the widget will be in a particular state when
    drawing, explicitly get and set the widget state. This fixes a warning
    with newer versions of GTK+.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=763245

 src/interface.c |    9 +++++++--
 1 files changed, 7 insertions(+), 2 deletions(-)
---
diff --git a/src/interface.c b/src/interface.c
index 55d0510..510974f 100644
--- a/src/interface.c
+++ b/src/interface.c
@@ -100,7 +100,9 @@ hitori_create_interface (Hitori *hitori)
 
        /* Set up font descriptions for the drawing area */
        style_context = gtk_widget_get_style_context (hitori->drawing_area);
-       gtk_style_context_get (style_context, 0, GTK_STYLE_PROPERTY_FONT, &font, NULL);
+       gtk_style_context_get (style_context,
+                              gtk_style_context_get_state (style_context),
+                              GTK_STYLE_PROPERTY_FONT, &font, NULL);
        hitori->normal_font_desc = pango_font_description_copy (font);
        hitori->painted_font_desc = pango_font_description_copy (font);
 
@@ -138,15 +140,18 @@ draw_cell (Hitori *hitori, GtkStyleContext *style_context, cairo_t *cr, gfloat c
        gchar *text;
        PangoLayout *layout;
        gint text_width, text_height;
-       GtkStateFlags state = 0;
+       GtkStateFlags state;
        gboolean painted = FALSE;
        PangoFontDescription *font_desc;
        GtkBorder border;
        GdkRGBA colour = {0.0, 0.0, 0.0, 0.0};
 
+       state = gtk_style_context_get_state (style_context);
+
        if (hitori->board[iter.x][iter.y].status & CELL_PAINTED) {
                painted = TRUE;
                state = GTK_STATE_FLAG_INSENSITIVE;
+               gtk_style_context_set_state (style_context, state);
        }
 
        /* Set up the border */


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