Commit d82fe556 authored by Richard Hughes's avatar Richard Hughes

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'.
parent f352063c
......@@ -147,6 +147,61 @@ gs_page_install_app (GsPage *page, GsApp *app)
data);
}
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)
{
......
......@@ -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,
......
......@@ -593,6 +593,18 @@ gs_shell_updates_activated_cb (GtkListBox *list_box,
show_update_details (app, self);
}
/**
* 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:
**/
......@@ -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);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment