[gnome-software/gnome-3-24] Allow to cancel app ops in the details view that were started elsewhere
- From: Robert Ancell <rancell src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-software/gnome-3-24] Allow to cancel app ops in the details view that were started elsewhere
- Date: Thu, 2 Nov 2017 22:09:11 +0000 (UTC)
commit 36665175a2a1ccea845d9a0fa88351954987a97d
Author: Joaquim Rocha <jrocha endlessm com>
Date: Tue Oct 10 12:26:20 2017 +0200
Allow to cancel app ops in the details view that were started elsewhere
The cancellation of app related operations has been tied to each view
individually. E.g. if an app update is started from the updates page and
the user goes to that app's details page, even though there is a cancel
button showing, it won't do anything because it's cancellable object is
not the one with which the update operation was started.
Now that each app has a cancellable object, this patch makes use of that
to ensure that any operations related to the app are cancellable even if
they were started from a different page.
src/gs-details-page.c | 29 ++++++++++++++++++-----------
src/gs-updates-page.c | 10 +++++-----
2 files changed, 23 insertions(+), 16 deletions(-)
---
diff --git a/src/gs-details-page.c b/src/gs-details-page.c
index fd97c22..fe37b5b 100644
--- a/src/gs-details-page.c
+++ b/src/gs-details-page.c
@@ -57,6 +57,7 @@ struct _GsDetailsPage
GsPluginLoader *plugin_loader;
GtkBuilder *builder;
GCancellable *cancellable;
+ GCancellable *app_cancellable;
GsApp *app;
GsShell *shell;
SoupSession *session;
@@ -398,7 +399,7 @@ gs_details_page_refresh_progress (GsDetailsPage *self)
case AS_APP_STATE_INSTALLING:
gtk_widget_set_visible (self->button_cancel, TRUE);
gtk_widget_set_sensitive (self->button_cancel,
- !g_cancellable_is_cancelled (self->cancellable));
+ !g_cancellable_is_cancelled (self->app_cancellable));
break;
default:
gtk_widget_set_visible (self->button_cancel, FALSE);
@@ -1490,6 +1491,8 @@ set_app (GsDetailsPage *self, GsApp *app)
gs_details_page_refresh_content_rating (self);
gs_details_page_set_state (self, GS_DETAILS_PAGE_STATE_READY);
+ g_set_object (&self->app_cancellable, gs_app_get_cancellable (app));
+
/* do 2nd stage refine */
gs_details_page_app_refine2 (self);
}
@@ -1657,6 +1660,9 @@ gs_details_page_set_app (GsDetailsPage *self, GsApp *app)
g_signal_connect_object (self->app, "notify::progress",
G_CALLBACK (gs_details_page_progress_changed_cb),
self, 0);
+
+ g_set_object (&self->app_cancellable, gs_app_get_cancellable (self->app));
+
gs_details_page_load (self);
/* change widgets */
@@ -1676,15 +1682,14 @@ gs_details_page_get_app (GsDetailsPage *self)
static void
gs_details_page_app_remove_button_cb (GtkWidget *widget, GsDetailsPage *self)
{
- g_autoptr(GCancellable) cancellable = g_cancellable_new ();
- g_set_object (&self->cancellable, cancellable);
- gs_page_remove_app (GS_PAGE (self), self->app, self->cancellable);
+ g_set_object (&self->app_cancellable, gs_app_get_cancellable (self->app));
+ gs_page_remove_app (GS_PAGE (self), self->app, self->app_cancellable);
}
static void
gs_details_page_app_cancel_button_cb (GtkWidget *widget, GsDetailsPage *self)
{
- g_cancellable_cancel (self->cancellable);
+ g_cancellable_cancel (self->app_cancellable);
gtk_widget_set_sensitive (widget, FALSE);
}
@@ -1693,7 +1698,6 @@ gs_details_page_app_install_button_cb (GtkWidget *widget, GsDetailsPage *self)
{
GList *l;
g_autoptr(GList) addons = NULL;
- g_autoptr(GCancellable) cancellable = g_cancellable_new ();
/* Mark ticked addons to be installed together with the app */
addons = gtk_container_get_children (GTK_CONTAINER (self->list_box_addons));
@@ -1706,15 +1710,15 @@ gs_details_page_app_install_button_cb (GtkWidget *widget, GsDetailsPage *self)
}
}
- g_set_object (&self->cancellable, cancellable);
+ g_set_object (&self->app_cancellable, gs_app_get_cancellable (self->app));
if (gs_app_get_state (self->app) == AS_APP_STATE_UPDATABLE_LIVE) {
- gs_page_update_app (GS_PAGE (self), self->app, self->cancellable);
+ gs_page_update_app (GS_PAGE (self), self->app, self->app_cancellable);
return;
}
gs_page_install_app (GS_PAGE (self), self->app, GS_SHELL_INTERACTION_FULL,
- self->cancellable);
+ self->app_cancellable);
}
static void
@@ -1734,10 +1738,12 @@ gs_details_page_addon_selected_cb (GsAppAddonRow *row,
case AS_APP_STATE_UPDATABLE:
case AS_APP_STATE_UPDATABLE_LIVE:
if (gs_app_addon_row_get_selected (row)) {
+ g_set_object (&self->app_cancellable, gs_app_get_cancellable (addon));
gs_page_install_app (GS_PAGE (self), addon, GS_SHELL_INTERACTION_FULL,
- self->cancellable);
+ self->app_cancellable);
} else {
- gs_page_remove_app (GS_PAGE (self), addon, self->cancellable);
+ g_set_object (&self->app_cancellable, gs_app_get_cancellable (addon));
+ gs_page_remove_app (GS_PAGE (self), addon, self->app_cancellable);
/* make sure the addon checkboxes are synced if the
* user clicks cancel in the remove confirmation dialog */
gs_details_page_refresh_addons (self);
@@ -2166,6 +2172,7 @@ gs_details_page_dispose (GObject *object)
g_clear_object (&self->builder);
g_clear_object (&self->plugin_loader);
g_clear_object (&self->cancellable);
+ g_clear_object (&self->app_cancellable);
g_clear_object (&self->session);
G_OBJECT_CLASS (gs_details_page_parent_class)->dispose (object);
diff --git a/src/gs-updates-page.c b/src/gs-updates-page.c
index 994513e..a5e2884 100644
--- a/src/gs-updates-page.c
+++ b/src/gs-updates-page.c
@@ -674,11 +674,9 @@ gs_updates_page_button_clicked_cb (GsUpdateList *update_list,
GsApp *app,
GsUpdatesPage *self)
{
- g_autoptr(GCancellable) cancellable = g_cancellable_new ();
if (gs_app_get_state (app) != AS_APP_STATE_UPDATABLE_LIVE)
return;
- g_set_object (&self->cancellable, cancellable);
- gs_page_update_app (GS_PAGE (self), app, self->cancellable);
+ gs_page_update_app (GS_PAGE (self), app, gs_app_get_cancellable (app));
}
static void
@@ -889,6 +887,7 @@ gs_updates_page_reboot_failed_cb (GObject *source, GAsyncResult *res, gpointer u
GsUpdatesPage *self = GS_UPDATES_PAGE (user_data);
g_autoptr(GError) error = NULL;
g_autoptr(GsAppList) apps = NULL;
+ GsApp *app = NULL;
g_autoptr(GVariant) retval = NULL;
/* get result */
@@ -903,11 +902,12 @@ gs_updates_page_reboot_failed_cb (GObject *source, GAsyncResult *res, gpointer u
/* cancel trigger */
apps = gs_update_list_get_apps (GS_UPDATE_LIST (self->list_box_updates));
+ app = gs_app_list_index (apps, 0);
gs_plugin_loader_app_action_async (self->plugin_loader,
- gs_app_list_index (apps, 0),
+ app,
GS_PLUGIN_ACTION_UPDATE_CANCEL,
GS_PLUGIN_FAILURE_FLAGS_USE_EVENTS,
- self->cancellable,
+ gs_app_get_cancellable (app),
cancel_trigger_failed_cb,
self);
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]