[balsa/stop-using-gtkbox-child-properties: 14/19] Various: Stop using GtkBox child properties



commit 6060a1fb763f428e4b414607692cb1c47342be7c
Author: Peter Bloomfield <PeterBloomfield bellsouth net>
Date:   Mon Jun 8 15:25:45 2020 -0400

    Various: Stop using GtkBox child properties
    
    Stop using GtkBox padding, fill and expand child properties.
    
    * src/filter-edit-callbacks.c (build_type_notebook), (build_condition_dialog):
    * src/filter-edit-dialog.c (build_left_side), (build_match_page),
      (build_action_page), (build_right_side), (filters_edit_dialog):
    * src/filter-export-dialog.c (filters_export_dialog):
    * src/filter-run-dialog.c (available_list_selection_changed),
      (selected_list_selection_changed), (balsa_filter_run_dialog_init):

 ChangeLog                   |  9 +++++++
 src/filter-edit-callbacks.c | 45 ++++++++++++++++++++++++-------
 src/filter-edit-dialog.c    | 65 +++++++++++++++++++++++++++++++--------------
 src/filter-export-dialog.c  | 10 ++++---
 src/filter-run-dialog.c     | 31 ++++++++++++++-------
 5 files changed, 117 insertions(+), 43 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index aa5303548..c7011be6c 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -109,6 +109,15 @@
        values;
        * src/filter-run-dialog.c (balsa_filter_run_dialog_new): call
        prepare-threading to get ready for filtering.
+       Various: Stop using GtkBox padding, fill and expand child properties
+
+       * src/filter-edit-callbacks.c (build_type_notebook),
+       (build_condition_dialog):
+       * src/filter-edit-dialog.c (build_left_side), (build_match_page),
+       (build_action_page), (build_right_side), (filters_edit_dialog):
+       * src/filter-export-dialog.c (filters_export_dialog):
+       * src/filter-run-dialog.c (available_list_selection_changed),
+       (selected_list_selection_changed), (balsa_filter_run_dialog_init):
 
 2020-06-07  Peter Bloomfield  <pbloomfield bellsouth net>
 
diff --git a/src/filter-edit-callbacks.c b/src/filter-edit-callbacks.c
index 386c70b81..481199cd5 100644
--- a/src/filter-edit-callbacks.c
+++ b/src/filter-edit-callbacks.c
@@ -1069,16 +1069,25 @@ build_type_notebook()
                      box,
                      0, 5, 4, 5,
                      GTK_FILL | GTK_SHRINK | GTK_EXPAND, GTK_SHRINK, 2, 2);
+
     button = gtk_button_new_with_mnemonic(_("A_dd"));
-    gtk_box_pack_start(GTK_BOX(box), button, TRUE, TRUE, 0);
+    gtk_widget_set_hexpand(button, TRUE);
+    gtk_widget_set_halign(button, GTK_ALIGN_FILL);
+    gtk_box_pack_start(GTK_BOX(box), button, FALSE, FALSE, 0);
     g_signal_connect(button, "clicked",
                      G_CALLBACK(fe_add_pressed), NULL);
+
     fe_regex_remove_button = gtk_button_new_with_mnemonic(_("_Remove"));
-    gtk_box_pack_start(GTK_BOX(box), fe_regex_remove_button, TRUE, TRUE, 0);
+    gtk_widget_set_hexpand(fe_regex_remove_button, TRUE);
+    gtk_widget_set_halign(fe_regex_remove_button, GTK_ALIGN_FILL);
+    gtk_box_pack_start(GTK_BOX(box), fe_regex_remove_button, FALSE, FALSE, 0);
     g_signal_connect(fe_regex_remove_button, "clicked",
                      G_CALLBACK(fe_remove_pressed), NULL);
+
     button = gtk_button_new_with_mnemonic(_("One _Matches/None Matches"));
-    gtk_box_pack_start(GTK_BOX(box), button, TRUE, TRUE, 0);
+    gtk_widget_set_hexpand(button, TRUE);
+    gtk_widget_set_halign(button, GTK_ALIGN_FILL);
+    gtk_box_pack_start(GTK_BOX(box), button, FALSE, FALSE, 0);
     g_signal_connect(button, "clicked",
                      G_CALLBACK(fe_negate_condition), NULL);
 
