[gnome-software: 1/2] Group the width of button labels and button images separately




commit 8e9f58f2978356669f863435d45bd63beffc2585
Author: Adrien Plazas <kekun plazas laposte net>
Date:   Wed Jul 21 10:15:09 2021 +0200

    Group the width of button labels and button images separately
    
    This is needed to keep button widths grouped like they were on desktops
    while making the narrow mode consistently work.

 src/gs-app-row.c         |  6 +++---
 src/gs-app-row.h         |  3 ++-
 src/gs-extras-page.c     | 12 ++++++++----
 src/gs-installed-page.c  | 12 ++++++++----
 src/gs-moderate-page.c   | 12 ++++++++----
 src/gs-progress-button.c | 21 +++++++++++++++++++++
 src/gs-progress-button.h |  3 +++
 src/gs-search-page.c     | 12 ++++++++----
 src/gs-update-list.c     |  1 +
 src/gs-updates-page.c    | 15 ++++++++++-----
 src/gs-updates-section.c | 21 +++++++++++++++------
 src/gs-updates-section.h |  3 ++-
 12 files changed, 89 insertions(+), 32 deletions(-)
---
diff --git a/src/gs-app-row.c b/src/gs-app-row.c
index 1f9052e9e..0fb1283a1 100644
--- a/src/gs-app-row.c
+++ b/src/gs-app-row.c
@@ -872,7 +872,8 @@ gs_app_row_set_size_groups (GsAppRow *app_row,
                            GtkSizeGroup *image,
                            GtkSizeGroup *name,
                            GtkSizeGroup *desc,
-                           GtkSizeGroup *button)
+                           GtkSizeGroup *button_label,
+                           GtkSizeGroup *button_image)
 {
        GsAppRowPrivate *priv = gs_app_row_get_instance_private (app_row);
 
@@ -882,8 +883,7 @@ gs_app_row_set_size_groups (GsAppRow *app_row,
                gtk_size_group_add_widget (name, priv->name_box);
        if (desc != NULL)
                gtk_size_group_add_widget (desc, priv->description_box);
-       if (button != NULL)
-               gtk_size_group_add_widget (button, priv->button);
+       gs_progress_button_set_size_groups (GS_PROGRESS_BUTTON (priv->button), button_label, button_image);
 }
 
 void
diff --git a/src/gs-app-row.h b/src/gs-app-row.h
index df92ebb96..2c34f502b 100644
--- a/src/gs-app-row.h
+++ b/src/gs-app-row.h
@@ -46,7 +46,8 @@ void           gs_app_row_set_size_groups             (GsAppRow       *app_row,
                                                         GtkSizeGroup   *image,
                                                         GtkSizeGroup   *name,
                                                         GtkSizeGroup   *desc,
-                                                        GtkSizeGroup   *button);
+                                                        GtkSizeGroup   *button_label,
+                                                        GtkSizeGroup   *button_image);
 void            gs_app_row_set_show_installed_size     (GsAppRow       *app_row,
                                                         gboolean        show_size);
 gboolean        gs_app_row_get_is_narrow               (GsAppRow       *app_row);
diff --git a/src/gs-extras-page.c b/src/gs-extras-page.c
index eb595a32e..c41d687ee 100644
--- a/src/gs-extras-page.c
+++ b/src/gs-extras-page.c
@@ -48,7 +48,8 @@ struct _GsExtrasPage
        GtkSizeGroup             *sizegroup_image;
        GtkSizeGroup             *sizegroup_name;
        GtkSizeGroup             *sizegroup_desc;
-       GtkSizeGroup             *sizegroup_button;
+       GtkSizeGroup             *sizegroup_button_label;
+       GtkSizeGroup             *sizegroup_button_image;
        GPtrArray                *array_search_data;
        GsExtrasPageMode          mode;
        GsLanguage               *language;
