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 @@ -327,6 +327,30 @@ cc_shell_model_add_item (CcShellModel *model, g_strfreev (keywords); } +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, 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));