@@ -1090,7 +1099,9 @@ build_type_notebook()
 #else                   /* REGULAR_EXPRESSION_FILTERING_IS_IMPLEMENTED */
     msg = _("Filtering using regular expressions is not yet implemented.");
     label = gtk_label_new(msg);
-    gtk_box_pack_start(GTK_BOX(box), label, TRUE, TRUE, 0);
+    gtk_widget_set_hexpand(label, TRUE);
+    gtk_widget_set_halign(label, GTK_ALIGN_FILL);
+    gtk_box_pack_start(GTK_BOX(box), label, FALSE, FALSE, 0);
 #endif                  /* REGULAR_EXPRESSION_FILTERING_IS_IMPLEMENTED */
 
     /* The date page of the notebook */
@@ -1176,21 +1187,35 @@ void build_condition_dialog(GtkWidget * condition_dialog)
     /* builds the toggle buttons to specify fields concerned by the
      * conditions of the filter */
     box = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 5);
+
     label = gtk_label_new_with_mnemonic(_("Search T_ype:"));
-    gtk_box_pack_start(GTK_BOX(box), label, FALSE, FALSE, 5);
-    fe_search_option_menu = 
+    gtk_widget_set_margin_start(label, 5);
+    gtk_widget_set_margin_end(label, 5);
+    gtk_box_pack_start(GTK_BOX(box), label, FALSE, FALSE, 0);
+
+    fe_search_option_menu =
         fe_build_option_menu(fe_search_type, G_N_ELEMENTS(fe_search_type),
                              G_CALLBACK(fe_typesmenu_cb), field_frame);
-    gtk_box_pack_start(GTK_BOX(box), fe_search_option_menu, FALSE, FALSE, 5);
+    gtk_widget_set_margin_start(fe_search_option_menu, 5);
+    gtk_widget_set_margin_end(fe_search_option_menu, 5);
+    gtk_box_pack_start(GTK_BOX(box), fe_search_option_menu, FALSE, FALSE, 0);
     gtk_label_set_mnemonic_widget(GTK_LABEL(label), fe_search_option_menu);
 
     content_box =
         GTK_BOX(gtk_dialog_get_content_area(GTK_DIALOG(condition_dialog)));
-    gtk_box_pack_start(content_box, box, FALSE, FALSE, 2);
-    gtk_box_pack_start(content_box, field_frame, FALSE, FALSE, 2);
+
+    gtk_widget_set_margin_top(box, 2);
+    gtk_widget_set_margin_bottom(box, 2);
+    gtk_box_pack_start(content_box, box, FALSE, FALSE, 0);
+
+    gtk_widget_set_margin_top(field_frame, 2);
+    gtk_widget_set_margin_bottom(field_frame, 2);
+    gtk_box_pack_start(content_box, field_frame, FALSE, FALSE, 0);
 
     build_type_notebook();
-    gtk_box_pack_start(content_box, fe_type_notebook, FALSE, FALSE, 2);
+    gtk_widget_set_margin_top(fe_type_notebook, 2);
+    gtk_widget_set_margin_bottom(fe_type_notebook, 2);
+    gtk_box_pack_start(content_box, fe_type_notebook, FALSE, FALSE, 0);
 }
 
 /*
diff --git a/src/filter-edit-dialog.c b/src/filter-edit-dialog.c
index e14e5e0a8..8f5df6462 100644
--- a/src/filter-edit-dialog.c
+++ b/src/filter-edit-dialog.c
@@ -195,7 +195,7 @@ build_left_side(void)
        | -- --  |
        \--------/
      */
-    vbox = gtk_box_new(GTK_ORIENTATION_VERTICAL, 2);
+    vbox = gtk_box_new(GTK_ORIENTATION_VERTICAL, 4);
 
     /* the list */
     sw = gtk_scrolled_window_new(NULL, NULL);
@@ -211,14 +211,18 @@ build_left_side(void)
 
     gtk_container_add(GTK_CONTAINER(sw), GTK_WIDGET(fe_filters_list));
 
-    gtk_box_pack_start(GTK_BOX(vbox), sw, TRUE, TRUE, 2);
+    gtk_widget_set_vexpand(sw, TRUE);
+    gtk_widget_set_valign(sw, GTK_ALIGN_FILL);
+    gtk_widget_set_margin_top(sw, 2);
+    gtk_widget_set_margin_bottom(sw, 2);
+    gtk_container_add(GTK_CONTAINER(vbox), sw);
 
     /* new and delete buttons */
     bbox = gtk_button_box_new(GTK_ORIENTATION_HORIZONTAL);
     gtk_box_set_spacing(GTK_BOX(bbox), 2);
     gtk_button_box_set_layout(GTK_BUTTON_BOX(bbox), GTK_BUTTONBOX_SPREAD);
 
