summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMatthias Clasen <mclasen@redhat.com>2015-12-11 15:23:54 -0500
committerMatthias Clasen <mclasen@redhat.com>2015-12-11 15:37:49 -0500
commit0c076cc8828cd80f1f156a08569199675bf35165 (patch)
tree06b8861d9125b76c55034d75d2b9a0aa9899fe9e
parented15bde7cd00c5a799ae6230b48448b3533493bd (diff)
downloadglade-0c076cc8828cd80f1f156a08569199675bf35165.tar.gz
Fix use of GTK+ style context APIs
Make sure to save the style context before querying with other states. This stops GTK+ from warning, and makes things work.
-rw-r--r--gladeui/glade-design-view.c10
-rw-r--r--gladeui/glade-placeholder.c6
2 files changed, 12 insertions, 4 deletions
diff --git a/gladeui/glade-design-view.c b/gladeui/glade-design-view.c
index 598579b7..3dc18bf8 100644
--- a/gladeui/glade-design-view.c
+++ b/gladeui/glade-design-view.c
@@ -332,11 +332,12 @@ glade_design_view_draw (GtkWidget *widget, cairo_t *cr)
GdkWindow *window = gtk_widget_get_window (widget);
gboolean should_draw = gtk_cairo_should_draw_window (cr, window);
gboolean sw_visible = gtk_widget_get_visible (priv->scrolled_window);
+ GtkStyleContext *context = gtk_widget_get_style_context (widget);
if (should_draw)
{
if (sw_visible)
- gtk_render_background (gtk_widget_get_style_context (widget),
+ gtk_render_background (context,
cr, 0, 0,
gtk_widget_get_allocated_width (widget),
gtk_widget_get_allocated_height (widget));
@@ -348,11 +349,14 @@ glade_design_view_draw (GtkWidget *widget, cairo_t *cr)
if (should_draw && sw_visible && priv->drag_highlight)
{
- GtkStyleContext *context = gtk_widget_get_style_context (widget);
GdkRGBA c;
- gtk_style_context_get_background_color (context, GTK_STATE_FLAG_SELECTED |
+ gtk_style_context_save (context);
+ gtk_style_context_get_background_color (context,
+ gtk_style_context_get_state (context) |
+ GTK_STATE_FLAG_SELECTED |
GTK_STATE_FLAG_FOCUSED, &c);
+ gtk_style_context_restore (context);
cairo_set_line_width (cr, 2);
gdk_cairo_set_source_rgba (cr, &c);
diff --git a/gladeui/glade-placeholder.c b/gladeui/glade-placeholder.c
index 5fcee12f..09d6e814 100644
--- a/gladeui/glade-placeholder.c
+++ b/gladeui/glade-placeholder.c
@@ -333,8 +333,12 @@ glade_placeholder_draw (GtkWidget *widget, cairo_t *cr)
GdkRGBA c;
context = gtk_widget_get_style_context (widget);
- gtk_style_context_get_background_color (context, GTK_STATE_FLAG_SELECTED |
+ gtk_style_context_save (context);
+ gtk_style_context_get_background_color (context,
+ gtk_style_context_get_state (context) |
+ GTK_STATE_FLAG_SELECTED |
GTK_STATE_FLAG_FOCUSED, &c);
+ gtk_style_context_restore (context);
ww = w/2.0;
hh = h/2.0;