[gnome-software] Replace gtk_box_pack_* with gtk_container_add



commit 770e9e65957dbbd37770ea556401eb7883d2cc8e
Author: Robert Ancell <robert ancell canonical com>
Date:   Fri Sep 28 10:17:17 2018 +1200

    Replace gtk_box_pack_* with gtk_container_add
    
    gtk_box_pack_* has different arguments in GTK+ 4, gtk_container_add has the
    same behaviour in both GTK+ 3 and 4.

 src/gs-app-folder-dialog.c |  3 ++-
 src/gs-common.c            |  6 ++++--
 src/gs-details-page.c      | 13 ++++++-------
 src/gs-editor.c            |  4 ++--
 src/gs-history-dialog.c    |  9 ++++++---
 src/gs-overview-page.c     |  2 +-
 src/gs-page.c              |  3 ++-
 src/gs-removal-dialog.c    |  2 +-
 src/gs-shell.c             | 12 ++++++------
 src/gs-update-dialog.c     | 13 +++++++------
 src/gs-updates-page.c      | 15 +++++++++------
 src/gs-updates-section.c   |  6 ++++--
 12 files changed, 50 insertions(+), 38 deletions(-)
---
diff --git a/src/gs-app-folder-dialog.c b/src/gs-app-folder-dialog.c
index 8ccdd3a0..467f90d8 100644
--- a/src/gs-app-folder-dialog.c
+++ b/src/gs-app-folder-dialog.c
@@ -176,7 +176,8 @@ create_row (GsAppFolderDialog *dialog, const gchar *folder)
                      NULL);
        gtk_widget_set_valign (label, GTK_ALIGN_CENTER);
        gtk_widget_set_halign (label, GTK_ALIGN_START);
-       gtk_box_pack_start (GTK_BOX (box), label, TRUE, TRUE, 0);
+       gtk_widget_set_hexpand (label, TRUE);
+       gtk_container_add (GTK_CONTAINER (box), label);
        image = gtk_image_new_from_icon_name ("object-select-symbolic", GTK_ICON_SIZE_MENU);
        gtk_widget_set_no_show_all (image, TRUE);
        gtk_widget_set_valign (image, GTK_ALIGN_CENTER);
diff --git a/src/gs-common.c b/src/gs-common.c
index 2e729c83..0eb7a36b 100644
--- a/src/gs-common.c
+++ b/src/gs-common.c
@@ -454,7 +454,7 @@ insert_details_widget (GtkMessageDialog *dialog, const gchar *details)
        label = gtk_label_new (_("Details"));
        gtk_widget_set_halign (label, GTK_ALIGN_START);
        gtk_widget_set_visible (label, TRUE);
-       gtk_box_pack_start (GTK_BOX (message_area), label, FALSE, FALSE, 0);
+       gtk_container_add (GTK_CONTAINER (message_area), label);
 
        sw = gtk_scrolled_window_new (NULL, NULL);
        gtk_scrolled_window_set_shadow_type (GTK_SCROLLED_WINDOW (sw),
@@ -475,7 +475,9 @@ insert_details_widget (GtkMessageDialog *dialog, const gchar *details)
        gtk_widget_set_visible (tv, TRUE);
 
        gtk_container_add (GTK_CONTAINER (sw), tv);
-       gtk_box_pack_end (GTK_BOX (message_area), sw, TRUE, TRUE, 0);
+       gtk_widget_set_vexpand (sw, TRUE);
+       gtk_container_add (GTK_CONTAINER (message_area), sw);
+       gtk_container_child_set (GTK_CONTAINER (message_area), sw, "pack-type", GTK_PACK_END, NULL);
 
        g_signal_connect (dialog, "map-event", G_CALLBACK (unset_focus), NULL);
 }
diff --git a/src/gs-details-page.c b/src/gs-details-page.c
index 66b9f1f1..8ba56827 100644
--- a/src/gs-details-page.c
+++ b/src/gs-details-page.c
@@ -654,7 +654,7 @@ gs_details_page_refresh_screenshots (GsDetailsPage *self)
                                      "max-width-chars", 10,
                                      "wrap", TRUE,
                                      NULL);
-                       gtk_box_pack_start (GTK_BOX (self->box_details_screenshot_main), label, FALSE, FALSE, 
0);
+                       gtk_container_add (GTK_CONTAINER (self->box_details_screenshot_main), label);
                        gtk_widget_set_visible (label, TRUE);
 
                        /* set images */