@@ -320,7 +321,8 @@ gs_extras_page_add_app (GsExtrasPage *self, GsApp *app, GsAppList *list, SearchD
                                    self->sizegroup_image,
                                    self->sizegroup_name,
                                    self->sizegroup_desc,
-                                   self->sizegroup_button);
+                                   self->sizegroup_button_label,
+                                   self->sizegroup_button_image);
        gtk_widget_show (app_row);
 }
 
@@ -1260,7 +1262,8 @@ gs_extras_page_dispose (GObject *object)
        g_clear_object (&self->sizegroup_image);
        g_clear_object (&self->sizegroup_name);
        g_clear_object (&self->sizegroup_desc);
-       g_clear_object (&self->sizegroup_button);
+       g_clear_object (&self->sizegroup_button_label);
+       g_clear_object (&self->sizegroup_button_image);
        g_clear_object (&self->language);
        g_clear_object (&self->vendor);
        g_clear_object (&self->plugin_loader);
@@ -1283,7 +1286,8 @@ gs_extras_page_init (GsExtrasPage *self)
        self->sizegroup_image = gtk_size_group_new (GTK_SIZE_GROUP_HORIZONTAL);
        self->sizegroup_name = gtk_size_group_new (GTK_SIZE_GROUP_HORIZONTAL);
        self->sizegroup_desc = gtk_size_group_new (GTK_SIZE_GROUP_HORIZONTAL);
-       self->sizegroup_button = gtk_size_group_new (GTK_SIZE_GROUP_HORIZONTAL);
+       self->sizegroup_button_label = gtk_size_group_new (GTK_SIZE_GROUP_HORIZONTAL);
+       self->sizegroup_button_image = gtk_size_group_new (GTK_SIZE_GROUP_HORIZONTAL);
        self->vendor = gs_vendor_new ();
 
        /* map ISO639 to language names */
diff --git a/src/gs-installed-page.c b/src/gs-installed-page.c
index 1f1351b7a..6207d5228 100644
--- a/src/gs-installed-page.c
+++ b/src/gs-installed-page.c
@@ -28,7 +28,8 @@ struct _GsInstalledPage
        GtkSizeGroup            *sizegroup_image;
        GtkSizeGroup            *sizegroup_name;
        GtkSizeGroup            *sizegroup_desc;
-       GtkSizeGroup            *sizegroup_button;
+       GtkSizeGroup            *sizegroup_button_label;
+       GtkSizeGroup            *sizegroup_button_image;
        gboolean                 cache_valid;
        gboolean                 waiting;
        GsShell                 *shell;
@@ -247,7 +248,8 @@ gs_installed_page_add_app (GsInstalledPage *self, GsAppList *list, GsApp *app)
                                    self->sizegroup_image,
                                    self->sizegroup_name,
                                    self->sizegroup_desc,
-                                   self->sizegroup_button);
+                                   self->sizegroup_button_label,
+                                   self->sizegroup_button_image);
 
        gs_app_row_set_show_description (GS_APP_ROW (app_row), FALSE);
        gs_app_row_set_show_source (GS_APP_ROW (app_row), FALSE);
@@ -625,7 +627,8 @@ gs_installed_page_dispose (GObject *object)
        g_clear_object (&self->sizegroup_image);
        g_clear_object (&self->sizegroup_name);
        g_clear_object (&self->sizegroup_desc);
-       g_clear_object (&self->sizegroup_button);
+       g_clear_object (&self->sizegroup_button_label);
+       g_clear_object (&self->sizegroup_button_image);
 
        g_clear_object (&self->plugin_loader);
        g_clear_object (&self->cancellable);
@@ -702,7 +705,8 @@ gs_installed_page_init (GsInstalledPage *self)
        self->sizegroup_image = gtk_size_group_new (GTK_SIZE_GROUP_HORIZONTAL);
        self->sizegroup_name = gtk_size_group_new (GTK_SIZE_GROUP_HORIZONTAL);
        self->sizegroup_desc = gtk_size_group_new (GTK_SIZE_GROUP_HORIZONTAL);
