[gnome-software: 76/110] gs-installed-page: Manually update sections
- From: Philip Withnall <pwithnall src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-software: 76/110] gs-installed-page: Manually update sections
- Date: Tue, 5 Oct 2021 20:32:41 +0000 (UTC)
commit 6edfe18fc842942e6d216dd98c7ce048f55c823f
Author: Georges Basile Stavracas Neto <georges stavracas gmail com>
Date: Wed Aug 25 22:57:38 2021 -0300
gs-installed-page: Manually update sections
GsInstalledPage was relying on old GtkContainer signals to update each
section. GtkContainer doesn't exist anymore, so reimplement this behavior
by manually updating each section after adding or removing rows.
src/gs-installed-page.c | 37 ++++++++++++++++++++++++++++---------
src/gs-installed-page.ui | 8 --------
2 files changed, 28 insertions(+), 17 deletions(-)
---
diff --git a/src/gs-installed-page.c b/src/gs-installed-page.c
index 6f2dcde78..5cc5e5ccb 100644
--- a/src/gs-installed-page.c
+++ b/src/gs-installed-page.c
@@ -37,6 +37,11 @@ struct _GsInstalledPage
guint pending_apps_counter;
gboolean is_narrow;
+ GtkWidget *group_install_in_progress;
+ GtkWidget *group_install_apps;
+ GtkWidget *group_install_system_apps;
+ GtkWidget *group_install_addons;
+
GtkWidget *list_box_install_in_progress;
GtkWidget *list_box_install_apps;
GtkWidget *list_box_install_system_apps;
@@ -91,6 +96,19 @@ gs_installed_page_get_app_section (GsApp *app)
return GS_UPDATE_LIST_SECTION_ADDONS;
}
+static void
+update_groups (GsInstalledPage *self)
+{
+ gtk_widget_set_visible (self->group_install_in_progress,
+ gtk_widget_get_first_child (self->list_box_install_in_progress) != NULL);
+ gtk_widget_set_visible (self->group_install_apps,
+ gtk_widget_get_first_child (self->list_box_install_apps) != NULL);
+ gtk_widget_set_visible (self->group_install_system_apps,
+ gtk_widget_get_first_child (self->list_box_install_system_apps) != NULL);
+ gtk_widget_set_visible (self->group_install_addons,
+ gtk_widget_get_first_child (self->list_box_install_addons) != NULL);
+}
+
static void
gs_installed_page_invalidate (GsInstalledPage *self)
{
@@ -110,12 +128,15 @@ gs_installed_page_app_row_activated_cb (GtkListBox *list_box,
static void
row_unrevealed (GObject *row, GParamSpec *pspec, gpointer data)
{
+ GsInstalledPage *self = GS_INSTALLED_PAGE (gtk_widget_get_ancestor (GTK_WIDGET (row),
+ GS_TYPE_INSTALLED_PAGE));
GtkWidget *list;
list = gtk_widget_get_parent (GTK_WIDGET (row));
if (list == NULL)
return;
gtk_list_box_remove (GTK_LIST_BOX (list), GTK_WIDGET (row));
+ update_groups (self);
}
static void
@@ -247,6 +268,8 @@ gs_installed_page_add_app (GsInstalledPage *self, GsAppList *list, GsApp *app)
g_assert_not_reached ();
}
+ update_groups (self);
+
gs_app_row_set_size_groups (GS_APP_ROW (app_row),
self->sizegroup_image,
self->sizegroup_name,
@@ -308,6 +331,7 @@ gs_installed_page_load (GsInstalledPage *self)
gs_widget_remove_all (self->list_box_install_apps, (GsRemoveFunc) gtk_list_box_remove);
gs_widget_remove_all (self->list_box_install_system_apps, (GsRemoveFunc) gtk_list_box_remove);
gs_widget_remove_all (self->list_box_install_addons, (GsRemoveFunc) gtk_list_box_remove);
+ update_groups (self);
flags = GS_PLUGIN_REFINE_FLAGS_REQUIRE_ICON |
GS_PLUGIN_REFINE_FLAGS_REQUIRE_HISTORY |
@@ -630,14 +654,6 @@ gs_installed_page_dispose (GObject *object)
G_OBJECT_CLASS (gs_installed_page_parent_class)->dispose (object);
}
-static void
-update_group_visibility_cb (GtkWidget *group,
- GtkWidget *widget,
- GtkWidget *list_box)
-{
- gtk_widget_set_visible (group, gtk_widget_get_first_child (list_box) != NULL);
-}
-
static void
gs_installed_page_class_init (GsInstalledPageClass *klass)
{
@@ -677,6 +693,10 @@ gs_installed_page_class_init (GsInstalledPageClass *klass)
gtk_widget_class_set_template_from_resource (widget_class,
"/org/gnome/Software/gs-installed-page.ui");
+ gtk_widget_class_bind_template_child (widget_class, GsInstalledPage, group_install_in_progress);
+ gtk_widget_class_bind_template_child (widget_class, GsInstalledPage, group_install_apps);
+ gtk_widget_class_bind_template_child (widget_class, GsInstalledPage, group_install_system_apps);
+ gtk_widget_class_bind_template_child (widget_class, GsInstalledPage, group_install_addons);
gtk_widget_class_bind_template_child (widget_class, GsInstalledPage, list_box_install_in_progress);
gtk_widget_class_bind_template_child (widget_class, GsInstalledPage, list_box_install_apps);
gtk_widget_class_bind_template_child (widget_class, GsInstalledPage, list_box_install_system_apps);
@@ -686,7 +706,6 @@ gs_installed_page_class_init (GsInstalledPageClass *klass)
gtk_widget_class_bind_template_child (widget_class, GsInstalledPage, stack_install);
gtk_widget_class_bind_template_callback (widget_class, gs_installed_page_app_row_activated_cb);
- gtk_widget_class_bind_template_callback (widget_class, update_group_visibility_cb);
}
static void
diff --git a/src/gs-installed-page.ui b/src/gs-installed-page.ui
index 19e365059..e7490d105 100644
--- a/src/gs-installed-page.ui
+++ b/src/gs-installed-page.ui
@@ -64,8 +64,6 @@
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="selection_mode">none</property>
- <signal name="add" handler="update_group_visibility_cb"
object="group_install_in_progress" swapped="yes"/>
- <signal name="remove" handler="update_group_visibility_cb"
object="group_install_in_progress" swapped="yes"/>
<signal name="row-activated"
handler="gs_installed_page_app_row_activated_cb"/>
<style>
<class name="content"/>
@@ -86,8 +84,6 @@
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="selection_mode">none</property>
- <signal name="add" handler="update_group_visibility_cb"
object="group_install_apps" swapped="yes"/>
- <signal name="remove" handler="update_group_visibility_cb"
object="group_install_apps" swapped="yes"/>
<signal name="row-activated"
handler="gs_installed_page_app_row_activated_cb"/>
<style>
<class name="content"/>
@@ -108,8 +104,6 @@
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="selection_mode">none</property>
- <signal name="add" handler="update_group_visibility_cb"
object="group_install_system_apps" swapped="yes"/>
- <signal name="remove" handler="update_group_visibility_cb"
object="group_install_system_apps" swapped="yes"/>
<signal name="row-activated"
handler="gs_installed_page_app_row_activated_cb"/>
<style>
<class name="content"/>
@@ -130,8 +124,6 @@
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="selection_mode">none</property>
- <signal name="add" handler="update_group_visibility_cb"
object="group_install_addons" swapped="yes"/>
- <signal name="remove" handler="update_group_visibility_cb"
object="group_install_addons" swapped="yes"/>
<signal name="row-activated"
handler="gs_installed_page_app_row_activated_cb"/>
<style>
<class name="content"/>
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]