@@ -665,7 +665,7 @@ gs_details_page_refresh_screenshots (GsDetailsPage *self)
                                                      48);
                        gs_screenshot_image_set_use_desktop_background (GS_SCREENSHOT_IMAGE (ssimg), FALSE);
                        gs_screenshot_image_load_async (GS_SCREENSHOT_IMAGE (ssimg), NULL);
-                       gtk_box_pack_start (GTK_BOX (self->box_details_screenshot_main), ssimg, FALSE, FALSE, 
0);
+                       gtk_container_add (GTK_CONTAINER (self->box_details_screenshot_main), ssimg);
                        gtk_widget_set_visible (ssimg, TRUE);
                }
                gtk_widget_set_visible (self->box_details_screenshot,
@@ -721,7 +721,7 @@ gs_details_page_refresh_screenshots (GsDetailsPage *self)
                                              AS_IMAGE_NORMAL_HEIGHT);
        }
        gs_screenshot_image_load_async (GS_SCREENSHOT_IMAGE (ssimg), NULL);
-       gtk_box_pack_start (GTK_BOX (self->box_details_screenshot_main), ssimg, FALSE, FALSE, 0);
+       gtk_container_add (GTK_CONTAINER (self->box_details_screenshot_main), ssimg);
        gtk_widget_set_visible (ssimg, TRUE);
 
        /* set all the thumbnails */
@@ -732,7 +732,7 @@ gs_details_page_refresh_screenshots (GsDetailsPage *self)
        list = gtk_list_box_new ();
        gtk_style_context_add_class (gtk_widget_get_style_context (list), "image-list");
        gtk_widget_show (list);
-       gtk_box_pack_start (GTK_BOX (self->box_details_screenshot_thumbnails), list, FALSE, FALSE, 0);
+       gtk_container_add (GTK_CONTAINER (self->box_details_screenshot_thumbnails), list);
        for (i = 0; i < screenshots->len; i++) {
                ss = g_ptr_array_index (screenshots, i);
                ssimg = gs_screenshot_image_new (self->session);
@@ -801,7 +801,7 @@ gs_details_page_set_description (GsDetailsPage *self, const gchar *tmp)
                gtk_style_context_add_class (style_context,
                                             "application-details-description");
 
-               gtk_box_pack_start (GTK_BOX (self->box_details_description), para, FALSE, FALSE, 0);
+               gtk_container_add (GTK_CONTAINER (self->box_details_description), para);
        }
 
        /* show the webapp warning */
@@ -813,8 +813,7 @@ gs_details_page_set_description (GsDetailsPage *self, const gchar *tmp)
                gtk_label_set_xalign (GTK_LABEL (label), 0.f);
                gtk_style_context_add_class (gtk_widget_get_style_context (label),
                                             "application-details-webapp-warning");
-               gtk_box_pack_start (GTK_BOX (self->box_details_description),
-                                   label, FALSE, FALSE, 0);
+               gtk_container_add (GTK_CONTAINER (self->box_details_description), label);
        }
 }
 
diff --git a/src/gs-editor.c b/src/gs-editor.c
index bcc5f7ca..10d1d4ca 100644
--- a/src/gs-editor.c
+++ b/src/gs-editor.c
@@ -1003,8 +1003,8 @@ gs_editor_startup_cb (GtkApplication *application, GsEditor *self)
        self->featured_tile1 = gs_feature_tile_new (NULL);
        self->upgrade_banner = gs_upgrade_banner_new ();
        widget = GTK_WIDGET (gtk_builder_get_object (self->builder, "box_featured"));
-       gtk_box_pack_start (GTK_BOX (widget), self->featured_tile1, FALSE, FALSE, 0);
-       gtk_box_pack_start (GTK_BOX (widget), self->upgrade_banner, FALSE, FALSE, 0);
+       gtk_container_add (GTK_CONTAINER (widget), self->featured_tile1);
+       gtk_container_add (GTK_CONTAINER (widget), self->upgrade_banner);
 
        widget = GTK_WIDGET (gtk_builder_get_object (self->builder, "textview_css"));
        buffer = gtk_text_view_get_buffer (GTK_TEXT_VIEW (widget));
diff --git a/src/gs-history-dialog.c b/src/gs-history-dialog.c
index 27f0b965..8feb2df5 100644
--- a/src/gs-history-dialog.c
+++ b/src/gs-history-dialog.c
@@ -108,9 +108,10 @@ gs_history_dialog_set_app (GsHistoryDialog *dialog, GsApp *app)
                              "margin-top", 6,
                              "margin-bottom", 6,
                              "xalign", 0.0,