-       self->sizegroup_button = gtk_size_group_new (GTK_SIZE_GROUP_HORIZONTAL);
+       self->sizegroup_button_label = gtk_size_group_new (GTK_SIZE_GROUP_HORIZONTAL);
+       self->sizegroup_button_image = gtk_size_group_new (GTK_SIZE_GROUP_HORIZONTAL);
 
        self->settings = g_settings_new ("org.gnome.software");
 }
diff --git a/src/gs-moderate-page.c b/src/gs-moderate-page.c
index 36d17b74d..54e184b92 100644
--- a/src/gs-moderate-page.c
+++ b/src/gs-moderate-page.c
@@ -29,7 +29,8 @@ struct _GsModeratePage
        GtkSizeGroup            *sizegroup_image;
        GtkSizeGroup            *sizegroup_name;
        GtkSizeGroup            *sizegroup_desc;
-       GtkSizeGroup            *sizegroup_button;
+       GtkSizeGroup            *sizegroup_button_label;
+       GtkSizeGroup            *sizegroup_button_image;
        GsShell                 *shell;
        GsOdrsProvider          *odrs_provider;
 
@@ -162,7 +163,8 @@ gs_moderate_page_add_app (GsModeratePage *self, GsApp *app)
                                    self->sizegroup_image,
                                    self->sizegroup_name,
                                    self->sizegroup_desc,
-                                   self->sizegroup_button);
+                                   self->sizegroup_button_label,
+                                   self->sizegroup_button_image);
 
        /* add reviews */
        reviews = gs_app_get_reviews (app);
@@ -364,7 +366,8 @@ gs_moderate_page_dispose (GObject *object)
        g_clear_object (&self->sizegroup_image);
        g_clear_object (&self->sizegroup_name);
        g_clear_object (&self->sizegroup_desc);
-       g_clear_object (&self->sizegroup_button);
+       g_clear_object (&self->sizegroup_button_label);
+       g_clear_object (&self->sizegroup_button_image);
 
        g_clear_object (&self->plugin_loader);
        g_clear_object (&self->cancellable);
@@ -424,7 +427,8 @@ gs_moderate_page_init (GsModeratePage *self)
        self->sizegroup_image = gtk_size_group_new (GTK_SIZE_GROUP_HORIZONTAL);
        self->sizegroup_name = gtk_size_group_new (GTK_SIZE_GROUP_HORIZONTAL);
        self->sizegroup_desc = gtk_size_group_new (GTK_SIZE_GROUP_HORIZONTAL);
-       self->sizegroup_button = gtk_size_group_new (GTK_SIZE_GROUP_HORIZONTAL);
+       self->sizegroup_button_label = gtk_size_group_new (GTK_SIZE_GROUP_HORIZONTAL);
+       self->sizegroup_button_image = gtk_size_group_new (GTK_SIZE_GROUP_HORIZONTAL);
 }
 
 GsModeratePage *
diff --git a/src/gs-progress-button.c b/src/gs-progress-button.c
index 3921e8979..4f084d0e4 100644
--- a/src/gs-progress-button.c
+++ b/src/gs-progress-button.c
@@ -213,6 +213,27 @@ gs_progress_button_set_show_icon (GsProgressButton *button, gboolean show_icon)
        g_object_notify_by_pspec (G_OBJECT (button), obj_props[PROP_SHOW_ICON]);
 }
 
