Actually implement visibility handling, and add

2006-01-31  Matthias Clasen  <mclasen@redhat.com>

	* gtk/gtk.symbols:
	* gtk/gtkassistant.h:
	* gtk/gtkassistant.c: Actually implement visibility handling,
	and add gtk_assistant_update_buttons_state.

	* tests/testassistant.c: Test visibility handling.
This commit is contained in:
Matthias Clasen 2006-01-31 16:57:18 +00:00 committed by Matthias Clasen
parent 5b8dbf0d5f
commit 6e6067d951
8 changed files with 112 additions and 25 deletions

View File

@ -1,3 +1,12 @@
2006-01-31 Matthias Clasen <mclasen@redhat.com>
* gtk/gtk.symbols:
* gtk/gtkassistant.h:
* gtk/gtkassistant.c: Actually implement visibility handling,
and add gtk_assistant_update_buttons_state.
* tests/testassistant.c: Test visibility handling.
2006-01-31 Kristian Rietveld <kris@imendio.com>
* gtk/gtkstyle.c (gtk_default_draw_flat_box): Add support for row

View File

@ -1,3 +1,12 @@
2006-01-31 Matthias Clasen <mclasen@redhat.com>
* gtk/gtk.symbols:
* gtk/gtkassistant.h:
* gtk/gtkassistant.c: Actually implement visibility handling,
and add gtk_assistant_update_buttons_state.
* tests/testassistant.c: Test visibility handling.
2006-01-31 Kristian Rietveld <kris@imendio.com>
* gtk/gtkstyle.c (gtk_default_draw_flat_box): Add support for row

View File

@ -1,3 +1,7 @@
2006-01-31 Matthias Clasen <mclasen@redhat.com>
* gtk/gtk-sections.txt: Add new functions
2006-01-30 Matthias Clasen <mclasen@redhat.com>
* gtk/visual_index.xml: Add GtkLinkButton

View File

@ -310,6 +310,7 @@ gtk_assistant_set_page_complete
gtk_assistant_get_page_complete
gtk_assistant_add_action_widget
gtk_assistant_remove_action_widget
gtk_assistant_update_buttons_state
<SUBSECTION Standard>
GtkAssistantClass

View File

@ -234,6 +234,7 @@ gtk_assistant_set_page_complete
gtk_assistant_get_page_complete
gtk_assistant_add_action_widget
gtk_assistant_remove_action_widget
gtk_assistant_update_buttons_state
#endif
#endif

View File

