[gnome-software] trivial: Split up the widget refresh



commit 124657741e183b3629b7bec639f8e24d0e867238
Author: Richard Hughes <richard hughsie com>
Date:   Mon Jul 11 08:19:38 2016 +0100

    trivial: Split up the widget refresh

 src/gs-app-row.c |   31 +++++++++++++++++++++++--------
 1 files changed, 23 insertions(+), 8 deletions(-)
---
diff --git a/src/gs-app-row.c b/src/gs-app-row.c
index d77d077..c7debf2 100644
--- a/src/gs-app-row.c
+++ b/src/gs-app-row.c
@@ -279,14 +279,33 @@ gs_app_row_refresh (GsAppRow *app_row)
        else
                gtk_style_context_remove_class (context, "dimmer-label");
 
-       gtk_widget_set_visible (priv->button, FALSE);
-       gtk_widget_set_sensitive (priv->button, TRUE);
+       /* pending label */
+       switch (gs_app_get_state (priv->app)) {
+       case AS_APP_STATE_QUEUED_FOR_INSTALL:
+               gtk_widget_set_visible (priv->label, TRUE);
+               gtk_label_set_label (GTK_LABEL (priv->label), _("Pending"));
+               break;
+       default:
+               gtk_widget_set_visible (priv->label, FALSE);
+               break;
+       }
+
+       /* spinner */
        gtk_widget_set_visible (priv->spinner, FALSE);
-       gtk_widget_set_visible (priv->label, FALSE);
+       switch (gs_app_get_state (priv->app)) {
+       case AS_APP_STATE_REMOVING:
+               gtk_spinner_start (GTK_SPINNER (priv->spinner));
+               gtk_widget_set_visible (priv->spinner, TRUE);
+               break;
+       default:
+               break;
+       }
 
+       /* button */
+       gtk_widget_set_visible (priv->button, FALSE);
+       gtk_widget_set_sensitive (priv->button, TRUE);
        context = gtk_widget_get_style_context (priv->button);
        gtk_style_context_remove_class (context, "destructive-action");
-
        switch (gs_app_get_state (priv->app)) {
        case AS_APP_STATE_UNAVAILABLE:
                gtk_widget_set_visible (priv->button, TRUE);
@@ -302,14 +321,12 @@ gs_app_row_refresh (GsAppRow *app_row)
                }
                break;
        case AS_APP_STATE_QUEUED_FOR_INSTALL:
-               gtk_widget_set_visible (priv->label, TRUE);
                gtk_widget_set_visible (priv->button, TRUE);
                /* TRANSLATORS: this is a button next to the search results that
                 * allows to cancel a queued install of the application */
                gtk_button_set_label (GTK_BUTTON (priv->button), _("Cancel"));
                /* TRANSLATORS: this is a label that describes an application
                 * that has been queued for installation */
-               gtk_label_set_label (GTK_LABEL (priv->label), _("Pending"));
                break;
        case AS_APP_STATE_AVAILABLE:
        case AS_APP_STATE_AVAILABLE_LOCAL:
@@ -350,8 +367,6 @@ gs_app_row_refresh (GsAppRow *app_row)
                gtk_button_set_label (GTK_BUTTON (priv->button), _("Installing"));
                break;
        case AS_APP_STATE_REMOVING:
-               gtk_spinner_start (GTK_SPINNER (priv->spinner));
-               gtk_widget_set_visible (priv->spinner, TRUE);
                gtk_widget_set_visible (priv->button, TRUE);
                gtk_widget_set_sensitive (priv->button, FALSE);
                /* TRANSLATORS: this is a button next to the search results that


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