[balsa/gtk4: 130/311] Various: Stop using GtkBox child properties




commit ec221e50a0bc8303b9bcb0c36af74de906f1ec67
Author: Peter Bloomfield <PeterBloomfield bellsouth net>
Date:   Sun Jun 7 16:15:14 2020 -0400

    Various: Stop using GtkBox child properties
    
    Stop using GtkBox padding, fill and expand child properties.
    Also, when the child is a GtkNotebook or a GtkStack or sometimes a
    GtkButton, we must again use container_add(…) instead of
    pack_start(…, FALSE, FALSE, 0).
    
    * src/ab-main.c (bab_get_filter_box), (bab_window_new):
    * src/ab-window.c (balsa_ab_window_init):
    * src/balsa-mblist.c (bmbl_mru_show_tree):
    * src/balsa-message.c (bm_find_bar_new), (balsa_message_init), (add_part):
    * src/balsa-mime-widget-crypto.c
      (balsa_mime_widget_signature_widget), (create_import_keys_widget):
    * src/balsa-mime-widget-message.c (bmw_message_extbody_url),
      (bmw_message_extbody_mail), (balsa_mime_widget_new_message_tl), (bm_header_widget_new):
    * src/balsa-mime-widget.c (balsa_mime_widget_new_unknown):

 ChangeLog                       | 16 ++++++++++++++++
 src/ab-main.c                   | 12 ++++++------
 src/ab-window.c                 | 16 ++++++++--------
 src/balsa-mblist.c              |  3 +--
 src/balsa-message.c             |  5 +++--
 src/balsa-mime-widget-crypto.c  | 14 ++++++++++----
 src/balsa-mime-widget-message.c | 22 +++++++++++++++++-----
 src/balsa-mime-widget.c         | 11 ++++++-----
 8 files changed, 67 insertions(+), 32 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index 79bd8db34..9dd05150b 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -737,6 +737,22 @@
        * libbalsa/autocrypt.c (autocrypt_db_dialog_run):
        * libbalsa/html.c (libbalsa_html_new):
 
+2020-06-07  Peter Bloomfield  <pbloomfield bellsouth net>
+
+       Various: Stop using GtkBox padding, fill and expand child properties
+
+       * src/ab-main.c (bab_get_filter_box), (bab_window_new):
+       * src/ab-window.c (balsa_ab_window_init):
+       * src/balsa-mblist.c (bmbl_mru_show_tree):
+       * src/balsa-message.c (bm_find_bar_new), (balsa_message_init),
+       (add_part):
+       * src/balsa-mime-widget-crypto.c
+       (balsa_mime_widget_signature_widget), (create_import_keys_widget):
+       * src/balsa-mime-widget-message.c (bmw_message_extbody_url),
+       (bmw_message_extbody_mail), (balsa_mime_widget_new_message_tl),
+       (bm_header_widget_new):
+       * src/balsa-mime-widget.c (balsa_mime_widget_new_unknown):
+
 2020-06-07  Peter Bloomfield  <pbloomfield bellsouth net>
 
        Various: Stop using GtkBox padding, fill and expand child properties
diff --git a/src/ab-main.c b/src/ab-main.c
index 7e7afc545..3f6ac5de0 100644
--- a/src/ab-main.c
+++ b/src/ab-main.c
@@ -878,7 +878,7 @@ bab_get_filter_box(void)
     widget = find_label;
     gtk_widget_set_margin_start(widget, 1);
     gtk_widget_set_margin_end(widget, 1);
-    gtk_container_add(GTK_CONTAINER(search_hbox), widget);
+    gtk_box_pack_start(GTK_BOX(search_hbox), widget, FALSE, FALSE, 0);
 
     find_entry = gtk_entry_new();
     gtk_widget_show(find_entry);
@@ -888,7 +888,7 @@ bab_get_filter_box(void)
     gtk_widget_set_halign(widget, GTK_ALIGN_FILL);
     gtk_widget_set_margin_start(widget, 1);
     gtk_widget_set_margin_end(widget, 1);
-    gtk_container_add(GTK_CONTAINER(search_hbox), widget);
+    gtk_box_pack_start(GTK_BOX(search_hbox), widget, FALSE, FALSE, 0);
 
     gtk_widget_show(search_hbox);
     gtk_label_set_mnemonic_widget(GTK_LABEL(find_label), find_entry);
