[gnome-software: 18/29] gs-shell: Move various shell widget visibility changes out of pages
- From: Philip Withnall <pwithnall src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-software: 18/29] gs-shell: Move various shell widget visibility changes out of pages
- Date: Wed, 31 Mar 2021 16:03:46 +0000 (UTC)
commit 43623f495bacef80c4c1286d235a7b7c46636743
Author: Philip Withnall <pwithnall endlessos org>
Date: Thu Jan 21 12:31:34 2021 +0000
gs-shell: Move various shell widget visibility changes out of pages
This code controls the visibility of shell-level widgets, so it should
be in the shell. It doesn’t really make sense for a page to control
whether it’s displayed with (for example) a menu button.
This is another step towards removing the layering violations which
allow the pages access to the shell’s UI.
Signed-off-by: Philip Withnall <pwithnall endlessos org>
src/gs-installed-page.c | 6 ------
src/gs-overview-page.c | 10 ----------
src/gs-search-page.c | 13 -------------
src/gs-shell.c | 13 +++++++++----
src/gs-updates-page.c | 6 ------
5 files changed, 9 insertions(+), 39 deletions(-)
---
diff --git a/src/gs-installed-page.c b/src/gs-installed-page.c
index f3c595cd2..eb623b6c8 100644
--- a/src/gs-installed-page.c
+++ b/src/gs-installed-page.c
@@ -281,7 +281,6 @@ static void
gs_installed_page_switch_to (GsPage *page)
{
GsInstalledPage *self = GS_INSTALLED_PAGE (page);
- GtkWidget *widget;
if (gs_shell_get_mode (self->shell) != GS_SHELL_MODE_INSTALLED) {
g_warning ("Called switch_to(installed) when in mode %s",
@@ -289,11 +288,6 @@ gs_installed_page_switch_to (GsPage *page)
return;
}
- widget = GTK_WIDGET (gtk_builder_get_object (self->builder, "buttonbox_main"));
- gtk_widget_show (widget);
- widget = GTK_WIDGET (gtk_builder_get_object (self->builder, "menu_button"));
- gtk_widget_show (widget);
-
if (gs_shell_get_mode (self->shell) == GS_SHELL_MODE_INSTALLED) {
gs_grab_focus_when_mapped (self->scrolledwindow_install);
}
diff --git a/src/gs-overview-page.c b/src/gs-overview-page.c
index fe67feb27..b557d95d9 100644
--- a/src/gs-overview-page.c
+++ b/src/gs-overview-page.c
@@ -757,7 +757,6 @@ static void
gs_overview_page_switch_to (GsPage *page)
{
GsOverviewPage *self = GS_OVERVIEW_PAGE (page);
- GtkWidget *widget;
if (gs_shell_get_mode (self->shell) != GS_SHELL_MODE_OVERVIEW) {
g_warning ("Called switch_to(overview) when in mode %s",
@@ -765,15 +764,6 @@ gs_overview_page_switch_to (GsPage *page)
return;
}
- /* we hid the search bar */
- widget = GTK_WIDGET (gtk_builder_get_object (self->builder, "search_button"));
- gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (widget), FALSE);
-
- widget = GTK_WIDGET (gtk_builder_get_object (self->builder, "buttonbox_main"));
- gtk_widget_show (widget);
- widget = GTK_WIDGET (gtk_builder_get_object (self->builder, "menu_button"));
- gtk_widget_show (widget);
-
gs_grab_focus_when_mapped (self->scrolledwindow_overview);
if (self->cache_valid || self->action_cnt > 0)
diff --git a/src/gs-search-page.c b/src/gs-search-page.c
index ae0130c19..bfa22edab 100644
--- a/src/gs-search-page.c
+++ b/src/gs-search-page.c
@@ -350,7 +350,6 @@ static void
gs_search_page_switch_to (GsPage *page)
{
GsSearchPage *self = GS_SEARCH_PAGE (page);
- GtkWidget *widget;
if (gs_shell_get_mode (self->shell) != GS_SHELL_MODE_SEARCH) {
g_warning ("Called switch_to(search) when in mode %s",
@@ -358,18 +357,6 @@ gs_search_page_switch_to (GsPage *page)
return;
}
- widget = GTK_WIDGET (gtk_builder_get_object (self->builder, "buttonbox_main"));
- gtk_widget_show (widget);
- widget = GTK_WIDGET (gtk_builder_get_object (self->builder, "menu_button"));
- gtk_widget_show (widget);
-
- widget = GTK_WIDGET (gtk_builder_get_object (self->builder, "search_bar"));
- gtk_widget_show (widget);
-
- /* hardcode */
- widget = GTK_WIDGET (gtk_builder_get_object (self->builder, "search_button"));
- gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (widget), TRUE);
-
if (self->value && self->changed)
gs_search_page_load (self);
}
diff --git a/src/gs-shell.c b/src/gs-shell.c
index c9bbb976d..aac0ce36f 100644
--- a/src/gs-shell.c
+++ b/src/gs-shell.c
@@ -406,6 +406,7 @@ stack_notify_visible_child_cb (GObject *object,
GtkStyleContext *context;
GsShellMode mode;
gsize i;
+ gboolean buttonbox_visible;
/* Work out the mode for this child. */
for (i = 0; i < G_N_ELEMENTS (page_name); i++) {
@@ -419,13 +420,17 @@ stack_notify_visible_child_cb (GObject *object,
widget = GTK_WIDGET (gtk_builder_get_object (shell->builder, "header"));
gtk_header_bar_set_show_close_button (GTK_HEADER_BAR (widget), TRUE);
- /* hide all mode specific header widgets here, they will be shown in the
- * refresh functions
+ /* update the visibility of mode-specific header widgets
*/
+ buttonbox_visible = (mode == GS_SHELL_MODE_OVERVIEW ||
+ mode == GS_SHELL_MODE_INSTALLED ||
+ mode == GS_SHELL_MODE_UPDATES ||
+ mode == GS_SHELL_MODE_SEARCH);
+
widget = GTK_WIDGET (gtk_builder_get_object (shell->builder, "buttonbox_main"));
- gtk_widget_hide (widget);
+ gtk_widget_set_visible (widget, buttonbox_visible);
widget = GTK_WIDGET (gtk_builder_get_object (shell->builder, "menu_button"));
- gtk_widget_hide (widget);
+ gtk_widget_set_visible (widget, buttonbox_visible);
widget = GTK_WIDGET (gtk_builder_get_object (shell->builder, "header_selection_menu_button"));
gtk_widget_hide (widget);
widget = GTK_WIDGET (gtk_builder_get_object (shell->builder, "origin_box"));
diff --git a/src/gs-updates-page.c b/src/gs-updates-page.c
index 24e4bf5c5..8ac643c1e 100644
--- a/src/gs-updates-page.c
+++ b/src/gs-updates-page.c
@@ -642,7 +642,6 @@ static void
gs_updates_page_switch_to (GsPage *page)
{
GsUpdatesPage *self = GS_UPDATES_PAGE (page);
- GtkWidget *widget;
if (gs_shell_get_mode (self->shell) != GS_SHELL_MODE_UPDATES) {
g_warning ("Called switch_to(updates) when in mode %s",
@@ -650,11 +649,6 @@ gs_updates_page_switch_to (GsPage *page)
return;
}
- widget = GTK_WIDGET (gtk_builder_get_object (self->builder, "buttonbox_main"));
- gtk_widget_show (widget);
- widget = GTK_WIDGET (gtk_builder_get_object (self->builder, "menu_button"));
- gtk_widget_show (widget);
-
gtk_widget_set_visible (self->button_refresh, TRUE);
/* no need to refresh */
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]