+                             "hexpand", TRUE,
                              NULL);
                gtk_size_group_add_widget (dialog->sizegroup_state, widget);
-               gtk_box_pack_start (box, widget, TRUE, TRUE, 0);
+               gtk_container_add (GTK_CONTAINER (box), widget);
 
                /* add the timestamp */
                timestamp = gs_app_get_install_date (app);
@@ -127,9 +128,10 @@ gs_history_dialog_set_app (GsHistoryDialog *dialog, GsApp *app)
                              "margin-top", 6,
                              "margin-bottom", 6,
                              "xalign", 0.0,
+                             "hexpand", TRUE,
                              NULL);
                gtk_size_group_add_widget (dialog->sizegroup_timestamp, widget);
-               gtk_box_pack_start (box, widget, TRUE, TRUE, 0);
+               gtk_container_add (GTK_CONTAINER (box), widget);
 
                /* add the version */
                widget = gtk_label_new (gs_app_get_version (app));
@@ -141,9 +143,10 @@ gs_history_dialog_set_app (GsHistoryDialog *dialog, GsApp *app)
                              "xalign", 1.0,
                              "ellipsize", PANGO_ELLIPSIZE_END,
                              "width-chars", 10,
+                             "hexpand", TRUE,
                              NULL);
                gtk_size_group_add_widget (dialog->sizegroup_version, widget);
-               gtk_box_pack_start (box, widget, TRUE, TRUE, 0);
+               gtk_container_add (GTK_CONTAINER (box), widget);
 
                gtk_widget_show_all (GTK_WIDGET (box));
                gtk_list_box_insert (GTK_LIST_BOX (dialog->list_box), GTK_WIDGET (box), -1);