@@ -901,7 +901,7 @@ bab_get_filter_box(void)
     widget = button;
     gtk_widget_set_margin_start(widget, 1);
     gtk_widget_set_margin_end(widget, 1);
-    gtk_container_add(GTK_CONTAINER(search_hbox), widget);
+    gtk_box_pack_start(GTK_BOX(search_hbox), widget, FALSE, FALSE, 0);
 
     g_signal_connect(find_entry, "activate",
                      G_CALLBACK(bab_filter_entry_activate),
@@ -968,7 +968,7 @@ bab_window_new(GtkApplication * application)
     widget = bab_get_filter_box();
     gtk_widget_set_margin_top(widget, 1);
     gtk_widget_set_margin_bottom(widget, 1);
-    gtk_container_add(GTK_CONTAINER(browse_widget), widget);
+    gtk_box_pack_start(GTK_BOX(browse_widget), widget, FALSE, FALSE, 0);
 
     scroll = gtk_scrolled_window_new(NULL, NULL);
     gtk_widget_show(scroll);
@@ -997,12 +997,12 @@ bab_window_new(GtkApplication * application)
     widget = contacts_app.edit_widget;
     gtk_widget_set_margin_top(widget, 1);
     gtk_widget_set_margin_bottom(widget, 1);
-    gtk_container_add(GTK_CONTAINER(edit_widget), widget);
+    gtk_box_pack_start(GTK_BOX(edit_widget), widget, FALSE, FALSE, 0);
 
     widget = bab_get_edit_button_box(&contacts_app);
     gtk_widget_set_margin_top(widget, 1);
     gtk_widget_set_margin_bottom(widget, 1);
-    gtk_container_add(GTK_CONTAINER(edit_widget), widget);
+    gtk_box_pack_start(GTK_BOX(edit_widget), widget, FALSE, FALSE, 0);
 
     gtk_notebook_append_page(GTK_NOTEBOOK(contacts_app.notebook), edit_widget,
                             gtk_label_new(_("Edit")));
diff --git a/src/ab-window.c b/src/ab-window.c
index c19884cb0..d0c8bacd3 100644
--- a/src/ab-window.c
+++ b/src/ab-window.c
@@ -287,7 +287,7 @@ balsa_ab_window_init(BalsaAbWindow *ab)
     gtk_grid_set_column_spacing(GTK_GRID(grid), 12);
     gtk_widget_set_vexpand(grid, TRUE);
     gtk_widget_set_valign(grid, GTK_ALIGN_FILL);
-    gtk_container_add(GTK_CONTAINER(vbox), grid);
+    gtk_box_pack_start(GTK_BOX(vbox), grid, FALSE, FALSE, 0);
     gtk_widget_show(grid);
 
     /* -- grid column 1 -- */
@@ -304,10 +304,10 @@ balsa_ab_window_init(BalsaAbWindow *ab)
     /* Pack the find stuff into the grid */
     box2 = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 1);
     gtk_grid_attach(GTK_GRID(grid), box2, 0, 0, 1, 1);
-    gtk_container_add(GTK_CONTAINER(box2), find_label);
+    gtk_box_pack_start(GTK_BOX(box2), find_label, FALSE, FALSE, 0);
     gtk_widget_set_vexpand(ab->filter_entry, TRUE);
     gtk_widget_set_valign(ab->filter_entry, GTK_ALIGN_FILL);
-    gtk_container_add(GTK_CONTAINER(box2), ab->filter_entry);
+    gtk_box_pack_start(GTK_BOX(box2), ab->filter_entry, FALSE, FALSE, 0);
     gtk_widget_show(GTK_WIDGET(box2));
 
 
@@ -350,7 +350,7 @@ balsa_ab_window_init(BalsaAbWindow *ab)
     w = gtk_button_new_from_icon_name("go-next-symbolic",
                                       GTK_ICON_SIZE_BUTTON);
     gtk_widget_set_vexpand(w, TRUE);
