[gnome-software] Make sure the back button always leads back to the overview
- From: Kalev Lember <klember src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-software] Make sure the back button always leads back to the overview
- Date: Tue, 19 Mar 2019 11:11:11 +0000 (UTC)
commit ef55f61f79a83ff1a56898e9144eae5e0c478d8a
Author: Kalev Lember <klember redhat com>
Date: Tue Mar 19 10:59:26 2019 +0000
Make sure the back button always leads back to the overview
When an external app invokes gnome-software and asks it to switch to a
page, make sure we reset the state so that the back button always leads
directly back to the overview.
Previously, we only did that when the user had closed the gnome-software
window before, but this commit changes the back button to go directly
back to the overview even if the user had something open before, as per
discussion with Allan.
Fixes: https://gitlab.gnome.org/GNOME/gnome-software/issues/410
src/gs-application.c | 16 ++++++++++++++--
src/gs-shell.c | 13 +++++++++++++
src/gs-shell.h | 1 +
3 files changed, 28 insertions(+), 2 deletions(-)
---
diff --git a/src/gs-application.c b/src/gs-application.c
index 49c7d2a9..c1d359ae 100644
--- a/src/gs-application.c
+++ b/src/gs-application.c
@@ -513,6 +513,8 @@ set_mode_activated (GSimpleAction *action,
gs_application_present_window (app, NULL);
+ gs_shell_reset_state (app->shell);
+
mode = g_variant_get_string (parameter, NULL);
if (g_strcmp0 (mode, "updates") == 0) {
gs_shell_set_mode (app->shell, GS_SHELL_MODE_UPDATES);
@@ -541,6 +543,7 @@ search_activated (GSimpleAction *action,
gs_application_present_window (app, NULL);
search = g_variant_get_string (parameter, NULL);
+ gs_shell_reset_state (app->shell);
gs_shell_show_search (app->shell, search);
}
@@ -556,14 +559,16 @@ details_activated (GSimpleAction *action,
gs_application_present_window (app, NULL);
g_variant_get (parameter, "(&s&s)", &id, &search);
- if (search != NULL && search[0] != '\0')
+ if (search != NULL && search[0] != '\0') {
+ gs_shell_reset_state (app->shell);
gs_shell_show_search_result (app->shell, id, search);
- else {
+ } else {
g_autoptr (GsApp) a = NULL;
if (as_utils_unique_id_valid (id))
a = gs_plugin_loader_app_create (app->plugin_loader, id);
else
a = gs_app_new (id);
+ gs_shell_reset_state (app->shell);
gs_shell_show_app (app->shell, a);
}
}
@@ -585,6 +590,7 @@ details_pkg_activated (GSimpleAction *action,
gs_app_add_source (a, name);
if (strcmp (plugin, "") != 0)
gs_app_set_management_plugin (a, plugin);
+ gs_shell_reset_state (app->shell);
gs_shell_show_app (app->shell, a);
}
@@ -605,6 +611,7 @@ details_url_activated (GSimpleAction *action,
* the gs_shell_change_mode() function -- not in the GsAppList */
a = gs_app_new (NULL);
gs_app_set_metadata (a, "GnomeSoftware::from-url", url);
+ gs_shell_reset_state (app->shell);
gs_shell_show_app (app->shell, a);
}
@@ -633,6 +640,7 @@ install_activated (GSimpleAction *action,
return;
}
+ gs_shell_reset_state (app->shell);
gs_shell_install (app->shell, a, interaction);
}
@@ -688,6 +696,7 @@ filename_activated (GSimpleAction *action,
} else {
file = g_file_new_for_path (filename);
}
+ gs_shell_reset_state (app->shell);
gs_shell_show_local_file (app->shell, file);
}
@@ -725,6 +734,7 @@ show_offline_updates_error (GSimpleAction *action,
gs_application_present_window (app, NULL);
+ gs_shell_reset_state (app->shell);
gs_shell_set_mode (app->shell, GS_SHELL_MODE_UPDATES);
gs_update_monitor_show_error (app->update_monitor, app->shell);
}
@@ -733,6 +743,7 @@ static void
autoupdate_activated (GSimpleAction *action, GVariant *parameter, gpointer data)
{
GsApplication *app = GS_APPLICATION (data);
+ gs_shell_reset_state (app->shell);
gs_shell_set_mode (app->shell, GS_SHELL_MODE_UPDATES);
gs_update_monitor_autoupdate (app->update_monitor);
}
@@ -768,6 +779,7 @@ install_resources_activated (GSimpleAction *action,
gs_application_present_window (app, startup_id);
+ gs_shell_reset_state (app->shell);
gs_shell_show_extras_search (app->shell, mode, resources);
}
diff --git a/src/gs-shell.c b/src/gs-shell.c
index d44d3d27..9cb8ed13 100644
--- a/src/gs-shell.c
+++ b/src/gs-shell.c
@@ -2126,6 +2126,19 @@ gs_shell_setup (GsShell *shell, GsPluginLoader *plugin_loader, GCancellable *can
gs_shell_change_mode (shell, GS_SHELL_MODE_LOADING, NULL, TRUE);
}
+void
+gs_shell_reset_state (GsShell *shell)
+{
+ GsShellPrivate *priv = gs_shell_get_instance_private (shell);
+
+ /* reset to overview, unless we're in the loading state which advances
+ * to overview on its own */
+ if (priv->mode != GS_SHELL_MODE_LOADING)
+ priv->mode = GS_SHELL_MODE_OVERVIEW;
+
+ gs_shell_clean_back_entry_stack (shell);
+}
+
void
gs_shell_set_mode (GsShell *shell, GsShellMode mode)
{
diff --git a/src/gs-shell.h b/src/gs-shell.h
index 08705fa6..984e7b42 100644
--- a/src/gs-shell.h
+++ b/src/gs-shell.h
@@ -54,6 +54,7 @@ void gs_shell_change_mode (GsShell *shell,
GsShellMode mode,
gpointer data,
gboolean scroll_up);
+void gs_shell_reset_state (GsShell *shell);
void gs_shell_set_mode (GsShell *shell,
GsShellMode mode);
void gs_shell_modal_dialog_present (GsShell *shell,
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]