[gnome-software/wip/installed_updates: 12/16] app widget: Avoid a hardcoded width request



commit 48d77e927e9e47078dc8bdd9526c73b810b790a3
Author: Kalev Lember <kalevlember gmail com>
Date:   Wed May 7 17:55:44 2014 +0200

    app widget: Avoid a hardcoded width request
    
    Instead of using a hardcoded width_request for name_label, make sure it
    is added to a size group in all the callers. This makes it appear nicer
    in cramped spaces, such as the installed updates dialog, where 164 px
    size request for the name label can look out of place.

 src/app-widget.ui      |    1 -
 src/gs-app-widget.c    |   11 -----------
 src/gs-shell-updates.c |    9 +++++++++
 src/gs-update-dialog.c |    9 +++++++++
 4 files changed, 18 insertions(+), 12 deletions(-)
---
diff --git a/src/app-widget.ui b/src/app-widget.ui
index ba19058..77e8277 100644
--- a/src/app-widget.ui
+++ b/src/app-widget.ui
@@ -45,7 +45,6 @@
                 <property name="max_width_chars">20</property>
                 <property name="xalign">0.0</property>
                 <property name="yalign">0.5</property>
-                <property name="width_request">164</property>
                 <attributes>
                   <attribute name="weight" value="bold"/>
                 </attributes>
diff --git a/src/gs-app-widget.c b/src/gs-app-widget.c
index c97be66..c565456 100644
--- a/src/gs-app-widget.c
+++ b/src/gs-app-widget.c
@@ -127,17 +127,6 @@ gs_app_widget_refresh (GsAppWidget *app_widget)
        if (app_widget->priv->app == NULL)
                return;
 
-       /* only show the name box if the application is found */
-       switch (gs_app_get_kind (priv->app)) {
-       case GS_APP_KIND_MISSING:
-               gtk_widget_set_visible (priv->name_box, FALSE);
-               gtk_widget_set_margin_end (priv->description_label, 250);
-               break;
-       default:
-               gtk_widget_set_visible (priv->name_box, TRUE);
-               gtk_widget_set_margin_end (priv->description_label, 0);
-       }
-
        /* join the lines*/
        str = gs_app_widget_get_description (app_widget);
        gs_string_replace (str, "\n", " ");
diff --git a/src/gs-shell-updates.c b/src/gs-shell-updates.c
index 94fa2f6..4793cea 100644
--- a/src/gs-shell-updates.c
+++ b/src/gs-shell-updates.c
@@ -65,6 +65,8 @@ struct GsShellUpdatesPrivate
        GsShellUpdatesState      state;
        gboolean                 has_agreed_to_mobile_data;
        gboolean                 ampm_available;
+       GtkSizeGroup            *sizegroup_image;
+       GtkSizeGroup            *sizegroup_name;
 
        GtkWidget               *button_updates_mobile;
        GtkWidget               *button_updates_offline;
@@ -464,6 +466,9 @@ gs_shell_updates_get_updates_cb (GsPluginLoader *plugin_loader,
                gs_app_widget_set_show_update (GS_APP_WIDGET (widget), TRUE);
                gs_app_widget_set_app (GS_APP_WIDGET (widget), app);
                gtk_container_add (GTK_CONTAINER (priv->list_box_updates), widget);
+               gs_app_widget_set_size_groups (GS_APP_WIDGET (widget),
+                                              priv->sizegroup_image,
+                                              priv->sizegroup_name);
                gtk_widget_show (widget);
        }
 
@@ -1066,6 +1071,8 @@ gs_shell_updates_init (GsShellUpdates *shell_updates)
        shell_updates->priv->state = GS_SHELL_UPDATES_STATE_STARTUP;
        shell_updates->priv->settings = g_settings_new ("org.gnome.software");
        shell_updates->priv->desktop_settings = g_settings_new ("org.gnome.desktop.interface");
+       shell_updates->priv->sizegroup_image = gtk_size_group_new (GTK_SIZE_GROUP_HORIZONTAL);
+       shell_updates->priv->sizegroup_name = gtk_size_group_new (GTK_SIZE_GROUP_HORIZONTAL);
 
        ampm = nl_langinfo (AM_STR);
        if (ampm != NULL && *ampm != '\0')
@@ -1090,6 +1097,8 @@ gs_shell_updates_finalize (GObject *object)
        g_object_unref (priv->control);
        g_object_unref (priv->settings);
        g_object_unref (priv->desktop_settings);
+       g_object_unref (priv->sizegroup_image);
+       g_object_unref (priv->sizegroup_name);
 
        G_OBJECT_CLASS (gs_shell_updates_parent_class)->finalize (object);
 }
diff --git a/src/gs-update-dialog.c b/src/gs-update-dialog.c
index 5174ce2..5470b53 100644
--- a/src/gs-update-dialog.c
+++ b/src/gs-update-dialog.c
@@ -39,6 +39,8 @@ typedef struct {
 struct _GsUpdateDialogPrivate
 {
        GQueue          *back_entry_stack;
+       GtkSizeGroup    *sizegroup_image;
+       GtkSizeGroup    *sizegroup_name;
        GtkWidget       *box_header;
        GtkWidget       *button_back;
        GtkWidget       *image_icon;
@@ -195,6 +197,9 @@ gs_update_dialog_show_installed_updates (GsUpdateDialog *dialog, GList *installe
                gs_app_widget_set_show_update (GS_APP_WIDGET (widget), TRUE);
                gs_app_widget_set_app (GS_APP_WIDGET (widget), app);
                gtk_container_add (GTK_CONTAINER (priv->list_box_installed_updates), widget);
+               gs_app_widget_set_size_groups (GS_APP_WIDGET (widget),
+                                              priv->sizegroup_image,
+                                              priv->sizegroup_name);
                gtk_widget_show (widget);
        }
 }
@@ -331,6 +336,8 @@ gs_update_dialog_finalize (GObject *object)
                g_queue_free_full (priv->back_entry_stack, (GDestroyNotify) back_entry_free);
                priv->back_entry_stack = NULL;
        }
+       g_object_unref (priv->sizegroup_image);
+       g_object_unref (priv->sizegroup_name);
 
        G_OBJECT_CLASS (gs_update_dialog_parent_class)->finalize (object);
 }
@@ -344,6 +351,8 @@ gs_update_dialog_init (GsUpdateDialog *dialog)
        gtk_widget_init_template (GTK_WIDGET (dialog));
 
        priv->back_entry_stack = g_queue_new ();
+       priv->sizegroup_image = gtk_size_group_new (GTK_SIZE_GROUP_HORIZONTAL);
+       priv->sizegroup_name = gtk_size_group_new (GTK_SIZE_GROUP_HORIZONTAL);
 
        g_signal_connect (GTK_LIST_BOX (priv->list_box), "row-activated",
                          G_CALLBACK (row_activated_cb), dialog);


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