[gnome-software/wip/kalev/confirm-upgrade-removals] Use REMOVING state to denote packages-to-be-removed
- From: Kalev Lember <klember src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-software/wip/kalev/confirm-upgrade-removals] Use REMOVING state to denote packages-to-be-removed
- Date: Tue, 12 Jul 2016 12:57:32 +0000 (UTC)
commit 6208100c3c29b5e4f650b2e5751615d4b3100da9
Author: Kalev Lember <klember redhat com>
Date: Tue Jul 12 14:43:50 2016 +0200
Use REMOVING state to denote packages-to-be-removed
src/gs-removal-dialog.c | 2 ++
src/gs-shell-updates.c | 14 +++++++++++++-
src/plugins/gs-plugin-packagekit-refine.c | 4 ++--
src/plugins/packagekit-common.c | 6 +++++-
4 files changed, 22 insertions(+), 4 deletions(-)
---
diff --git a/src/gs-removal-dialog.c b/src/gs-removal-dialog.c
index 7fb29c7..f373218 100644
--- a/src/gs-removal-dialog.c
+++ b/src/gs-removal-dialog.c
@@ -134,6 +134,8 @@ gs_removal_dialog_show_upgrade_removals (GsRemovalDialog *self,
GsApp *app = g_ptr_array_index (removals, i);
g_autofree gchar *tmp = NULL;
+ if (gs_app_get_state (app) != AS_APP_STATE_REMOVING)
+ continue;
tmp = gs_app_to_string (app);
g_debug ("removal %d: %s", i, tmp);
add_app (GTK_LIST_BOX (self->listbox), app);
diff --git a/src/gs-shell-updates.c b/src/gs-shell-updates.c
index c3d005c..3031a63 100644
--- a/src/gs-shell-updates.c
+++ b/src/gs-shell-updates.c
@@ -1154,8 +1154,11 @@ static void
gs_shell_updates_upgrade_install_cb (GsUpgradeBanner *upgrade_banner,
GsShellUpdates *self)
{
+ GPtrArray *removals;
GsApp *upgrade;
GtkWidget *dialog;
+ guint cnt = 0;
+ guint i;
upgrade = gs_upgrade_banner_get_app (GS_UPGRADE_BANNER (self->upgrade_banner));
if (upgrade == NULL) {
@@ -1163,7 +1166,16 @@ gs_shell_updates_upgrade_install_cb (GsUpgradeBanner *upgrade_banner,
return;
}
- if (gs_app_get_related (upgrade) == NULL) {
+ /* count the removals */
+ removals = gs_app_get_related (upgrade);
+ for (i = 0; i < removals->len; i++) {
+ GsApp *app = g_ptr_array_index (removals, i);
+ if (gs_app_get_state (app) != AS_APP_STATE_REMOVING)
+ continue;
+ cnt++;
+ }
+
+ if (cnt == 0) {
/* no need for a removal confirmation dialog */
trigger_upgrade (self);
return;
diff --git a/src/plugins/gs-plugin-packagekit-refine.c b/src/plugins/gs-plugin-packagekit-refine.c
index f5b4402..486e03f 100644
--- a/src/plugins/gs-plugin-packagekit-refine.c
+++ b/src/plugins/gs-plugin-packagekit-refine.c
@@ -765,7 +765,7 @@ gs_plugin_packagekit_refine_distro_upgrade (GsPlugin *plugin,
/* add each of these as related applications */
for (i = 0; i < gs_app_list_length (list); i++) {
app2 = gs_app_list_index (list, i);
- if (gs_app_get_state (app2) != AS_APP_STATE_AVAILABLE)
+ if (gs_app_get_state (app2) != AS_APP_STATE_REMOVING)
continue;
gs_app_add_related (app, app2);
}
@@ -798,7 +798,7 @@ gs_plugin_refine (GsPlugin *plugin,
/* when we need the cannot-be-upgraded applications, we implement this
* by doing a UpgradeSystem(SIMULATE) which adds the removed packages
- * to the related-apps list with a state of %AS_APP_STATE_AVAILABLE */
+ * to the related-apps list with a state of %AS_APP_STATE_REMOVING */
if (flags & GS_PLUGIN_REFINE_FLAGS_REQUIRE_UPGRADE_REMOVED) {
for (i = 0; i < gs_app_list_length (list); i++) {
app = gs_app_list_index (list, i);
diff --git a/src/plugins/packagekit-common.c b/src/plugins/packagekit-common.c
index 6da73f4..e1715a8 100644
--- a/src/plugins/packagekit-common.c
+++ b/src/plugins/packagekit-common.c
@@ -253,9 +253,13 @@ gs_plugin_packagekit_add_results (GsPlugin *plugin,
gs_app_set_state (app, AS_APP_STATE_INSTALLED);
break;
case PK_INFO_ENUM_AVAILABLE:
- case PK_INFO_ENUM_REMOVING:
gs_app_set_state (app, AS_APP_STATE_AVAILABLE);
break;
+ case PK_INFO_ENUM_REMOVING:
+ /* do a little dance to make GsApp happy */
+ gs_app_set_state (app, AS_APP_STATE_INSTALLED);
+ gs_app_set_state (app, AS_APP_STATE_REMOVING);
+ break;
case PK_INFO_ENUM_INSTALLING:
case PK_INFO_ENUM_UPDATING:
case PK_INFO_ENUM_DOWNGRADING:
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]