diff options
author | Benjamin Berg <bberg@redhat.com> | 2018-04-25 10:32:10 +0200 |
---|---|---|
committer | Benjamin Berg <benjamin@sipsolutions.net> | 2018-04-30 14:02:25 +0000 |
commit | f547d9129d6d69c0eacd24cef7cda7eca09d6106 (patch) | |
tree | b1ac842ed94564d0677d0fa304dec3c8e47ea7c1 | |
parent | 256b4a45c0ffd11cd54e80f09d20c6d7d17202be (diff) | |
download | gnome-control-center-benzea/startup-fix.tar.gz |
shell: Only try to select an existing panel on startupbenzea/startup-fix
When selecting the panel on startup based on the "last-panel" settings,
we need to make sure that the panel exists.
Note that this is a special case which does not use the internal
set_active_panel_from_id API. Using it is currently not possible because
the API does not report back the error and we would end up not selecting
any panel.
-rw-r--r-- | shell/cc-shell-model.c | 24 | ||||
-rw-r--r-- | shell/cc-shell-model.h | 3 | ||||
-rw-r--r-- | shell/cc-window.c | 2 |
3 files changed, 28 insertions, 1 deletions
diff --git a/shell/cc-shell-model.c b/shell/cc-shell-model.c index 55f3e3c82..2a69d6a12 100644 --- a/shell/cc-shell-model.c +++ b/shell/cc-shell-model.c @@ -328,6 +328,30 @@ cc_shell_model_add_item (CcShellModel *model, } gboolean +cc_shell_model_has_panel (CcShellModel *model, + const char *id) +{ + GtkTreeIter iter; + gboolean valid; + + g_assert (id); + + valid = gtk_tree_model_get_iter_first (model, &iter); + while (valid) + { + g_autofree gchar *panel_id = NULL; + + gtk_tree_model_get (model, &iter, COL_ID, &panel_id, -1); + if (g_str_equal (id, panel_id)) + return TRUE; + + valid = gtk_tree_model_iter_next (model, &iter); + } + + return FALSE; +} + +gboolean cc_shell_model_iter_matches_search (CcShellModel *model, GtkTreeIter *iter, const char *term) diff --git a/shell/cc-shell-model.h b/shell/cc-shell-model.h index 259407109..4ba8342e5 100644 --- a/shell/cc-shell-model.h +++ b/shell/cc-shell-model.h @@ -98,6 +98,9 @@ void cc_shell_model_add_item (CcShellModel *model, GAppInfo *appinfo, const char *id); +gboolean cc_shell_model_has_panel (CcShellModel *model, + const char *id); + gboolean cc_shell_model_iter_matches_search (CcShellModel *model, GtkTreeIter *iter, const char *term); diff --git a/shell/cc-window.c b/shell/cc-window.c index c0fc19446..c05712475 100644 --- a/shell/cc-window.c +++ b/shell/cc-window.c @@ -756,7 +756,7 @@ cc_window_init (CcWindow *self) /* 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') + if (id != NULL && cc_shell_model_has_panel (self->store, id)) cc_panel_list_set_active_panel (CC_PANEL_LIST (self->panel_list), id); else cc_panel_list_activate (CC_PANEL_LIST (self->panel_list)); |