-    gtk_box_pack_start(GTK_BOX(vbox), bbox, FALSE, FALSE, 2);
+    gtk_box_pack_start(GTK_BOX(vbox), bbox, FALSE, FALSE, 0);
 
     /* new button */
     /* Translators: button "New" filter */
@@ -283,8 +287,9 @@ build_match_page()
                                                NULL, NULL);
     g_signal_connect(fe_op_codes_option_menu, "changed",
                      G_CALLBACK(fe_action_changed), NULL);
-    gtk_box_pack_start(GTK_BOX(box), fe_op_codes_option_menu, FALSE, FALSE,
-                      2);
+    gtk_widget_set_margin_top(fe_op_codes_option_menu, 2);
+    gtk_widget_set_margin_bottom(fe_op_codes_option_menu, 2);
+    gtk_box_pack_start(GTK_BOX(box), fe_op_codes_option_menu, FALSE, FALSE, 0);
 
     /* list of conditions defining how this filter matches */
 
@@ -447,8 +452,10 @@ build_action_page(GtkWindow * window)
     fe_action_option_menu =
         fe_build_option_menu(fe_actions, G_N_ELEMENTS(fe_actions),
                              G_CALLBACK(fe_action_selected), NULL);
-    gtk_box_pack_start(GTK_BOX(box), fe_action_option_menu,
-                       TRUE, FALSE, 1);
+    gtk_widget_set_vexpand(fe_action_option_menu, TRUE);
+    gtk_widget_set_margin_top(fe_action_option_menu, 1);
+    gtk_widget_set_margin_bottom(fe_action_option_menu, 1);
+    gtk_container_add(GTK_CONTAINER(box), fe_action_option_menu);
 
     /* FIXME : we use the global mru folder list, perhaps we should use
        our own. We'll see this later, for now let's make something usable
@@ -459,10 +466,17 @@ build_action_page(GtkWindow * window)
                                                &balsa_app.folder_mru);
     g_signal_connect(fe_mailboxes, "changed",
                      G_CALLBACK(fe_action_changed), NULL);
-    gtk_box_pack_start(GTK_BOX(box), fe_mailboxes, TRUE, FALSE, 1);
+    gtk_widget_set_vexpand(fe_mailboxes, TRUE);
+    gtk_widget_set_margin_top(fe_mailboxes, 1);
+    gtk_widget_set_margin_bottom(fe_mailboxes, 1);
+    gtk_container_add(GTK_CONTAINER(box), fe_mailboxes);
 
     fe_color_buttons = fe_make_color_buttons();
-    gtk_box_pack_start(GTK_BOX(box), fe_color_buttons, TRUE, FALSE, 1);
+    gtk_widget_set_vexpand(fe_color_buttons, TRUE);
+    gtk_widget_set_margin_top(fe_color_buttons, 1);
+    gtk_widget_set_margin_bottom(fe_color_buttons, 1);
+    gtk_container_add(GTK_CONTAINER(box), fe_color_buttons);
+
     return page;
 }                              /* end build_action_page() */
 
@@ -484,7 +498,9 @@ build_right_side(GtkWindow * window)
     /* the main notebook */
     notebook = gtk_notebook_new();
     gtk_notebook_set_tab_pos(GTK_NOTEBOOK(notebook), GTK_POS_TOP);
-    gtk_box_pack_start(GTK_BOX(rightside), notebook, TRUE, TRUE, 0);
+    gtk_widget_set_vexpand(notebook, TRUE);
+    gtk_widget_set_valign(notebook, GTK_ALIGN_FILL);
+    gtk_container_add(GTK_CONTAINER(rightside), notebook);
 
     page = build_match_page();
     gtk_notebook_append_page(GTK_NOTEBOOK(notebook),
@@ -586,11 +602,15 @@ filters_edit_dialog(GtkWindow * parent)
 
     /* main hbox */
     hbox = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, FILTER_EDIT_PADDING);
