[gtksourceview/gnome-3-18] Revert "gutter: avoid connecting to GtkWidget::draw()"



commit c0d3919deb11547602f54d81fe382401ff5ed399
Author: Chris Mayo <aklhfex gmail com>
Date:   Thu Jun 2 19:33:00 2016 +0200

    Revert "gutter: avoid connecting to GtkWidget::draw()"
    
    This caused a problem in Meld.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=767085

 gtksourceview/gtksourcegutter-private.h |    6 ------
 gtksourceview/gtksourcegutter.c         |   22 +++++++++++++++++-----
 gtksourceview/gtksourceview.c           |   11 -----------
 3 files changed, 17 insertions(+), 22 deletions(-)
---
diff --git a/gtksourceview/gtksourcegutter-private.h b/gtksourceview/gtksourcegutter-private.h
index e31131d..d5dbe72 100644
--- a/gtksourceview/gtksourcegutter-private.h
+++ b/gtksourceview/gtksourcegutter-private.h
@@ -31,12 +31,6 @@ G_GNUC_INTERNAL
 GtkSourceGutter *      gtk_source_gutter_new           (GtkSourceView     *view,
                                                         GtkTextWindowType  type);
 
-G_GNUC_INTERNAL
-void                   gtk_source_gutter_draw          (GtkSourceGutter *gutter,
-                                                        GtkSourceView   *view,
-                                                        cairo_t         *cr);
-
-
 G_END_DECLS
 
 #endif /* __GTK_SOURCE_GUTTER_PRIVATE_H__ */
diff --git a/gtksourceview/gtksourcegutter.c b/gtksourceview/gtksourcegutter.c
index 0fa7ae6..cd4410f 100644
--- a/gtksourceview/gtksourcegutter.c
+++ b/gtksourceview/gtksourcegutter.c
@@ -89,6 +89,10 @@ struct _GtkSourceGutterPrivate
 
 G_DEFINE_TYPE_WITH_PRIVATE (GtkSourceGutter, gtk_source_gutter, G_TYPE_OBJECT)
 
+static gboolean on_view_draw (GtkSourceView   *view,
+                              cairo_t         *cr,
+                              GtkSourceGutter *gutter);
+
 static gboolean on_view_motion_notify_event (GtkSourceView   *view,
                                              GdkEventMotion  *event,
                                              GtkSourceGutter *gutter);
@@ -286,6 +290,12 @@ set_view (GtkSourceGutter *gutter,
        gutter->priv->view = view;
 
        g_signal_connect_object (view,
+                                "draw",
+                                G_CALLBACK (on_view_draw),
+                                gutter,
+                                G_CONNECT_AFTER);
+
+       g_signal_connect_object (view,
                                 "motion-notify-event",
                                 G_CALLBACK (on_view_motion_notify_event),
                                 gutter,
@@ -1217,10 +1227,10 @@ end_draw (GtkSourceGutter *gutter)
        }
 }
 
-void
-gtk_source_gutter_draw (GtkSourceGutter *gutter,
-                        GtkSourceView   *view,
-                        cairo_t         *cr)
+static gboolean
+on_view_draw (GtkSourceView   *view,
+              cairo_t         *cr,
+              GtkSourceGutter *gutter)
 {
        GdkRectangle clip;
        GtkTextView *text_view;
@@ -1234,7 +1244,7 @@ gtk_source_gutter_draw (GtkSourceGutter *gutter,
 
        if (!get_clip_rectangle (gutter, view, cr, &clip))
        {
-               return;
+               return GDK_EVENT_PROPAGATE;
        }
 
        gutter->priv->is_drawing = TRUE;
@@ -1291,6 +1301,8 @@ gtk_source_gutter_draw (GtkSourceGutter *gutter,
 
        g_array_free (renderer_widths, TRUE);
        lines_info_free (info);
+
+       return GDK_EVENT_PROPAGATE;
 }
 
 static Renderer *
diff --git a/gtksourceview/gtksourceview.c b/gtksourceview/gtksourceview.c
index 81484a3..f3e756f 100644
--- a/gtksourceview/gtksourceview.c
+++ b/gtksourceview/gtksourceview.c
@@ -2952,7 +2952,6 @@ static gboolean
 gtk_source_view_draw (GtkWidget *widget,
                      cairo_t   *cr)
 {
-       GtkSourceView *view = GTK_SOURCE_VIEW (widget);
        gboolean event_handled;
 
 #ifdef ENABLE_PROFILE
@@ -2971,16 +2970,6 @@ gtk_source_view_draw (GtkWidget *widget,
 
        event_handled = GTK_WIDGET_CLASS (gtk_source_view_parent_class)->draw (widget, cr);
 
-       if (view->priv->left_gutter != NULL)
-       {
-               gtk_source_gutter_draw (view->priv->left_gutter, view, cr);
-       }
-
-       if (view->priv->right_gutter != NULL)
-       {
-               gtk_source_gutter_draw (view->priv->right_gutter, view, cr);
-       }
-
        PROFILE ({
                g_timer_stop (timer);
                g_print ("    gtk_source_view_draw time: %g (sec * 1000)\n",


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