[gtksourceview: 5/5] view: save/restore StyleContext when getting colors



commit 2a3053527c2b2805450dee7a66490a1c87277d05
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 dbc70dd..ec8a44b 100644
--- a/gtksourceview/gtksourceview.c
+++ b/gtksourceview/gtksourceview.c
@@ -5029,7 +5029,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 =
@@ -5083,9 +5088,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]