@ -424,7 +424,7 @@ compute_last_button_state (GtkAssistant *assistant)
}
static void
_set_assistant_header_image (GtkAssistant *assistant)
set_assistant_header_image (GtkAssistant *assistant)
{
GtkAssistantPrivate *priv = assistant->priv;
@ -433,7 +433,7 @@ _set_assistant_header_image (GtkAssistant *assistant)
}
static void
_set_assistant_sidebar_image (GtkAssistant *assistant)
set_assistant_sidebar_image (GtkAssistant *assistant)
{
GtkAssistantPrivate *priv = assistant->priv;
@ -447,7 +447,7 @@ _set_assistant_sidebar_image (GtkAssistant *assistant)
}
static void
_set_assistant_buttons_state (GtkAssistant *assistant)
set_assistant_buttons_state (GtkAssistant *assistant)
{
GtkAssistantPrivate *priv = assistant->priv;
@ -516,8 +516,8 @@ _set_assistant_buttons_state (GtkAssistant *assistant)
}
static void
_set_current_page (GtkAssistant *assistant,
GtkAssistantPage *page)
set_current_page (GtkAssistant *assistant,
GtkAssistantPage *page)
{
GtkAssistantPrivate *priv = assistant->priv;
GtkAssistantPage *old_page;
@ -530,9 +530,9 @@ _set_current_page (GtkAssistant *assistant,
priv->current_page = page;
_set_assistant_buttons_state (assistant);
_set_assistant_header_image (assistant);
_set_assistant_sidebar_image (assistant);
set_assistant_buttons_state (assistant);
set_assistant_header_image (assistant);
set_assistant_sidebar_image (assistant);
g_signal_emit (assistant, signals [PREPARE], 0, priv->current_page->page);
@ -570,7 +570,7 @@ compute_next_step (GtkAssistant *assistant)
if (next_page >= 0 && next_page < n_pages)
{
priv->visited_pages = g_slist_prepend (priv->visited_pages, page_info);
_set_current_page (assistant, g_list_nth_data (priv->pages, next_page));
set_current_page (assistant, g_list_nth_data (priv->pages, next_page));
return TRUE;
}
@ -630,7 +630,7 @@ on_assistant_back (GtkWidget *widget, GtkAssistant *assistant)
while (page_info->type == GTK_ASSISTANT_PAGE_PROGRESS ||
!GTK_WIDGET_VISIBLE (page_info->page));
_set_current_page (assistant, page_info);
set_current_page (assistant, page_info);
}
static void
@ -823,6 +823,18 @@ gtk_assistant_get_child_property (GtkContainer *container,
}
}
static void
on_page_notify_visibility (GtkWidget *widget,
GParamSpec *arg,
gpointer data)
{
GtkAssistant *assistant = GTK_ASSISTANT (data);
/* update buttons state, flow may have changed */
if (GTK_WIDGET_MAPPED (assistant))
set_assistant_buttons_state (assistant);
}
static void
remove_page (GtkAssistant *assistant,
GList *element)
@ -837,8 +849,9 @@ remove_page (GtkAssistant *assistant,
compute_next_step (assistant);
priv->pages = g_list_remove_link (priv->pages, element);
priv->visited_pages = g_slist_remove_all (priv->visited_pages, page_info);
g_signal_handlers_disconnect_by_func (page_info->page, on_page_notify_visibility, assistant);
gtk_widget_unparent (page_info->page);
if (page_info->header_image)
@ -1158,9 +1171,9 @@ gtk_assistant_map (GtkWidget *widget)
GTK_WIDGET_VISIBLE (priv->current_page->page) &&
!GTK_WIDGET_MAPPED (priv->current_page->page))
{
_set_assistant_buttons_state ((GtkAssistant *) widget);
_set_assistant_header_image ((GtkAssistant*) widget);
_set_assistant_sidebar_image ((GtkAssistant*) widget);
set_assistant_buttons_state ((GtkAssistant *) widget);
set_assistant_header_image ((GtkAssistant*) widget);
set_assistant_sidebar_image ((GtkAssistant*) widget);
g_signal_emit (widget, signals [PREPARE], 0, priv->current_page->page);
gtk_widget_set_child_visible (priv->current_page->page, TRUE);
@ -1477,7 +1490,7 @@ gtk_assistant_set_current_page (GtkAssistant *assistant,
if (GTK_WIDGET_MAPPED (assistant))
priv->visited_pages = g_slist_prepend (priv->visited_pages, page);
_set_current_page (assistant, page);
set_current_page (assistant, page);
}
/**
@ -1610,6 +1623,9 @@ gtk_assistant_insert_page (GtkAssistant *assistant,
page_info->page = page;
page_info->title = gtk_label_new (NULL);
g_signal_connect (G_OBJECT (page), "notify::visible",
G_CALLBACK (on_page_notify_visibility), assistant);
gtk_misc_set_alignment (GTK_MISC (page_info->title), 0.,0.5);
set_title_colors (GTK_WIDGET (assistant), page_info->title);
set_title_font (GTK_WIDGET (assistant), page_info->title);
@ -1684,7 +1700,7 @@ gtk_assistant_set_forward_page_func (GtkAssistant *assistant,
/* Page flow has possibly changed, so the
buttons state might need to change too */
if (priv->current_page)
_set_assistant_buttons_state (assistant);
set_assistant_buttons_state (assistant);
}
/**
@ -1843,7 +1859,7 @@ gtk_assistant_set_page_type (GtkAssistant *assistant,
/* Always set buttons state, a change in a future page
might change current page buttons */
if (priv->current_page)
_set_assistant_buttons_state (assistant);
set_assistant_buttons_state (assistant);
gtk_widget_child_notify (page, "page-type");
}
@ -1924,7 +1940,7 @@ gtk_assistant_set_page_header_image (GtkAssistant *assistant,
page_info->header_image = g_object_ref (pixbuf);
if (page_info == priv->current_page)
_set_assistant_header_image (assistant);
set_assistant_header_image (assistant);
gtk_widget_child_notify (page, "header-image");
}
@ -2006,7 +2022,7 @@ gtk_assistant_set_page_side_image (GtkAssistant *assistant,
page_info->sidebar_image = g_object_ref (pixbuf);
if (page_info == priv->current_page)
_set_assistant_sidebar_image (assistant);
set_assistant_sidebar_image (assistant);
gtk_widget_child_notify (page, "sidebar-image");
}
@ -2082,7 +2098,7 @@ gtk_assistant_set_page_complete (GtkAssistant *assistant,
/* Always set buttons state, a change in a future page
might change current page buttons */
if (priv->current_page)
_set_assistant_buttons_state (assistant);
set_assistant_buttons_state (assistant);
gtk_widget_child_notify (page, "complete");
}
@ -2120,6 +2136,30 @@ gtk_assistant_get_page_complete (GtkAssistant *assistant,
return page_info->complete;
}
/**
* gtk_assistant_update_buttons_state:
* @assistant: a #GtkAssistant
*
* Forces @assistant to recompute the buttons state.
*
* GTK+ automatically takes care of this in most situations,
* e.g. when the user goes to a different page, or when the
* visibility or completeness of a page changes.
*
* One situation where it can be necessary to call this
* function is when changing a value on the current page
* affects the future page flow of the assistant.
*
* Since: 2.10
**/
void
gtk_assistant_update_buttons_state (GtkAssistant *assistant)
{
g_return_if_fail (GTK_IS_ASSISTANT (assistant));
set_assistant_buttons_state (assistant);
}
#define __GTK_ASSISTANT_C__
#include "gtkaliasdef.c"