+/**
+ * gs_progress_button_set_size_groups:
+ * @button: a #GsProgressButton
+ * @label: the #GtkSizeGroup for the label
+ * @image: the #GtkSizeGroup for the image
+ *
+ * Groups the size of different buttons while keeping adaptiveness.
+ *
+ * Since: 41
+ */
+void
+gs_progress_button_set_size_groups (GsProgressButton *button, GtkSizeGroup *label, GtkSizeGroup *image)
+{
+       g_return_if_fail (GS_IS_PROGRESS_BUTTON (button));
+
+       if (label != NULL)
+               gtk_size_group_add_widget (label, button->label);
+       if (image != NULL)
+               gtk_size_group_add_widget (image, button->image);
+}
+
 static void
 gs_progress_button_page_get_property (GObject *object, guint prop_id, GValue *value, GParamSpec *pspec)
 {
diff --git a/src/gs-progress-button.h b/src/gs-progress-button.h
index 42b2a118e..a2d89cbc4 100644
--- a/src/gs-progress-button.h
+++ b/src/gs-progress-button.h
@@ -31,5 +31,8 @@ void           gs_progress_button_set_progress        (GsProgressButton       *button,
                                                         guint                   percentage);
 void            gs_progress_button_set_show_progress   (GsProgressButton       *button,
                                                         gboolean                show_progress);
+void            gs_progress_button_set_size_groups     (GsProgressButton       *button,
+                                                        GtkSizeGroup           *label,
+                                                        GtkSizeGroup           *image);
 
 G_END_DECLS
diff --git a/src/gs-search-page.c b/src/gs-search-page.c
index b22e3bd3b..abaa358a1 100644
--- a/src/gs-search-page.c
+++ b/src/gs-search-page.c
@@ -29,7 +29,8 @@ struct _GsSearchPage
        GtkSizeGroup            *sizegroup_image;
        GtkSizeGroup            *sizegroup_name;
        GtkSizeGroup            *sizegroup_desc;
-       GtkSizeGroup            *sizegroup_button;
+       GtkSizeGroup            *sizegroup_button_label;
+       GtkSizeGroup            *sizegroup_button_image;
        GsShell                 *shell;
        gchar                   *appid_to_show;
        gchar                   *value;
@@ -132,7 +133,8 @@ gs_search_page_get_search_cb (GObject *source_object,
                                            self->sizegroup_image,
                                            self->sizegroup_name,
                                            self->sizegroup_desc,
-                                           self->sizegroup_button);
+                                           self->sizegroup_button_label,
+                                           self->sizegroup_button_image);
                gtk_widget_show (app_row);
        }
 
@@ -454,7 +456,8 @@ gs_search_page_dispose (GObject *object)
        g_clear_object (&self->sizegroup_image);
        g_clear_object (&self->sizegroup_name);
        g_clear_object (&self->sizegroup_desc);
-       g_clear_object (&self->sizegroup_button);
+       g_clear_object (&self->sizegroup_button_label);
+       g_clear_object (&self->sizegroup_button_image);
 
        g_clear_object (&self->plugin_loader);
        g_clear_object (&self->cancellable);
@@ -511,7 +514,8 @@ gs_search_page_init (GsSearchPage *self)
        self->sizegroup_image = gtk_size_group_new (GTK_SIZE_GROUP_HORIZONTAL);
        self->sizegroup_name = gtk_size_group_new (GTK_SIZE_GROUP_HORIZONTAL);
        self->sizegroup_desc = gtk_size_group_new (GTK_SIZE_GROUP_HORIZONTAL);
-       self->sizegroup_button = gtk_size_group_new (GTK_SIZE_GROUP_HORIZONTAL);
+       self->sizegroup_button_label = gtk_size_group_new (GTK_SIZE_GROUP_HORIZONTAL);
+       self->sizegroup_button_image = gtk_size_group_new (GTK_SIZE_GROUP_HORIZONTAL);
 
        self->max_results = GS_SEARCH_PAGE_MAX_RESULTS;
 }
diff --git a/src/gs-update-list.c b/src/gs-update-list.c
index 85cabe8f5..aa8b4735b 100644
--- a/src/gs-update-list.c
+++ b/src/gs-update-list.c
@@ -48,6 +48,7 @@ gs_update_list_add_app (GsUpdateList *update_list, GsApp *app)
                                    priv->sizegroup_image,
                                    priv->sizegroup_name,
                                    priv->sizegroup_desc,
