[balsa/gtk4: 257/283] Various: Fix migration errors




commit dda9e2ae96e9945cf7461eedb1143d9449e24955
Author: Peter Bloomfield <PeterBloomfield bellsouth net>
Date:   Wed Nov 18 10:42:24 2020 -0500

    Various: Fix migration errors
    
    Many show up only at run time.
    
    modified:   src/balsa-index.c
    modified:   src/balsa-message.c
    modified:   src/balsa-mime-widget-message.c
    modified:   src/main-window.c

 src/balsa-index.c               | 24 ++++++++++-------------
 src/balsa-message.c             | 39 +++++++++++++++++---------------------
 src/balsa-mime-widget-message.c | 15 ++++++++++-----
 src/main-window.c               | 42 ++++++++++++++++++++++-------------------
 4 files changed, 60 insertions(+), 60 deletions(-)
---
diff --git a/src/balsa-index.c b/src/balsa-index.c
index 79fd24419..8ae5a3176 100644
--- a/src/balsa-index.c
+++ b/src/balsa-index.c
@@ -87,8 +87,7 @@ static void bndx_gesture_pressed_cb(GtkGestureClick *click_gesture,
 static void bndx_row_activated(GtkTreeView * tree_view, GtkTreePath * path,
                                GtkTreeViewColumn * column,
                                gpointer user_data);
-static void bndx_column_resize(GtkWidget * widget,
-                               GtkAllocation * allocation, gpointer data);
+static void bndx_column_resize(GtkWidget * widget, gpointer user_data);
 static void bndx_tree_expand_cb(GtkTreeView * tree_view,
                                 GtkTreeIter * iter, GtkTreePath * path,
                                 gpointer user_data);
@@ -524,10 +523,9 @@ balsa_index_init(BalsaIndex * index)
         g_signal_connect_after(tree_view, "row-collapsed",
                                G_CALLBACK(bndx_tree_collapse_cb), NULL);
 
-    /* We want to catch column resize attempts to store the new value */
-    g_signal_connect_after(tree_view, "size-allocate",
-                           G_CALLBACK(bndx_column_resize),
-                           NULL);
+    /* We catch unmap events to store the column widths */
+    g_signal_connect(tree_view, "unmap",
+                     G_CALLBACK(bndx_column_resize), NULL);
     gtk_tree_view_set_enable_search(tree_view, FALSE);
 
     drag_source = gtk_drag_source_new();
@@ -799,8 +797,7 @@ bndx_tree_collapse_cb(GtkTreeView * tree_view, GtkTreeIter * iter,
 
 /* When a column is resized, store the new size for later use */
 static void
-bndx_column_resize(GtkWidget * widget, GtkAllocation * allocation,
-                   gpointer data)
+bndx_column_resize(GtkWidget * widget, gpointer user_data)
 {
     GtkTreeView *tree_view = GTK_TREE_VIEW(widget);
 
@@ -1825,20 +1822,19 @@ balsa_message_move_to_trash(gpointer user_data)
     balsa_mailbox_node_set_last_use_time(index->mailbox_node);
 }
 
-gint
+int
 balsa_find_notebook_page_num(LibBalsaMailbox * mailbox)
 {
     GtkWidget *page;
-    gint i;
+    int i;
 
-    if (!balsa_app.notebook)
+    if (balsa_app.notebook == NULL)
         return -1;
 
     for (i = 0;
-         (page =
-          gtk_notebook_get_nth_page(GTK_NOTEBOOK(balsa_app.notebook), i));
+         (page = gtk_notebook_get_nth_page(GTK_NOTEBOOK(balsa_app.notebook), i)) != NULL;
          i++) {
-        GtkWidget *index = gtk_notebook_page_get_child(GTK_NOTEBOOK_PAGE(page));
+        GtkWidget *index = gtk_scrolled_window_get_child(GTK_SCROLLED_WINDOW(page));
         BalsaMailboxNode *mbnode;
 
         if (index != NULL &&
diff --git a/src/balsa-message.c b/src/balsa-message.c
index a9d6ada75..bab29b5e8 100644
--- a/src/balsa-message.c
+++ b/src/balsa-message.c
@@ -253,24 +253,20 @@ bm_header_tl_buttons(BalsaMessage * balsa_message)
 {
     GPtrArray *array;
     GtkWidget *button;
-    GtkWidget *image;
-    GtkEventController *key_controller;
+    GtkEventController *controller;
 
     array = g_ptr_array_new();
 
     balsa_message->attach_button = button = gtk_menu_button_new();
-    gtk_button_set_has_frame(GTK_BUTTON(button), FALSE);
-
-    image = gtk_image_new_from_icon_name(balsa_icon_id(BALSA_PIXMAP_ATTACHMENT));
-    gtk_button_set_child(GTK_BUTTON(button), image);
+    gtk_menu_button_set_has_frame(GTK_MENU_BUTTON(button), FALSE);
 
     gtk_widget_set_tooltip_text(button, _("Select message part to display"));
 
-    key_controller = gtk_event_controller_key_new();
-    gtk_widget_add_controller(button, key_controller);
-    g_signal_connect(key_controller, "focus-in",
+    controller = gtk_event_controller_focus_new();
+    gtk_widget_add_controller(button, controller);
+    g_signal_connect(controller, "enter",
                     G_CALLBACK(balsa_mime_widget_limit_focus), balsa_message);
-    g_signal_connect(key_controller, "focus-out",
+    g_signal_connect(controller, "leave",
                     G_CALLBACK(balsa_mime_widget_unlimit_focus), balsa_message);
 
     g_ptr_array_add(array, button);
@@ -896,7 +892,7 @@ balsa_message_init(BalsaMessage * balsa_message)
     GtkTreeStore *model;
     GtkCellRenderer *renderer;
     GtkTreeSelection *selection;
-    GtkEventController *key_controller;
+    GtkEventController *controller;
     GtkGesture *gesture;
     GMenu *menu;
 
@@ -923,9 +919,9 @@ balsa_message_init(BalsaMessage * balsa_message)
                                    GTK_POLICY_AUTOMATIC,
                                    GTK_POLICY_AUTOMATIC);
 
-    key_controller = gtk_event_controller_key_new();
-    gtk_widget_add_controller(scroll, key_controller);
-    g_signal_connect(key_controller, "key-pressed",
+    controller = gtk_event_controller_key_new();
+    gtk_widget_add_controller(scroll, controller);
+    g_signal_connect(controller, "key-pressed",
                     G_CALLBACK(balsa_mime_widget_key_pressed), balsa_message);
 
     gtk_widget_set_vexpand(scroll, TRUE);
@@ -937,12 +933,11 @@ balsa_message_init(BalsaMessage * balsa_message)
     balsa_message->bm_widget = balsa_mime_widget_new_message_tl(balsa_message, buttons);
     g_free(buttons);
 
-    /* Widget to hold message */
-    key_controller = gtk_event_controller_key_new();
-    gtk_widget_add_controller(GTK_WIDGET(balsa_message->bm_widget), key_controller);
-    g_signal_connect(key_controller, "focus-in",
+    controller = gtk_event_controller_focus_new();
+    gtk_widget_add_controller(GTK_WIDGET(balsa_message->bm_widget), controller);
+    g_signal_connect(controller, "enter",
                      G_CALLBACK(balsa_mime_widget_limit_focus), balsa_message);
-    g_signal_connect(key_controller, "focus-out",
+    g_signal_connect(controller, "leave",
                      G_CALLBACK(balsa_mime_widget_unlimit_focus), balsa_message);
 
     /* If we do not add the widget to a viewport, GtkContainer would
@@ -970,9 +965,9 @@ balsa_message_init(BalsaMessage * balsa_message)
                      G_CALLBACK(tree_button_press_cb), balsa_message);
     gtk_event_controller_set_propagation_phase(GTK_EVENT_CONTROLLER(gesture), GTK_PHASE_CAPTURE);
 
-    key_controller = gtk_event_controller_key_new();
-    gtk_widget_add_controller(GTK_WIDGET(balsa_message->treeview), key_controller);
-    g_signal_connect(key_controller, "key-pressed",
+    controller = gtk_event_controller_key_new();
+    gtk_widget_add_controller(GTK_WIDGET(balsa_message->treeview), controller);
+    g_signal_connect(controller, "key-pressed",
                     G_CALLBACK(tree_key_press_cb), balsa_message);
     g_object_unref(model);
     gtk_tree_selection_set_mode(selection, GTK_SELECTION_MULTIPLE);
diff --git a/src/balsa-mime-widget-message.c b/src/balsa-mime-widget-message.c
index fedeb7334..ba786cbb8 100644
--- a/src/balsa-mime-widget-message.c
+++ b/src/balsa-mime-widget-message.c
@@ -528,22 +528,27 @@ bm_header_widget_new(BalsaMessage * bm, GtkWidget * const * buttons)
 
     controller = gtk_event_controller_key_new();
     gtk_widget_add_controller(grid, controller);
-    g_signal_connect(controller, "focus-in",
-                    G_CALLBACK(balsa_mime_widget_limit_focus), bm);
-    g_signal_connect(controller, "focus-out",
-                    G_CALLBACK(balsa_mime_widget_unlimit_focus), bm);
     g_signal_connect(controller, "key-pressed",
                     G_CALLBACK(balsa_mime_widget_key_pressed), bm);
 
+    controller = gtk_event_controller_focus_new();
+    gtk_widget_add_controller(grid, controller);
+    g_signal_connect(controller, "enter",
+                    G_CALLBACK(balsa_mime_widget_limit_focus), bm);
+    g_signal_connect(controller, "leave",
+                    G_CALLBACK(balsa_mime_widget_unlimit_focus), bm);
+
     info_bar_widget = gtk_info_bar_new();
     info_bar = GTK_INFO_BAR(info_bar_widget);
 
     gtk_info_bar_add_child(info_bar, grid);
 
     vbox = gtk_box_new(GTK_ORIENTATION_VERTICAL, 6);
+    gtk_widget_set_hexpand(vbox, TRUE);
+    gtk_widget_set_halign(vbox, GTK_ALIGN_END);
     gtk_widget_set_vexpand(vbox, TRUE);
     gtk_widget_set_valign(vbox, GTK_ALIGN_START);
-    gtk_info_bar_add_action_widget(info_bar, vbox, 0);
+    gtk_info_bar_add_child(info_bar, vbox);
 
     if (balsa_message_get_face_box(bm) == NULL) {
         GtkWidget *face_box = gtk_box_new(GTK_ORIENTATION_VERTICAL, 0);
diff --git a/src/main-window.c b/src/main-window.c
index b417c30b3..ab9d987a3 100644
--- a/src/main-window.c
+++ b/src/main-window.c
@@ -143,9 +143,9 @@ static void bw_notebook_switch_page_cb(GtkWidget *notebook,
                                        unsigned   page_num,
                                        gpointer   user_data);
 static void bw_send_msg_window_destroy_cb(GtkWidget * widget, gpointer data);
-static void bw_notebook_page_notify_cb(GtkWidget  *child,
-                                       GParamSpec *child_property,
-                                       gpointer    user_data);
+static void bw_notebook_page_notify_cb(GtkNotebookPage *notebook_page,
+                                       GParamSpec      *property,
+                                       gpointer         notebook);
 
 
 static GtkWidget *bw_notebook_label_new (BalsaMailboxNode* mbnode);
@@ -457,10 +457,8 @@ static struct {
 static gboolean view_filters_translated = FALSE;
 
 static void
-bw_sos_icon_release(GtkEditable         *entry,
-                    GtkEntryIconPosition icon_pos,
-                    GdkEvent            *event,
-                    gpointer             user_data)
+bw_sos_stop_search(GtkEditable *entry,
+                   gpointer     user_data)
 {
     /* User clicked the button for clearing the text, so we also clear the
      * search results. */
@@ -503,8 +501,8 @@ bw_create_index_widget(BalsaWindow *bw)
                      G_CALLBACK(bw_check_filter), bw);
 
     button = gtk_button_new_from_icon_name("gtk-ok");
-    g_signal_connect(priv->sos_entry, "icon-release",
-                     G_CALLBACK(bw_sos_icon_release), button);
+    g_signal_connect(priv->sos_entry, "stop-search",
+                     G_CALLBACK(bw_sos_stop_search), button);
 
     gtk_widget_set_hexpand(priv->sos_entry, TRUE);
     gtk_widget_set_halign(priv->sos_entry, GTK_ALIGN_FILL);
@@ -615,6 +613,9 @@ bw_set_panes(BalsaWindow * window)
        priv->paned_parent = gtk_paned_new(GTK_ORIENTATION_HORIZONTAL);
        priv->paned_child  = gtk_paned_new(GTK_ORIENTATION_VERTICAL);
 
+        priv->mblist_parent = priv->paned_parent;
+        priv->notebook_parent = priv->paned_child;
+
         gtk_paned_set_start_child(GTK_PANED(priv->paned_parent), bw_frame(priv->mblist));
         gtk_paned_set_end_child(GTK_PANED(priv->paned_parent), priv->paned_child);
         gtk_paned_set_start_child(GTK_PANED(priv->paned_child), bw_frame(index_widget));
@@ -2891,6 +2892,7 @@ bw_real_open_mbnode_idle_cb(BalsaWindowRealOpenMbnodeInfo * info)
     GtkWidget         *scroll;
     gint               page_num;
     LibBalsaCondition *filter;
+    GtkNotebookPage   *notebook_page;
 
     if (mbnode == NULL)
         return FALSE;
@@ -2912,11 +2914,13 @@ bw_real_open_mbnode_idle_cb(BalsaWindowRealOpenMbnodeInfo * info)
                                    GTK_POLICY_AUTOMATIC,
                                    GTK_POLICY_AUTOMATIC);
     gtk_scrolled_window_set_child(GTK_SCROLLED_WINDOW(scroll), GTK_WIDGET(index));
-    g_signal_connect(scroll, "child-notify::position",
-                     G_CALLBACK(bw_notebook_page_notify_cb), priv->notebook);
     page_num = gtk_notebook_append_page(GTK_NOTEBOOK(priv->notebook), scroll, label);
     gtk_notebook_set_tab_reorderable(GTK_NOTEBOOK(priv->notebook), scroll, TRUE);
 
+    notebook_page = gtk_notebook_get_page(GTK_NOTEBOOK(priv->notebook), scroll);
+    g_signal_connect(notebook_page, "notify::position",
+                     G_CALLBACK(bw_notebook_page_notify_cb), priv->notebook);
+
     if (info->set_current) {
         /* change the page to the newly selected notebook item */
         gtk_notebook_set_current_page(GTK_NOTEBOOK(priv->notebook), page_num);
@@ -4267,7 +4271,6 @@ bw_notebook_switch_page_cb(GtkWidget *notebook,
 {
     BalsaWindow *window = BALSA_WINDOW(user_data);
     BalsaWindowPrivate *priv = balsa_window_get_instance_private(window);
-    GtkNotebookPage *notebook_page;
     BalsaIndex *index;
     LibBalsaMailbox *mailbox;
     gchar *title;
@@ -4285,8 +4288,7 @@ bw_notebook_switch_page_cb(GtkWidget *notebook,
         /* Quitt'n time! */
         return;
 
-    notebook_page = gtk_notebook_get_page(GTK_NOTEBOOK(notebook), page);
-    priv->current_index = gtk_notebook_page_get_child(notebook_page);
+    priv->current_index = gtk_scrolled_window_get_child(GTK_SCROLLED_WINDOW(page));
 
     index = BALSA_INDEX(priv->current_index);
     g_object_add_weak_pointer(G_OBJECT(index),
@@ -4416,23 +4418,25 @@ bw_send_msg_window_destroy_cb(GtkWidget * widget, gpointer data)
 }
 
 static void
-bw_notebook_page_notify_cb(GtkWidget  *widget,
-                           GParamSpec *child_property,
-                           gpointer    notebook)
+bw_notebook_page_notify_cb(GtkNotebookPage *notebook_page,
+                           GParamSpec      *property,
+                           gpointer         notebook)
 {
+    GtkWidget *scroll;
     GtkWidget *child;
 
     if (balsa_app.in_destruction)
         return;
 
-    child = gtk_scrolled_window_get_child(GTK_SCROLLED_WINDOW(widget));
+    scroll = gtk_notebook_page_get_child(notebook_page);
+    child = gtk_scrolled_window_get_child(GTK_SCROLLED_WINDOW(scroll));
 
     if (child != NULL) {
         LibBalsaMailbox *mailbox;
         int page_num;
 
         mailbox = balsa_index_get_mailbox(BALSA_INDEX(child));
-        page_num = gtk_notebook_page_num(notebook, widget);
+        page_num = gtk_notebook_page_num(notebook, scroll);
         libbalsa_mailbox_set_position(mailbox, page_num);
     }
 }


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