View File

@ -134,6 +134,8 @@ void gtk_assistant_add_action_widget (GtkAssistant
void gtk_assistant_remove_action_widget (GtkAssistant *assistant,
GtkWidget *child);
void gtk_assistant_update_buttons_state (GtkAssistant *assistant);
G_END_DECLS
#endif /* __GTK_ASSISTANT_H__ */

View File

@ -49,9 +49,8 @@ complete_cb (GtkWidget *check,
pdata->page,
complete);
}
static void
static GtkWidget *
add_completion_test_page (GtkWidget *assistant,
const gchar *text,
gboolean visible,
@ -82,6 +81,8 @@ add_completion_test_page (GtkWidget *assistant,
gtk_assistant_append_page (GTK_ASSISTANT (assistant), page);
gtk_assistant_set_page_title (GTK_ASSISTANT (assistant), page, text);
gtk_assistant_set_page_complete (GTK_ASSISTANT (assistant), page, complete);
return page;
}
static void
@ -192,6 +193,18 @@ create_simple_assistant (GtkWidget *widget)
}
}
static void
visible_cb (GtkWidget *check,
gpointer data)
{
GtkWidget *page = data;
gboolean visible;
visible = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (check));
g_object_set (G_OBJECT (page), "visible", visible, NULL);
}
static void
create_generous_assistant (GtkWidget *widget)
{
@ -199,7 +212,7 @@ create_generous_assistant (GtkWidget *widget)
if (!assistant)
{
GtkWidget *page;
GtkWidget *page, *next, *check;
assistant = gtk_assistant_new ();
gtk_window_set_default_size (GTK_WINDOW (assistant), 400, 300);
@ -220,8 +233,16 @@ create_generous_assistant (GtkWidget *widget)
gtk_assistant_set_page_type (GTK_ASSISTANT (assistant), page, GTK_ASSISTANT_PAGE_INTRO);
gtk_assistant_set_page_complete (GTK_ASSISTANT (assistant), page, TRUE);
add_completion_test_page (assistant, "Content", TRUE, FALSE);
add_completion_test_page (assistant, "More Content", TRUE, TRUE);
page = add_completion_test_page (assistant, "Content", TRUE, FALSE);
next = add_completion_test_page (assistant, "More Content", TRUE, TRUE);
check = gtk_check_button_new_with_label ("Next page visible");
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (check), TRUE);
g_signal_connect (G_OBJECT (check), "toggled",
G_CALLBACK (visible_cb), next);
gtk_widget_show (check);
gtk_container_add (GTK_CONTAINER (page), check);
add_completion_test_page (assistant, "Even More Content", TRUE, TRUE);
page = get_test_page ("Confirmation");