diff options
author | Bastien Nocera <hadess@hadess.net> | 2010-10-30 20:12:58 +0100 |
---|---|---|
committer | Bastien Nocera <hadess@hadess.net> | 2010-10-31 16:08:46 +0000 |
commit | cbbfd7beb6c7faed9ba73bd8e3b7523a61e98f23 (patch) | |
tree | 2aaa7170e6fe0a283560178c0233e3c752e770be /gtk/gtkassistant.c | |
parent | b5abd10940176d544fd544ebe9a4b2e313bf1e8c (diff) | |
download | gtk+-cbbfd7beb6c7faed9ba73bd8e3b7523a61e98f23.tar.gz |
GtkAssistant: Add custom page type
The custom page type will not show any buttons by default, and
it is left to the application to add its own buttons instead.
The _next_page() and _previous_page() functions can be used
for the back and forward buttons used by the application.
https://bugzilla.gnome.org/show_bug.cgi?id=576498
Diffstat (limited to 'gtk/gtkassistant.c')
-rw-r--r-- | gtk/gtkassistant.c | 102 |
1 files changed, 79 insertions, 23 deletions
diff --git a/gtk/gtkassistant.c b/gtk/gtkassistant.c index 10241a399f..d5ceb8286c 100644 --- a/gtk/gtkassistant.c +++ b/gtk/gtkassistant.c @@ -590,13 +590,22 @@ set_assistant_buttons_state (GtkAssistant *assistant) gtk_widget_hide (priv->last); compute_progress_state (assistant); break; + case GTK_ASSISTANT_PAGE_CUSTOM: + gtk_widget_hide (priv->cancel); + gtk_widget_hide (priv->back); + gtk_widget_hide (priv->forward); + gtk_widget_hide (priv->apply); + gtk_widget_hide (priv->last); + gtk_widget_hide (priv->close); + break; default: g_assert_not_reached (); } if (priv->committed) gtk_widget_hide (priv->cancel); - else if (priv->current_page->type == GTK_ASSISTANT_PAGE_SUMMARY) + else if (priv->current_page->type == GTK_ASSISTANT_PAGE_SUMMARY || + priv->current_page->type == GTK_ASSISTANT_PAGE_CUSTOM) gtk_widget_hide (priv->cancel); else gtk_widget_show (priv->cancel); @@ -720,34 +729,14 @@ static void on_assistant_forward (GtkWidget *widget, GtkAssistant *assistant) { - if (!compute_next_step (assistant)) - g_critical ("Page flow is broken, you may want to end it with a page of " - "type GTK_ASSISTANT_PAGE_CONFIRM or GTK_ASSISTANT_PAGE_SUMMARY"); + gtk_assistant_next_page (assistant); } static void on_assistant_back (GtkWidget *widget, GtkAssistant *assistant) { - GtkAssistantPrivate *priv = assistant->priv; - GtkAssistantPage *page_info; - GSList *page_node; - - /* skip the progress pages when going back */ - do - { - page_node = priv->visited_pages; - - g_return_if_fail (page_node != NULL); - - priv->visited_pages = priv->visited_pages->next; - page_info = (GtkAssistantPage *) page_node->data; - g_slist_free_1 (page_node); - } - while (page_info->type == GTK_ASSISTANT_PAGE_PROGRESS || - !gtk_widget_get_visible (page_info->page)); - - set_current_page (assistant, page_info); + gtk_assistant_previous_page (assistant); } static void @@ -1685,6 +1674,73 @@ gtk_assistant_set_current_page (GtkAssistant *assistant, } /** + * gtk_assistant_next_page: + * @assistant: a #GtkAssistant + * + * Navigate to the next page. It is a programming + * error to call this function if there is no next page. + * + * This function is for use when creating pages of the + * #GTK_ASSISTANT_PAGE_CUSTOM type. + * + * Since: 3.0 + **/ +void +gtk_assistant_next_page (GtkAssistant *assistant) +{ + GtkAssistantPrivate *priv; + + g_return_if_fail (GTK_IS_ASSISTANT (assistant)); + + priv = assistant->priv; + + if (!compute_next_step (assistant)) + g_critical ("Page flow is broken, you may want to end it with a page of " + "type GTK_ASSISTANT_PAGE_CONFIRM or GTK_ASSISTANT_PAGE_SUMMARY"); +} + +/** + * gtk_assistant_previous_page: + * @assistant: a #GtkAssistant + * + * Navigate to the previous visited page. It is a programming + * error to call this function if no previous page is + * available. + * + * This function is for use when creating pages of the + * #GTK_ASSISTANT_PAGE_CUSTOM type. + * + * Since: 3.0 + **/ +void +gtk_assistant_previous_page (GtkAssistant *assistant) +{ + GtkAssistantPrivate *priv; + GtkAssistantPage *page_info; + GSList *page_node; + + g_return_if_fail (GTK_IS_ASSISTANT (assistant)); + + priv = assistant->priv; + + /* skip the progress pages when going back */ + do + { + page_node = priv->visited_pages; + + g_return_if_fail (page_node != NULL); + + priv->visited_pages = priv->visited_pages->next; + page_info = (GtkAssistantPage *) page_node->data; + g_slist_free_1 (page_node); + } + while (page_info->type == GTK_ASSISTANT_PAGE_PROGRESS || + !gtk_widget_get_visible (page_info->page)); + + set_current_page (assistant, page_info); +} + +/** * gtk_assistant_get_n_pages: * @assistant: a #GtkAssistant * |