-    gtk_box_pack_start(GTK_BOX
-                       (gtk_dialog_get_content_area(GTK_DIALOG(fe_window))),
-                       hbox, TRUE, TRUE, FILTER_EDIT_PADDING);
-    gtk_box_pack_start(GTK_BOX(hbox), piece, FALSE, FALSE,
-                       FILTER_EDIT_PADDING);
+    gtk_widget_set_hexpand(hbox, TRUE);
+    gtk_widget_set_halign(hbox, GTK_ALIGN_FILL);
+    gtk_widget_set_margin_start(hbox, FILTER_EDIT_PADDING);
+    gtk_widget_set_margin_end(hbox, FILTER_EDIT_PADDING);
+    gtk_container_add(GTK_CONTAINER(gtk_dialog_get_content_area(GTK_DIALOG(fe_window))), hbox);
+
+    gtk_widget_set_margin_start(piece, FILTER_EDIT_PADDING);
+    gtk_widget_set_margin_end(piece, FILTER_EDIT_PADDING);
+    gtk_box_pack_start(GTK_BOX(hbox), piece, FALSE, FALSE, 0);
 
     gtk_box_pack_start(GTK_BOX(hbox),
                        gtk_separator_new(GTK_ORIENTATION_VERTICAL),
@@ -598,20 +618,25 @@ filters_edit_dialog(GtkWindow * parent)
 
     fe_right_page = build_right_side(GTK_WINDOW(fe_window));
     gtk_widget_set_sensitive(fe_right_page, FALSE);
-    gtk_box_pack_start(GTK_BOX(hbox), fe_right_page, TRUE, TRUE,
-                       FILTER_EDIT_PADDING);
+
+    gtk_widget_set_hexpand(fe_right_page, TRUE);
+    gtk_widget_set_halign(fe_right_page, GTK_ALIGN_FILL);
+    gtk_widget_set_margin_start(fe_right_page, FILTER_EDIT_PADDING);
+    gtk_widget_set_margin_end(fe_right_page, FILTER_EDIT_PADDING);
+    gtk_box_pack_start(GTK_BOX(hbox), fe_right_page, FALSE, FALSE, 0);
 
     fe_user_headers_list = NULL;
 
     /* Populate the list of filters */
     model = gtk_tree_view_get_model(fe_filters_list);
-    for(filter_list=balsa_app.filters; 
-        filter_list; filter_list=g_slist_next(filter_list)) {
+    for (filter_list = balsa_app.filters;
+         filter_list != NULL;
+         filter_list = filter_list->next) {
 
        fil=(LibBalsaFilter*)filter_list->data;
        /* Make a copy of the current filter */
        cpfil=libbalsa_filter_new();
-       
+
        cpfil->name=g_strdup(fil->name);
        cpfil->flags=fil->flags;
        if (fil->sound) cpfil->sound=g_strdup(fil->sound);
diff --git a/src/filter-export-dialog.c b/src/filter-export-dialog.c
index efc3413a8..de5b87ca2 100644
--- a/src/filter-export-dialog.c
+++ b/src/filter-export-dialog.c
@@ -90,11 +90,13 @@ filters_export_dialog(GtkWindow * parent)
     list =
         libbalsa_filter_list_new(TRUE, _("Name"), GTK_SELECTION_MULTIPLE,
                                  NULL, TRUE);
-
     gtk_container_add(GTK_CONTAINER(sw), GTK_WIDGET(list));
-    gtk_box_pack_start(GTK_BOX
-                       (gtk_dialog_get_content_area(GTK_DIALOG(fex_window))),
-                       sw, TRUE, TRUE, 2);
+
+    gtk_widget_set_vexpand(sw, TRUE);
+    gtk_widget_set_valign(sw, GTK_ALIGN_FILL);
+    gtk_widget_set_margin_top(sw, 2);
+    gtk_widget_set_margin_bottom(sw, 2);
+    gtk_container_add(GTK_CONTAINER(gtk_dialog_get_content_area(GTK_DIALOG(fex_window))), sw);
 
     /* Populate the list of filters */
 
diff --git a/src/filter-run-dialog.c b/src/filter-run-dialog.c
index 337f47d7a..e9cc6120f 100644
--- a/src/filter-run-dialog.c
+++ b/src/filter-run-dialog.c
@@ -308,11 +308,14 @@ balsa_filter_run_dialog_init(BalsaFilterRunDialog *p)
 
     hbox = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 2);
 
-    gtk_box_pack_start(GTK_BOX(gtk_dialog_get_content_area(GTK_DIALOG(p))),
-                      hbox, TRUE, TRUE, 0);
+    gtk_widget_set_vexpand(hbox, TRUE);
+    gtk_widget_set_valign(hbox, GTK_ALIGN_FILL);
+    gtk_container_add(GTK_CONTAINER(gtk_dialog_get_content_area(GTK_DIALOG(p))), hbox);
 
     vbox = gtk_box_new(GTK_ORIENTATION_VERTICAL, 2);
-    gtk_box_pack_start(GTK_BOX(hbox), vbox, TRUE, TRUE, 0);
+    gtk_widget_set_hexpand(vbox, TRUE);
+    gtk_widget_set_halign(vbox, GTK_ALIGN_FILL);
+    gtk_box_pack_start(GTK_BOX(hbox), vbox, FALSE, FALSE, 0);
 
     p->available_filters =
         libbalsa_filter_list_new(TRUE, _("Name"), GTK_SELECTION_MULTIPLE,
@@ -328,15 +331,19 @@ balsa_filter_run_dialog_init(BalsaFilterRunDialog *p)
     gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(sw),
                                    GTK_POLICY_AUTOMATIC,
                                    GTK_POLICY_AUTOMATIC);
-
     gtk_container_add(GTK_CONTAINER(sw), GTK_WIDGET(p->available_filters));
-    gtk_box_pack_start(GTK_BOX(vbox), sw, TRUE, TRUE, 0);
+
+    gtk_widget_set_vexpand(sw, TRUE);
+    gtk_widget_set_valign(sw, GTK_ALIGN_FILL);
+    gtk_container_add(GTK_CONTAINER(vbox), sw);
 
     /* To keep a consistent look, make a button box for a single button. */
     bbox = gtk_button_box_new(GTK_ORIENTATION_HORIZONTAL);
     gtk_box_set_spacing(GTK_BOX(bbox), 2);
     gtk_button_box_set_layout(GTK_BUTTON_BOX(bbox), GTK_BUTTONBOX_SPREAD);
-    gtk_box_pack_start(GTK_BOX(vbox), bbox, FALSE, FALSE, 2);
+    gtk_widget_set_margin_top(bbox, 2);
+    gtk_widget_set_margin_bottom(bbox, 2);
+    gtk_box_pack_start(GTK_BOX(vbox), bbox, FALSE, FALSE, 0);
 
     /* "Apply selected" button */
     p->apply_selected_button = button =
@@ -376,7 +383,9 @@ balsa_filter_run_dialog_init(BalsaFilterRunDialog *p)
 
     vbox = gtk_box_new(GTK_ORIENTATION_VERTICAL, 2);
 
-    gtk_box_pack_start(GTK_BOX(hbox),vbox, TRUE, TRUE, 0);
+    gtk_widget_set_hexpand(vbox, TRUE);
+    gtk_widget_set_halign(vbox, GTK_ALIGN_FILL);
+    gtk_box_pack_start(GTK_BOX(hbox),vbox, FALSE, FALSE, 0);
 
     sw = gtk_scrolled_window_new(NULL, NULL);
     gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(sw),
@@ -393,14 +402,18 @@ balsa_filter_run_dialog_init(BalsaFilterRunDialog *p)
 
     gtk_container_add(GTK_CONTAINER(sw), GTK_WIDGET(p->selected_filters));
 
-    gtk_box_pack_start(GTK_BOX(vbox),sw, TRUE, TRUE, 0);
+    gtk_widget_set_vexpand(sw, TRUE);
+    gtk_widget_set_valign(sw, GTK_ALIGN_FILL);
+    gtk_container_add(GTK_CONTAINER(vbox), sw);
 
     /* up down arrow buttons */
     bbox = gtk_button_box_new(GTK_ORIENTATION_HORIZONTAL);
     gtk_box_set_spacing(GTK_BOX(bbox), 2);
     gtk_button_box_set_layout(GTK_BUTTON_BOX(bbox), GTK_BUTTONBOX_SPREAD);
 
-    gtk_box_pack_start(GTK_BOX(vbox), bbox, FALSE, FALSE, 2);
+    gtk_widget_set_margin_top(bbox, 2);
+    gtk_widget_set_margin_bottom(bbox, 2);
+    gtk_box_pack_start(GTK_BOX(vbox), bbox, FALSE, FALSE, 0);
 
     /* up button */
     p->move_up_button = button =


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