[gtksourceview/wip/chergert/hoverers] style fixups, fix bounds check



commit 06d605c012ab8ad2eeb026ff4f3886622c9d7396
Author: Christian Hergert <chergert redhat com>
Date:   Tue Mar 9 14:27:11 2021 -0800

    style fixups, fix bounds check

 gtksourceview/gtksourcehover.c | 53 ++++++++++++++++++++++--------------------
 1 file changed, 28 insertions(+), 25 deletions(-)
---
diff --git a/gtksourceview/gtksourcehover.c b/gtksourceview/gtksourcehover.c
index a44f5946..8097709e 100644
--- a/gtksourceview/gtksourcehover.c
+++ b/gtksourceview/gtksourcehover.c
@@ -274,11 +274,13 @@ gtk_source_hover_motion_timeout_cb (gpointer data)
 
        if (self->view == NULL ||
            self->state != HOVER_STATE_INITIAL ||
-           gtk_source_hover_get_bounds (self, &begin, &end, &location))
+           !gtk_source_hover_get_bounds (self, &begin, &end, &location))
        {
                return G_SOURCE_REMOVE;
        }
 
+       g_assert (GTK_SOURCE_IS_VIEW (self->view));
+
        if (self->assistant == NULL)
        {
                GtkEventController *motion;
@@ -307,6 +309,7 @@ gtk_source_hover_motion_timeout_cb (gpointer data)
        }
 
        self->state = HOVER_STATE_DISPLAY;
+
        gtk_text_view_get_iter_location (GTK_TEXT_VIEW (self->view), &begin, &begin_rect);
        gtk_text_view_get_iter_location (GTK_TEXT_VIEW (self->view), &end, &end_rect);
        gtk_text_view_get_iter_location (GTK_TEXT_VIEW (self->view), &location, &location_rect);
@@ -469,40 +472,40 @@ _gtk_source_hover_new (GtkSourceView *view)
 
        key = gtk_event_controller_key_new ();
        g_signal_connect_object (key,
-                                "key-pressed",
-                                G_CALLBACK (on_key_pressed_cb),
-                                self,
-                                G_CONNECT_SWAPPED);
-       gtk_widget_add_controller (GTK_WIDGET (self), key);
+                                "key-pressed",
+                                G_CALLBACK (on_key_pressed_cb),
+                                self,
+                                G_CONNECT_SWAPPED);
+       gtk_widget_add_controller (GTK_WIDGET (view), key);
 
        focus = gtk_event_controller_focus_new ();
        g_signal_connect_object (focus,
-                                "enter",
-                                G_CALLBACK (on_focus_enter_cb),
-                                self,
-                                G_CONNECT_SWAPPED);
+                                "enter",
+                                G_CALLBACK (on_focus_enter_cb),
+                                self,
+                                G_CONNECT_SWAPPED);
        g_signal_connect_object (focus,
-                                "leave",
-                                G_CALLBACK (on_focus_leave_cb),
-                                self,
-                                G_CONNECT_SWAPPED);
-       gtk_widget_add_controller (GTK_WIDGET (self), focus);
+                                "leave",
+                                G_CALLBACK (on_focus_leave_cb),
+                                self,
+                                G_CONNECT_SWAPPED);
+       gtk_widget_add_controller (GTK_WIDGET (view), focus);
 
        motion = gtk_event_controller_motion_new ();
        g_signal_connect_object (motion,
-                                "motion",
-                                G_CALLBACK (on_motion_cb),
-                                self,
-                                G_CONNECT_SWAPPED);
-       gtk_widget_add_controller (GTK_WIDGET (self), motion);
+                                "motion",
+                                G_CALLBACK (on_motion_cb),
+                                self,
+                                G_CONNECT_SWAPPED);
+       gtk_widget_add_controller (GTK_WIDGET (view), motion);
 
        scroll = gtk_event_controller_scroll_new (GTK_EVENT_CONTROLLER_SCROLL_BOTH_AXES);
        g_signal_connect_object (scroll,
-                                "scroll",
-                                G_CALLBACK (on_scroll_cb),
-                                self,
-                                G_CONNECT_SWAPPED);
-       gtk_widget_add_controller (GTK_WIDGET (self), scroll);
+                                "scroll",
+                                G_CALLBACK (on_scroll_cb),
+                                self,
+                                G_CONNECT_SWAPPED);
+       gtk_widget_add_controller (GTK_WIDGET (view), scroll);
 
        return self;
 }


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