[balsa/focus-chain] mime-widget-callbacks: Deprecation cleanup



commit 9adc943fc7e0f930d9023df085d8260521956b46
Author: Peter Bloomfield <PeterBloomfield bellsouth net>
Date:   Wed Oct 17 20:17:16 2018 -0400

    mime-widget-callbacks: Deprecation cleanup
    
    * src/balsa-mime-widget-callbacks.c (bmw_set_can_focus),
      (balsa_mime_widget_limit_focus), (balsa_mime_widget_unlimit_focus):
      gtk_container_*_focus_chain functions are deprecated.

 ChangeLog                         |  6 ++++++
 src/balsa-mime-widget-callbacks.c | 34 +++++++++++++++++++++++++++-------
 2 files changed, 33 insertions(+), 7 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index a7293c8e8..7d09d59f9 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2018-10-17  Peter Bloomfield  <pbloomfield bellsouth net>
+
+       * src/balsa-mime-widget-callbacks.c (bmw_set_can_focus),
+       (balsa_mime_widget_limit_focus), (balsa_mime_widget_unlimit_focus):
+       gtk_container_*_focus_chain functions are deprecated.
+
 2018-09-14  Peter Bloomfield  <pbloomfield bellsouth net>
 
        * libbalsa/information.c (libbalsa_information_varg): use
diff --git a/src/balsa-mime-widget-callbacks.c b/src/balsa-mime-widget-callbacks.c
index efa1e25f6..080f56652 100644
--- a/src/balsa-mime-widget-callbacks.c
+++ b/src/balsa-mime-widget-callbacks.c
@@ -257,33 +257,53 @@ balsa_mime_widget_key_press_event(GtkWidget * widget, GdkEventKey * event,
     return TRUE;
 }
 
+/*
+ * Focus callbacks
+ */
+
+static void
+bmw_set_can_focus(GtkWidget *widget,
+                  gpointer   data)
+{
+    if (GTK_IS_CONTAINER(widget))
+        gtk_container_foreach(GTK_CONTAINER(widget), bmw_set_can_focus, data);
+    gtk_widget_set_can_focus(widget, GPOINTER_TO_INT(data));
+}
+
 
 gint
-balsa_mime_widget_limit_focus(GtkWidget * widget, GdkEventFocus * event, BalsaMessage * bm)
+balsa_mime_widget_limit_focus(GtkWidget     *widget,
+                              GdkEventFocus *event,
+                              BalsaMessage  *bm)
 {
     /* Disable can_focus on other message parts so that TAB does not
      * attempt to move the focus on them. */
-    GList *list = g_list_append(NULL, widget);
+    bmw_set_can_focus(bm->bm_widget->container, GINT_TO_POINTER(FALSE));
+    gtk_widget_set_can_focus(widget, TRUE);
 
-    gtk_container_set_focus_chain(GTK_CONTAINER(bm->bm_widget->container), list);
-    g_list_free(list);
     if (bm->focus_state == BALSA_MESSAGE_FOCUS_STATE_NO)
         bm->focus_state = BALSA_MESSAGE_FOCUS_STATE_YES;
+
     return FALSE;
 }
 
 
 gint
-balsa_mime_widget_unlimit_focus(GtkWidget * widget, GdkEventFocus * event, BalsaMessage * bm)
+balsa_mime_widget_unlimit_focus(GtkWidget     *widget,
+                                GdkEventFocus *event,
+                                BalsaMessage  *bm)
 {
-    gtk_container_unset_focus_chain(GTK_CONTAINER(bm->bm_widget->container));
-    if (bm->message) {
+    bmw_set_can_focus(bm->bm_widget->container, GINT_TO_POINTER(TRUE));
+
+    if (bm->message != NULL) {
         BalsaMessageFocusState focus_state = bm->focus_state;
+
         if (focus_state == BALSA_MESSAGE_FOCUS_STATE_HOLD) {
             balsa_message_grab_focus(bm);
             bm->focus_state = BALSA_MESSAGE_FOCUS_STATE_YES;
         } else
             bm->focus_state = BALSA_MESSAGE_FOCUS_STATE_NO;
     }
+
     return FALSE;
 }


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