diff --git a/src/gs-overview-page.c b/src/gs-overview-page.c
index ded50c1c..81d27000 100644
--- a/src/gs-overview-page.c
+++ b/src/gs-overview-page.c
@@ -510,7 +510,7 @@ gs_overview_page_get_featured_cb (GObject *source_object,
                gtk_widget_show (event_box);
                g_signal_connect (event_box, "button_release_event",
                          G_CALLBACK (featured_switcher_clicked), self);
-               gtk_box_pack_start (GTK_BOX (priv->box_featured_switcher), event_box, FALSE, TRUE, 0);
+               gtk_container_add (GTK_CONTAINER (priv->box_featured_switcher), event_box);
 
                label = gtk_label_new (i == 0 ? FEATURED_SWITCHER_ACTIVE_TEXT : 
FEATURED_SWITCHER_INACTIVE_TEXT);
                gtk_style_context_add_class (gtk_widget_get_style_context (label),
diff --git a/src/gs-page.c b/src/gs-page.c
index 1432d63d..415b2ceb 100644
--- a/src/gs-page.c
+++ b/src/gs-page.c
@@ -612,7 +612,8 @@ gs_page_needs_user_action (GsPageHelper *helper, AsScreenshot *ss)
        gtk_widget_set_margin_start (ssimg, 24);
        gtk_widget_set_margin_end (ssimg, 24);
        content_area = gtk_dialog_get_content_area (GTK_DIALOG (dialog));
-       gtk_box_pack_end (GTK_BOX (content_area), ssimg, FALSE, FALSE, 0);
+       gtk_container_add (GTK_CONTAINER (content_area), ssimg);
+       gtk_container_child_set (GTK_CONTAINER (content_area), ssimg, "pack-type", GTK_PACK_END, NULL);
 
        /* handle this async */
        g_signal_connect (dialog, "response",
diff --git a/src/gs-removal-dialog.c b/src/gs-removal-dialog.c
index 344b889a..63cc0054 100644
--- a/src/gs-removal-dialog.c
+++ b/src/gs-removal-dialog.c
@@ -74,7 +74,7 @@ add_app (GtkListBox *listbox, GsApp *app)
        widget = gtk_label_new (gs_app_get_name (app));
        gtk_widget_set_halign (widget, GTK_ALIGN_START);
        gtk_label_set_ellipsize (GTK_LABEL (widget), PANGO_ELLIPSIZE_END);
-       gtk_box_pack_start (GTK_BOX (box), widget, FALSE, FALSE, 0);
+       gtk_container_add (GTK_CONTAINER (box), widget);
 
        g_object_set_data_full (G_OBJECT (box),
                                "sort",
diff --git a/src/gs-shell.c b/src/gs-shell.c
index ca826714..cc7553ab 100644
--- a/src/gs-shell.c
+++ b/src/gs-shell.c
@@ -733,8 +733,8 @@ add_buttons_for_auth (GsShell *shell, GsAuth *auth)
 
        gtk_widget_show (signin_button);
        gtk_widget_show (signout_button);
-       gtk_box_pack_start (GTK_BOX (account_box), signin_button, TRUE, TRUE, 0);
-       gtk_box_pack_start (GTK_BOX (account_box), signout_button, TRUE, TRUE, 0);
+       gtk_container_add (GTK_CONTAINER (account_box), signin_button);
+       gtk_container_add (GTK_CONTAINER (account_box), signout_button);
 }
 
 static void
@@ -760,11 +760,11 @@ account_button_clicked_cb (GtkButton *button, GsShell *shell)
                GsAuth *auth = g_ptr_array_index (auth_array, i);
                add_buttons_for_auth (shell, auth);
 
-               /* Add sepeartor between each block */
+               /* Add separator between each block */
                if (i < auth_array->len - 1) {
-                       GtkWidget *seprator = gtk_separator_new (GTK_ORIENTATION_HORIZONTAL);
-                       gtk_widget_show (seprator);
-                       gtk_box_pack_start (GTK_BOX (account_box), seprator, TRUE, TRUE, 0);
+                       GtkWidget *separator = gtk_separator_new (GTK_ORIENTATION_HORIZONTAL);
+                       gtk_widget_show (separator);
+                       gtk_container_add (GTK_CONTAINER (account_box), separator);
                }
        }
 
diff --git a/src/gs-update-dialog.c b/src/gs-update-dialog.c
index f0627574..c34f51d6 100644
--- a/src/gs-update-dialog.c
+++ b/src/gs-update-dialog.c
@@ -324,8 +324,9 @@ create_app_row (GsApp *app)
                      "ellipsize", PANGO_ELLIPSIZE_END,
                      NULL);
        gtk_widget_set_halign (label, GTK_ALIGN_START);
+       gtk_widget_set_hexpand (label, TRUE);
        gtk_widget_set_valign (label, GTK_ALIGN_CENTER);
-       gtk_box_pack_start (GTK_BOX (row), label, TRUE, TRUE, 0);
+       gtk_container_add (GTK_CONTAINER (row), label);
        if (gs_app_get_state (app) == AS_APP_STATE_UPDATABLE ||
            gs_app_get_state (app) == AS_APP_STATE_UPDATABLE_LIVE) {
                g_autofree gchar *verstr = format_version_update (app);
@@ -343,7 +344,7 @@ create_app_row (GsApp *app)
                      NULL);
        gtk_widget_set_halign (label, GTK_ALIGN_END);
        gtk_widget_set_valign (label, GTK_ALIGN_CENTER);
-       gtk_box_pack_start (GTK_BOX (row), label, FALSE, FALSE, 0);
+       gtk_container_add (GTK_CONTAINER (row), label);
        gtk_widget_show_all (row);
 
        return row;
@@ -471,7 +472,8 @@ get_section_header (GsUpdateDialog *dialog, GsUpdateDialogSection section)
        gtk_style_context_add_class (context, "app-listbox-header");
 
        /* put label into the header */
-       gtk_box_pack_start (GTK_BOX (header), label, TRUE, TRUE, 0);
+       gtk_widget_set_hexpand (label, TRUE);
+       gtk_container_add (GTK_CONTAINER (header), label);
        gtk_widget_set_visible (label, TRUE);
        gtk_widget_set_margin_start (label, 6);
        gtk_label_set_xalign (GTK_LABEL (label), 0.0);
@@ -516,9 +518,8 @@ create_section (GsUpdateDialog *dialog, GsUpdateDialogSection section)
        g_signal_connect (GTK_LIST_BOX (dialog->list_boxes[section]), "row-activated",
                          G_CALLBACK (row_activated_cb), dialog);
        gtk_widget_set_visible (dialog->list_boxes[section], TRUE);
-       gtk_box_pack_start (GTK_BOX (dialog->os_update_box),
-                           dialog->list_boxes[section],
-                           TRUE, TRUE, 0);
+       gtk_widget_set_vexpand (dialog->list_boxes[section], TRUE);
+       gtk_container_add (GTK_CONTAINER (dialog->os_update_box), dialog->list_boxes[section]);
        gtk_widget_set_margin_top (dialog->list_boxes[section], 24);
 
        /* reorder the children */
diff --git a/src/gs-updates-page.c b/src/gs-updates-page.c
index 0f419e8c..c753957f 100644
--- a/src/gs-updates-page.c
+++ b/src/gs-updates-page.c
@@ -1303,9 +1303,8 @@ gs_updates_page_setup (GsPage *page,
                                                    self->sizegroup_desc,
                                                    self->sizegroup_button,
                                                    self->sizegroup_header);
-               gtk_box_pack_start (GTK_BOX (self->updates_box),
-                                   GTK_WIDGET (self->sections[i]),
-                                   TRUE, TRUE, 0);
+               gtk_widget_set_vexpand (GTK_WIDGET (self->sections[i]), TRUE);
+               gtk_container_add (GTK_CONTAINER (self->updates_box), GTK_WIDGET (self->sections[i]));
        }
 
        self->shell = shell;
