[gnome-software/wip/kalev/more-origin-popover: 3/3] origin popover row: Align items using a size group



commit 34377e6ac52f54a03d7e17af58ceeab290ea5cbc
Author: Kalev Lember <klember redhat com>
Date:   Thu Sep 27 20:09:28 2018 +0200

    origin popover row: Align items using a size group

 src/gs-details-page.c        |  5 +++++
 src/gs-origin-popover-row.c  | 11 +++++++++++
 src/gs-origin-popover-row.h  |  2 ++
 src/gs-origin-popover-row.ui |  4 +++-
 4 files changed, 21 insertions(+), 1 deletion(-)
---
diff --git a/src/gs-details-page.c b/src/gs-details-page.c
index d74aec6e..ef5995ef 100644
--- a/src/gs-details-page.c
+++ b/src/gs-details-page.c
@@ -66,6 +66,7 @@ struct _GsDetailsPage
        gboolean                 enable_reviews;
        gboolean                 show_all_reviews;
        GSettings               *settings;
+       GtkSizeGroup            *size_group_origin_popover;
 
        GtkWidget               *application_details_icon;
        GtkWidget               *application_details_summary;
@@ -919,6 +920,8 @@ gs_details_page_get_alternates_cb (GObject *source_object,
                gtk_widget_show (row);
                if (app == self->app)
                        gs_origin_popover_row_set_selected (GS_ORIGIN_POPOVER_ROW (row), TRUE);
+               gs_origin_popover_row_set_size_group (GS_ORIGIN_POPOVER_ROW (row),
+                                                     self->size_group_origin_popover);
                gtk_container_add (GTK_CONTAINER (origin_popover_list_box), row);
        }
 
@@ -2487,6 +2490,7 @@ gs_details_page_dispose (GObject *object)
        g_clear_object (&self->cancellable);
        g_clear_object (&self->app_cancellable);
        g_clear_object (&self->session);
+       g_clear_object (&self->size_group_origin_popover);
 
        G_OBJECT_CLASS (gs_details_page_parent_class)->dispose (object);
 }
@@ -2600,6 +2604,7 @@ gs_details_page_init (GsDetailsPage *self)
        self->session = soup_session_new_with_options (SOUP_SESSION_USER_AGENT, gs_user_agent (),
                                                       NULL);
        self->settings = g_settings_new ("org.gnome.software");
+       self->size_group_origin_popover = gtk_size_group_new (GTK_SIZE_GROUP_HORIZONTAL);
 
        gtk_list_box_set_header_func (GTK_LIST_BOX (self->list_box_addons),
                                      list_header_func,
diff --git a/src/gs-origin-popover-row.c b/src/gs-origin-popover-row.c
index cd80b828..06f017c1 100644
--- a/src/gs-origin-popover-row.c
+++ b/src/gs-origin-popover-row.c
@@ -33,6 +33,7 @@ typedef struct
        GtkWidget       *url_title;
        GtkWidget       *url_label;
        GtkWidget       *format_box;
+       GtkWidget       *format_title;
        GtkWidget       *format_label;
        GtkWidget       *selected_image;
 } GsOriginPopoverRowPrivate;
@@ -106,6 +107,15 @@ gs_origin_popover_row_set_selected (GsOriginPopoverRow *row, gboolean selected)
        gtk_widget_set_visible (priv->selected_image, selected);
 }
 
+void
+gs_origin_popover_row_set_size_group (GsOriginPopoverRow *row, GtkSizeGroup *size_group)
+{
+       GsOriginPopoverRowPrivate *priv = gs_origin_popover_row_get_instance_private (row);
+
+       gtk_size_group_add_widget (size_group, priv->url_title);
+       gtk_size_group_add_widget (size_group, priv->format_title);
+}
+
 static void
 gs_origin_popover_row_destroy (GtkWidget *object)
 {
@@ -137,6 +147,7 @@ gs_origin_popover_row_class_init (GsOriginPopoverRowClass *klass)
        gtk_widget_class_bind_template_child_private (widget_class, GsOriginPopoverRow, url_title);
        gtk_widget_class_bind_template_child_private (widget_class, GsOriginPopoverRow, url_label);
        gtk_widget_class_bind_template_child_private (widget_class, GsOriginPopoverRow, format_box);
+       gtk_widget_class_bind_template_child_private (widget_class, GsOriginPopoverRow, format_title);
        gtk_widget_class_bind_template_child_private (widget_class, GsOriginPopoverRow, format_label);
        gtk_widget_class_bind_template_child_private (widget_class, GsOriginPopoverRow, selected_image);
 }
diff --git a/src/gs-origin-popover-row.h b/src/gs-origin-popover-row.h
index 3c721fbf..98c7d51f 100644
--- a/src/gs-origin-popover-row.h
+++ b/src/gs-origin-popover-row.h
@@ -40,6 +40,8 @@ GtkWidget     *gs_origin_popover_row_new              (GsApp                  *app);
 GsApp          *gs_origin_popover_row_get_app          (GsOriginPopoverRow     *row);
 void            gs_origin_popover_row_set_selected     (GsOriginPopoverRow     *row,
                                                         gboolean                selected);
+void            gs_origin_popover_row_set_size_group   (GsOriginPopoverRow     *row,
+                                                        GtkSizeGroup           *size_group);
 
 G_END_DECLS
 
diff --git a/src/gs-origin-popover-row.ui b/src/gs-origin-popover-row.ui
index 3b276b4c..7a708ded 100644
--- a/src/gs-origin-popover-row.ui
+++ b/src/gs-origin-popover-row.ui
@@ -36,6 +36,7 @@
                   <object class="GtkLabel" id="url_title">
                     <property name="visible">True</property>
                     <property name="halign">start</property>
+                    <property name="xalign">0</property>
                     <property name="label" translatable="yes">URL</property>
                     <style>
                       <class name="app-row-origin-text"/>
@@ -73,9 +74,10 @@
                 <property name="orientation">horizontal</property>
                 <property name="spacing">4</property>
                 <child>
-                  <object class="GtkLabel">
+                  <object class="GtkLabel" id="format_title">
                     <property name="visible">True</property>
                     <property name="halign">start</property>
+                    <property name="xalign">0</property>
                     <property name="label" translatable="yes" comments="Translators: The packaging format of 
the app being installed, e.g. 'RPM' or 'Flatpak'">Format</property>
                     <style>
                       <class name="app-row-origin-text"/>


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