From 10738d68c6e44c5be95c1bdb2a8b76f1ee4b50df Mon Sep 17 00:00:00 2001 From: Bastien Nocera Date: Tue, 22 Aug 2017 18:10:25 +0200 Subject: [PATCH] shell: Remember the last used panel And restore it if the application is launched without any panels requested. https://bugzilla.gnome.org/show_bug.cgi?id=786607 --- meson.build | 1 + shell/cc-window.c | 17 +++++++++++++++-- shell/meson.build | 3 +++ shell/org.gnome.ControlCenter.gschema.xml | 12 ++++++++++++ 4 files changed, 31 insertions(+), 2 deletions(-) create mode 100644 shell/org.gnome.ControlCenter.gschema.xml diff --git a/meson.build b/meson.build index 02eb6e2f0..34ba20842 100644 --- a/meson.build +++ b/meson.build @@ -16,6 +16,7 @@ control_center_sysconfdir = join_paths(control_center_prefix, get_option('syscon control_center_pkgdatadir = join_paths(control_center_datadir, meson.project_name()) control_center_desktopdir = join_paths(control_center_datadir, 'applications') control_center_icondir = join_paths(control_center_datadir, 'icons') +control_center_schemadir = join_paths (control_center_datadir, 'glib-2.0', 'schemas') control_center_gettext = meson.project_name() + '-2.0' diff --git a/shell/cc-window.c b/shell/cc-window.c index 1f0a6c01a..913d1c063 100644 --- a/shell/cc-window.c +++ b/shell/cc-window.c @@ -74,6 +74,7 @@ struct _CcWindow GtkListStore *store; CcPanel *active_panel; + GSettings *settings; }; static void cc_shell_iface_init (CcShellInterface *iface); @@ -123,6 +124,8 @@ activate_panel (CcWindow *self, if (!id) return FALSE; + g_settings_set_string (self->settings, "last-panel", id); + self->current_panel = GTK_WIDGET (cc_panel_loader_load_by_name (CC_SHELL (self), id, parameters)); cc_shell_set_active_panel (CC_SHELL (self), CC_PANEL (self->current_panel)); gtk_widget_show (self->current_panel); @@ -664,6 +667,8 @@ cc_window_finalize (GObject *object) self->previous_panels = NULL; } + g_clear_object (&self->settings); + G_OBJECT_CLASS (cc_window_parent_class)->finalize (object); } @@ -713,11 +718,14 @@ static void cc_window_init (CcWindow *self) { GtkSettings *settings; + g_autofree char *id = NULL; gtk_widget_init_template (GTK_WIDGET (self)); gtk_widget_add_events (GTK_WIDGET (self), GDK_BUTTON_RELEASE_MASK); + self->settings = g_settings_new ("org.gnome.ControlCenter"); + /* Handle decorations for the split headers. */ settings = gtk_settings_get_default (); g_signal_connect (settings, @@ -733,8 +741,13 @@ cc_window_init (CcWindow *self) setup_model (self); - /* After everything is loaded, select the first visible panel */ - cc_panel_list_activate (CC_PANEL_LIST (self->panel_list)); + /* After everything is loaded, select the last used panel, if any, + * or the first visible panel */ + id = g_settings_get_string (self->settings, "last-panel"); + if (id != NULL && *id != '\0') + cc_panel_list_set_active_panel (CC_PANEL_LIST (self->panel_list), id); + else + cc_panel_list_activate (CC_PANEL_LIST (self->panel_list)); } CcWindow * diff --git a/shell/meson.build b/shell/meson.build index ac67fa236..ea0116542 100644 --- a/shell/meson.build +++ b/shell/meson.build @@ -133,3 +133,6 @@ exe = executable( ) test(test_unit, exe) + +install_data ('org.gnome.ControlCenter.gschema.xml', + install_dir: control_center_schemadir) diff --git a/shell/org.gnome.ControlCenter.gschema.xml b/shell/org.gnome.ControlCenter.gschema.xml new file mode 100644 index 000000000..013ffceeb --- /dev/null +++ b/shell/org.gnome.ControlCenter.gschema.xml @@ -0,0 +1,12 @@ + + + + '' + The identifier for the last Settings panel to be opened + + The identifier for the last Settings panel to be opened. Unrecognised values + will be ignored and the first panel in the list selected. + + + +