[gtksourceview/wip/delegate-space-drawing: 2/2] SpaceDrawer: update color



commit b3490563b23cee88ff9ba925df579d0c4cf88228
Author: Sébastien Wilmet <swilmet gnome org>
Date:   Thu Jul 21 17:15:03 2016 +0200

    SpaceDrawer: update color

 gtksourceview/gtksourcespacedrawer.c |   64 ++++++++++++++++++++++++++++++++++
 gtksourceview/gtksourceview.c        |   61 --------------------------------
 2 files changed, 64 insertions(+), 61 deletions(-)
---
diff --git a/gtksourceview/gtksourcespacedrawer.c b/gtksourceview/gtksourcespacedrawer.c
index 683e5e6..882261f 100644
--- a/gtksourceview/gtksourcespacedrawer.c
+++ b/gtksourceview/gtksourcespacedrawer.c
@@ -38,6 +38,12 @@ G_DEFINE_TYPE_WITH_PRIVATE (GtkSourceSpaceDrawer, _gtk_source_space_drawer, G_TY
 static void
 _gtk_source_space_drawer_finalize (GObject *object)
 {
+       GtkSourceSpaceDrawer *drawer = GTK_SOURCE_SPACE_DRAWER (object);
+
+       if (drawer->priv->color != NULL)
+       {
+               gdk_rgba_free (drawer->priv->color);
+       }
 
        G_OBJECT_CLASS (_gtk_source_space_drawer_parent_class)->finalize (object);
 }
@@ -51,6 +57,64 @@ _gtk_source_space_drawer_class_init (GtkSourceSpaceDrawerClass *klass)
 }
 
 static void
+update_color (GtkSourceSpaceDrawer *drawer)
+{
+       GtkSourceStyleScheme *style_scheme;
+
+       if (drawer->priv->color != NULL)
+       {
+               gdk_rgba_free (drawer->priv->color);
+               drawer->priv->color = NULL;
+       }
+
+       style_scheme = gtk_source_view_get_style_sche
+
+       if (drawer->priv->style_scheme != NULL)
+       {
+               GtkSourceStyle *style;
+
+               style = _gtk_source_style_scheme_get_draw_spaces_style (drawer->priv->style_scheme);
+
+               if (style != NULL)
+               {
+                       gchar *color_str = NULL;
+                       gboolean color_set;
+                       GdkRGBA color;
+
+                       g_object_get (style,
+                                     "foreground", &color_str,
+                                     "foreground-set", &color_set,
+                                     NULL);
+
+                       if (color_set &&
+                           color_str != NULL &&
+                           gdk_rgba_parse (&color, color_str))
+                       {
+                               drawer->priv->color = gdk_rgba_copy (&color);
+                       }
+
+                       g_free (color_str);
+               }
+       }
+
+       if (drawer->priv->color == NULL)
+       {
+               GtkStyleContext *context;
+               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_style_context_get_state (context),
+                                            &color);
+               gtk_style_context_restore (context);
+
+               drawer->priv->color = gdk_rgba_copy (&color);
+       }
+}
+
+static void
 _gtk_source_space_drawer_init (GtkSourceSpaceDrawer *drawer)
 {
        drawer->priv = _gtk_source_space_drawer_get_instance_private (drawer);
diff --git a/gtksourceview/gtksourceview.c b/gtksourceview/gtksourceview.c
index a168012..690bd8b 100644
--- a/gtksourceview/gtksourceview.c
+++ b/gtksourceview/gtksourceview.c
@@ -5139,67 +5139,6 @@ update_right_margin_colors (GtkSourceView *view)
 }
 
 static void
-update_spaces_color (GtkSourceView *view)
-{
-       GtkWidget *widget = GTK_WIDGET (view);
-
-       if (!gtk_widget_get_realized (widget))
-       {
-               return;
-       }
-
-       if (view->priv->spaces_color != NULL)
-       {
-               gdk_rgba_free (view->priv->spaces_color);
-               view->priv->spaces_color = NULL;
-       }
-
-       if (view->priv->style_scheme != NULL)
-       {
-               GtkSourceStyle *style;
-
-               style = _gtk_source_style_scheme_get_draw_spaces_style (view->priv->style_scheme);
-
-               if (style != NULL)
-               {
-                       gchar *color_str = NULL;
-                       gboolean color_set;
-                       GdkRGBA color;
-
-                       g_object_get (style,
-                                     "foreground", &color_str,
-                                     "foreground-set", &color_set,
-                                     NULL);
-
-                       if (color_set &&
-                           color_str != NULL &&
-                           gdk_rgba_parse (&color, color_str))
-                       {
-                               view->priv->spaces_color = gdk_rgba_copy (&color);
-                       }
-
-                       g_free (color_str);
-               }
-       }
-
-       if (view->priv->spaces_color == NULL)
-       {
-               GtkStyleContext *context;
-               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_style_context_get_state (context),
-                                            &color);
-               gtk_style_context_restore (context);
-
-               view->priv->spaces_color = gdk_rgba_copy (&color);
-       }
-}
-
-static void
 update_style (GtkSourceView *view)
 {
        if (view->priv->style_scheme != NULL &&


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