[gtksourceview/wip/chergert/gsv-gtk4: 140/175] completion: use focus controller



commit 38e397b161a53a3d3f5656052e3dc3cbf624597c
Author: Christian Hergert <chergert redhat com>
Date:   Tue Mar 17 14:07:11 2020 -0700

    completion: use focus controller

 gtksourceview/gtksourcecompletion.c     |  8 ++++++--
 gtksourceview/gtksourcecompletioninfo.c | 16 ++++++++--------
 2 files changed, 14 insertions(+), 10 deletions(-)
---
diff --git a/gtksourceview/gtksourcecompletion.c b/gtksourceview/gtksourcecompletion.c
index eaf0405f..1ccdfdc0 100644
--- a/gtksourceview/gtksourcecompletion.c
+++ b/gtksourceview/gtksourcecompletion.c
@@ -1799,6 +1799,7 @@ connect_view (GtkSourceCompletion *completion,
              GtkSourceView       *view)
 {
        GtkEventController *key;
+       GtkEventController *focus;
        GtkGesture *click;
 
        g_assert (completion->view == NULL);
@@ -1810,6 +1811,9 @@ connect_view (GtkSourceCompletion *completion,
        click = gtk_gesture_click_new ();
        gtk_widget_add_controller (GTK_WIDGET (view), GTK_EVENT_CONTROLLER (click));
 
+       focus = gtk_event_controller_focus_new ();
+       gtk_widget_add_controller (GTK_WIDGET (view), GTK_EVENT_CONTROLLER (focus));
+
        g_object_add_weak_pointer (G_OBJECT (view),
                                   (gpointer *)&completion->view);
 
@@ -1819,8 +1823,8 @@ connect_view (GtkSourceCompletion *completion,
                                 completion,
                                 G_CONNECT_SWAPPED);
 
-       g_signal_connect_object (key,
-                                "focus-out",
+       g_signal_connect_object (focus,
+                                "leave",
                                 G_CALLBACK (hide_completion_cb),
                                 completion,
                                 G_CONNECT_SWAPPED);
diff --git a/gtksourceview/gtksourcecompletioninfo.c b/gtksourceview/gtksourcecompletioninfo.c
index ed21886c..baffb233 100644
--- a/gtksourceview/gtksourcecompletioninfo.c
+++ b/gtksourceview/gtksourcecompletioninfo.c
@@ -59,7 +59,7 @@ struct _GtkSourceCompletionInfo
        guint idle_resize;
 
        GtkWidget *attached_to;
-       GtkEventController *key;
+       GtkEventController *focus;
        gulong focus_out_event_handler;
 
        gint xoffset;
@@ -89,16 +89,16 @@ set_attached_to (GtkSourceCompletionInfo *info,
 
                if (info->focus_out_event_handler != 0)
                {
-                       g_signal_handler_disconnect (info->key,
+                       g_signal_handler_disconnect (info->focus,
                                                     info->focus_out_event_handler);
 
                        info->focus_out_event_handler = 0;
-                       info->key = NULL;
+                       info->focus = NULL;
                }
        }
 
        info->attached_to = attached_to;
-       info->key = NULL;
+       info->focus = NULL;
 
        if (attached_to == NULL)
        {
@@ -108,12 +108,12 @@ set_attached_to (GtkSourceCompletionInfo *info,
        g_object_add_weak_pointer (G_OBJECT (attached_to),
                                   (gpointer *) &info->attached_to);
 
-       info->key = gtk_event_controller_key_new ();
-       gtk_widget_add_controller (GTK_WIDGET (attached_to), info->key);
+       info->focus = gtk_event_controller_focus_new ();
+       gtk_widget_add_controller (GTK_WIDGET (attached_to), info->focus);
 
        info->focus_out_event_handler =
-               g_signal_connect_swapped (info->key,
-                                         "focus-out",
+               g_signal_connect_swapped (info->focus,
+                                         "leave",
                                          G_CALLBACK (gtk_widget_hide),
                                          info);
 


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