[gnome-software] Connect up the live-update button to the plugin loader



commit d82fe556dda27a9f74a70ebbdb47155a6020dd98
Author: Richard Hughes <richard hughsie com>
Date:   Wed Nov 25 16:38:13 2015 +0000

    Connect up the live-update button to the plugin loader
    
    Also, show UI in case a device needs to be put into a special 'update mode'.

 src/gs-page.c          |   55 ++++++++++++++++++++++++++++++++++++++++++++++++
 src/gs-page.h          |    2 +
 src/gs-shell-updates.c |   14 ++++++++++++
 3 files changed, 71 insertions(+), 0 deletions(-)
---
diff --git a/src/gs-page.c b/src/gs-page.c
index f4e65f5..72642e6 100644
--- a/src/gs-page.c
+++ b/src/gs-page.c
@@ -148,6 +148,61 @@ gs_page_install_app (GsPage *page, GsApp *app)
 }
 
 void
+gs_page_update_app (GsPage *page, GsApp *app)
+{
+       GsPagePrivate *priv = gs_page_get_instance_private (page);
+       GtkResponseType response;
+       GtkWidget *dialog;
+       AsScreenshot *ss;
+
+       /* there are no steps required to put the device into DFU mode */
+       if (gs_app_get_screenshots (app)->len == 0) {
+               InstallRemoveData *data;
+               data = g_slice_new0 (InstallRemoveData);
+               data->app = g_object_ref (app);
+               data->page = g_object_ref (page);
+               g_debug ("update %s", gs_app_get_id (app));
+               gs_plugin_loader_app_action_async (priv->plugin_loader,
+                                                  app,
+                                                  GS_PLUGIN_LOADER_ACTION_UPDATE,
+                                                  priv->cancellable,
+                                                  gs_page_app_installed_cb,
+                                                  data);
+               return;
+       }
+
+       /* tell the user what they have to do */
+       ss = g_ptr_array_index (gs_app_get_screenshots (app), 0);
+       dialog = gtk_message_dialog_new (gs_shell_get_window (priv->shell),
+                                        GTK_DIALOG_MODAL,
+                                        GTK_MESSAGE_INFO,
+                                        GTK_BUTTONS_CANCEL,
+                                        /* TRANSLATORS: this is a prompt message, and
+                                         * '%s' is an application summary, e.g. 'GNOME Clocks' */
+                                        _("Prepare %s"),
+                                        gs_app_get_name (app));
+       gtk_message_dialog_format_secondary_markup (GTK_MESSAGE_DIALOG (dialog),
+                                                   "%s", as_screenshot_get_caption (ss, NULL));
+       /* TRANSLATORS: this is button text to update the firware */
+       gtk_dialog_add_button (GTK_DIALOG (dialog), _("Install"), GTK_RESPONSE_OK);
+       response = gtk_dialog_run (GTK_DIALOG (dialog));
+       if (response == GTK_RESPONSE_OK) {
+               InstallRemoveData *data;
+               g_debug ("update %s", gs_app_get_id (app));
+               data = g_slice_new0 (InstallRemoveData);
+               data->app = g_object_ref (app);
+               data->page = g_object_ref (page);
+               gs_plugin_loader_app_action_async (priv->plugin_loader,
+                                                  app,
+                                                  GS_PLUGIN_LOADER_ACTION_UPDATE,
+                                                  priv->cancellable,
+                                                  gs_page_app_installed_cb,
+                                                  data);
+       }
+       gtk_widget_destroy (dialog);
+}
+
+void
 gs_page_remove_app (GsPage *page, GsApp *app)
 {
        GsPagePrivate *priv = gs_page_get_instance_private (page);
diff --git a/src/gs-page.h b/src/gs-page.h
index 70fcae9..0f34a88 100644
--- a/src/gs-page.h
+++ b/src/gs-page.h
@@ -49,6 +49,8 @@ void           gs_page_install_app                    (GsPage         *page,
                                                         GsApp          *app);
 void            gs_page_remove_app                     (GsPage         *page,
                                                         GsApp          *app);
+void            gs_page_update_app                     (GsPage         *page,
+                                                        GsApp          *app);
 void            gs_page_setup                          (GsPage         *page,
                                                         GsShell        *shell,
                                                         GsPluginLoader *plugin_loader,
diff --git a/src/gs-shell-updates.c b/src/gs-shell-updates.c
index 530eb07..2d01fcc 100644
--- a/src/gs-shell-updates.c
+++ b/src/gs-shell-updates.c
@@ -594,6 +594,18 @@ gs_shell_updates_activated_cb (GtkListBox *list_box,
 }
 
 /**
+ * gs_shell_updates_button_clicked_cb:
+ **/
+static void
+gs_shell_updates_button_clicked_cb (GsUpdateList *update_list,
+                                   GsApp *app,
+                                   GsShellUpdates *self)
+{
+       if (gs_app_get_state (app) == AS_APP_STATE_UPDATABLE_LIVE)
+               gs_page_update_app (GS_PAGE (self), app);
+}
+
+/**
  * gs_shell_updates_refresh_cb:
  **/
 static void
@@ -946,6 +958,8 @@ gs_shell_updates_setup (GsShellUpdates *self,
        /* setup updates */
        g_signal_connect (self->list_box_updates, "row-activated",
                          G_CALLBACK (gs_shell_updates_activated_cb), self);
+       g_signal_connect (self->list_box_updates, "button-clicked",
+                         G_CALLBACK (gs_shell_updates_button_clicked_cb), self);
 
        widget = GTK_WIDGET (gtk_builder_get_object (self->builder, "button_update_all"));
        g_signal_connect (widget, "clicked", G_CALLBACK (gs_shell_updates_button_update_all_cb), self);


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