[gnome-software/1492-gnome-software-does-not-refresh-after-installation-from-rpm] gs-installed-page: Change section on application state change
- From: Milan Crha <mcrha src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-software/1492-gnome-software-does-not-refresh-after-installation-from-rpm] gs-installed-page: Change section on application state change
- Date: Tue, 12 Oct 2021 10:19:24 +0000 (UTC)
commit f7bcc415b7ad65c2178a88c5c14f2058875131cd
Author: Milan Crha <mcrha redhat com>
Date: Tue Oct 12 12:16:49 2021 +0200
gs-installed-page: Change section on application state change
when an application is being installed, it's shown in the "In Progress"
section, but when the installation is finished it had been left in
that section, even it belongs to a different section.
Similarly with the uninstall, the application was sorted to the top
of the section, but it might be better to be added to the "In Progress"
section.
Closes https://gitlab.gnome.org/GNOME/gnome-software/-/issues/1492
src/gs-installed-page.c | 84 +++++++++++++++++++++++++++++++++++++++++++++++--
1 file changed, 81 insertions(+), 3 deletions(-)
---
diff --git a/src/gs-installed-page.c b/src/gs-installed-page.c
index 14628cc58..08d7a34aa 100644
--- a/src/gs-installed-page.c
+++ b/src/gs-installed-page.c
@@ -109,6 +109,30 @@ update_groups (GsInstalledPage *self)
gtk_widget_get_first_child (self->list_box_install_addons) != NULL);
}
+static GsInstalledPageSection
+gs_installed_page_get_row_section (GsInstalledPage *self,
+ GsAppRow *app_row)
+{
+ GtkWidget *parent;
+
+ g_return_val_if_fail (GS_IS_INSTALLED_PAGE (self), GS_UPDATE_LIST_SECTION_LAST);
+ g_return_val_if_fail (GS_IS_APP_ROW (app_row), GS_UPDATE_LIST_SECTION_LAST);
+
+ parent = gtk_widget_get_parent (GTK_WIDGET (app_row));
+ if (parent == self->list_box_install_in_progress)
+ return GS_UPDATE_LIST_SECTION_INSTALLING_AND_REMOVING;
+ if (parent == self->list_box_install_apps)
+ return GS_UPDATE_LIST_SECTION_REMOVABLE_APPS;
+ if (parent == self->list_box_install_system_apps)
+ return GS_UPDATE_LIST_SECTION_SYSTEM_APPS;
+ if (parent == self->list_box_install_addons)
+ return GS_UPDATE_LIST_SECTION_ADDONS;
+
+ g_warn_if_reached ();
+
+ return GS_UPDATE_LIST_SECTION_LAST;
+}
+
static void
gs_installed_page_invalidate (GsInstalledPage *self)
{
@@ -142,9 +166,17 @@ row_unrevealed (GObject *row, GParamSpec *pspec, gpointer data)
static void
gs_installed_page_unreveal_row (GsAppRow *app_row)
{
- g_signal_connect (app_row, "unrevealed",
- G_CALLBACK (row_unrevealed), NULL);
- gs_app_row_unreveal (app_row);
+ /* This check is required, because GsAppRow does not emit
+ * the signal when the row is not realized. This can happen
+ * when installing/uninstalling an app without visiting
+ * the Installed page. */
+ if (!gtk_widget_get_mapped (GTK_WIDGET (app_row))) {
+ row_unrevealed (G_OBJECT (app_row), NULL, NULL);
+ } else {
+ g_signal_connect (app_row, "unrevealed",
+ G_CALLBACK (row_unrevealed), NULL);
+ gs_app_row_unreveal (app_row);
+ }
}
static void
@@ -181,12 +213,55 @@ gs_installed_page_app_remove_cb (GsAppRow *app_row,
gs_page_remove_app (GS_PAGE (self), app, self->cancellable);
}
+static void
+gs_installed_page_maybe_move_app_row (GsInstalledPage *self,
+ GsAppRow *app_row)
+{
+ GsInstalledPageSection current_section, expected_section;
+
+ current_section = gs_installed_page_get_row_section (self, app_row);
+ g_return_if_fail (current_section != GS_UPDATE_LIST_SECTION_LAST);
+
+ expected_section = gs_installed_page_get_app_section (gs_app_row_get_app (app_row));
+ if (expected_section != current_section) {
+ GtkWidget *widget = GTK_WIDGET (app_row);
+
+ g_object_ref (app_row);
+ gtk_list_box_remove (GTK_LIST_BOX (gtk_widget_get_parent (widget)), widget);
+ switch (expected_section) {
+ case GS_UPDATE_LIST_SECTION_INSTALLING_AND_REMOVING:
+ widget = self->list_box_install_in_progress;
+ break;
+ case GS_UPDATE_LIST_SECTION_REMOVABLE_APPS:
+ widget = self->list_box_install_apps;
+ break;
+ case GS_UPDATE_LIST_SECTION_SYSTEM_APPS:
+ widget = self->list_box_install_system_apps;
+ break;
+ case GS_UPDATE_LIST_SECTION_ADDONS:
+ widget = self->list_box_install_addons;
+ break;
+ default:
+ g_warn_if_reached ();
+ widget = NULL;
+ break;
+ }
+
+ if (widget != NULL)
+ gtk_list_box_append (GTK_LIST_BOX (widget), GTK_WIDGET (app_row));
+
+ g_object_unref (app_row);
+ update_groups (self);
+ }
+}
+
static gboolean
gs_installed_page_invalidate_sort_idle (gpointer user_data)
{
GsAppRow *app_row = user_data;
GsApp *app = gs_app_row_get_app (app_row);
GsAppState state = gs_app_get_state (app);
+ GsInstalledPage *self = g_object_get_data (G_OBJECT (app_row), "installed-page");
gtk_list_box_row_changed (GTK_LIST_BOX_ROW (app_row));
@@ -197,6 +272,8 @@ gs_installed_page_invalidate_sort_idle (gpointer user_data)
state != GS_APP_STATE_UPDATABLE &&
state != GS_APP_STATE_UPDATABLE_LIVE)
gs_installed_page_unreveal_row (app_row);
+ else
+ gs_installed_page_maybe_move_app_row (self, app_row);
g_object_unref (app_row);
return G_SOURCE_REMOVE;
@@ -244,6 +321,7 @@ gs_installed_page_add_app (GsInstalledPage *self, GsAppList *list, GsApp *app)
"show-source", gs_utils_list_has_component_fuzzy (list, app),
"show-installed-size", !gs_app_has_quirk (app, GS_APP_QUIRK_COMPULSORY) &&
should_show_installed_size (self),
NULL);
+ g_object_set_data (G_OBJECT (app_row), "installed-page", self);
g_signal_connect (app_row, "button-clicked",
G_CALLBACK (gs_installed_page_app_remove_cb), self);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]