mirror of
https://gitlab.gnome.org/GNOME/gtk.git
synced 2024-12-25 13:11:13 +00:00
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
This commit is contained in:
parent
b5abd10940
commit
cbbfd7beb6
@ -262,6 +262,8 @@ gtk_application_remove_window
|
|||||||
#if IN_FILE(__GTK_ASSISTANT_C__)
|
#if IN_FILE(__GTK_ASSISTANT_C__)
|
||||||
gtk_assistant_get_type G_GNUC_CONST
|
gtk_assistant_get_type G_GNUC_CONST
|
||||||
gtk_assistant_new
|
gtk_assistant_new
|
||||||
|
gtk_assistant_next_page
|
||||||
|
gtk_assistant_previous_page
|
||||||
gtk_assistant_get_current_page
|
gtk_assistant_get_current_page
|
||||||
gtk_assistant_set_current_page
|
gtk_assistant_set_current_page
|
||||||
gtk_assistant_get_n_pages
|
gtk_assistant_get_n_pages
|
||||||
|
@ -590,13 +590,22 @@ set_assistant_buttons_state (GtkAssistant *assistant)
|
|||||||
gtk_widget_hide (priv->last);
|
gtk_widget_hide (priv->last);
|
||||||
compute_progress_state (assistant);
|
compute_progress_state (assistant);
|
||||||
break;
|
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:
|
default:
|
||||||
g_assert_not_reached ();
|
g_assert_not_reached ();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (priv->committed)
|
if (priv->committed)
|
||||||
gtk_widget_hide (priv->cancel);
|
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);
|
gtk_widget_hide (priv->cancel);
|
||||||
else
|
else
|
||||||
gtk_widget_show (priv->cancel);
|
gtk_widget_show (priv->cancel);
|
||||||
@ -720,34 +729,14 @@ static void
|
|||||||
on_assistant_forward (GtkWidget *widget,
|
on_assistant_forward (GtkWidget *widget,
|
||||||
GtkAssistant *assistant)
|
GtkAssistant *assistant)
|
||||||
{
|
{
|
||||||
if (!compute_next_step (assistant))
|
gtk_assistant_next_page (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");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
on_assistant_back (GtkWidget *widget,
|
on_assistant_back (GtkWidget *widget,
|
||||||
GtkAssistant *assistant)
|
GtkAssistant *assistant)
|
||||||
{
|
{
|
||||||
GtkAssistantPrivate *priv = assistant->priv;
|
gtk_assistant_previous_page (assistant);
|
||||||
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);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
@ -1684,6 +1673,73 @@ gtk_assistant_set_current_page (GtkAssistant *assistant,
|
|||||||
set_current_page (assistant, page);
|
set_current_page (assistant, page);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 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:
|
* gtk_assistant_get_n_pages:
|
||||||
* @assistant: a #GtkAssistant
|
* @assistant: a #GtkAssistant
|
||||||
|
@ -55,6 +55,9 @@ G_BEGIN_DECLS
|
|||||||
* @GTK_ASSISTANT_PAGE_PROGRESS: Used for tasks that take a long time to
|
* @GTK_ASSISTANT_PAGE_PROGRESS: Used for tasks that take a long time to
|
||||||
* complete, blocks the assistant until the page is marked as complete.
|
* complete, blocks the assistant until the page is marked as complete.
|
||||||
* Only the back button will be shown.
|
* Only the back button will be shown.
|
||||||
|
* @GTK_ASSISTANT_PAGE_CUSTOM: Used for when other page types are not
|
||||||
|
* appropriate. No buttons will be shown, and the application must
|
||||||
|
* add its own buttons through gtk_assistant_add_action_widget().
|
||||||
*
|
*
|
||||||
* An enum for determining the page role inside the #GtkAssistant. It's
|
* An enum for determining the page role inside the #GtkAssistant. It's
|
||||||
* used to handle buttons sensitivity and visibility.
|
* used to handle buttons sensitivity and visibility.
|
||||||
@ -72,7 +75,8 @@ typedef enum
|
|||||||
GTK_ASSISTANT_PAGE_INTRO,
|
GTK_ASSISTANT_PAGE_INTRO,
|
||||||
GTK_ASSISTANT_PAGE_CONFIRM,
|
GTK_ASSISTANT_PAGE_CONFIRM,
|
||||||
GTK_ASSISTANT_PAGE_SUMMARY,
|
GTK_ASSISTANT_PAGE_SUMMARY,
|
||||||
GTK_ASSISTANT_PAGE_PROGRESS
|
GTK_ASSISTANT_PAGE_PROGRESS,
|
||||||
|
GTK_ASSISTANT_PAGE_CUSTOM
|
||||||
} GtkAssistantPageType;
|
} GtkAssistantPageType;
|
||||||
|
|
||||||
typedef struct _GtkAssistant GtkAssistant;
|
typedef struct _GtkAssistant GtkAssistant;
|
||||||
@ -120,6 +124,8 @@ typedef gint (*GtkAssistantPageFunc) (gint current_page, gpointer data);
|
|||||||
|
|
||||||
GType gtk_assistant_get_type (void) G_GNUC_CONST;
|
GType gtk_assistant_get_type (void) G_GNUC_CONST;
|
||||||
GtkWidget *gtk_assistant_new (void);
|
GtkWidget *gtk_assistant_new (void);
|
||||||
|
void gtk_assistant_next_page (GtkAssistant *assistant);
|
||||||
|
void gtk_assistant_previous_page (GtkAssistant *assistant);
|
||||||
gint gtk_assistant_get_current_page (GtkAssistant *assistant);
|
gint gtk_assistant_get_current_page (GtkAssistant *assistant);
|
||||||
void gtk_assistant_set_current_page (GtkAssistant *assistant,
|
void gtk_assistant_set_current_page (GtkAssistant *assistant,
|
||||||
gint page_num);
|
gint page_num);
|
||||||
|
Loading…
Reference in New Issue
Block a user