shell: Only try to select an existing panel on startup
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.
This commit is contained in:
parent
256b4a45c0
commit
f547d9129d
3 changed files with 28 additions and 1 deletions
|
@ -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,
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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));
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue