diff options
| author | David Zeuthen <davidz@redhat.com> | 2008-03-21 16:12:49 -0400 |
|---|---|---|
| committer | David Zeuthen <davidz@redhat.com> | 2008-03-21 16:12:49 -0400 |
| commit | fadb06c77df2d598767da0a1dc505e282eae87e8 (patch) | |
| tree | a8a86ab702d08d0795db967447ac0b2ff5677087 /src | |
| parent | b5c691a1f488dad6bd2990090e858fb19758d00e (diff) | |
fix what page should be shown if the currently shown page changes
If a page gets hidden, select the first visible page starting from 0.
Diffstat (limited to 'src')
| -rw-r--r-- | src/gdu-shell.c | 33 |
1 files changed, 28 insertions, 5 deletions
diff --git a/src/gdu-shell.c b/src/gdu-shell.c index fd8fa4c..8d79ba4 100644 --- a/src/gdu-shell.c +++ b/src/gdu-shell.c @@ -138,6 +138,7 @@ gdu_shell_select_presentable (GduShell *shell, GduPresentable *presentable) void gdu_shell_update (GduShell *shell) { + int n; GList *l; GduDevice *device; gboolean job_in_progress; @@ -145,6 +146,7 @@ gdu_shell_update (GduShell *shell) gboolean can_mount; gboolean can_unmount; gboolean can_eject; + GtkWidget *page_widget_currently_showing; job_in_progress = FALSE; last_job_failed = FALSE; @@ -178,6 +180,10 @@ gdu_shell_update (GduShell *shell) } + page_widget_currently_showing = gtk_notebook_get_nth_page ( + GTK_NOTEBOOK (shell->priv->notebook), + gtk_notebook_get_current_page (GTK_NOTEBOOK (shell->priv->notebook))); + for (l = shell->priv->pages; l != NULL; l = l->next) { GduPage *page = GDU_PAGE (l->data); gboolean show_page; @@ -186,10 +192,13 @@ gdu_shell_update (GduShell *shell) show_page = gdu_page_update (page, shell->priv->presentable_now_showing); page_widget = gdu_page_get_widget (page); - if (show_page) + if (show_page) { gtk_widget_show (page_widget); - else + } else { gtk_widget_hide (page_widget); + if (page_widget == page_widget_currently_showing) + page_widget_currently_showing = NULL; + } /* make the page insenstive if there's a job running on the device or the last job failed */ if (job_in_progress || last_job_failed) @@ -198,6 +207,20 @@ gdu_shell_update (GduShell *shell) gtk_widget_set_sensitive (page_widget, TRUE); } + /* the page we were showing was switching away from */ + if (page_widget_currently_showing == NULL) { + /* go to the first visible page */ + for (n = 0; n < gtk_notebook_get_n_pages (GTK_NOTEBOOK (shell->priv->notebook)); n++) { + GtkWidget *page_widget; + + page_widget = gtk_notebook_get_nth_page (GTK_NOTEBOOK (shell->priv->notebook), n); + if (GTK_WIDGET_VISIBLE (page_widget)) { + gtk_notebook_set_current_page (GTK_NOTEBOOK (shell->priv->notebook), n); + break; + } + } + } + /* update summary page */ gdu_page_update (shell->priv->page_summary, shell->priv->presentable_now_showing); @@ -525,10 +548,10 @@ create_window (GduShell *shell) /* add pages in a notebook */ shell->priv->notebook = gtk_notebook_new (); - add_page (shell, GDU_TYPE_PAGE_ERASE); - add_page (shell, GDU_TYPE_PAGE_PARTITION_CREATE); - add_page (shell, GDU_TYPE_PAGE_PARTITION_MODIFY); add_page (shell, GDU_TYPE_PAGE_PARTITION_TABLE); + add_page (shell, GDU_TYPE_PAGE_PARTITION_MODIFY); + add_page (shell, GDU_TYPE_PAGE_PARTITION_CREATE); + add_page (shell, GDU_TYPE_PAGE_ERASE); vbox2 = gtk_vbox_new (FALSE, 0); gtk_box_pack_start (GTK_BOX (vbox2), shell->priv->notebook, TRUE, TRUE, 0); |