+                                   NULL,
                                    NULL);
        g_signal_connect_object (app, "notify::state",
                                 G_CALLBACK (gs_update_list_app_state_notify_cb),
diff --git a/src/gs-updates-page.c b/src/gs-updates-page.c
index 94f7067bf..606f8d7cb 100644
--- a/src/gs-updates-page.c
+++ b/src/gs-updates-page.c
@@ -81,7 +81,8 @@ struct _GsUpdatesPage
        GtkSizeGroup            *sizegroup_image;
        GtkSizeGroup            *sizegroup_name;
        GtkSizeGroup            *sizegroup_desc;
-       GtkSizeGroup            *sizegroup_button;
+       GtkSizeGroup            *sizegroup_button_label;
+       GtkSizeGroup            *sizegroup_button_image;
        GtkSizeGroup            *sizegroup_header;
        GtkListBox              *sections[GS_UPDATES_SECTION_KIND_LAST];
 
@@ -1238,7 +1239,8 @@ gs_updates_page_setup (GsPage *page,
                                                    self->sizegroup_image,
                                                    self->sizegroup_name,
                                                    self->sizegroup_desc,
-                                                   self->sizegroup_button,
+                                                   self->sizegroup_button_label,
+                                                   self->sizegroup_button_image,
                                                    self->sizegroup_header);
                gtk_widget_set_vexpand (GTK_WIDGET (self->sections[i]), FALSE);
                gtk_container_add (GTK_CONTAINER (self->updates_box), GTK_WIDGET (self->sections[i]));
@@ -1313,7 +1315,8 @@ gs_updates_page_setup (GsPage *page,
        self->sizegroup_image = gtk_size_group_new (GTK_SIZE_GROUP_HORIZONTAL);
        self->sizegroup_name = gtk_size_group_new (GTK_SIZE_GROUP_HORIZONTAL);
        self->sizegroup_desc = gtk_size_group_new (GTK_SIZE_GROUP_HORIZONTAL);
-       self->sizegroup_button = gtk_size_group_new (GTK_SIZE_GROUP_HORIZONTAL);
+       self->sizegroup_button_label = gtk_size_group_new (GTK_SIZE_GROUP_HORIZONTAL);
+       self->sizegroup_button_image = gtk_size_group_new (GTK_SIZE_GROUP_HORIZONTAL);
        self->sizegroup_header = gtk_size_group_new (GTK_SIZE_GROUP_VERTICAL);
 
        /* set initial state */
@@ -1392,7 +1395,8 @@ gs_updates_page_dispose (GObject *object)
        g_clear_object (&self->sizegroup_image);
        g_clear_object (&self->sizegroup_name);
        g_clear_object (&self->sizegroup_desc);
-       g_clear_object (&self->sizegroup_button);
+       g_clear_object (&self->sizegroup_button_label);
+       g_clear_object (&self->sizegroup_button_image);
        g_clear_object (&self->sizegroup_header);
 
        G_OBJECT_CLASS (gs_updates_page_parent_class)->dispose (object);
@@ -1446,7 +1450,8 @@ gs_updates_page_init (GsUpdatesPage *self)
        self->sizegroup_image = gtk_size_group_new (GTK_SIZE_GROUP_HORIZONTAL);
        self->sizegroup_name = gtk_size_group_new (GTK_SIZE_GROUP_HORIZONTAL);
        self->sizegroup_desc = gtk_size_group_new (GTK_SIZE_GROUP_HORIZONTAL);
-       self->sizegroup_button = gtk_size_group_new (GTK_SIZE_GROUP_HORIZONTAL);
+       self->sizegroup_button_label = gtk_size_group_new (GTK_SIZE_GROUP_HORIZONTAL);
+       self->sizegroup_button_image = gtk_size_group_new (GTK_SIZE_GROUP_HORIZONTAL);
        self->sizegroup_header = gtk_size_group_new (GTK_SIZE_GROUP_VERTICAL);
 
 }
diff --git a/src/gs-updates-section.c b/src/gs-updates-section.c
index 05660e7d3..5ce435a84 100644
--- a/src/gs-updates-section.c
+++ b/src/gs-updates-section.c
@@ -32,7 +32,8 @@ struct _GsUpdatesSection
        GtkSizeGroup            *sizegroup_image;
        GtkSizeGroup            *sizegroup_name;
        GtkSizeGroup            *sizegroup_desc;
-       GtkSizeGroup            *sizegroup_button;
+       GtkSizeGroup            *sizegroup_button_label;
+       GtkSizeGroup            *sizegroup_button_image;
        GtkSizeGroup            *sizegroup_header;
        GtkWidget               *button_download;
        GtkWidget               *button_update;
@@ -112,7 +113,8 @@ gs_updates_section_add_app (GsUpdatesSection *self, GsApp *app)
                                    self->sizegroup_image,
                                    self->sizegroup_name,
                                    self->sizegroup_desc,
-                                   self->sizegroup_button);
+                                   self->sizegroup_button_label,
+                                   self->sizegroup_button_image);
        g_signal_connect_object (app, "notify::state",
                                 G_CALLBACK (_app_state_notify_cb),
                                 app_row, 0);
