2 * GTK - The GIMP Toolkit
3 * Copyright (C) 1999 Red Hat, Inc.
4 * Copyright (C) 2002 Anders Carlsson <andersca@gnu.org>
5 * Copyright (C) 2003 Matthias Clasen <mclasen@redhat.com>
6 * Copyright (C) 2005 Carlos Garnacho Parro <carlosg@gnome.org>
10 * This library is free software; you can redistribute it and/or
11 * modify it under the terms of the GNU Lesser General Public
12 * License as published by the Free Software Foundation; either
13 * version 2 of the License, or (at your option) any later version.
15 * This library is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
18 * Lesser General Public License for more details.
20 * You should have received a copy of the GNU Lesser General Public
21 * License along with this library; if not, write to the
22 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
23 * Boston, MA 02111-1307, USA.
27 * SECTION:gtkassistant
28 * @Short_description: A widget used to guide users through multi-step operations
29 * @Title: GtkAssistant
31 * A #GtkAssistant is a widget used to represent a generally complex
32 * operation splitted in several steps, guiding the user through its pages
33 * and controlling the page flow to collect the necessary data.
35 * The design of GtkAssistant is that it controls what buttons to show and
36 * to make sensitive, based on what it knows about the page sequence and
37 * the <link linkend="GtkAssistantPageType">type</link> of each page, in
38 * addition to state information like the page
39 * <link linkend="gtk-assistant-set-page-complete">completion</link> and
40 * <link linkend="gtk-assistant-commit">committed</link> status.
42 * If you have a case that doesn't quite fit in #GtkAssistants way of
43 * handling buttons, you can use the #GTK_ASSISTANT_PAGE_CUSTOM page type
44 * and handle buttons yourself.
46 * <refsect2 id="GtkAssistant-BUILDER-UI">
47 * <title>GtkAssistant as GtkBuildable</title>
49 * The GtkAssistant implementation of the GtkBuildable interface exposes the
50 * @action_area as internal children with the name "action_area".
52 * To add pages to an assistant in GtkBuilder, simply add it as a
53 * <child> to the GtkAssistant object, and set its child properties
63 #include "gtkassistant.h"
65 #include "gtkaccessible.h"
66 #include "gtkbutton.h"
71 #include "gtksizegroup.h"
72 #include "gtksizerequest.h"
76 #include "gtkprivate.h"
77 #include "gtkbuildable.h"
80 #define HEADER_SPACING 12
81 #define ACTION_AREA_SPACING 12
83 typedef struct _GtkAssistantPage GtkAssistantPage;
85 struct _GtkAssistantPage
88 GtkAssistantPageType type;
90 guint complete_set : 1;
93 GdkPixbuf *header_image;
94 GdkPixbuf *sidebar_image;
97 struct _GtkAssistantPrivate
106 GtkWidget *header_image;
107 GtkWidget *sidebar_image;
109 GtkWidget *action_area;
113 GtkAssistantPage *current_page;
115 GSList *visited_pages;
117 GtkSizeGroup *size_group;
119 GtkAssistantPageFunc forward_function;
120 gpointer forward_function_data;
121 GDestroyNotify forward_data_destroy;
126 static void gtk_assistant_class_init (GtkAssistantClass *class);
127 static void gtk_assistant_init (GtkAssistant *assistant);
128 static void gtk_assistant_destroy (GtkWidget *widget);
129 static void gtk_assistant_style_updated (GtkWidget *widget);
130 static void gtk_assistant_get_preferred_width (GtkWidget *widget,
133 static void gtk_assistant_get_preferred_height (GtkWidget *widget,
136 static void gtk_assistant_size_allocate (GtkWidget *widget,
137 GtkAllocation *allocation);
138 static void gtk_assistant_map (GtkWidget *widget);
139 static void gtk_assistant_unmap (GtkWidget *widget);
140 static gboolean gtk_assistant_delete_event (GtkWidget *widget,
142 static gboolean gtk_assistant_draw (GtkWidget *widget,
144 static gboolean gtk_assistant_focus (GtkWidget *widget,
145 GtkDirectionType direction);
146 static void gtk_assistant_add (GtkContainer *container,
148 static void gtk_assistant_remove (GtkContainer *container,
150 static void gtk_assistant_forall (GtkContainer *container,
151 gboolean include_internals,
152 GtkCallback callback,
153 gpointer callback_data);
154 static void gtk_assistant_set_child_property (GtkContainer *container,
159 static void gtk_assistant_get_child_property (GtkContainer *container,
165 static AtkObject *gtk_assistant_get_accessible (GtkWidget *widget);
166 static GType gtk_assistant_accessible_factory_get_type (void);
168 static void gtk_assistant_buildable_interface_init (GtkBuildableIface *iface);
169 static GObject *gtk_assistant_buildable_get_internal_child (GtkBuildable *buildable,
171 const gchar *childname);
172 static gboolean gtk_assistant_buildable_custom_tag_start (GtkBuildable *buildable,
175 const gchar *tagname,
176 GMarkupParser *parser,
178 static void gtk_assistant_buildable_custom_finished (GtkBuildable *buildable,
181 const gchar *tagname,
184 static GList* find_page (GtkAssistant *assistant,
190 CHILD_PROP_PAGE_TYPE,
191 CHILD_PROP_PAGE_TITLE,
192 CHILD_PROP_PAGE_HEADER_IMAGE,
193 CHILD_PROP_PAGE_SIDEBAR_IMAGE,
194 CHILD_PROP_PAGE_COMPLETE
206 static guint signals [LAST_SIGNAL] = { 0 };
209 G_DEFINE_TYPE_WITH_CODE (GtkAssistant, gtk_assistant, GTK_TYPE_WINDOW,
210 G_IMPLEMENT_INTERFACE (GTK_TYPE_BUILDABLE,
211 gtk_assistant_buildable_interface_init))
215 gtk_assistant_class_init (GtkAssistantClass *class)
217 GObjectClass *gobject_class;
218 GtkWidgetClass *widget_class;
219 GtkContainerClass *container_class;
221 gobject_class = (GObjectClass *) class;
222 widget_class = (GtkWidgetClass *) class;
223 container_class = (GtkContainerClass *) class;
225 widget_class->destroy = gtk_assistant_destroy;
226 widget_class->style_updated = gtk_assistant_style_updated;
227 widget_class->get_preferred_width = gtk_assistant_get_preferred_width;
228 widget_class->get_preferred_height = gtk_assistant_get_preferred_height;
229 widget_class->size_allocate = gtk_assistant_size_allocate;
230 widget_class->map = gtk_assistant_map;
231 widget_class->unmap = gtk_assistant_unmap;
232 widget_class->delete_event = gtk_assistant_delete_event;
233 widget_class->draw = gtk_assistant_draw;
234 widget_class->focus = gtk_assistant_focus;
235 widget_class->get_accessible = gtk_assistant_get_accessible;
237 container_class->add = gtk_assistant_add;
238 container_class->remove = gtk_assistant_remove;
239 container_class->forall = gtk_assistant_forall;
240 container_class->set_child_property = gtk_assistant_set_child_property;
241 container_class->get_child_property = gtk_assistant_get_child_property;
244 * GtkAssistant::cancel:
245 * @assistant: the #GtkAssistant
247 * The ::cancel signal is emitted when then the cancel button is clicked.
252 g_signal_new (I_("cancel"),
253 G_TYPE_FROM_CLASS (gobject_class),
255 G_STRUCT_OFFSET (GtkAssistantClass, cancel),
257 g_cclosure_marshal_VOID__VOID,
261 * GtkAssistant::prepare:
262 * @assistant: the #GtkAssistant
263 * @page: the current page
265 * The ::prepare signal is emitted when a new page is set as the assistant's
266 * current page, before making the new page visible. A handler for this signal
267 * can do any preparation which are necessary before showing @page.
272 g_signal_new (I_("prepare"),
273 G_TYPE_FROM_CLASS (gobject_class),
275 G_STRUCT_OFFSET (GtkAssistantClass, prepare),
277 g_cclosure_marshal_VOID__OBJECT,
278 G_TYPE_NONE, 1, GTK_TYPE_WIDGET);
281 * GtkAssistant::apply:
282 * @assistant: the #GtkAssistant
284 * The ::apply signal is emitted when the apply button is clicked. The default
285 * behavior of the #GtkAssistant is to switch to the page after the current
286 * page, unless the current page is the last one.
288 * A handler for the ::apply signal should carry out the actions for which
289 * the wizard has collected data. If the action takes a long time to complete,
290 * you might consider putting a page of type %GTK_ASSISTANT_PAGE_PROGRESS
291 * after the confirmation page and handle this operation within the
292 * #GtkAssistant::prepare signal of the progress page.
297 g_signal_new (I_("apply"),
298 G_TYPE_FROM_CLASS (gobject_class),
300 G_STRUCT_OFFSET (GtkAssistantClass, apply),
302 g_cclosure_marshal_VOID__VOID,
306 * GtkAssistant::close:
307 * @assistant: the #GtkAssistant
309 * The ::close signal is emitted either when the close button of
310 * a summary page is clicked, or when the apply button in the last
311 * page in the flow (of type %GTK_ASSISTANT_PAGE_CONFIRM) is clicked.
316 g_signal_new (I_("close"),
317 G_TYPE_FROM_CLASS (gobject_class),
319 G_STRUCT_OFFSET (GtkAssistantClass, close),
321 g_cclosure_marshal_VOID__VOID,
324 gtk_widget_class_install_style_property (widget_class,
325 g_param_spec_int ("header-padding",
326 P_("Header Padding"),
327 P_("Number of pixels around the header."),
331 GTK_PARAM_READABLE));
332 gtk_widget_class_install_style_property (widget_class,
333 g_param_spec_int ("content-padding",
334 P_("Content Padding"),
335 P_("Number of pixels around the content pages."),
339 GTK_PARAM_READABLE));
342 * GtkAssistant:page-type:
344 * The type of the assistant page.
348 gtk_container_class_install_child_property (container_class,
349 CHILD_PROP_PAGE_TYPE,
350 g_param_spec_enum ("page-type",
352 P_("The type of the assistant page"),
353 GTK_TYPE_ASSISTANT_PAGE_TYPE,
354 GTK_ASSISTANT_PAGE_CONTENT,
355 GTK_PARAM_READWRITE));
358 * GtkAssistant:title:
360 * The title that is displayed in the page header.
362 * If title and header-image are both %NULL, no header is displayed.
366 gtk_container_class_install_child_property (container_class,
367 CHILD_PROP_PAGE_TITLE,
368 g_param_spec_string ("title",
370 P_("The title of the assistant page"),
372 GTK_PARAM_READWRITE));
375 * GtkAssistant:header-image:
377 * The image that is displayed next to the title in the page header.
379 * If title and header-image are both %NULL, no header is displayed.
383 gtk_container_class_install_child_property (container_class,
384 CHILD_PROP_PAGE_HEADER_IMAGE,
385 g_param_spec_object ("header-image",
387 P_("Header image for the assistant page"),
389 GTK_PARAM_READWRITE));
392 * GtkAssistant:header-image:
394 * The image that is displayed next to the page.
396 * Set this to %NULL to make the sidebar disappear.
400 gtk_container_class_install_child_property (container_class,
401 CHILD_PROP_PAGE_SIDEBAR_IMAGE,
402 g_param_spec_object ("sidebar-image",
404 P_("Sidebar image for the assistant page"),
406 GTK_PARAM_READWRITE));
408 * GtkAssistant:complete:
410 * Setting the "complete" child property to %TRUE marks a page as complete
411 * (i.e.: all the required fields are filled out). GTK+ uses this information
412 * to control the sensitivity of the navigation buttons.
416 gtk_container_class_install_child_property (container_class,
417 CHILD_PROP_PAGE_COMPLETE,
418 g_param_spec_boolean ("complete",
420 P_("Whether all required fields on the page have been filled out"),
424 g_type_class_add_private (gobject_class, sizeof (GtkAssistantPrivate));
428 default_forward_function (gint current_page, gpointer data)
430 GtkAssistant *assistant;
431 GtkAssistantPrivate *priv;
432 GtkAssistantPage *page_info;
435 assistant = GTK_ASSISTANT (data);
436 priv = assistant->priv;
438 page_node = g_list_nth (priv->pages, ++current_page);
443 page_info = (GtkAssistantPage *) page_node->data;
445 while (page_node && !gtk_widget_get_visible (page_info->page))
447 page_node = page_node->next;
451 page_info = (GtkAssistantPage *) page_node->data;
458 compute_last_button_state (GtkAssistant *assistant)
460 GtkAssistantPrivate *priv = assistant->priv;
461 GtkAssistantPage *page_info, *current_page_info;
462 gint count, page_num, n_pages;
465 page_num = gtk_assistant_get_current_page (assistant);
466 n_pages = gtk_assistant_get_n_pages (assistant);
467 current_page_info = page_info = g_list_nth_data (priv->pages, page_num);
469 while (page_num >= 0 && page_num < n_pages &&
470 page_info->type == GTK_ASSISTANT_PAGE_CONTENT &&
471 (count == 0 || page_info->complete) &&
474 page_num = (priv->forward_function) (page_num, priv->forward_function_data);
475 page_info = g_list_nth_data (priv->pages, page_num);
480 /* make the last button visible if we can skip multiple
481 * pages and end on a confirmation or summary page
483 if (count > 1 && page_info &&
484 (page_info->type == GTK_ASSISTANT_PAGE_CONFIRM ||
485 page_info->type == GTK_ASSISTANT_PAGE_SUMMARY))
487 gtk_widget_show (priv->last);
488 gtk_widget_set_sensitive (priv->last,
489 current_page_info->complete);
492 gtk_widget_hide (priv->last);
496 compute_progress_state (GtkAssistant *assistant)
498 GtkAssistantPrivate *priv = assistant->priv;
499 gint page_num, n_pages;
501 n_pages = gtk_assistant_get_n_pages (assistant);
502 page_num = gtk_assistant_get_current_page (assistant);
504 page_num = (priv->forward_function) (page_num, priv->forward_function_data);
506 if (page_num >= 0 && page_num < n_pages)
507 gtk_widget_show (priv->forward);
509 gtk_widget_hide (priv->forward);
513 set_assistant_header_image (GtkAssistant *assistant)
515 GtkAssistantPrivate *priv = assistant->priv;
517 gtk_image_set_from_pixbuf (GTK_IMAGE (priv->header_image),
518 priv->current_page->header_image);
522 set_assistant_sidebar_image (GtkAssistant *assistant)
524 GtkAssistantPrivate *priv = assistant->priv;
526 gtk_image_set_from_pixbuf (GTK_IMAGE (priv->sidebar_image),
527 priv->current_page->sidebar_image);
529 if (priv->current_page->sidebar_image)
530 gtk_widget_show (priv->sidebar_image);
532 gtk_widget_hide (priv->sidebar_image);
536 set_assistant_buttons_state (GtkAssistant *assistant)
538 GtkAssistantPrivate *priv = assistant->priv;
540 if (!priv->current_page)
543 switch (priv->current_page->type)
545 case GTK_ASSISTANT_PAGE_INTRO:
546 gtk_widget_set_sensitive (priv->cancel, TRUE);
547 gtk_widget_set_sensitive (priv->forward, priv->current_page->complete);
548 gtk_widget_grab_default (priv->forward);
549 gtk_widget_show (priv->forward);
550 gtk_widget_hide (priv->back);
551 gtk_widget_hide (priv->apply);
552 gtk_widget_hide (priv->close);
553 compute_last_button_state (assistant);
555 case GTK_ASSISTANT_PAGE_CONFIRM:
556 gtk_widget_set_sensitive (priv->cancel, TRUE);
557 gtk_widget_set_sensitive (priv->back, TRUE);
558 gtk_widget_set_sensitive (priv->apply, priv->current_page->complete);
559 gtk_widget_grab_default (priv->apply);
560 gtk_widget_show (priv->back);
561 gtk_widget_show (priv->apply);
562 gtk_widget_hide (priv->forward);
563 gtk_widget_hide (priv->close);
564 gtk_widget_hide (priv->last);
566 case GTK_ASSISTANT_PAGE_CONTENT:
567 gtk_widget_set_sensitive (priv->cancel, TRUE);
568 gtk_widget_set_sensitive (priv->back, TRUE);
569 gtk_widget_set_sensitive (priv->forward, priv->current_page->complete);
570 gtk_widget_grab_default (priv->forward);
571 gtk_widget_show (priv->back);
572 gtk_widget_show (priv->forward);
573 gtk_widget_hide (priv->apply);
574 gtk_widget_hide (priv->close);
575 compute_last_button_state (assistant);
577 case GTK_ASSISTANT_PAGE_SUMMARY:
578 gtk_widget_set_sensitive (priv->close, priv->current_page->complete);
579 gtk_widget_grab_default (priv->close);
580 gtk_widget_show (priv->close);
581 gtk_widget_hide (priv->back);
582 gtk_widget_hide (priv->forward);
583 gtk_widget_hide (priv->apply);
584 gtk_widget_hide (priv->last);
586 case GTK_ASSISTANT_PAGE_PROGRESS:
587 gtk_widget_set_sensitive (priv->cancel, priv->current_page->complete);
588 gtk_widget_set_sensitive (priv->back, priv->current_page->complete);
589 gtk_widget_set_sensitive (priv->forward, priv->current_page->complete);
590 gtk_widget_grab_default (priv->forward);
591 gtk_widget_show (priv->back);
592 gtk_widget_hide (priv->apply);
593 gtk_widget_hide (priv->close);
594 gtk_widget_hide (priv->last);
595 compute_progress_state (assistant);
597 case GTK_ASSISTANT_PAGE_CUSTOM:
598 gtk_widget_hide (priv->cancel);
599 gtk_widget_hide (priv->back);
600 gtk_widget_hide (priv->forward);
601 gtk_widget_hide (priv->apply);
602 gtk_widget_hide (priv->last);
603 gtk_widget_hide (priv->close);
606 g_assert_not_reached ();
610 gtk_widget_hide (priv->cancel);
611 else if (priv->current_page->type == GTK_ASSISTANT_PAGE_SUMMARY ||
612 priv->current_page->type == GTK_ASSISTANT_PAGE_CUSTOM)
613 gtk_widget_hide (priv->cancel);
615 gtk_widget_show (priv->cancel);
617 /* this is quite general, we don't want to
618 * go back if it's the first page */
619 if (!priv->visited_pages)
620 gtk_widget_hide (priv->back);
624 set_current_page (GtkAssistant *assistant,
625 GtkAssistantPage *page)
627 GtkAssistantPrivate *priv = assistant->priv;
628 GtkAssistantPage *old_page;
630 if (priv->current_page &&
631 gtk_widget_is_drawable (priv->current_page->page))
632 old_page = priv->current_page;
636 priv->current_page = page;
638 set_assistant_buttons_state (assistant);
639 set_assistant_header_image (assistant);
640 set_assistant_sidebar_image (assistant);
642 g_signal_emit (assistant, signals [PREPARE], 0, priv->current_page->page);
644 if (gtk_widget_get_visible (priv->current_page->page) && gtk_widget_get_mapped (GTK_WIDGET (assistant)))
646 gtk_widget_set_child_visible (priv->current_page->page, TRUE);
647 gtk_widget_map (priv->current_page->page);
648 gtk_widget_map (priv->current_page->title);
651 if (old_page && gtk_widget_get_mapped (old_page->page))
653 gtk_widget_set_child_visible (old_page->page, FALSE);
654 gtk_widget_unmap (old_page->page);
655 gtk_widget_unmap (old_page->title);
658 if (!gtk_widget_child_focus (priv->current_page->page, GTK_DIR_TAB_FORWARD))
660 GtkWidget *button[6];
663 /* find the best button to focus */
664 button[0] = priv->apply;
665 button[1] = priv->close;
666 button[2] = priv->forward;
667 button[3] = priv->back;
668 button[4] = priv->cancel;
669 button[5] = priv->last;
670 for (i = 0; i < 6; i++)
672 if (gtk_widget_get_visible (button[i]) && gtk_widget_get_sensitive (button[i]))
674 gtk_widget_grab_focus (button[i]);
680 gtk_widget_queue_resize (GTK_WIDGET (assistant));
684 compute_next_step (GtkAssistant *assistant)
686 GtkAssistantPrivate *priv = assistant->priv;
687 GtkAssistantPage *page_info;
688 gint current_page, n_pages, next_page;
690 current_page = gtk_assistant_get_current_page (assistant);
691 page_info = priv->current_page;
692 n_pages = gtk_assistant_get_n_pages (assistant);
694 next_page = (priv->forward_function) (current_page,
695 priv->forward_function_data);
697 if (next_page >= 0 && next_page < n_pages)
699 priv->visited_pages = g_slist_prepend (priv->visited_pages, page_info);
700 set_current_page (assistant, g_list_nth_data (priv->pages, next_page));
709 on_assistant_close (GtkWidget *widget,
710 GtkAssistant *assistant)
712 g_signal_emit (assistant, signals [CLOSE], 0, NULL);
716 on_assistant_apply (GtkWidget *widget,
717 GtkAssistant *assistant)
721 g_signal_emit (assistant, signals [APPLY], 0);
723 success = compute_next_step (assistant);
725 /* if the assistant hasn't switched to another page, just emit
726 * the CLOSE signal, it't the last page in the assistant flow
729 g_signal_emit (assistant, signals [CLOSE], 0);
733 on_assistant_forward (GtkWidget *widget,
734 GtkAssistant *assistant)
736 gtk_assistant_next_page (assistant);
740 on_assistant_back (GtkWidget *widget,
741 GtkAssistant *assistant)
743 gtk_assistant_previous_page (assistant);
747 on_assistant_cancel (GtkWidget *widget,
748 GtkAssistant *assistant)
750 g_signal_emit (assistant, signals [CANCEL], 0, NULL);
754 on_assistant_last (GtkWidget *widget,
755 GtkAssistant *assistant)
757 GtkAssistantPrivate *priv = assistant->priv;
759 while (priv->current_page->type == GTK_ASSISTANT_PAGE_CONTENT &&
760 priv->current_page->complete)
761 compute_next_step (assistant);
765 alternative_button_order (GtkAssistant *assistant)
767 GtkSettings *settings;
771 screen = gtk_widget_get_screen (GTK_WIDGET (assistant));
772 settings = gtk_settings_get_for_screen (screen);
774 g_object_get (settings,
775 "gtk-alternative-button-order", &result,
781 gtk_assistant_init (GtkAssistant *assistant)
783 GtkAssistantPrivate *priv;
784 GtkStyleContext *context;
786 assistant->priv = G_TYPE_INSTANCE_GET_PRIVATE (assistant,
788 GtkAssistantPrivate);
789 priv = assistant->priv;
791 gtk_container_set_reallocate_redraws (GTK_CONTAINER (assistant), TRUE);
792 gtk_container_set_border_width (GTK_CONTAINER (assistant), 12);
794 gtk_widget_push_composite_child ();
797 priv->header_image = gtk_image_new ();
798 gtk_misc_set_alignment (GTK_MISC (priv->header_image), 1., 0.5);
799 gtk_widget_set_parent (priv->header_image, GTK_WIDGET (assistant));
800 gtk_widget_show (priv->header_image);
802 context = gtk_widget_get_style_context (priv->header_image);
803 gtk_style_context_add_class (context, GTK_STYLE_CLASS_HIGHLIGHT);
806 priv->sidebar_image = gtk_image_new ();
807 gtk_misc_set_alignment (GTK_MISC (priv->sidebar_image), 0., 0.);
808 gtk_widget_set_parent (priv->sidebar_image, GTK_WIDGET (assistant));
809 gtk_widget_show (priv->sidebar_image);
811 context = gtk_widget_get_style_context (priv->sidebar_image);
812 gtk_style_context_add_class (context, GTK_STYLE_CLASS_HIGHLIGHT);
815 priv->action_area = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 6);
817 priv->close = gtk_button_new_from_stock (GTK_STOCK_CLOSE);
818 priv->apply = gtk_button_new_from_stock (GTK_STOCK_APPLY);
819 priv->forward = gtk_button_new_from_stock (GTK_STOCK_GO_FORWARD);
820 priv->back = gtk_button_new_from_stock (GTK_STOCK_GO_BACK);
821 priv->cancel = gtk_button_new_from_stock (GTK_STOCK_CANCEL);
822 priv->last = gtk_button_new_from_stock (GTK_STOCK_GOTO_LAST);
823 gtk_widget_set_can_default (priv->close, TRUE);
824 gtk_widget_set_can_default (priv->apply, TRUE);
825 gtk_widget_set_can_default (priv->forward, TRUE);
827 priv->size_group = gtk_size_group_new (GTK_SIZE_GROUP_HORIZONTAL);
828 gtk_size_group_add_widget (priv->size_group, priv->close);
829 gtk_size_group_add_widget (priv->size_group, priv->apply);
830 gtk_size_group_add_widget (priv->size_group, priv->forward);
831 gtk_size_group_add_widget (priv->size_group, priv->back);
832 gtk_size_group_add_widget (priv->size_group, priv->cancel);
833 gtk_size_group_add_widget (priv->size_group, priv->last);
835 if (!alternative_button_order (assistant))
837 gtk_box_pack_end (GTK_BOX (priv->action_area), priv->apply, FALSE, FALSE, 0);
838 gtk_box_pack_end (GTK_BOX (priv->action_area), priv->forward, FALSE, FALSE, 0);
839 gtk_box_pack_end (GTK_BOX (priv->action_area), priv->back, FALSE, FALSE, 0);
840 gtk_box_pack_end (GTK_BOX (priv->action_area), priv->last, FALSE, FALSE, 0);
841 gtk_box_pack_end (GTK_BOX (priv->action_area), priv->cancel, FALSE, FALSE, 0);
842 gtk_box_pack_end (GTK_BOX (priv->action_area), priv->close, FALSE, FALSE, 0);
846 gtk_box_pack_end (GTK_BOX (priv->action_area), priv->close, FALSE, FALSE, 0);
847 gtk_box_pack_end (GTK_BOX (priv->action_area), priv->cancel, FALSE, FALSE, 0);
848 gtk_box_pack_end (GTK_BOX (priv->action_area), priv->apply, FALSE, FALSE, 0);
849 gtk_box_pack_end (GTK_BOX (priv->action_area), priv->forward, FALSE, FALSE, 0);
850 gtk_box_pack_end (GTK_BOX (priv->action_area), priv->back, FALSE, FALSE, 0);
851 gtk_box_pack_end (GTK_BOX (priv->action_area), priv->last, FALSE, FALSE, 0);
854 gtk_widget_set_parent (priv->action_area, GTK_WIDGET (assistant));
855 gtk_widget_show (priv->forward);
856 gtk_widget_show (priv->back);
857 gtk_widget_show (priv->cancel);
858 gtk_widget_show (priv->action_area);
860 gtk_widget_pop_composite_child ();
863 priv->current_page = NULL;
864 priv->visited_pages = NULL;
866 priv->forward_function = default_forward_function;
867 priv->forward_function_data = assistant;
868 priv->forward_data_destroy = NULL;
870 g_signal_connect (G_OBJECT (priv->close), "clicked",
871 G_CALLBACK (on_assistant_close), assistant);
872 g_signal_connect (G_OBJECT (priv->apply), "clicked",
873 G_CALLBACK (on_assistant_apply), assistant);
874 g_signal_connect (G_OBJECT (priv->forward), "clicked",
875 G_CALLBACK (on_assistant_forward), assistant);
876 g_signal_connect (G_OBJECT (priv->back), "clicked",
877 G_CALLBACK (on_assistant_back), assistant);
878 g_signal_connect (G_OBJECT (priv->cancel), "clicked",
879 G_CALLBACK (on_assistant_cancel), assistant);
880 g_signal_connect (G_OBJECT (priv->last), "clicked",
881 G_CALLBACK (on_assistant_last), assistant);
885 gtk_assistant_set_child_property (GtkContainer *container,
893 case CHILD_PROP_PAGE_TYPE:
894 gtk_assistant_set_page_type (GTK_ASSISTANT (container), child,
895 g_value_get_enum (value));
897 case CHILD_PROP_PAGE_TITLE:
898 gtk_assistant_set_page_title (GTK_ASSISTANT (container), child,
899 g_value_get_string (value));
901 case CHILD_PROP_PAGE_HEADER_IMAGE:
902 gtk_assistant_set_page_header_image (GTK_ASSISTANT (container), child,
903 g_value_get_object (value));
905 case CHILD_PROP_PAGE_SIDEBAR_IMAGE:
906 gtk_assistant_set_page_side_image (GTK_ASSISTANT (container), child,
907 g_value_get_object (value));
909 case CHILD_PROP_PAGE_COMPLETE:
910 gtk_assistant_set_page_complete (GTK_ASSISTANT (container), child,
911 g_value_get_boolean (value));
914 GTK_CONTAINER_WARN_INVALID_CHILD_PROPERTY_ID (container, property_id, pspec);
920 gtk_assistant_get_child_property (GtkContainer *container,
928 case CHILD_PROP_PAGE_TYPE:
929 g_value_set_enum (value,
930 gtk_assistant_get_page_type (GTK_ASSISTANT (container), child));
932 case CHILD_PROP_PAGE_TITLE:
933 g_value_set_string (value,
934 gtk_assistant_get_page_title (GTK_ASSISTANT (container), child));
936 case CHILD_PROP_PAGE_HEADER_IMAGE:
937 g_value_set_object (value,
938 gtk_assistant_get_page_header_image (GTK_ASSISTANT (container), child));
940 case CHILD_PROP_PAGE_SIDEBAR_IMAGE:
941 g_value_set_object (value,
942 gtk_assistant_get_page_side_image (GTK_ASSISTANT (container), child));
944 case CHILD_PROP_PAGE_COMPLETE:
945 g_value_set_boolean (value,
946 gtk_assistant_get_page_complete (GTK_ASSISTANT (container), child));
949 GTK_CONTAINER_WARN_INVALID_CHILD_PROPERTY_ID (container, property_id, pspec);
955 on_page_notify_visibility (GtkWidget *widget,
959 GtkAssistant *assistant = GTK_ASSISTANT (data);
961 /* update buttons state, flow may have changed */
962 if (gtk_widget_get_mapped (GTK_WIDGET (assistant)))
963 set_assistant_buttons_state (assistant);
967 remove_page (GtkAssistant *assistant,
970 GtkAssistantPrivate *priv = assistant->priv;
971 GtkAssistantPage *page_info;
974 page_info = element->data;
976 /* If this is the current page, we need to switch away. */
977 if (page_info == priv->current_page)
979 if (!compute_next_step (assistant))
981 /* The best we can do at this point is probably to pick the first
984 page_node = priv->pages;
986 while (page_node && !gtk_widget_get_visible (((GtkAssistantPage *) page_node->data)->page))
987 page_node = page_node->next;
989 if (page_node == element)
990 page_node = page_node->next;
993 priv->current_page = page_node->data;
995 priv->current_page = NULL;
999 priv->pages = g_list_remove_link (priv->pages, element);
1000 priv->visited_pages = g_slist_remove_all (priv->visited_pages, page_info);
1002 g_signal_handlers_disconnect_by_func (page_info->page, on_page_notify_visibility, assistant);
1003 gtk_widget_unparent (page_info->page);
1005 if (page_info->header_image)
1006 g_object_unref (page_info->header_image);
1008 if (page_info->sidebar_image)
1009 g_object_unref (page_info->sidebar_image);
1011 gtk_widget_destroy (page_info->title);
1012 g_slice_free (GtkAssistantPage, page_info);
1013 g_list_free_1 (element);
1017 gtk_assistant_destroy (GtkWidget *widget)
1019 GtkAssistant *assistant = GTK_ASSISTANT (widget);
1020 GtkAssistantPrivate *priv = assistant->priv;
1022 if (priv->header_image)
1024 gtk_widget_destroy (priv->header_image);
1025 priv->header_image = NULL;
1028 if (priv->sidebar_image)
1030 gtk_widget_destroy (priv->sidebar_image);
1031 priv->sidebar_image = NULL;
1034 if (priv->action_area)
1036 gtk_widget_destroy (priv->action_area);
1037 priv->action_area = NULL;
1040 if (priv->size_group)
1042 g_object_unref (priv->size_group);
1043 priv->size_group = NULL;
1046 if (priv->forward_function)
1048 if (priv->forward_function_data &&
1049 priv->forward_data_destroy)
1050 priv->forward_data_destroy (priv->forward_function_data);
1052 priv->forward_function = NULL;
1053 priv->forward_function_data = NULL;
1054 priv->forward_data_destroy = NULL;
1057 if (priv->visited_pages)
1059 g_slist_free (priv->visited_pages);
1060 priv->visited_pages = NULL;
1063 /* We set current to NULL so that the remove code doesn't try
1064 * to do anything funny */
1065 priv->current_page = NULL;
1068 remove_page (assistant, priv->pages);
1070 GTK_WIDGET_CLASS (gtk_assistant_parent_class)->destroy (widget);
1074 find_page (GtkAssistant *assistant,
1077 GtkAssistantPrivate *priv = assistant->priv;
1078 GList *child = priv->pages;
1082 GtkAssistantPage *page_info = child->data;
1083 if (page_info->page == page)
1086 child = child->next;
1093 set_title_font (GtkWidget *assistant,
1094 GtkWidget *title_label)
1096 PangoFontDescription *desc;
1097 GtkStyleContext *context;
1100 desc = pango_font_description_new ();
1101 context = gtk_widget_get_style_context (title_label);
1102 size = pango_font_description_get_size (gtk_style_context_get_font (context, 0));
1104 pango_font_description_set_weight (desc, PANGO_WEIGHT_ULTRABOLD);
1105 pango_font_description_set_size (desc, size * PANGO_SCALE_XX_LARGE);
1107 gtk_widget_modify_font (title_label, desc);
1108 pango_font_description_free (desc);
1112 gtk_assistant_style_updated (GtkWidget *widget)
1114 GtkAssistant *assistant = GTK_ASSISTANT (widget);
1115 GtkAssistantPrivate *priv = assistant->priv;
1122 GtkAssistantPage *page = list->data;
1124 set_title_font (widget, page->title);
1130 gtk_assistant_size_request (GtkWidget *widget,
1131 GtkRequisition *requisition)
1133 GtkAssistant *assistant = GTK_ASSISTANT (widget);
1134 GtkAssistantPrivate *priv = assistant->priv;
1135 GtkRequisition child_requisition;
1136 gint header_padding, content_padding;
1137 gint width, height, header_width, header_height;
1141 gtk_widget_style_get (widget,
1142 "header-padding", &header_padding,
1143 "content-padding", &content_padding,
1146 header_width = header_height = 0;
1151 GtkAssistantPage *page = list->data;
1154 gtk_widget_get_preferred_size (page->page,
1155 &child_requisition, NULL);
1156 width = MAX (width, child_requisition.width);
1157 height = MAX (height, child_requisition.height);
1159 gtk_widget_get_preferred_size (page->title,
1160 &child_requisition, NULL);
1161 w = child_requisition.width;
1162 h = child_requisition.height;
1164 if (page->header_image)
1166 w += gdk_pixbuf_get_width (page->header_image) + HEADER_SPACING;
1167 h = MAX (h, gdk_pixbuf_get_height (page->header_image));
1170 header_width = MAX (header_width, w);
1171 header_height = MAX (header_height, h);
1176 gtk_widget_get_preferred_size (priv->sidebar_image,
1177 &child_requisition, NULL);
1178 width += child_requisition.width;
1179 height = MAX (height, child_requisition.height);
1181 gtk_widget_set_size_request (priv->header_image, header_width, header_height);
1182 gtk_widget_get_preferred_size (priv->header_image,
1183 &child_requisition, NULL);
1184 width = MAX (width, header_width) + 2 * header_padding;
1185 height += header_height + 2 * header_padding;
1187 gtk_widget_get_preferred_size (priv->action_area,
1188 &child_requisition, NULL);
1189 width = MAX (width, child_requisition.width);
1190 height += child_requisition.height + ACTION_AREA_SPACING;
1192 border_width = gtk_container_get_border_width (GTK_CONTAINER (widget));
1193 width += border_width * 2 + content_padding * 2;
1194 height += border_width * 2 + content_padding * 2;
1196 requisition->width = width;
1197 requisition->height = height;
1201 gtk_assistant_get_preferred_width (GtkWidget *widget,
1205 GtkRequisition requisition;
1207 gtk_assistant_size_request (widget, &requisition);
1209 *minimum = *natural = requisition.width;
1213 gtk_assistant_get_preferred_height (GtkWidget *widget,
1217 GtkRequisition requisition;
1219 gtk_assistant_size_request (widget, &requisition);
1221 *minimum = *natural = requisition.height;
1225 gtk_assistant_size_allocate (GtkWidget *widget,
1226 GtkAllocation *allocation)
1228 GtkAssistant *assistant = GTK_ASSISTANT (widget);
1229 GtkAssistantPrivate *priv = assistant->priv;
1230 GtkRequisition header_requisition, action_requisition, sidebar_requisition;
1231 GtkAllocation child_allocation, header_allocation;
1232 GtkAllocation action_area_allocation, header_image_allocation;
1233 gint header_padding, content_padding;
1238 rtl = (gtk_widget_get_direction (widget) == GTK_TEXT_DIR_RTL);
1239 pages = priv->pages;
1241 gtk_widget_style_get (widget,
1242 "header-padding", &header_padding,
1243 "content-padding", &content_padding,
1246 gtk_widget_set_allocation (widget, allocation);
1247 border_width = gtk_container_get_border_width (GTK_CONTAINER (widget));
1250 gtk_widget_get_preferred_size (priv->header_image,
1251 &header_requisition, NULL);
1253 header_allocation.x = border_width + header_padding;
1254 header_allocation.y = border_width + header_padding;
1255 header_allocation.width = allocation->width - 2 * border_width - 2 * header_padding;
1256 header_allocation.height = header_requisition.height;
1258 gtk_widget_size_allocate (priv->header_image, &header_allocation);
1261 gtk_widget_get_preferred_size (priv->action_area,
1262 &action_requisition, NULL);
1264 child_allocation.x = border_width;
1265 child_allocation.y = allocation->height - border_width - action_requisition.height;
1266 child_allocation.width = allocation->width - 2 * border_width;
1267 child_allocation.height = action_requisition.height;
1269 gtk_widget_size_allocate (priv->action_area, &child_allocation);
1271 gtk_widget_get_allocation (priv->header_image, &header_image_allocation);
1272 gtk_widget_get_allocation (priv->action_area, &action_area_allocation);
1275 gtk_widget_get_preferred_size (priv->sidebar_image,
1276 &sidebar_requisition, NULL);
1279 child_allocation.x = allocation->width - border_width - sidebar_requisition.width;
1281 child_allocation.x = border_width;
1283 child_allocation.y = border_width + header_image_allocation.height + 2 * header_padding;
1284 child_allocation.width = sidebar_requisition.width;
1285 child_allocation.height = allocation->height - 2 * border_width -
1286 header_image_allocation.height - 2 * header_padding - action_area_allocation.height;
1288 gtk_widget_size_allocate (priv->sidebar_image, &child_allocation);
1291 child_allocation.x = border_width + content_padding;
1292 child_allocation.y = border_width +
1293 header_image_allocation.height + 2 * header_padding + content_padding;
1294 child_allocation.width = allocation->width - 2 * border_width - 2 * content_padding;
1295 child_allocation.height = allocation->height - 2 * border_width -
1296 header_image_allocation.height - 2 * header_padding - ACTION_AREA_SPACING - action_area_allocation.height - 2 * content_padding;
1298 if (gtk_widget_get_visible (priv->sidebar_image))
1300 GtkAllocation sidebar_image_allocation;
1302 gtk_widget_get_allocation (priv->sidebar_image, &sidebar_image_allocation);
1305 child_allocation.x += sidebar_image_allocation.width;
1307 child_allocation.width -= sidebar_image_allocation.width;
1312 GtkAssistantPage *page = pages->data;
1314 gtk_widget_size_allocate (page->page, &child_allocation);
1315 gtk_widget_size_allocate (page->title, &header_allocation);
1316 pages = pages->next;
1321 gtk_assistant_map (GtkWidget *widget)
1323 GtkAssistant *assistant = GTK_ASSISTANT (widget);
1324 GtkAssistantPrivate *priv = assistant->priv;
1326 GtkAssistantPage *page;
1328 gtk_widget_set_mapped (widget, TRUE);
1330 gtk_widget_map (priv->header_image);
1331 gtk_widget_map (priv->action_area);
1333 if (gtk_widget_get_visible (priv->sidebar_image) &&
1334 !gtk_widget_get_mapped (priv->sidebar_image))
1335 gtk_widget_map (priv->sidebar_image);
1337 /* if there's no default page, pick the first one */
1339 if (!priv->current_page)
1341 page_node = priv->pages;
1343 while (page_node && !gtk_widget_get_visible (((GtkAssistantPage *) page_node->data)->page))
1344 page_node = page_node->next;
1347 page = page_node->data;
1351 gtk_widget_get_visible (page->page) &&
1352 !gtk_widget_get_mapped (page->page))
1353 set_current_page (assistant, page);
1355 GTK_WIDGET_CLASS (gtk_assistant_parent_class)->map (widget);
1359 gtk_assistant_unmap (GtkWidget *widget)
1361 GtkAssistant *assistant = GTK_ASSISTANT (widget);
1362 GtkAssistantPrivate *priv = assistant->priv;
1364 gtk_widget_set_mapped (widget, FALSE);
1366 gtk_widget_unmap (priv->header_image);
1367 gtk_widget_unmap (priv->action_area);
1369 if (gtk_widget_is_drawable (priv->sidebar_image))
1370 gtk_widget_unmap (priv->sidebar_image);
1372 if (priv->current_page &&
1373 gtk_widget_is_drawable (priv->current_page->page))
1374 gtk_widget_unmap (priv->current_page->page);
1376 g_slist_free (priv->visited_pages);
1377 priv->visited_pages = NULL;
1378 priv->current_page = NULL;
1380 GTK_WIDGET_CLASS (gtk_assistant_parent_class)->unmap (widget);
1384 gtk_assistant_delete_event (GtkWidget *widget,
1387 GtkAssistant *assistant = GTK_ASSISTANT (widget);
1388 GtkAssistantPrivate *priv = assistant->priv;
1390 /* Do not allow cancelling in the middle of a progress page */
1391 if (priv->current_page &&
1392 (priv->current_page->type != GTK_ASSISTANT_PAGE_PROGRESS ||
1393 priv->current_page->complete))
1394 g_signal_emit (widget, signals [CANCEL], 0, NULL);
1400 assistant_paint_colored_box (GtkWidget *widget,
1403 GtkAssistant *assistant = GTK_ASSISTANT (widget);
1404 GtkAssistantPrivate *priv = assistant->priv;
1405 GtkAllocation allocation, action_area_allocation, header_image_allocation;
1406 GtkStyleContext *context;
1407 GtkStateFlags state;
1409 gint border_width, header_padding, content_padding;
1410 gint content_x, content_width;
1413 rtl = (gtk_widget_get_direction (widget) == GTK_TEXT_DIR_RTL);
1414 border_width = gtk_container_get_border_width (GTK_CONTAINER (widget));
1416 gtk_widget_style_get (widget,
1417 "header-padding", &header_padding,
1418 "content-padding", &content_padding,
1421 context = gtk_widget_get_style_context (widget);
1422 state = gtk_widget_get_state_flags (widget);
1424 gtk_widget_get_allocation (widget, &allocation);
1425 gtk_widget_get_allocation (priv->action_area, &action_area_allocation);
1426 gtk_widget_get_allocation (priv->header_image, &header_image_allocation);
1429 gtk_style_context_save (context);
1430 gtk_style_context_add_class (context, GTK_STYLE_CLASS_HIGHLIGHT);
1432 gtk_style_context_get_background_color (context, state, &color);
1433 gdk_cairo_set_source_rgba (cr, &color);
1435 cairo_rectangle (cr,
1438 allocation.width - 2 * border_width,
1439 allocation.height - action_area_allocation.height - 2 * border_width - ACTION_AREA_SPACING);
1443 content_x = content_padding + border_width;
1444 content_width = allocation.width - 2 * content_padding - 2 * border_width;
1446 if (gtk_widget_get_visible (priv->sidebar_image))
1448 GtkAllocation sidebar_image_allocation;
1450 gtk_widget_get_allocation (priv->sidebar_image, &sidebar_image_allocation);
1453 content_x += sidebar_image_allocation.width;
1454 content_width -= sidebar_image_allocation.width;
1457 gtk_style_context_restore (context);
1459 gtk_style_context_get_background_color (context, state, &color);
1460 gdk_cairo_set_source_rgba (cr, &color);
1462 cairo_rectangle (cr,
1464 header_image_allocation.height + content_padding + 2 * header_padding + border_width,
1466 allocation.height - 2 * border_width - action_area_allocation.height -
1467 header_image_allocation.height - 2 * content_padding - 2 * header_padding - ACTION_AREA_SPACING);
1472 gtk_assistant_draw (GtkWidget *widget,
1475 GtkAssistant *assistant = GTK_ASSISTANT (widget);
1476 GtkAssistantPrivate *priv = assistant->priv;
1477 GtkContainer *container = GTK_CONTAINER (widget);
1479 if (GTK_WIDGET_CLASS (gtk_assistant_parent_class)->draw)
1480 GTK_WIDGET_CLASS (gtk_assistant_parent_class)->draw (widget, cr);
1482 assistant_paint_colored_box (widget, cr);
1484 gtk_container_propagate_draw (container, priv->header_image, cr);
1485 gtk_container_propagate_draw (container, priv->sidebar_image, cr);
1486 gtk_container_propagate_draw (container, priv->action_area, cr);
1488 if (priv->current_page)
1490 gtk_container_propagate_draw (container, priv->current_page->page, cr);
1491 gtk_container_propagate_draw (container, priv->current_page->title, cr);
1498 gtk_assistant_focus (GtkWidget *widget,
1499 GtkDirectionType direction)
1501 GtkAssistantPrivate *priv;
1502 GtkContainer *container;
1504 container = GTK_CONTAINER (widget);
1505 priv = GTK_ASSISTANT (widget)->priv;
1507 /* we only have to care about 2 widgets, action area and the current page */
1508 if (gtk_container_get_focus_child (container) == priv->action_area)
1510 if (!gtk_widget_child_focus (priv->action_area, direction) &&
1511 (priv->current_page == NULL ||
1512 !gtk_widget_child_focus (priv->current_page->page, direction)))
1514 /* if we're leaving the action area and the current page hasn't
1515 any focusable widget, clear focus and go back to the action area */
1516 gtk_container_set_focus_child (GTK_CONTAINER (priv->action_area), NULL);
1517 gtk_widget_child_focus (priv->action_area, direction);
1522 if ((priv->current_page == NULL ||
1523 !gtk_widget_child_focus (priv->current_page->page, direction)) &&
1524 !gtk_widget_child_focus (priv->action_area, direction))
1526 /* if we're leaving the current page and there isn't nothing focusable
1527 in the action area, try to clear focus and go back to the page */
1528 gtk_window_set_focus (GTK_WINDOW (widget), NULL);
1529 if (priv->current_page != NULL)
1530 gtk_widget_child_focus (priv->current_page->page, direction);
1538 gtk_assistant_add (GtkContainer *container,
1541 gtk_assistant_append_page (GTK_ASSISTANT (container), page);
1545 gtk_assistant_remove (GtkContainer *container,
1548 GtkAssistant *assistant = (GtkAssistant*) container;
1551 element = find_page (assistant, page);
1555 remove_page (assistant, element);
1556 gtk_widget_queue_resize ((GtkWidget *) container);
1561 gtk_assistant_forall (GtkContainer *container,
1562 gboolean include_internals,
1563 GtkCallback callback,
1564 gpointer callback_data)
1566 GtkAssistant *assistant = (GtkAssistant*) container;
1567 GtkAssistantPrivate *priv = assistant->priv;
1570 if (include_internals)
1572 (*callback) (priv->header_image, callback_data);
1573 (*callback) (priv->sidebar_image, callback_data);
1574 (*callback) (priv->action_area, callback_data);
1577 pages = priv->pages;
1581 GtkAssistantPage *page = (GtkAssistantPage *) pages->data;
1583 (*callback) (page->page, callback_data);
1585 if (include_internals)
1586 (*callback) (page->title, callback_data);
1588 pages = pages->next;
1593 * gtk_assistant_new:
1595 * Creates a new #GtkAssistant.
1597 * Return value: a newly created #GtkAssistant
1602 gtk_assistant_new (void)
1604 GtkWidget *assistant;
1606 assistant = g_object_new (GTK_TYPE_ASSISTANT, NULL);
1612 * gtk_assistant_get_current_page:
1613 * @assistant: a #GtkAssistant
1615 * Returns the page number of the current page
1617 * Return value: The index (starting from 0) of the current page in
1618 * the @assistant, if the @assistant has no pages, -1 will be returned
1623 gtk_assistant_get_current_page (GtkAssistant *assistant)
1625 GtkAssistantPrivate *priv;
1627 g_return_val_if_fail (GTK_IS_ASSISTANT (assistant), -1);
1629 priv = assistant->priv;
1631 if (!priv->pages || !priv->current_page)
1634 return g_list_index (priv->pages, priv->current_page);
1638 * gtk_assistant_set_current_page:
1639 * @assistant: a #GtkAssistant
1640 * @page_num: index of the page to switch to, starting from 0.
1641 * If negative, the last page will be used. If greater
1642 * than the number of pages in the @assistant, nothing
1645 * Switches the page to @page_num. Note that this will only be necessary
1646 * in custom buttons, as the @assistant flow can be set with
1647 * gtk_assistant_set_forward_page_func().
1652 gtk_assistant_set_current_page (GtkAssistant *assistant,
1655 GtkAssistantPrivate *priv;
1656 GtkAssistantPage *page;
1658 g_return_if_fail (GTK_IS_ASSISTANT (assistant));
1660 priv = assistant->priv;
1663 page = (GtkAssistantPage *) g_list_nth_data (priv->pages, page_num);
1665 page = (GtkAssistantPage *) g_list_last (priv->pages)->data;
1667 g_return_if_fail (page != NULL);
1669 if (priv->current_page == page)
1672 /* only add the page to the visited list if the
1673 * assistant is mapped, if not, just use it as an
1674 * initial page setting, for the cases where the
1675 * initial page is != to 0
1677 if (gtk_widget_get_mapped (GTK_WIDGET (assistant)))
1678 priv->visited_pages = g_slist_prepend (priv->visited_pages,
1679 priv->current_page);
1681 set_current_page (assistant, page);
1685 * gtk_assistant_next_page:
1686 * @assistant: a #GtkAssistant
1688 * Navigate to the next page. It is a programming
1689 * error to call this function if there is no next page.
1691 * This function is for use when creating pages of the
1692 * #GTK_ASSISTANT_PAGE_CUSTOM type.
1697 gtk_assistant_next_page (GtkAssistant *assistant)
1699 GtkAssistantPrivate *priv;
1701 g_return_if_fail (GTK_IS_ASSISTANT (assistant));
1703 priv = assistant->priv;
1705 if (!compute_next_step (assistant))
1706 g_critical ("Page flow is broken, you may want to end it with a page of "
1707 "type GTK_ASSISTANT_PAGE_CONFIRM or GTK_ASSISTANT_PAGE_SUMMARY");
1711 * gtk_assistant_previous_page:
1712 * @assistant: a #GtkAssistant
1714 * Navigate to the previous visited page. It is a programming
1715 * error to call this function if no previous page is
1718 * This function is for use when creating pages of the
1719 * #GTK_ASSISTANT_PAGE_CUSTOM type.
1724 gtk_assistant_previous_page (GtkAssistant *assistant)
1726 GtkAssistantPrivate *priv;
1727 GtkAssistantPage *page_info;
1730 g_return_if_fail (GTK_IS_ASSISTANT (assistant));
1732 priv = assistant->priv;
1734 /* skip the progress pages when going back */
1737 page_node = priv->visited_pages;
1739 g_return_if_fail (page_node != NULL);
1741 priv->visited_pages = priv->visited_pages->next;
1742 page_info = (GtkAssistantPage *) page_node->data;
1743 g_slist_free_1 (page_node);
1745 while (page_info->type == GTK_ASSISTANT_PAGE_PROGRESS ||
1746 !gtk_widget_get_visible (page_info->page));
1748 set_current_page (assistant, page_info);
1752 * gtk_assistant_get_n_pages:
1753 * @assistant: a #GtkAssistant
1755 * Returns the number of pages in the @assistant
1757 * Return value: The number of pages in the @assistant.
1762 gtk_assistant_get_n_pages (GtkAssistant *assistant)
1764 GtkAssistantPrivate *priv;
1766 g_return_val_if_fail (GTK_IS_ASSISTANT (assistant), 0);
1768 priv = assistant->priv;
1770 return g_list_length (priv->pages);
1774 * gtk_assistant_get_nth_page:
1775 * @assistant: a #GtkAssistant
1776 * @page_num: The index of a page in the @assistant, or -1 to get the last page;
1778 * Returns the child widget contained in page number @page_num.
1780 * Return value: (transfer none): The child widget, or %NULL
1781 * if @page_num is out of bounds.
1786 gtk_assistant_get_nth_page (GtkAssistant *assistant,
1789 GtkAssistantPrivate *priv;
1790 GtkAssistantPage *page;
1793 g_return_val_if_fail (GTK_IS_ASSISTANT (assistant), NULL);
1794 g_return_val_if_fail (page_num >= -1, NULL);
1796 priv = assistant->priv;
1799 elem = g_list_last (priv->pages);
1801 elem = g_list_nth (priv->pages, page_num);
1806 page = (GtkAssistantPage *) elem->data;
1812 * gtk_assistant_prepend_page:
1813 * @assistant: a #GtkAssistant
1814 * @page: a #GtkWidget
1816 * Prepends a page to the @assistant.
1818 * Return value: the index (starting at 0) of the inserted page
1823 gtk_assistant_prepend_page (GtkAssistant *assistant,
1826 g_return_val_if_fail (GTK_IS_ASSISTANT (assistant), 0);
1827 g_return_val_if_fail (GTK_IS_WIDGET (page), 0);
1829 return gtk_assistant_insert_page (assistant, page, 0);
1833 * gtk_assistant_append_page:
1834 * @assistant: a #GtkAssistant
1835 * @page: a #GtkWidget
1837 * Appends a page to the @assistant.
1839 * Return value: the index (starting at 0) of the inserted page
1844 gtk_assistant_append_page (GtkAssistant *assistant,
1847 g_return_val_if_fail (GTK_IS_ASSISTANT (assistant), 0);
1848 g_return_val_if_fail (GTK_IS_WIDGET (page), 0);
1850 return gtk_assistant_insert_page (assistant, page, -1);
1854 * gtk_assistant_insert_page:
1855 * @assistant: a #GtkAssistant
1856 * @page: a #GtkWidget
1857 * @position: the index (starting at 0) at which to insert the page,
1858 * or -1 to append the page to the @assistant
1860 * Inserts a page in the @assistant at a given position.
1862 * Return value: the index (starting from 0) of the inserted page
1867 gtk_assistant_insert_page (GtkAssistant *assistant,
1871 GtkAssistantPrivate *priv;
1872 GtkAssistantPage *page_info;
1873 GtkStyleContext *context;
1876 g_return_val_if_fail (GTK_IS_ASSISTANT (assistant), 0);
1877 g_return_val_if_fail (GTK_IS_WIDGET (page), 0);
1878 g_return_val_if_fail (gtk_widget_get_parent (page) == NULL, 0);
1879 g_return_val_if_fail (!gtk_widget_is_toplevel (page), 0);
1881 priv = assistant->priv;
1883 page_info = g_slice_new0 (GtkAssistantPage);
1884 page_info->page = page;
1885 page_info->title = gtk_label_new (NULL);
1887 g_signal_connect (G_OBJECT (page), "notify::visible",
1888 G_CALLBACK (on_page_notify_visibility), assistant);
1890 gtk_misc_set_alignment (GTK_MISC (page_info->title), 0.,0.5);
1891 set_title_font (GTK_WIDGET (assistant), page_info->title);
1892 gtk_widget_show (page_info->title);
1894 context = gtk_widget_get_style_context (page_info->title);
1895 gtk_style_context_add_class (context, GTK_STYLE_CLASS_HIGHLIGHT);
1897 n_pages = g_list_length (priv->pages);
1899 if (position < 0 || position > n_pages)
1902 priv->pages = g_list_insert (priv->pages, page_info, position);
1904 gtk_widget_set_child_visible (page_info->page, FALSE);
1905 gtk_widget_set_parent (page_info->page, GTK_WIDGET (assistant));
1906 gtk_widget_set_parent (page_info->title, GTK_WIDGET (assistant));
1908 if (gtk_widget_get_realized (GTK_WIDGET (assistant)))
1910 gtk_widget_realize (page_info->page);
1911 gtk_widget_realize (page_info->title);
1914 gtk_widget_queue_resize (GTK_WIDGET (assistant));
1920 * gtk_assistant_set_forward_page_func:
1921 * @assistant: a #GtkAssistant
1922 * @page_func: (allow-none): the #GtkAssistantPageFunc, or %NULL to use the default one
1923 * @data: user data for @page_func
1924 * @destroy: destroy notifier for @data
1926 * Sets the page forwarding function to be @page_func, this function will
1927 * be used to determine what will be the next page when the user presses
1928 * the forward button. Setting @page_func to %NULL will make the assistant
1929 * to use the default forward function, which just goes to the next visible
1935 gtk_assistant_set_forward_page_func (GtkAssistant *assistant,
1936 GtkAssistantPageFunc page_func,
1938 GDestroyNotify destroy)
1940 GtkAssistantPrivate *priv;
1942 g_return_if_fail (GTK_IS_ASSISTANT (assistant));
1944 priv = assistant->priv;
1946 if (priv->forward_data_destroy &&
1947 priv->forward_function_data)
1948 (*priv->forward_data_destroy) (priv->forward_function_data);
1952 priv->forward_function = page_func;
1953 priv->forward_function_data = data;
1954 priv->forward_data_destroy = destroy;
1958 priv->forward_function = default_forward_function;
1959 priv->forward_function_data = assistant;
1960 priv->forward_data_destroy = NULL;
1963 /* Page flow has possibly changed, so the
1964 buttons state might need to change too */
1965 set_assistant_buttons_state (assistant);
1969 * gtk_assistant_add_action_widget:
1970 * @assistant: a #GtkAssistant
1971 * @child: a #GtkWidget
1973 * Adds a widget to the action area of a #GtkAssistant.
1978 gtk_assistant_add_action_widget (GtkAssistant *assistant,
1981 GtkAssistantPrivate *priv;
1983 g_return_if_fail (GTK_IS_ASSISTANT (assistant));
1984 g_return_if_fail (GTK_IS_WIDGET (child));
1986 priv = assistant->priv;
1988 if (GTK_IS_BUTTON (child))
1989 gtk_size_group_add_widget (priv->size_group, child);
1991 gtk_box_pack_end (GTK_BOX (priv->action_area), child, FALSE, FALSE, 0);
1995 * gtk_assistant_remove_action_widget:
1996 * @assistant: a #GtkAssistant
1997 * @child: a #GtkWidget
1999 * Removes a widget from the action area of a #GtkAssistant.
2004 gtk_assistant_remove_action_widget (GtkAssistant *assistant,
2007 GtkAssistantPrivate *priv;
2009 g_return_if_fail (GTK_IS_ASSISTANT (assistant));
2010 g_return_if_fail (GTK_IS_WIDGET (child));
2012 priv = assistant->priv;
2014 if (GTK_IS_BUTTON (child))
2015 gtk_size_group_remove_widget (priv->size_group, child);
2017 gtk_container_remove (GTK_CONTAINER (priv->action_area), child);
2021 * gtk_assistant_set_page_title:
2022 * @assistant: a #GtkAssistant
2023 * @page: a page of @assistant
2024 * @title: the new title for @page
2026 * Sets a title for @page. The title is displayed in the header
2027 * area of the assistant when @page is the current page.
2032 gtk_assistant_set_page_title (GtkAssistant *assistant,
2036 GtkAssistantPage *page_info;
2039 g_return_if_fail (GTK_IS_ASSISTANT (assistant));
2040 g_return_if_fail (GTK_IS_WIDGET (page));
2042 child = find_page (assistant, page);
2044 g_return_if_fail (child != NULL);
2046 page_info = (GtkAssistantPage*) child->data;
2048 gtk_label_set_text ((GtkLabel*) page_info->title, title);
2049 gtk_widget_queue_resize (GTK_WIDGET (assistant));
2050 gtk_widget_child_notify (page, "title");
2054 * gtk_assistant_get_page_title:
2055 * @assistant: a #GtkAssistant
2056 * @page: a page of @assistant
2058 * Gets the title for @page.
2060 * Return value: the title for @page.
2064 G_CONST_RETURN gchar*
2065 gtk_assistant_get_page_title (GtkAssistant *assistant,
2068 GtkAssistantPage *page_info;
2071 g_return_val_if_fail (GTK_IS_ASSISTANT (assistant), NULL);
2072 g_return_val_if_fail (GTK_IS_WIDGET (page), NULL);
2074 child = find_page (assistant, page);
2076 g_return_val_if_fail (child != NULL, NULL);
2078 page_info = (GtkAssistantPage*) child->data;
2080 return gtk_label_get_text ((GtkLabel*) page_info->title);
2084 * gtk_assistant_set_page_type:
2085 * @assistant: a #GtkAssistant
2086 * @page: a page of @assistant
2087 * @type: the new type for @page
2089 * Sets the page type for @page. The page type determines the page
2090 * behavior in the @assistant.
2095 gtk_assistant_set_page_type (GtkAssistant *assistant,
2097 GtkAssistantPageType type)
2099 GtkAssistantPrivate *priv;
2100 GtkAssistantPage *page_info;
2103 g_return_if_fail (GTK_IS_ASSISTANT (assistant));
2104 g_return_if_fail (GTK_IS_WIDGET (page));
2106 priv = assistant->priv;
2107 child = find_page (assistant, page);
2109 g_return_if_fail (child != NULL);
2111 page_info = (GtkAssistantPage*) child->data;
2113 if (type != page_info->type)
2115 page_info->type = type;
2117 /* backwards compatibility to the era before fixing bug 604289 */
2118 if (type == GTK_ASSISTANT_PAGE_SUMMARY && !page_info->complete_set)
2120 gtk_assistant_set_page_complete (assistant, page, TRUE);
2121 page_info->complete_set = FALSE;
2124 /* Always set buttons state, a change in a future page
2125 might change current page buttons */
2126 set_assistant_buttons_state (assistant);
2128 gtk_widget_child_notify (page, "page-type");
2133 * gtk_assistant_get_page_type:
2134 * @assistant: a #GtkAssistant
2135 * @page: a page of @assistant
2137 * Gets the page type of @page.
2139 * Return value: the page type of @page.
2143 GtkAssistantPageType
2144 gtk_assistant_get_page_type (GtkAssistant *assistant,
2147 GtkAssistantPage *page_info;
2150 g_return_val_if_fail (GTK_IS_ASSISTANT (assistant), GTK_ASSISTANT_PAGE_CONTENT);
2151 g_return_val_if_fail (GTK_IS_WIDGET (page), GTK_ASSISTANT_PAGE_CONTENT);
2153 child = find_page (assistant, page);
2155 g_return_val_if_fail (child != NULL, GTK_ASSISTANT_PAGE_CONTENT);
2157 page_info = (GtkAssistantPage*) child->data;
2159 return page_info->type;
2163 * gtk_assistant_set_page_header_image:
2164 * @assistant: a #GtkAssistant
2165 * @page: a page of @assistant
2166 * @pixbuf: (allow-none): the new header image @page
2168 * Sets a header image for @page. This image is displayed in the header
2169 * area of the assistant when @page is the current page.
2174 gtk_assistant_set_page_header_image (GtkAssistant *assistant,
2178 GtkAssistantPrivate *priv;
2179 GtkAssistantPage *page_info;
2182 g_return_if_fail (GTK_IS_ASSISTANT (assistant));
2183 g_return_if_fail (GTK_IS_WIDGET (page));
2184 g_return_if_fail (pixbuf == NULL || GDK_IS_PIXBUF (pixbuf));
2186 priv = assistant->priv;
2187 child = find_page (assistant, page);
2189 g_return_if_fail (child != NULL);
2191 page_info = (GtkAssistantPage*) child->data;
2193 if (pixbuf != page_info->header_image)
2195 if (page_info->header_image)
2197 g_object_unref (page_info->header_image);
2198 page_info->header_image = NULL;
2202 page_info->header_image = g_object_ref (pixbuf);
2204 if (page_info == priv->current_page)
2205 set_assistant_header_image (assistant);
2207 gtk_widget_child_notify (page, "header-image");
2212 * gtk_assistant_get_page_header_image:
2213 * @assistant: a #GtkAssistant
2214 * @page: a page of @assistant
2216 * Gets the header image for @page.
2218 * Return value: (transfer none): the header image for @page, or %NULL
2219 * if there's no header image for the page.
2224 gtk_assistant_get_page_header_image (GtkAssistant *assistant,
2227 GtkAssistantPage *page_info;
2230 g_return_val_if_fail (GTK_IS_ASSISTANT (assistant), NULL);
2231 g_return_val_if_fail (GTK_IS_WIDGET (page), NULL);
2233 child = find_page (assistant, page);
2235 g_return_val_if_fail (child != NULL, NULL);
2237 page_info = (GtkAssistantPage*) child->data;
2239 return page_info->header_image;
2243 * gtk_assistant_set_page_side_image:
2244 * @assistant: a #GtkAssistant
2245 * @page: a page of @assistant
2246 * @pixbuf: (allow-none): the new header image @page
2248 * Sets a header image for @page. This image is displayed in the side
2249 * area of the assistant when @page is the current page.
2254 gtk_assistant_set_page_side_image (GtkAssistant *assistant,
2258 GtkAssistantPrivate *priv;
2259 GtkAssistantPage *page_info;
2262 g_return_if_fail (GTK_IS_ASSISTANT (assistant));
2263 g_return_if_fail (GTK_IS_WIDGET (page));
2264 g_return_if_fail (pixbuf == NULL || GDK_IS_PIXBUF (pixbuf));
2266 priv = assistant->priv;
2267 child = find_page (assistant, page);
2269 g_return_if_fail (child != NULL);
2271 page_info = (GtkAssistantPage*) child->data;
2273 if (pixbuf != page_info->sidebar_image)
2275 if (page_info->sidebar_image)
2277 g_object_unref (page_info->sidebar_image);
2278 page_info->sidebar_image = NULL;
2282 page_info->sidebar_image = g_object_ref (pixbuf);
2284 if (page_info == priv->current_page)
2285 set_assistant_sidebar_image (assistant);
2287 gtk_widget_child_notify (page, "sidebar-image");
2292 * gtk_assistant_get_page_side_image:
2293 * @assistant: a #GtkAssistant
2294 * @page: a page of @assistant
2296 * Gets the header image for @page.
2298 * Return value: (transfer none): the side image for @page, or %NULL
2299 * if there's no side image for the page.
2304 gtk_assistant_get_page_side_image (GtkAssistant *assistant,
2307 GtkAssistantPage *page_info;
2310 g_return_val_if_fail (GTK_IS_ASSISTANT (assistant), NULL);
2311 g_return_val_if_fail (GTK_IS_WIDGET (page), NULL);
2313 child = find_page (assistant, page);
2315 g_return_val_if_fail (child != NULL, NULL);
2317 page_info = (GtkAssistantPage*) child->data;
2319 return page_info->sidebar_image;
2323 * gtk_assistant_set_page_complete:
2324 * @assistant: a #GtkAssistant
2325 * @page: a page of @assistant
2326 * @complete: the completeness status of the page
2328 * Sets whether @page contents are complete. This will make
2329 * @assistant update the buttons state to be able to continue the task.
2334 gtk_assistant_set_page_complete (GtkAssistant *assistant,
2338 GtkAssistantPrivate *priv;
2339 GtkAssistantPage *page_info;
2342 g_return_if_fail (GTK_IS_ASSISTANT (assistant));
2343 g_return_if_fail (GTK_IS_WIDGET (page));
2345 priv = assistant->priv;
2346 child = find_page (assistant, page);
2348 g_return_if_fail (child != NULL);
2350 page_info = (GtkAssistantPage*) child->data;
2352 if (complete != page_info->complete)
2354 page_info->complete = complete;
2355 page_info->complete_set = TRUE;
2357 /* Always set buttons state, a change in a future page
2358 might change current page buttons */
2359 set_assistant_buttons_state (assistant);
2361 gtk_widget_child_notify (page, "complete");
2366 * gtk_assistant_get_page_complete:
2367 * @assistant: a #GtkAssistant
2368 * @page: a page of @assistant
2370 * Gets whether @page is complete.
2372 * Return value: %TRUE if @page is complete.
2377 gtk_assistant_get_page_complete (GtkAssistant *assistant,
2380 GtkAssistantPage *page_info;
2383 g_return_val_if_fail (GTK_IS_ASSISTANT (assistant), FALSE);
2384 g_return_val_if_fail (GTK_IS_WIDGET (page), FALSE);
2386 child = find_page (assistant, page);
2388 g_return_val_if_fail (child != NULL, FALSE);
2390 page_info = (GtkAssistantPage*) child->data;
2392 return page_info->complete;
2396 * gtk_assistant_update_buttons_state:
2397 * @assistant: a #GtkAssistant
2399 * Forces @assistant to recompute the buttons state.
2401 * GTK+ automatically takes care of this in most situations,
2402 * e.g. when the user goes to a different page, or when the
2403 * visibility or completeness of a page changes.
2405 * One situation where it can be necessary to call this
2406 * function is when changing a value on the current page
2407 * affects the future page flow of the assistant.
2412 gtk_assistant_update_buttons_state (GtkAssistant *assistant)
2414 g_return_if_fail (GTK_IS_ASSISTANT (assistant));
2416 set_assistant_buttons_state (assistant);
2420 * gtk_assistant_commit:
2421 * @assistant: a #GtkAssistant
2423 * Erases the visited page history so the back button is not
2424 * shown on the current page, and removes the cancel button
2425 * from subsequent pages.
2427 * Use this when the information provided up to the current
2428 * page is hereafter deemed permanent and cannot be modified
2429 * or undone. For example, showing a progress page to track
2430 * a long-running, unreversible operation after the user has
2431 * clicked apply on a confirmation page.
2436 gtk_assistant_commit (GtkAssistant *assistant)
2438 g_return_if_fail (GTK_IS_ASSISTANT (assistant));
2440 g_slist_free (assistant->priv->visited_pages);
2441 assistant->priv->visited_pages = NULL;
2443 assistant->priv->committed = TRUE;
2445 set_assistant_buttons_state (assistant);
2449 gtk_assistant_get_accessible (GtkWidget *widget)
2451 static gboolean first_time = TRUE;
2455 AtkObjectFactory *factory;
2456 AtkRegistry *registry;
2458 GType derived_atk_type;
2461 * Figure out whether accessibility is enabled by looking at the
2462 * type of the accessible object which would be created for
2463 * the parent type of GtkAssistant.
2465 derived_type = g_type_parent (GTK_TYPE_ASSISTANT);
2467 registry = atk_get_default_registry ();
2468 factory = atk_registry_get_factory (registry, derived_type);
2469 derived_atk_type = atk_object_factory_get_accessible_type (factory);
2470 if (g_type_is_a (derived_atk_type, GTK_TYPE_ACCESSIBLE))
2471 atk_registry_set_factory_type (registry,
2473 gtk_assistant_accessible_factory_get_type ());
2478 return GTK_WIDGET_CLASS (gtk_assistant_parent_class)->get_accessible (widget);
2481 /* accessible implementation */
2483 /* dummy typedefs */
2484 typedef struct _GtkAssistantAccessible GtkAssistantAccessible;
2485 typedef struct _GtkAssistantAccessibleClass GtkAssistantAccessibleClass;
2487 ATK_DEFINE_TYPE (GtkAssistantAccessible, _gtk_assistant_accessible, GTK_TYPE_ASSISTANT);
2490 gtk_assistant_accessible_get_n_children (AtkObject *accessible)
2494 widget = gtk_accessible_get_widget (GTK_ACCESSIBLE (accessible));
2498 return g_list_length (GTK_ASSISTANT (accessible)->priv->pages) + 1;
2502 gtk_assistant_accessible_ref_child (AtkObject *accessible,
2505 GtkAssistant *assistant;
2506 GtkAssistantPrivate *priv;
2507 GtkWidget *widget, *child;
2512 widget = gtk_accessible_get_widget (GTK_ACCESSIBLE (accessible));
2516 assistant = GTK_ASSISTANT (widget);
2517 priv = assistant->priv;
2518 n_pages = g_list_length (priv->pages);
2522 else if (index < n_pages)
2524 GtkAssistantPage *page = g_list_nth_data (priv->pages, index);
2527 title = gtk_assistant_get_page_title (assistant, child);
2529 else if (index == n_pages)
2531 child = priv->action_area;
2537 obj = gtk_widget_get_accessible (child);
2540 atk_object_set_name (obj, title);
2542 return g_object_ref (obj);
2546 _gtk_assistant_accessible_class_init (GtkAssistantAccessibleClass *klass)
2548 AtkObjectClass *atk_class = ATK_OBJECT_CLASS (klass);
2550 atk_class->get_n_children = gtk_assistant_accessible_get_n_children;
2551 atk_class->ref_child = gtk_assistant_accessible_ref_child;
2555 _gtk_assistant_accessible_init (GtkAssistantAccessible *self)
2560 typedef AtkObjectFactory GtkAssistantAccessibleFactory;
2561 typedef AtkObjectFactoryClass GtkAssistantAccessibleFactoryClass;
2563 G_DEFINE_TYPE (GtkAssistantAccessibleFactory,
2564 gtk_assistant_accessible_factory,
2565 ATK_TYPE_OBJECT_FACTORY);
2568 gtk_assistant_accessible_factory_get_accessible_type (void)
2570 return _gtk_assistant_accessible_get_type ();
2574 gtk_assistant_accessible_factory_create_accessible (GObject *obj)
2576 AtkObject *accessible;
2578 accessible = g_object_new (_gtk_assistant_accessible_get_type (), NULL);
2579 atk_object_initialize (accessible, obj);
2585 gtk_assistant_accessible_factory_class_init (AtkObjectFactoryClass *class)
2587 class->create_accessible = gtk_assistant_accessible_factory_create_accessible;
2588 class->get_accessible_type = gtk_assistant_accessible_factory_get_accessible_type;
2592 gtk_assistant_accessible_factory_init (AtkObjectFactory *factory)
2596 /* buildable implementation */
2598 static GtkBuildableIface *parent_buildable_iface;
2601 gtk_assistant_buildable_interface_init (GtkBuildableIface *iface)
2603 parent_buildable_iface = g_type_interface_peek_parent (iface);
2604 iface->get_internal_child = gtk_assistant_buildable_get_internal_child;
2605 iface->custom_tag_start = gtk_assistant_buildable_custom_tag_start;
2606 iface->custom_finished = gtk_assistant_buildable_custom_finished;
2610 gtk_assistant_buildable_get_internal_child (GtkBuildable *buildable,
2611 GtkBuilder *builder,
2612 const gchar *childname)
2614 if (strcmp (childname, "action_area") == 0)
2615 return G_OBJECT (GTK_ASSISTANT (buildable)->priv->action_area);
2617 return parent_buildable_iface->get_internal_child (buildable,
2623 gtk_assistant_buildable_custom_tag_start (GtkBuildable *buildable,
2624 GtkBuilder *builder,
2626 const gchar *tagname,
2627 GMarkupParser *parser,
2630 return parent_buildable_iface->custom_tag_start (buildable, builder, child,
2631 tagname, parser, data);
2635 gtk_assistant_buildable_custom_finished (GtkBuildable *buildable,
2636 GtkBuilder *builder,
2638 const gchar *tagname,
2641 parent_buildable_iface->custom_finished (buildable, builder, child,
2642 tagname, user_data);