@@ -1349,16 +1348,20 @@ gs_updates_page_setup (GsPage *page,
 
        /* This label indicates that the update check is in progress */
        self->header_checking_label = gtk_label_new (_("Checking…"));
-       gtk_box_pack_end (GTK_BOX (self->header_start_box), self->header_checking_label, FALSE, FALSE, 0);
+       gtk_container_add (GTK_CONTAINER (self->header_start_box), self->header_checking_label);
+       gtk_container_child_set(GTK_CONTAINER (self->header_start_box), self->header_checking_label,
+                               "pack-type", GTK_PACK_END, NULL);
        self->header_spinner_start = gtk_spinner_new ();
-       gtk_box_pack_end (GTK_BOX (self->header_start_box), self->header_spinner_start, FALSE, FALSE, 0);
+       gtk_container_add (GTK_CONTAINER (self->header_start_box), self->header_spinner_start);
+       gtk_container_child_set (GTK_CONTAINER (self->header_start_box), self->header_spinner_start,
+                                "pack-type", GTK_PACK_END, NULL);
 
        /* setup update details window */
        self->button_refresh = gtk_button_new_from_icon_name ("view-refresh-symbolic", GTK_ICON_SIZE_MENU);
        accessible = gtk_widget_get_accessible (self->button_refresh);
        if (accessible != NULL)
                atk_object_set_name (accessible, _("Check for updates"));
-       gtk_box_pack_start (GTK_BOX (self->header_start_box), self->button_refresh, FALSE, FALSE, 0);
+       gtk_container_add (GTK_CONTAINER (self->header_start_box), self->button_refresh);
        g_signal_connect (self->button_refresh, "clicked",
                          G_CALLBACK (gs_updates_page_button_refresh_cb),
                          self);
diff --git a/src/gs-updates-section.c b/src/gs-updates-section.c
index 1228f2e1..2403e6a8 100644
--- a/src/gs-updates-section.c
+++ b/src/gs-updates-section.c
@@ -387,7 +387,8 @@ _build_section_header (GsUpdatesSection *self)
        gtk_style_context_add_class (context, "app-listbox-header");
 
        /* put label into the header */
-       gtk_box_pack_start (GTK_BOX (header), label, TRUE, TRUE, 0);
+       gtk_widget_set_hexpand (label, TRUE);
+       gtk_container_add (GTK_CONTAINER (header), label);
        gtk_widget_set_visible (label, TRUE);
        gtk_widget_set_margin_start (label, 6);
        gtk_label_set_xalign (GTK_LABEL (label), 0.0);
@@ -397,7 +398,8 @@ _build_section_header (GsUpdatesSection *self)
        /* use a stack so we can switch which buttons are showing without the
         * sizegroup resizing */
        self->button_stack = GTK_STACK (gtk_stack_new ());
-       gtk_box_pack_end (GTK_BOX (header), GTK_WIDGET (self->button_stack), FALSE, FALSE, 0);
+       gtk_container_add (GTK_CONTAINER (header), GTK_WIDGET (self->button_stack));
+       gtk_container_child_set (GTK_CONTAINER (header), GTK_WIDGET (self->button_stack), "pack-type", 
GTK_PACK_END, NULL);
        gtk_size_group_add_widget (self->sizegroup_button, GTK_WIDGET (self->button_stack));
 
        /* add button, which may be hidden */


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