[gnome-software/gnome-3-16] Show app install progress on the details page as well



commit 45802627a7e612802903a7fffed5cce39e36b1aa
Author: Kalev Lember <klember redhat com>
Date:   Thu Jul 30 11:23:52 2015 +0200

    Show app install progress on the details page as well
    
    In addition to showing install progress in the search view, show it on
    the details page as well, reusing the same code.

 src/gs-shell-details.c  |   37 ++++++++++++++++++++++++++++++++++++-
 src/gs-shell-details.ui |    2 +-
 2 files changed, 37 insertions(+), 2 deletions(-)
---
diff --git a/src/gs-shell-details.c b/src/gs-shell-details.c
index 1fe0dc0..da1e26b 100644
--- a/src/gs-shell-details.c
+++ b/src/gs-shell-details.c
@@ -34,6 +34,7 @@
 #include "gs-app-addon-row.h"
 #include "gs-history-dialog.h"
 #include "gs-screenshot-image.h"
+#include "gs-progress-button.h"
 #include "gs-star-widget.h"
 
 static void    gs_shell_details_finalize       (GObject        *object);
@@ -250,6 +251,16 @@ gs_shell_details_switch_to (GsShellDetails *shell_details)
                }
        }
 
+       /* do a fill bar for the current progress */
+       switch (gs_app_get_state (priv->app)) {
+       case AS_APP_STATE_INSTALLING:
+               gs_progress_button_set_show_progress (GS_PROGRESS_BUTTON (priv->button_install), TRUE);
+               break;
+       default:
+               gs_progress_button_set_show_progress (GS_PROGRESS_BUTTON (priv->button_install), FALSE);
+               break;
+       }
+
        /* spinner */
        if (kind == GS_APP_KIND_SYSTEM) {
                gtk_widget_set_visible (priv->spinner_install_remove, FALSE);
@@ -263,10 +274,10 @@ gs_shell_details_switch_to (GsShellDetails *shell_details)
                case AS_APP_STATE_UPDATABLE:
                case AS_APP_STATE_UNAVAILABLE:
                case AS_APP_STATE_AVAILABLE_LOCAL:
+               case AS_APP_STATE_INSTALLING:
                        gtk_widget_set_visible (priv->spinner_install_remove, FALSE);
                        gtk_spinner_stop (GTK_SPINNER (priv->spinner_install_remove));
                        break;
-               case AS_APP_STATE_INSTALLING:
                case AS_APP_STATE_REMOVING:
                        gtk_spinner_start (GTK_SPINNER (priv->spinner_install_remove));
                        gtk_widget_set_visible (priv->spinner_install_remove, TRUE);
@@ -285,6 +296,27 @@ gs_shell_details_switch_to (GsShellDetails *shell_details)
 }
 
 static gboolean
+gs_shell_details_refresh_progress_idle (gpointer user_data)
+{
+       GsShellDetails *shell_details = GS_SHELL_DETAILS (user_data);
+       GsShellDetailsPrivate *priv = shell_details->priv;
+
+       gs_progress_button_set_progress (GS_PROGRESS_BUTTON (priv->button_install),
+                                        gs_app_get_progress (priv->app));
+
+       g_object_unref (shell_details);
+       return G_SOURCE_REMOVE;
+}
+
+static void
+gs_shell_details_progress_changed_cb (GsApp *app,
+                                      GParamSpec *pspec,
+                                      GsShellDetails *shell_details)
+{
+       g_idle_add (gs_shell_details_refresh_progress_idle, g_object_ref (shell_details));
+}
+
+static gboolean
 gs_shell_details_switch_to_idle (gpointer user_data)
 {
        GsShellDetails *shell_details = GS_SHELL_DETAILS (user_data);
@@ -1009,6 +1041,9 @@ gs_shell_details_set_app (GsShellDetails *shell_details, GsApp *app)
        g_signal_connect_object (priv->app, "notify::licence",
                                 G_CALLBACK (gs_shell_details_notify_state_changed_cb),
                                 shell_details, 0);
+       g_signal_connect_object (priv->app, "notify::progress",
+                                G_CALLBACK (gs_shell_details_progress_changed_cb),
+                                shell_details, 0);
        gs_shell_details_load (shell_details);
 
        /* change widgets */
diff --git a/src/gs-shell-details.ui b/src/gs-shell-details.ui
index 595b546..0e1511f 100644
--- a/src/gs-shell-details.ui
+++ b/src/gs-shell-details.ui
@@ -139,7 +139,7 @@
                                 <property name="can_focus">False</property>
                                 <property name="spacing">6</property>
                                 <child>
-                                  <object class="GtkButton" id="button_install">
+                                  <object class="GsProgressButton" id="button_install">
                                     <property name="use_underline">True</property>
                                     <property name="label" translatable="yes">_Install</property>
                                     <property name="width_request">105</property>


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