[gtksourceview] view: update style on ::style-updated, not ::realize



commit 8568dabf9f380971eb8ca31d908e489ed0ce47fa
Author: Sébastien Wilmet <swilmet gnome org>
Date:   Sun Jul 24 19:44:57 2016 +0200

    view: update style on ::style-updated, not ::realize
    
    Updating the style in the realize vfunc is a leftover from GTK+ 2 days.
    In GTK+ 3, it's better to use style-updated.

 gtksourceview/gtksourcespacedrawer.c |    5 ---
 gtksourceview/gtksourceview.c        |   59 ++++++++++++----------------------
 2 files changed, 21 insertions(+), 43 deletions(-)
---
diff --git a/gtksourceview/gtksourcespacedrawer.c b/gtksourceview/gtksourcespacedrawer.c
index a87e0d8..d396382 100644
--- a/gtksourceview/gtksourcespacedrawer.c
+++ b/gtksourceview/gtksourcespacedrawer.c
@@ -111,11 +111,6 @@ _gtk_source_space_drawer_update_color (GtkSourceSpaceDrawer *drawer,
        g_return_if_fail (GTK_SOURCE_IS_SPACE_DRAWER (drawer));
        g_return_if_fail (GTK_SOURCE_IS_VIEW (view));
 
-       if (!gtk_widget_get_realized (GTK_WIDGET (view)))
-       {
-               return;
-       }
-
        if (drawer->priv->color != NULL)
        {
                gdk_rgba_free (drawer->priv->color);
diff --git a/gtksourceview/gtksourceview.c b/gtksourceview/gtksourceview.c
index da0db2c..1943bdb 100644
--- a/gtksourceview/gtksourceview.c
+++ b/gtksourceview/gtksourceview.c
@@ -290,7 +290,6 @@ static void gtk_source_view_get_property            (GObject           *object,
                                                         GValue            *value,
                                                         GParamSpec        *pspec);
 static void    gtk_source_view_style_updated           (GtkWidget         *widget);
-static void    gtk_source_view_realize                 (GtkWidget         *widget);
 static void    gtk_source_view_update_style_scheme     (GtkSourceView     *view);
 static void    gtk_source_view_draw_layer              (GtkTextView        *view,
                                                         GtkTextViewLayer   layer,
@@ -464,7 +463,6 @@ gtk_source_view_class_init (GtkSourceViewClass *klass)
        widget_class->key_press_event = gtk_source_view_key_press_event;
        widget_class->draw = gtk_source_view_draw;
        widget_class->style_updated = gtk_source_view_style_updated;
-       widget_class->realize = gtk_source_view_realize;
 
        textview_class->populate_popup = gtk_source_view_populate_popup;
        textview_class->move_cursor = gtk_source_view_move_cursor;
@@ -4487,27 +4485,6 @@ gtk_source_view_get_visual_column (GtkSourceView     *view,
 }
 
 static void
-gtk_source_view_style_updated (GtkWidget *widget)
-{
-       GtkSourceView *view;
-
-       /* call default handler first */
-       GTK_WIDGET_CLASS (gtk_source_view_parent_class)->style_updated (widget);
-
-       view = GTK_SOURCE_VIEW (widget);
-
-       /* re-set tab stops, but only if we already modified them, i.e.
-        * do nothing with good old 8-space tabs */
-       if (view->priv->tabs_set)
-       {
-               set_tab_stops_internal (view);
-       }
-
-       /* make sure the margin position is recalculated on next redraw */
-       view->priv->cached_right_margin_pos = -1;
-}
-
-static void
 update_background_pattern_color (GtkSourceView *view)
 {
        if (view->priv->style_scheme == NULL)
@@ -4540,11 +4517,6 @@ update_right_margin_colors (GtkSourceView *view)
 {
        GtkWidget *widget = GTK_WIDGET (view);
 
-       if (!gtk_widget_get_realized (widget))
-       {
-               return;
-       }
-
        if (view->priv->right_margin_line_color != NULL)
        {
                gdk_rgba_free (view->priv->right_margin_line_color);
@@ -4646,14 +4618,6 @@ update_style (GtkSourceView *view)
 }
 
 static void
-gtk_source_view_realize (GtkWidget *widget)
-{
-       GTK_WIDGET_CLASS (gtk_source_view_parent_class)->realize (widget);
-
-       update_style (GTK_SOURCE_VIEW (widget));
-}
-
-static void
 gtk_source_view_update_style_scheme (GtkSourceView *view)
 {
        GtkTextBuffer *buffer;
@@ -4679,11 +4643,30 @@ gtk_source_view_update_style_scheme (GtkSourceView *view)
        g_set_object (&view->priv->style_scheme, new_scheme);
 
        view->priv->style_scheme_applied = FALSE;
+       update_style (view);
+}
+
+static void
+gtk_source_view_style_updated (GtkWidget *widget)
+{
+       GtkSourceView *view;
+
+       /* call default handler first */
+       GTK_WIDGET_CLASS (gtk_source_view_parent_class)->style_updated (widget);
+
+       view = GTK_SOURCE_VIEW (widget);
 
-       if (gtk_widget_get_realized (GTK_WIDGET (view)))
+       /* re-set tab stops, but only if we already modified them, i.e.
+        * do nothing with good old 8-space tabs */
+       if (view->priv->tabs_set)
        {
-               update_style (view);
+               set_tab_stops_internal (view);
        }
+
+       /* make sure the margin position is recalculated on next redraw */
+       view->priv->cached_right_margin_pos = -1;
+
+       update_style (view);
 }
 
 static MarkCategory *


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