[balsa] address-view: Connect to "notify::has-focus"



commit f7fa19bf4cffcc81a64b2a4bee7b1fa390bd0ffe
Author: Peter Bloomfield <PeterBloomfield bellsouth net>
Date:   Fri May 29 17:36:34 2020 -0400

    address-view: Connect to "notify::has-focus"
    
    Connect to "notify::has-focus" signal instead of "focus-out-event".
    
    * libbalsa/address-view.c (lbav_notify_has_focus_cb), (lbav_row_editing_cb):

 ChangeLog               |  8 ++++++++
 libbalsa/address-view.c | 30 ++++++++++++++++++------------
 2 files changed, 26 insertions(+), 12 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index ff3d8dbb3..3426b17ea 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,11 @@
+2020-05-29  Peter Bloomfield  <pbloomfield bellsouth net>
+
+       address-view: Connect to "notify::has-focus" signal instead of
+       "focus-out-event".
+
+       * libbalsa/address-view.c (lbav_notify_has_focus_cb),
+       (lbav_row_editing_cb):
+
 2020-05-29  Peter Bloomfield  <pbloomfield bellsouth net>
 
        compose window: Hold a reference to identity
diff --git a/libbalsa/address-view.c b/libbalsa/address-view.c
index 271694e1a..5a27c4dd1 100644
--- a/libbalsa/address-view.c
+++ b/libbalsa/address-view.c
@@ -735,24 +735,32 @@ lbav_editing_done(GtkCellEditable * cell_editable,
 
 
 /*
- * Focus Out callback
+ * notify::has-focus callback
  * If only one completion matches, fill it into the entry
  */
-static gboolean
-lbav_focus_out_cb(GtkEntry * entry, GdkEventFocus * event,
-                  LibBalsaAddressView * address_view)
+static void
+lbav_notify_has_focus_cb(GtkEntry            *entry,
+                         GParamSpec          *pspec,
+                         LibBalsaAddressView *address_view)
 {
-    const gchar *the_entry = gtk_entry_get_text(entry);
+    const gchar *the_entry;
+
+    if (gtk_widget_has_focus(GTK_WIDGET(entry))) {
+        /* Not a focus-out event */
+        return;
+     }
+
+    the_entry = gtk_entry_get_text(entry);
 
-    if (the_entry && *the_entry) {
+    if (the_entry != NULL && the_entry[0] != '\0') {
         GList *match;
 
         match = lbav_get_matching_addresses(address_view,
                                             the_entry,
                                             LIBBALSA_ADDRESS_VIEW_MATCH_ALL);
 
-        if (match) {
-            if (!match->next) {
+        if (match != NULL) {
+            if (match->next == NULL) {
                 gchar *the_addr =
                     internet_address_to_string((InternetAddress *) match->data,
                                                 NULL, FALSE);
@@ -770,8 +778,6 @@ lbav_focus_out_cb(GtkEntry * entry, GdkEventFocus * event,
             g_list_free_full(match, g_object_unref);
         }
     }
-
-    return FALSE;
 }
 
 
@@ -813,8 +819,8 @@ lbav_row_editing_cb(GtkCellRenderer * renderer,
                      G_CALLBACK(lbav_insert_text_cb), address_view);
     g_signal_connect(editable, "editing-done",
                      G_CALLBACK(lbav_editing_done), address_view);
-    g_signal_connect_after(GTK_ENTRY(editable), "focus-out-event",
-                          G_CALLBACK(lbav_focus_out_cb), address_view);
+    g_signal_connect_after(editable, "notify::has-focus",
+                     G_CALLBACK(lbav_notify_has_focus_cb), address_view);
     gtk_entry_set_completion(GTK_ENTRY(editable), completion);
     g_object_unref(completion);
 


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