[balsa] main-window: Connect to "focus-{in,out}" signals



commit 823d66d134f07ff8d8957d7f3c442bf674599d88
Author: Peter Bloomfield <PeterBloomfield bellsouth net>
Date:   Wed Jun 3 18:44:28 2020 -0400

    main-window: Connect to "focus-{in,out}" signals
    
    Connect to the "focus-{in,out}" signals of a GtkEventControllerKey
    instead of the "focus-{in,out}-event" widget signals.
    
    This is preparation for GTK4, but will still need to be changed to use
    GtkEventControllerFocus in that distant future.
    
    * src/main-window.c (bw_enable_filter), (bw_disable_filter), (bw_create_index_widget):

 ChangeLog         | 12 ++++++++++++
 src/main-window.c | 24 ++++++++++++++----------
 2 files changed, 26 insertions(+), 10 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index fa7b79a17..84ff30622 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,15 @@
+2020-06-03  Peter Bloomfield  <pbloomfield bellsouth net>
+
+       main-window: Connect to the "focus-{in,out}" signals of a
+       GtkEventControllerKey instead of the "focus-{in,out}-event" widget
+       signals.
+
+       This is preparation for GTK4, but will still need to be changed
+       to use GtkEventControllerFocus in that distant future.
+
+       * src/main-window.c (bw_enable_filter), (bw_disable_filter),
+       (bw_create_index_widget):
+
 2020-06-03  Peter Bloomfield  <pbloomfield bellsouth net>
 
        mime-widget-text: Connect to the "pressed" signal of a
diff --git a/src/main-window.c b/src/main-window.c
index 70d927e18..c3bfbd6fb 100644
--- a/src/main-window.c
+++ b/src/main-window.c
@@ -374,20 +374,22 @@ bw_pass_to_filter(BalsaWindow *window, GdkEventKey *event, gpointer data)
 
     return res;
 }
-static gboolean
-bw_enable_filter(GtkWidget *widget, GdkEventFocus *event, gpointer data)
+
+static void
+bw_enable_filter(GtkEventControllerKey *eventcontrollerkey,
+                 gpointer               user_data)
 {
-    g_signal_connect(data, "key_press_event",
+    g_signal_connect(user_data, "key_press_event",
                      G_CALLBACK(bw_pass_to_filter), NULL);
-    return FALSE;
 }
-static gboolean
-bw_disable_filter(GtkWidget *widget, GdkEventFocus *event, gpointer data)
+
+static void
+bw_disable_filter(GtkEventControllerKey *eventcontrollerkey,
+                  gpointer               user_data)
 {
-    g_signal_handlers_disconnect_by_func(data,
+    g_signal_handlers_disconnect_by_func(user_data,
                                          G_CALLBACK(bw_pass_to_filter),
                                          NULL);
-    return FALSE;
 }
 
 static void
@@ -536,6 +538,7 @@ bw_create_index_widget(BalsaWindow *bw)
     BalsaWindowPrivate *priv = balsa_window_get_instance_private(bw);
     GtkWidget *vbox, *button;
     unsigned i;
+    GtkEventController *key_controller;
 
     if(!view_filters_translated) {
         for(i=0; i<G_N_ELEMENTS(view_filters); i++)
@@ -557,9 +560,10 @@ bw_create_index_widget(BalsaWindow *bw)
     priv->sos_entry = gtk_search_entry_new();
     /* gtk_label_set_mnemonic_widget(GTK_LABEL(priv->filter_choice),
        priv->sos_entry); */
-    g_signal_connect(priv->sos_entry, "focus_in_event",
+    key_controller = gtk_event_controller_key_new(priv->sos_entry);
+    g_signal_connect(key_controller, "focus-in",
                      G_CALLBACK(bw_enable_filter), bw);
-    g_signal_connect(priv->sos_entry, "focus_out_event",
+    g_signal_connect(key_controller, "focus-out",
                      G_CALLBACK(bw_disable_filter), bw);
 
     button = gtk_button_new();


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