[gtksourceview/gnome-3-18] view: save/restore StyleContext when getting colors



commit ae13570f5ad85ecd35505ee2e1e497d6a8199632
Author: Sébastien Wilmet <swilmet gnome org>
Date:   Wed Nov 25 15:31:32 2015 +0100

    view: save/restore StyleContext when getting colors

 gtksourceview/gtksourceview.c |   13 +++++++++++--
 1 files changed, 11 insertions(+), 2 deletions(-)
---
diff --git a/gtksourceview/gtksourceview.c b/gtksourceview/gtksourceview.c
index 4f51573..f3e756f 100644
--- a/gtksourceview/gtksourceview.c
+++ b/gtksourceview/gtksourceview.c
@@ -4921,7 +4921,12 @@ update_right_margin_colors (GtkSourceView *view)
                GdkRGBA color;
 
                context = gtk_widget_get_style_context (widget);
-               gtk_style_context_get_color (context, GTK_STATE_FLAG_NORMAL, &color);
+               gtk_style_context_save (context);
+               gtk_style_context_set_state (context, GTK_STATE_FLAG_NORMAL);
+               gtk_style_context_get_color (context,
+                                            gtk_style_context_get_state (context),
+                                            &color);
+               gtk_style_context_restore (context);
 
                view->priv->right_margin_line_color = gdk_rgba_copy (&color);
                view->priv->right_margin_line_color->alpha =
@@ -4975,9 +4980,13 @@ update_spaces_color (GtkSourceView *view)
                GdkRGBA color;
 
                context = gtk_widget_get_style_context (widget);
+               gtk_style_context_save (context);
+               gtk_style_context_set_state (context, GTK_STATE_FLAG_INSENSITIVE);
                gtk_style_context_get_color (context,
-                                            GTK_STATE_FLAG_INSENSITIVE,
+                                            gtk_style_context_get_state (context),
                                             &color);
+               gtk_style_context_restore (context);
+
                view->priv->spaces_color = gdk_rgba_copy (&color);
        }
 }


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