app: gimp_session_info_book_restore(): don't set a non-existing current page

Don't set the first page of the restored dockbook active if there are
less than two pages. Also add a comment that explains why we return
the dockbook even though we know that all its dockables failed to
restore.
This commit is contained in:
Michael Natterer 2011-05-12 20:29:05 +02:00
parent 80cf95319e
commit 68a56a861e
1 changed files with 13 additions and 2 deletions

View File

@ -251,6 +251,7 @@ gimp_session_info_book_restore (GimpSessionInfoBook *info,
{
GtkWidget *dockbook;
GList *pages;
gint n_dockables = 0;
g_return_val_if_fail (info != NULL, NULL);
g_return_val_if_fail (GIMP_IS_DOCK (dock), NULL);
@ -267,7 +268,10 @@ gimp_session_info_book_restore (GimpSessionInfoBook *info,
dockable = gimp_session_info_dockable_restore (dockable_info, dock);
if (dockable)
gimp_dockbook_add (GIMP_DOCKBOOK (dockbook), dockable, -1);
{
gimp_dockbook_add (GIMP_DOCKBOOK (dockbook), dockable, -1);
n_dockables++;
}
}
if (info->current_page <
@ -276,10 +280,17 @@ gimp_session_info_book_restore (GimpSessionInfoBook *info,
gtk_notebook_set_current_page (GTK_NOTEBOOK (dockbook),
info->current_page);
}
else
else if (n_dockables > 1)
{
gtk_notebook_set_current_page (GTK_NOTEBOOK (dockbook), 0);
}
/* Return the dockbook even if no dockable could be restored
* (n_dockables == 0) because otherwise we would have to remove it
* from the dock right here, which could implicitly destroy the
* dock and make catching restore errors much harder on higher
* levels. Instead, we check for restored empty dockbooks in our
* caller.
*/
return GIMP_DOCKBOOK (dockbook);
}