@@ -555,7 +557,8 @@ gs_updates_section_dispose (GObject *object)
        g_clear_object (&self->sizegroup_image);
        g_clear_object (&self->sizegroup_name);
        g_clear_object (&self->sizegroup_desc);
-       g_clear_object (&self->sizegroup_button);
+       g_clear_object (&self->sizegroup_button_label);
+       g_clear_object (&self->sizegroup_button_image);
        g_clear_object (&self->sizegroup_header);
        self->button_download = NULL;
        self->button_update = NULL;
@@ -581,16 +584,22 @@ gs_updates_section_set_size_groups (GsUpdatesSection *self,
                                    GtkSizeGroup *image,
                                    GtkSizeGroup *name,
                                    GtkSizeGroup *desc,
-                                   GtkSizeGroup *button,
+                                   GtkSizeGroup *button_label,
+                                   GtkSizeGroup *button_image,
                                    GtkSizeGroup *header)
 {
+       g_return_if_fail (GS_IS_UPDATES_SECTION (self));
+
        g_set_object (&self->sizegroup_image, image);
        g_set_object (&self->sizegroup_name, name);
        g_set_object (&self->sizegroup_desc, desc);
-       g_set_object (&self->sizegroup_button, button);
+       g_set_object (&self->sizegroup_button_label, button_label);
+       g_set_object (&self->sizegroup_button_image, button_image);
        g_set_object (&self->sizegroup_header, header);
 
-       gtk_size_group_add_widget (self->sizegroup_button, GTK_WIDGET (self->button_stack));
+       gs_progress_button_set_size_groups (GS_PROGRESS_BUTTON (self->button_cancel), button_label, 
button_image);
+       gs_progress_button_set_size_groups (GS_PROGRESS_BUTTON (self->button_download), button_label, 
button_image);
+       gs_progress_button_set_size_groups (GS_PROGRESS_BUTTON (self->button_update), button_label, 
button_image);
        gtk_size_group_add_widget (self->sizegroup_header, self->section_header);
 }
 
diff --git a/src/gs-updates-section.h b/src/gs-updates-section.h
index 852a0b577..1fe574307 100644
--- a/src/gs-updates-section.h
+++ b/src/gs-updates-section.h
@@ -40,7 +40,8 @@ void           gs_updates_section_set_size_groups     (GsUpdatesSection       *self,
                                                         GtkSizeGroup           *image,
                                                         GtkSizeGroup           *name,
                                                         GtkSizeGroup           *desc,
-                                                        GtkSizeGroup           *button,
+                                                        GtkSizeGroup           *button_label,
+                                                        GtkSizeGroup           *button_image,
                                                         GtkSizeGroup           *header);
 
 G_END_DECLS


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