-    gtk_container_add(GTK_CONTAINER(ab->arrow_box), w);
+    gtk_box_pack_start(GTK_BOX(ab->arrow_box), w, FALSE, FALSE, 0);
     gtk_widget_show(w);
     g_signal_connect(w, "clicked",
                     G_CALLBACK(balsa_ab_window_move_to_recipient_list),
@@ -359,7 +359,7 @@ balsa_ab_window_init(BalsaAbWindow *ab)
     w = gtk_button_new_from_icon_name("go-previous-symbolic",
                                       GTK_ICON_SIZE_BUTTON);
     gtk_widget_set_vexpand(w, TRUE);
-    gtk_container_add(GTK_CONTAINER(ab->arrow_box), w);
+    gtk_box_pack_start(GTK_BOX(ab->arrow_box), w, FALSE, FALSE, 0);
     gtk_widget_show(w);
     g_signal_connect(w, "clicked",
                     G_CALLBACK(balsa_ab_window_remove_from_recipient_list),
@@ -408,11 +408,11 @@ balsa_ab_window_init(BalsaAbWindow *ab)
 
     gtk_widget_set_margin_top(ab->single_address_mode_radio, 1);
     gtk_widget_set_margin_bottom(ab->single_address_mode_radio, 1);
-    gtk_container_add(GTK_CONTAINER(box2), ab->single_address_mode_radio);
+    gtk_box_pack_start(GTK_BOX(box2), ab->single_address_mode_radio, FALSE, FALSE, 0);
 
     gtk_widget_set_margin_top(ab->dist_address_mode_radio, 1);
     gtk_widget_set_margin_bottom(ab->dist_address_mode_radio, 1);
-    gtk_container_add(GTK_CONTAINER(box2), ab->dist_address_mode_radio);
+    gtk_box_pack_start(GTK_BOX(box2), ab->dist_address_mode_radio, FALSE, FALSE, 0);
 
     gtk_widget_show(box2);
 
@@ -422,7 +422,7 @@ balsa_ab_window_init(BalsaAbWindow *ab)
 
     gtk_widget_set_margin_top(frame, 1);
     gtk_widget_set_margin_bottom(frame, 1);
-    gtk_container_add(GTK_CONTAINER(vbox), frame);
+    gtk_box_pack_start(GTK_BOX(vbox), frame, FALSE, FALSE, 0);
 
     gtk_widget_grab_focus(ab->filter_entry);
 }
diff --git a/src/balsa-mblist.c b/src/balsa-mblist.c
index c51cf84ed..abd3075c6 100644
--- a/src/balsa-mblist.c
+++ b/src/balsa-mblist.c
@@ -1821,10 +1821,9 @@ bmbl_mru_show_tree(GtkWidget * widget, gpointer data)
 #if HAVE_MACOSX_DESKTOP
     libbalsa_macosx_menu_for_parent(dialog, mru->window);
 #endif
-
     gtk_widget_set_vexpand(scroll, TRUE);
     gtk_widget_set_valign(scroll, GTK_ALIGN_FILL);
-    gtk_container_add(GTK_CONTAINER(content_area), scroll);
+    gtk_container_add(GTK_CONTAINER(gtk_dialog_get_content_area(GTK_DIALOG(dialog))), scroll);
 
     g_signal_connect(dialog, "size-allocate",
                      G_CALLBACK(bmbl_mru_size_allocate_cb), NULL);
diff --git a/src/balsa-message.c b/src/balsa-message.c
index d97b7e61b..11d09b7d9 100644
--- a/src/balsa-message.c
+++ b/src/balsa-message.c
@@ -550,7 +550,7 @@ bm_find_bar_new(BalsaMessage * balsa_message)
     gtk_toolbar_set_style(GTK_TOOLBAR(toolbar), GTK_TOOLBAR_BOTH_HORIZ);
 
     hbox = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 6);
-    gtk_container_add(GTK_CONTAINER(hbox), gtk_label_new(_("Find:")));
+    gtk_box_pack_start(GTK_BOX(hbox), gtk_label_new(_("Find:")), FALSE, FALSE, 0);
     balsa_message->find_entry = gtk_search_entry_new();
     g_signal_connect(balsa_message->find_entry, "search-changed",
                      G_CALLBACK(bm_find_entry_changed_cb), balsa_message);
@@ -2303,7 +2303,8 @@ add_part(BalsaMessage * balsa_message, BalsaPartInfo * info, GtkWidget * contain
     if (info->mime_widget == NULL)
        part_info_init(balsa_message, info);
 
-    gtk_container_add(GTK_CONTAINER(container), GTK_WIDGET(info->mime_widget));
+    gtk_widget_set_valign(GTK_WIDGET(info->mime_widget), TRUE);
+    gtk_box_pack_start(GTK_BOX(container), GTK_WIDGET(info->mime_widget), FALSE, FALSE, 0);
 
     info_container = balsa_mime_widget_get_container(info->mime_widget);
     body = add_multipart(balsa_message, info->body,
diff --git a/src/balsa-mime-widget-crypto.c b/src/balsa-mime-widget-crypto.c
index e9e45d546..1ad3737a2 100644
--- a/src/balsa-mime-widget-crypto.c
+++ b/src/balsa-mime-widget-crypto.c
@@ -130,11 +130,13 @@ balsa_mime_widget_signature_widget(LibBalsaMessageBody * mime_body,
        GtkWidget *hbox;
         GtkWidget *button;
 
-        hbox = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, BMW_HBOX_SPACE);
+        hbox = gtk_button_box_new(GTK_ORIENTATION_HORIZONTAL);
+        gtk_button_box_set_layout(GTK_BUTTON_BOX(hbox), GTK_BUTTONBOX_EXPAND);
+        gtk_box_set_spacing(GTK_BOX(hbox), BMW_HBOX_SPACE);
+
         gtk_widget_set_vexpand(hbox, TRUE);
         gtk_widget_set_valign(hbox, GTK_ALIGN_FILL);
-        gtk_container_add(GTK_CONTAINER(vbox), hbox);
-
+        gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, FALSE, 0);
         if (g_mime_gpgme_sigstat_status(mime_body->sig_info) == GPG_ERR_NO_PUBKEY) {
 #ifdef ENABLE_AUTOCRYPT
                GBytes *autocrypt_key;
@@ -162,6 +164,10 @@ balsa_mime_widget_signature_widget(LibBalsaMessageBody * mime_body,
         g_signal_connect(button, "clicked",
                          G_CALLBACK(on_gpg_key_button),
                          (gpointer) g_mime_gpgme_sigstat_fingerprint(mime_body->sig_info));
+
+        gtk_widget_set_hexpand(button, TRUE);
+        gtk_widget_set_halign(button, GTK_ALIGN_FILL);
+        gtk_container_add(GTK_CONTAINER(hbox), button);
     }
 
     /* Hack alert: if we omit the box below and use the expander as signature widget
@@ -372,7 +378,7 @@ create_import_keys_widget(BalsaMimeWidget *mw, const gchar *key_buf, GError **er
                                                                               BMW_VBOX_SPACE);
                                                     gtk_widget_set_margin_bottom(separator,
                                                                                  BMW_VBOX_SPACE);
-                                                    gtk_container_add(GTK_CONTAINER(mw), separator);
+                                                    gtk_box_pack_start(box, separator, FALSE, FALSE, 0);
                                                }
                                        }
                                }
diff --git a/src/balsa-mime-widget-message.c b/src/balsa-mime-widget-message.c
index 16389be8d..aa57f4669 100644
--- a/src/balsa-mime-widget-message.c
+++ b/src/balsa-mime-widget-message.c
@@ -245,13 +245,13 @@ bmw_message_extbody_url(LibBalsaMessageBody * mime_body,
     gtk_container_set_border_width(GTK_CONTAINER(mw),
                                   BMW_CONTAINER_BORDER);
 
-    gtk_container_add(GTK_CONTAINER(mw), gtk_label_new(msg->str));
+    gtk_box_pack_start(GTK_BOX(mw), gtk_label_new(msg->str), FALSE, FALSE, 0);
     g_string_free(msg, TRUE);
 
     button = gtk_button_new_with_label(url);
     gtk_widget_set_margin_top(button, BMW_BUTTON_PACK_SPACE);
     gtk_widget_set_margin_bottom(button, BMW_BUTTON_PACK_SPACE);
-    gtk_container_add(GTK_CONTAINER(mw), button);
+    gtk_box_pack_start(GTK_BOX(mw), button, FALSE, FALSE, 0);
 
     g_object_set_data_full(G_OBJECT(button), "call_url", url,
                           (GDestroyNotify) g_free);
@@ -292,7 +292,7 @@ bmw_message_extbody_mail(LibBalsaMessageBody * mime_body)
     gtk_container_set_border_width(GTK_CONTAINER(mw),
                                   BMW_CONTAINER_BORDER);
 
-    gtk_container_add(GTK_CONTAINER(mw), gtk_label_new(msg->str));
+    gtk_box_pack_start(GTK_BOX(mw), gtk_label_new(msg->str), FALSE, FALSE, 0);
     g_string_free(msg, TRUE);
 
     button =
@@ -300,7 +300,7 @@ bmw_message_extbody_mail(LibBalsaMessageBody * mime_body)
                                     ("Se_nd message to obtain this part"));
     gtk_widget_set_margin_top(button, BMW_BUTTON_PACK_SPACE);
     gtk_widget_set_margin_bottom(button, BMW_BUTTON_PACK_SPACE);
-    gtk_container_add(GTK_CONTAINER(mw), button);
+    gtk_box_pack_start(GTK_BOX(mw), button, FALSE, FALSE, 0);
     g_signal_connect(button, "clicked",
                     G_CALLBACK(extbody_send_mail), (gpointer) mime_body);
 
@@ -424,7 +424,7 @@ balsa_mime_widget_new_message_tl(BalsaMessage * bm,
     gtk_widget_set_valign(container, GTK_ALIGN_FILL);
     gtk_widget_set_margin_top(container, BMW_CONTAINER_BORDER - BMW_MESSAGE_PADDING);
     gtk_widget_set_margin_bottom(container, BMW_CONTAINER_BORDER - BMW_MESSAGE_PADDING);
-    gtk_container_add(GTK_CONTAINER(mw), container);
+    gtk_box_pack_start(GTK_BOX(mw), container, FALSE, FALSE, 0);
 
     return mw;
 }
@@ -527,6 +527,18 @@ bm_header_widget_new(BalsaMessage * bm, GtkWidget * const * buttons)
     g_signal_connect(key_controller, "key-pressed",
                     G_CALLBACK(balsa_mime_widget_key_pressed), bm);
 
+#ifdef GTK_INFO_BAR_WRAPPING_IS_BROKEN
+    hbox = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 0);
+    gtk_container_add(GTK_CONTAINER(hbox), grid);
+    gtk_container_set_border_width(GTK_CONTAINER(hbox), 6);
+
+    action_area = gtk_button_box_new(GTK_ORIENTATION_VERTICAL);
+    gtk_button_box_set_layout(GTK_BUTTON_BOX(action_area),
+                              GTK_BUTTONBOX_START);
+
+    gtk_widget_set_valign(action_area, GTK_ALIGN_FILL);
+    gtk_box_pack_end(GTK_BOX(hbox), action_area, FALSE, FALSE, 0);
+#else                           /* GTK_INFO_BAR_WRAPPING_IS_BROKEN */
     info_bar_widget = gtk_info_bar_new();
     info_bar = GTK_INFO_BAR(info_bar_widget);
 
diff --git a/src/balsa-mime-widget.c b/src/balsa-mime-widget.c
index e8682a261..a66320097 100644
--- a/src/balsa-mime-widget.c
+++ b/src/balsa-mime-widget.c
@@ -204,7 +204,7 @@ balsa_mime_widget_new_unknown(BalsaMessage * bm,
 
     if (mime_body->filename) {
        msg = g_strdup_printf(_("File name: %s"), mime_body->filename);
-       gtk_container_add(GTK_CONTAINER(mw), gtk_label_new(msg));
+       gtk_box_pack_start(GTK_BOX(mw), gtk_label_new(msg), FALSE, FALSE, 0);
        g_free(msg);
     }
 
@@ -267,18 +267,19 @@ balsa_mime_widget_new_unknown(BalsaMessage * bm,
                                            (gpointer) mime_body))) {
         gtk_widget_set_hexpand(button, TRUE);
         gtk_widget_set_halign(button, GTK_ALIGN_FILL);
-        gtk_container_add(GTK_CONTAINER(hbox), button);
+       gtk_box_pack_start(GTK_BOX(hbox), button, FALSE, FALSE, 0);
     } else {
-       gtk_container_add(GTK_CONTAINER(mw),
+       gtk_box_pack_start(GTK_BOX(mw),
                           gtk_label_new(_("No open or view action "
-                                          "defined for this content type")));
+                                          "defined for this content type")),
+                          FALSE, FALSE, 0);
     }
     g_free(use_content_type);
 
     button = gtk_button_new_with_mnemonic(_("S_ave part"));
     gtk_widget_set_hexpand(button, TRUE);
     gtk_widget_set_halign(button, GTK_ALIGN_FILL);
-    gtk_container_add(GTK_CONTAINER(hbox), button);
+    gtk_box_pack_start(GTK_BOX(hbox), button, FALSE, FALSE, 0);
     g_signal_connect(button, "clicked",
                     G_CALLBACK(balsa_mime_widget_ctx_menu_save),
                     (gpointer) mime_body);


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