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 * <refsect2 id="GtkAssistant-BUILDER-UI">
43 * <title>GtkAssistant as GtkBuildable</title>
45 * The GtkAssistant implementation of the GtkBuildable interface exposes the
46 * @action_area as internal children with the name "action_area".
48 * To add pages to an assistant in GtkBuilder, simply add it as a
49 * <child> to the GtkAssistant object, and set its child properties
59 #include "gtkassistant.h"
61 #include "gtkaccessible.h"
62 #include "gtkbutton.h"
67 #include "gtksizegroup.h"
68 #include "gtksizerequest.h"
72 #include "gtkprivate.h"
73 #include "gtkbuildable.h"
76 #define HEADER_SPACING 12
77 #define ACTION_AREA_SPACING 12
79 typedef struct _GtkAssistantPage GtkAssistantPage;
81 struct _GtkAssistantPage
84 GtkAssistantPageType type;
86 guint complete_set : 1;
89 GdkPixbuf *header_image;
90 GdkPixbuf *sidebar_image;
93 struct _GtkAssistantPrivate
102 GtkWidget *header_image;
103 GtkWidget *sidebar_image;
105 GtkWidget *action_area;
109 GtkAssistantPage *current_page;
111 GSList *visited_pages;
113 GtkSizeGroup *size_group;
115 GtkAssistantPageFunc forward_function;
116 gpointer forward_function_data;
117 GDestroyNotify forward_data_destroy;
122 static void gtk_assistant_class_init (GtkAssistantClass *class);
123 static void gtk_assistant_init (GtkAssistant *assistant);
124 static void gtk_assistant_destroy (GtkWidget *widget);
125 static void gtk_assistant_style_set (GtkWidget *widget,
126 GtkStyle *old_style);
127 static void gtk_assistant_get_preferred_width (GtkWidget *widget,
130 static void gtk_assistant_get_preferred_height (GtkWidget *widget,
133 static void gtk_assistant_size_allocate (GtkWidget *widget,
134 GtkAllocation *allocation);
135 static void gtk_assistant_map (GtkWidget *widget);
136 static void gtk_assistant_unmap (GtkWidget *widget);
137 static gboolean gtk_assistant_delete_event (GtkWidget *widget,
139 static gboolean gtk_assistant_draw (GtkWidget *widget,
141 static gboolean gtk_assistant_focus (GtkWidget *widget,
142 GtkDirectionType direction);
143 static void gtk_assistant_add (GtkContainer *container,
145 static void gtk_assistant_remove (GtkContainer *container,
147 static void gtk_assistant_forall (GtkContainer *container,
148 gboolean include_internals,
149 GtkCallback callback,
150 gpointer callback_data);
151 static void gtk_assistant_set_child_property (GtkContainer *container,
156 static void gtk_assistant_get_child_property (GtkContainer *container,
162 static AtkObject *gtk_assistant_get_accessible (GtkWidget *widget);
164 static void gtk_assistant_buildable_interface_init (GtkBuildableIface *iface);
165 static GObject *gtk_assistant_buildable_get_internal_child (GtkBuildable *buildable,
167 const gchar *childname);
168 static gboolean gtk_assistant_buildable_custom_tag_start (GtkBuildable *buildable,
171 const gchar *tagname,
172 GMarkupParser *parser,
174 static void gtk_assistant_buildable_custom_finished (GtkBuildable *buildable,
177 const gchar *tagname,
180 static GList* find_page (GtkAssistant *assistant,
186 CHILD_PROP_PAGE_TYPE,
187 CHILD_PROP_PAGE_TITLE,
188 CHILD_PROP_PAGE_HEADER_IMAGE,
189 CHILD_PROP_PAGE_SIDEBAR_IMAGE,
190 CHILD_PROP_PAGE_COMPLETE
202 static guint signals [LAST_SIGNAL] = { 0 };
205 G_DEFINE_TYPE_WITH_CODE (GtkAssistant, gtk_assistant, GTK_TYPE_WINDOW,
206 G_IMPLEMENT_INTERFACE (GTK_TYPE_BUILDABLE,
207 gtk_assistant_buildable_interface_init))
211 gtk_assistant_class_init (GtkAssistantClass *class)
213 GObjectClass *gobject_class;
214 GtkWidgetClass *widget_class;
215 GtkContainerClass *container_class;
217 gobject_class = (GObjectClass *) class;
218 widget_class = (GtkWidgetClass *) class;
219 container_class = (GtkContainerClass *) class;
221 widget_class->destroy = gtk_assistant_destroy;
222 widget_class->style_set = gtk_assistant_style_set;
223 widget_class->get_preferred_width = gtk_assistant_get_preferred_width;
224 widget_class->get_preferred_height = gtk_assistant_get_preferred_height;
225 widget_class->size_allocate = gtk_assistant_size_allocate;
226 widget_class->map = gtk_assistant_map;
227 widget_class->unmap = gtk_assistant_unmap;
228 widget_class->delete_event = gtk_assistant_delete_event;
229 widget_class->draw = gtk_assistant_draw;
230 widget_class->focus = gtk_assistant_focus;
231 widget_class->get_accessible = gtk_assistant_get_accessible;
233 container_class->add = gtk_assistant_add;
234 container_class->remove = gtk_assistant_remove;
235 container_class->forall = gtk_assistant_forall;
236 container_class->set_child_property = gtk_assistant_set_child_property;
237 container_class->get_child_property = gtk_assistant_get_child_property;
240 * GtkAssistant::cancel:
241 * @assistant: the #GtkAssistant
243 * The ::cancel signal is emitted when then the cancel button is clicked.
248 g_signal_new (I_("cancel"),
249 G_TYPE_FROM_CLASS (gobject_class),
251 G_STRUCT_OFFSET (GtkAssistantClass, cancel),
253 g_cclosure_marshal_VOID__VOID,
257 * GtkAssistant::prepare:
258 * @assistant: the #GtkAssistant
259 * @page: the current page
261 * The ::prepare signal is emitted when a new page is set as the assistant's
262 * current page, before making the new page visible. A handler for this signal
263 * can do any preparation which are necessary before showing @page.
268 g_signal_new (I_("prepare"),
269 G_TYPE_FROM_CLASS (gobject_class),
271 G_STRUCT_OFFSET (GtkAssistantClass, prepare),
273 g_cclosure_marshal_VOID__OBJECT,
274 G_TYPE_NONE, 1, GTK_TYPE_WIDGET);
277 * GtkAssistant::apply:
278 * @assistant: the #GtkAssistant
280 * The ::apply signal is emitted when the apply button is clicked. The default
281 * behavior of the #GtkAssistant is to switch to the page after the current
282 * page, unless the current page is the last one.
284 * A handler for the ::apply signal should carry out the actions for which
285 * the wizard has collected data. If the action takes a long time to complete,
286 * you might consider putting a page of type %GTK_ASSISTANT_PAGE_PROGRESS
287 * after the confirmation page and handle this operation within the
288 * #GtkAssistant::prepare signal of the progress page.
293 g_signal_new (I_("apply"),
294 G_TYPE_FROM_CLASS (gobject_class),
296 G_STRUCT_OFFSET (GtkAssistantClass, apply),
298 g_cclosure_marshal_VOID__VOID,
302 * GtkAssistant::close:
303 * @assistant: the #GtkAssistant
305 * The ::close signal is emitted either when the close button of
306 * a summary page is clicked, or when the apply button in the last
307 * page in the flow (of type %GTK_ASSISTANT_PAGE_CONFIRM) is clicked.
312 g_signal_new (I_("close"),
313 G_TYPE_FROM_CLASS (gobject_class),
315 G_STRUCT_OFFSET (GtkAssistantClass, close),
317 g_cclosure_marshal_VOID__VOID,
320 gtk_widget_class_install_style_property (widget_class,
321 g_param_spec_int ("header-padding",
322 P_("Header Padding"),
323 P_("Number of pixels around the header."),
327 GTK_PARAM_READABLE));
328 gtk_widget_class_install_style_property (widget_class,
329 g_param_spec_int ("content-padding",
330 P_("Content Padding"),
331 P_("Number of pixels around the content pages."),
335 GTK_PARAM_READABLE));
338 * GtkAssistant:page-type:
340 * The type of the assistant page.
344 gtk_container_class_install_child_property (container_class,
345 CHILD_PROP_PAGE_TYPE,
346 g_param_spec_enum ("page-type",
348 P_("The type of the assistant page"),
349 GTK_TYPE_ASSISTANT_PAGE_TYPE,
350 GTK_ASSISTANT_PAGE_CONTENT,
351 GTK_PARAM_READWRITE));
354 * GtkAssistant:title:
356 * The title that is displayed in the page header.
358 * If title and header-image are both %NULL, no header is displayed.
362 gtk_container_class_install_child_property (container_class,
363 CHILD_PROP_PAGE_TITLE,
364 g_param_spec_string ("title",
366 P_("The title of the assistant page"),
368 GTK_PARAM_READWRITE));
371 * GtkAssistant:header-image:
373 * The image that is displayed next to the title in the page header.
375 * If title and header-image are both %NULL, no header is displayed.
379 gtk_container_class_install_child_property (container_class,
380 CHILD_PROP_PAGE_HEADER_IMAGE,
381 g_param_spec_object ("header-image",
383 P_("Header image for the assistant page"),
385 GTK_PARAM_READWRITE));
388 * GtkAssistant:header-image:
390 * The image that is displayed next to the page.
392 * Set this to %NULL to make the sidebar disappear.
396 gtk_container_class_install_child_property (container_class,
397 CHILD_PROP_PAGE_SIDEBAR_IMAGE,
398 g_param_spec_object ("sidebar-image",
400 P_("Sidebar image for the assistant page"),
402 GTK_PARAM_READWRITE));
404 * GtkAssistant:complete:
406 * Setting the "complete" child property to %TRUE marks a page as complete
407 * (i.e.: all the required fields are filled out). GTK+ uses this information
408 * to control the sensitivity of the navigation buttons.
412 gtk_container_class_install_child_property (container_class,
413 CHILD_PROP_PAGE_COMPLETE,
414 g_param_spec_boolean ("complete",
416 P_("Whether all required fields on the page have been filled out"),
420 g_type_class_add_private (gobject_class, sizeof (GtkAssistantPrivate));
424 default_forward_function (gint current_page, gpointer data)
426 GtkAssistant *assistant;
427 GtkAssistantPrivate *priv;
428 GtkAssistantPage *page_info;
431 assistant = GTK_ASSISTANT (data);
432 priv = assistant->priv;
434 page_node = g_list_nth (priv->pages, ++current_page);
439 page_info = (GtkAssistantPage *) page_node->data;
441 while (page_node && !gtk_widget_get_visible (page_info->page))
443 page_node = page_node->next;
447 page_info = (GtkAssistantPage *) page_node->data;
454 compute_last_button_state (GtkAssistant *assistant)
456 GtkAssistantPrivate *priv = assistant->priv;
457 GtkAssistantPage *page_info, *current_page_info;
458 gint count, page_num, n_pages;
461 page_num = gtk_assistant_get_current_page (assistant);
462 n_pages = gtk_assistant_get_n_pages (assistant);
463 current_page_info = page_info = g_list_nth_data (priv->pages, page_num);
465 while (page_num >= 0 && page_num < n_pages &&
466 page_info->type == GTK_ASSISTANT_PAGE_CONTENT &&
467 (count == 0 || page_info->complete) &&
470 page_num = (priv->forward_function) (page_num, priv->forward_function_data);
471 page_info = g_list_nth_data (priv->pages, page_num);
476 /* make the last button visible if we can skip multiple
477 * pages and end on a confirmation or summary page
479 if (count > 1 && page_info &&
480 (page_info->type == GTK_ASSISTANT_PAGE_CONFIRM ||
481 page_info->type == GTK_ASSISTANT_PAGE_SUMMARY))
483 gtk_widget_show (priv->last);
484 gtk_widget_set_sensitive (priv->last,
485 current_page_info->complete);
488 gtk_widget_hide (priv->last);
492 compute_progress_state (GtkAssistant *assistant)
494 GtkAssistantPrivate *priv = assistant->priv;
495 gint page_num, n_pages;
497 n_pages = gtk_assistant_get_n_pages (assistant);
498 page_num = gtk_assistant_get_current_page (assistant);
500 page_num = (priv->forward_function) (page_num, priv->forward_function_data);
502 if (page_num >= 0 && page_num < n_pages)
503 gtk_widget_show (priv->forward);
505 gtk_widget_hide (priv->forward);
509 set_assistant_header_image (GtkAssistant *assistant)
511 GtkAssistantPrivate *priv = assistant->priv;
513 gtk_image_set_from_pixbuf (GTK_IMAGE (priv->header_image),
514 priv->current_page->header_image);
518 set_assistant_sidebar_image (GtkAssistant *assistant)
520 GtkAssistantPrivate *priv = assistant->priv;
522 gtk_image_set_from_pixbuf (GTK_IMAGE (priv->sidebar_image),
523 priv->current_page->sidebar_image);
525 if (priv->current_page->sidebar_image)
526 gtk_widget_show (priv->sidebar_image);
528 gtk_widget_hide (priv->sidebar_image);
532 set_assistant_buttons_state (GtkAssistant *assistant)
534 GtkAssistantPrivate *priv = assistant->priv;
536 if (!priv->current_page)
539 switch (priv->current_page->type)
541 case GTK_ASSISTANT_PAGE_INTRO:
542 gtk_widget_set_sensitive (priv->cancel, TRUE);
543 gtk_widget_set_sensitive (priv->forward, priv->current_page->complete);
544 gtk_widget_grab_default (priv->forward);
545 gtk_widget_show (priv->forward);
546 gtk_widget_hide (priv->back);
547 gtk_widget_hide (priv->apply);
548 gtk_widget_hide (priv->close);
549 compute_last_button_state (assistant);
551 case GTK_ASSISTANT_PAGE_CONFIRM:
552 gtk_widget_set_sensitive (priv->cancel, TRUE);
553 gtk_widget_set_sensitive (priv->back, TRUE);
554 gtk_widget_set_sensitive (priv->apply, priv->current_page->complete);
555 gtk_widget_grab_default (priv->apply);
556 gtk_widget_show (priv->back);
557 gtk_widget_show (priv->apply);
558 gtk_widget_hide (priv->forward);
559 gtk_widget_hide (priv->close);
560 gtk_widget_hide (priv->last);
562 case GTK_ASSISTANT_PAGE_CONTENT:
563 gtk_widget_set_sensitive (priv->cancel, TRUE);
564 gtk_widget_set_sensitive (priv->back, TRUE);
565 gtk_widget_set_sensitive (priv->forward, priv->current_page->complete);
566 gtk_widget_grab_default (priv->forward);
567 gtk_widget_show (priv->back);
568 gtk_widget_show (priv->forward);
569 gtk_widget_hide (priv->apply);
570 gtk_widget_hide (priv->close);
571 compute_last_button_state (assistant);
573 case GTK_ASSISTANT_PAGE_SUMMARY:
574 gtk_widget_set_sensitive (priv->close, priv->current_page->complete);
575 gtk_widget_grab_default (priv->close);
576 gtk_widget_show (priv->close);
577 gtk_widget_hide (priv->back);
578 gtk_widget_hide (priv->forward);
579 gtk_widget_hide (priv->apply);
580 gtk_widget_hide (priv->last);
582 case GTK_ASSISTANT_PAGE_PROGRESS:
583 gtk_widget_set_sensitive (priv->cancel, priv->current_page->complete);
584 gtk_widget_set_sensitive (priv->back, priv->current_page->complete);
585 gtk_widget_set_sensitive (priv->forward, priv->current_page->complete);
586 gtk_widget_grab_default (priv->forward);
587 gtk_widget_show (priv->back);
588 gtk_widget_hide (priv->apply);
589 gtk_widget_hide (priv->close);
590 gtk_widget_hide (priv->last);
591 compute_progress_state (assistant);
593 case GTK_ASSISTANT_PAGE_CUSTOM:
594 gtk_widget_hide (priv->cancel);
595 gtk_widget_hide (priv->back);
596 gtk_widget_hide (priv->forward);
597 gtk_widget_hide (priv->apply);
598 gtk_widget_hide (priv->last);
599 gtk_widget_hide (priv->close);
602 g_assert_not_reached ();
606 gtk_widget_hide (priv->cancel);
607 else if (priv->current_page->type == GTK_ASSISTANT_PAGE_SUMMARY ||
608 priv->current_page->type == GTK_ASSISTANT_PAGE_CUSTOM)
609 gtk_widget_hide (priv->cancel);
611 gtk_widget_show (priv->cancel);
613 /* this is quite general, we don't want to
614 * go back if it's the first page */
615 if (!priv->visited_pages)
616 gtk_widget_hide (priv->back);
620 set_current_page (GtkAssistant *assistant,
621 GtkAssistantPage *page)
623 GtkAssistantPrivate *priv = assistant->priv;
624 GtkAssistantPage *old_page;
626 if (priv->current_page &&
627 gtk_widget_is_drawable (priv->current_page->page))
628 old_page = priv->current_page;
632 priv->current_page = page;
634 set_assistant_buttons_state (assistant);
635 set_assistant_header_image (assistant);
636 set_assistant_sidebar_image (assistant);
638 g_signal_emit (assistant, signals [PREPARE], 0, priv->current_page->page);
640 if (gtk_widget_get_visible (priv->current_page->page) && gtk_widget_get_mapped (GTK_WIDGET (assistant)))
642 gtk_widget_set_child_visible (priv->current_page->page, TRUE);
643 gtk_widget_map (priv->current_page->page);
644 gtk_widget_map (priv->current_page->title);
647 if (old_page && gtk_widget_get_mapped (old_page->page))
649 gtk_widget_set_child_visible (old_page->page, FALSE);
650 gtk_widget_unmap (old_page->page);
651 gtk_widget_unmap (old_page->title);
654 if (!gtk_widget_child_focus (priv->current_page->page, GTK_DIR_TAB_FORWARD))
656 GtkWidget *button[6];
659 /* find the best button to focus */
660 button[0] = priv->apply;
661 button[1] = priv->close;
662 button[2] = priv->forward;
663 button[3] = priv->back;
664 button[4] = priv->cancel;
665 button[5] = priv->last;
666 for (i = 0; i < 6; i++)
668 if (gtk_widget_get_visible (button[i]) && gtk_widget_get_sensitive (button[i]))
670 gtk_widget_grab_focus (button[i]);
676 gtk_widget_queue_resize (GTK_WIDGET (assistant));
680 compute_next_step (GtkAssistant *assistant)
682 GtkAssistantPrivate *priv = assistant->priv;
683 GtkAssistantPage *page_info;
684 gint current_page, n_pages, next_page;
686 current_page = gtk_assistant_get_current_page (assistant);
687 page_info = priv->current_page;
688 n_pages = gtk_assistant_get_n_pages (assistant);
690 next_page = (priv->forward_function) (current_page,
691 priv->forward_function_data);
693 if (next_page >= 0 && next_page < n_pages)
695 priv->visited_pages = g_slist_prepend (priv->visited_pages, page_info);
696 set_current_page (assistant, g_list_nth_data (priv->pages, next_page));
705 on_assistant_close (GtkWidget *widget,
706 GtkAssistant *assistant)
708 g_signal_emit (assistant, signals [CLOSE], 0, NULL);
712 on_assistant_apply (GtkWidget *widget,
713 GtkAssistant *assistant)
717 g_signal_emit (assistant, signals [APPLY], 0);
719 success = compute_next_step (assistant);
721 /* if the assistant hasn't switched to another page, just emit
722 * the CLOSE signal, it't the last page in the assistant flow
725 g_signal_emit (assistant, signals [CLOSE], 0);
729 on_assistant_forward (GtkWidget *widget,
730 GtkAssistant *assistant)
732 gtk_assistant_next_page (assistant);
736 on_assistant_back (GtkWidget *widget,
737 GtkAssistant *assistant)
739 gtk_assistant_previous_page (assistant);
743 on_assistant_cancel (GtkWidget *widget,
744 GtkAssistant *assistant)
746 g_signal_emit (assistant, signals [CANCEL], 0, NULL);
750 on_assistant_last (GtkWidget *widget,
751 GtkAssistant *assistant)
753 GtkAssistantPrivate *priv = assistant->priv;
755 while (priv->current_page->type == GTK_ASSISTANT_PAGE_CONTENT &&
756 priv->current_page->complete)
757 compute_next_step (assistant);
761 alternative_button_order (GtkAssistant *assistant)
763 GtkSettings *settings;
767 screen = gtk_widget_get_screen (GTK_WIDGET (assistant));
768 settings = gtk_settings_get_for_screen (screen);
770 g_object_get (settings,
771 "gtk-alternative-button-order", &result,
777 gtk_assistant_init (GtkAssistant *assistant)
779 GtkAssistantPrivate *priv;
781 assistant->priv = G_TYPE_INSTANCE_GET_PRIVATE (assistant,
783 GtkAssistantPrivate);
784 priv = assistant->priv;
786 gtk_container_set_reallocate_redraws (GTK_CONTAINER (assistant), TRUE);
787 gtk_container_set_border_width (GTK_CONTAINER (assistant), 12);
789 gtk_widget_push_composite_child ();
792 priv->header_image = gtk_image_new ();
793 gtk_misc_set_alignment (GTK_MISC (priv->header_image), 1., 0.5);
794 gtk_widget_set_parent (priv->header_image, GTK_WIDGET (assistant));
795 gtk_widget_show (priv->header_image);
798 priv->sidebar_image = gtk_image_new ();
799 gtk_misc_set_alignment (GTK_MISC (priv->sidebar_image), 0., 0.);
800 gtk_widget_set_parent (priv->sidebar_image, GTK_WIDGET (assistant));
801 gtk_widget_show (priv->sidebar_image);
804 priv->action_area = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, FALSE, 6);
806 priv->close = gtk_button_new_from_stock (GTK_STOCK_CLOSE);
807 priv->apply = gtk_button_new_from_stock (GTK_STOCK_APPLY);
808 priv->forward = gtk_button_new_from_stock (GTK_STOCK_GO_FORWARD);
809 priv->back = gtk_button_new_from_stock (GTK_STOCK_GO_BACK);
810 priv->cancel = gtk_button_new_from_stock (GTK_STOCK_CANCEL);
811 priv->last = gtk_button_new_from_stock (GTK_STOCK_GOTO_LAST);
812 gtk_widget_set_can_default (priv->close, TRUE);
813 gtk_widget_set_can_default (priv->apply, TRUE);
814 gtk_widget_set_can_default (priv->forward, TRUE);
816 priv->size_group = gtk_size_group_new (GTK_SIZE_GROUP_HORIZONTAL);
817 gtk_size_group_add_widget (priv->size_group, priv->close);
818 gtk_size_group_add_widget (priv->size_group, priv->apply);
819 gtk_size_group_add_widget (priv->size_group, priv->forward);
820 gtk_size_group_add_widget (priv->size_group, priv->back);
821 gtk_size_group_add_widget (priv->size_group, priv->cancel);
822 gtk_size_group_add_widget (priv->size_group, priv->last);
824 if (!alternative_button_order (assistant))
826 gtk_box_pack_end (GTK_BOX (priv->action_area), priv->apply, FALSE, FALSE, 0);
827 gtk_box_pack_end (GTK_BOX (priv->action_area), priv->forward, FALSE, FALSE, 0);
828 gtk_box_pack_end (GTK_BOX (priv->action_area), priv->back, FALSE, FALSE, 0);
829 gtk_box_pack_end (GTK_BOX (priv->action_area), priv->last, FALSE, FALSE, 0);
830 gtk_box_pack_end (GTK_BOX (priv->action_area), priv->cancel, FALSE, FALSE, 0);
831 gtk_box_pack_end (GTK_BOX (priv->action_area), priv->close, FALSE, FALSE, 0);
835 gtk_box_pack_end (GTK_BOX (priv->action_area), priv->close, FALSE, FALSE, 0);
836 gtk_box_pack_end (GTK_BOX (priv->action_area), priv->cancel, FALSE, FALSE, 0);
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);
843 gtk_widget_set_parent (priv->action_area, GTK_WIDGET (assistant));
844 gtk_widget_show (priv->forward);
845 gtk_widget_show (priv->back);
846 gtk_widget_show (priv->cancel);
847 gtk_widget_show (priv->action_area);
849 gtk_widget_pop_composite_child ();
852 priv->current_page = NULL;
853 priv->visited_pages = NULL;
855 priv->forward_function = default_forward_function;
856 priv->forward_function_data = assistant;
857 priv->forward_data_destroy = NULL;
859 g_signal_connect (G_OBJECT (priv->close), "clicked",
860 G_CALLBACK (on_assistant_close), assistant);
861 g_signal_connect (G_OBJECT (priv->apply), "clicked",
862 G_CALLBACK (on_assistant_apply), assistant);
863 g_signal_connect (G_OBJECT (priv->forward), "clicked",
864 G_CALLBACK (on_assistant_forward), assistant);
865 g_signal_connect (G_OBJECT (priv->back), "clicked",
866 G_CALLBACK (on_assistant_back), assistant);
867 g_signal_connect (G_OBJECT (priv->cancel), "clicked",
868 G_CALLBACK (on_assistant_cancel), assistant);
869 g_signal_connect (G_OBJECT (priv->last), "clicked",
870 G_CALLBACK (on_assistant_last), assistant);
874 gtk_assistant_set_child_property (GtkContainer *container,
882 case CHILD_PROP_PAGE_TYPE:
883 gtk_assistant_set_page_type (GTK_ASSISTANT (container), child,
884 g_value_get_enum (value));
886 case CHILD_PROP_PAGE_TITLE:
887 gtk_assistant_set_page_title (GTK_ASSISTANT (container), child,
888 g_value_get_string (value));
890 case CHILD_PROP_PAGE_HEADER_IMAGE:
891 gtk_assistant_set_page_header_image (GTK_ASSISTANT (container), child,
892 g_value_get_object (value));
894 case CHILD_PROP_PAGE_SIDEBAR_IMAGE:
895 gtk_assistant_set_page_side_image (GTK_ASSISTANT (container), child,
896 g_value_get_object (value));
898 case CHILD_PROP_PAGE_COMPLETE:
899 gtk_assistant_set_page_complete (GTK_ASSISTANT (container), child,
900 g_value_get_boolean (value));
903 GTK_CONTAINER_WARN_INVALID_CHILD_PROPERTY_ID (container, property_id, pspec);
909 gtk_assistant_get_child_property (GtkContainer *container,
917 case CHILD_PROP_PAGE_TYPE:
918 g_value_set_enum (value,
919 gtk_assistant_get_page_type (GTK_ASSISTANT (container), child));
921 case CHILD_PROP_PAGE_TITLE:
922 g_value_set_string (value,
923 gtk_assistant_get_page_title (GTK_ASSISTANT (container), child));
925 case CHILD_PROP_PAGE_HEADER_IMAGE:
926 g_value_set_object (value,
927 gtk_assistant_get_page_header_image (GTK_ASSISTANT (container), child));
929 case CHILD_PROP_PAGE_SIDEBAR_IMAGE:
930 g_value_set_object (value,
931 gtk_assistant_get_page_side_image (GTK_ASSISTANT (container), child));
933 case CHILD_PROP_PAGE_COMPLETE:
934 g_value_set_boolean (value,
935 gtk_assistant_get_page_complete (GTK_ASSISTANT (container), child));
938 GTK_CONTAINER_WARN_INVALID_CHILD_PROPERTY_ID (container, property_id, pspec);
944 on_page_notify_visibility (GtkWidget *widget,
948 GtkAssistant *assistant = GTK_ASSISTANT (data);
950 /* update buttons state, flow may have changed */
951 if (gtk_widget_get_mapped (GTK_WIDGET (assistant)))
952 set_assistant_buttons_state (assistant);
956 remove_page (GtkAssistant *assistant,
959 GtkAssistantPrivate *priv = assistant->priv;
960 GtkAssistantPage *page_info;
963 page_info = element->data;
965 /* If this is the current page, we need to switch away. */
966 if (page_info == priv->current_page)
968 if (!compute_next_step (assistant))
970 /* The best we can do at this point is probably to pick the first
973 page_node = priv->pages;
975 while (page_node && !gtk_widget_get_visible (((GtkAssistantPage *) page_node->data)->page))
976 page_node = page_node->next;
978 if (page_node == element)
979 page_node = page_node->next;
982 priv->current_page = page_node->data;
984 priv->current_page = NULL;
988 priv->pages = g_list_remove_link (priv->pages, element);
989 priv->visited_pages = g_slist_remove_all (priv->visited_pages, page_info);
991 g_signal_handlers_disconnect_by_func (page_info->page, on_page_notify_visibility, assistant);
992 gtk_widget_unparent (page_info->page);
994 if (page_info->header_image)
995 g_object_unref (page_info->header_image);
997 if (page_info->sidebar_image)
998 g_object_unref (page_info->sidebar_image);
1000 gtk_widget_destroy (page_info->title);
1001 g_slice_free (GtkAssistantPage, page_info);
1002 g_list_free_1 (element);
1006 gtk_assistant_destroy (GtkWidget *widget)
1008 GtkAssistant *assistant = GTK_ASSISTANT (widget);
1009 GtkAssistantPrivate *priv = assistant->priv;
1011 if (priv->header_image)
1013 gtk_widget_destroy (priv->header_image);
1014 priv->header_image = NULL;
1017 if (priv->sidebar_image)
1019 gtk_widget_destroy (priv->sidebar_image);
1020 priv->sidebar_image = NULL;
1023 if (priv->action_area)
1025 gtk_widget_destroy (priv->action_area);
1026 priv->action_area = NULL;
1029 if (priv->size_group)
1031 g_object_unref (priv->size_group);
1032 priv->size_group = NULL;
1035 if (priv->forward_function)
1037 if (priv->forward_function_data &&
1038 priv->forward_data_destroy)
1039 priv->forward_data_destroy (priv->forward_function_data);
1041 priv->forward_function = NULL;
1042 priv->forward_function_data = NULL;
1043 priv->forward_data_destroy = NULL;
1046 if (priv->visited_pages)
1048 g_slist_free (priv->visited_pages);
1049 priv->visited_pages = NULL;
1052 /* We set current to NULL so that the remove code doesn't try
1053 * to do anything funny */
1054 priv->current_page = NULL;
1057 remove_page (assistant, priv->pages);
1059 GTK_WIDGET_CLASS (gtk_assistant_parent_class)->destroy (widget);
1063 find_page (GtkAssistant *assistant,
1066 GtkAssistantPrivate *priv = assistant->priv;
1067 GList *child = priv->pages;
1071 GtkAssistantPage *page_info = child->data;
1072 if (page_info->page == page)
1075 child = child->next;
1082 set_title_colors (GtkWidget *assistant,
1083 GtkWidget *title_label)
1087 gtk_widget_ensure_style (assistant);
1088 style = gtk_widget_get_style (assistant);
1090 /* change colors schema, for making the header text visible */
1091 gtk_widget_modify_bg (title_label, GTK_STATE_NORMAL, &style->bg[GTK_STATE_SELECTED]);
1092 gtk_widget_modify_fg (title_label, GTK_STATE_NORMAL, &style->fg[GTK_STATE_SELECTED]);
1096 set_title_font (GtkWidget *assistant,
1097 GtkWidget *title_label)
1099 PangoFontDescription *desc;
1102 desc = pango_font_description_new ();
1103 size = pango_font_description_get_size (gtk_widget_get_style (assistant)->font_desc);
1105 pango_font_description_set_weight (desc, PANGO_WEIGHT_ULTRABOLD);
1106 pango_font_description_set_size (desc, size * PANGO_SCALE_XX_LARGE);
1108 gtk_widget_modify_font (title_label, desc);
1109 pango_font_description_free (desc);
1113 gtk_assistant_style_set (GtkWidget *widget,
1114 GtkStyle *old_style)
1116 GtkAssistant *assistant = GTK_ASSISTANT (widget);
1117 GtkAssistantPrivate *priv = assistant->priv;
1124 GtkAssistantPage *page = list->data;
1126 set_title_colors (widget, page->title);
1127 set_title_font (widget, page->title);
1134 gtk_assistant_size_request (GtkWidget *widget,
1135 GtkRequisition *requisition)
1137 GtkAssistant *assistant = GTK_ASSISTANT (widget);
1138 GtkAssistantPrivate *priv = assistant->priv;
1139 GtkRequisition child_requisition;
1140 gint header_padding, content_padding;
1141 gint width, height, header_width, header_height;
1145 gtk_widget_style_get (widget,
1146 "header-padding", &header_padding,
1147 "content-padding", &content_padding,
1150 header_width = header_height = 0;
1155 GtkAssistantPage *page = list->data;
1158 gtk_widget_get_preferred_size (page->page,
1159 &child_requisition, NULL);
1160 width = MAX (width, child_requisition.width);
1161 height = MAX (height, child_requisition.height);
1163 gtk_widget_get_preferred_size (page->title,
1164 &child_requisition, NULL);
1165 w = child_requisition.width;
1166 h = child_requisition.height;
1168 if (page->header_image)
1170 w += gdk_pixbuf_get_width (page->header_image) + HEADER_SPACING;
1171 h = MAX (h, gdk_pixbuf_get_height (page->header_image));
1174 header_width = MAX (header_width, w);
1175 header_height = MAX (header_height, h);
1180 gtk_widget_get_preferred_size (priv->sidebar_image,
1181 &child_requisition, NULL);
1182 width += child_requisition.width;
1183 height = MAX (height, child_requisition.height);
1185 gtk_widget_set_size_request (priv->header_image, header_width, header_height);
1186 gtk_widget_get_preferred_size (priv->header_image,
1187 &child_requisition, NULL);
1188 width = MAX (width, header_width) + 2 * header_padding;
1189 height += header_height + 2 * header_padding;
1191 gtk_widget_get_preferred_size (priv->action_area,
1192 &child_requisition, NULL);
1193 width = MAX (width, child_requisition.width);
1194 height += child_requisition.height + ACTION_AREA_SPACING;
1196 border_width = gtk_container_get_border_width (GTK_CONTAINER (widget));
1197 width += border_width * 2 + content_padding * 2;
1198 height += border_width * 2 + content_padding * 2;
1200 requisition->width = width;
1201 requisition->height = height;
1205 gtk_assistant_get_preferred_width (GtkWidget *widget,
1209 GtkRequisition requisition;
1211 gtk_assistant_size_request (widget, &requisition);
1213 *minimum = *natural = requisition.width;
1217 gtk_assistant_get_preferred_height (GtkWidget *widget,
1221 GtkRequisition requisition;
1223 gtk_assistant_size_request (widget, &requisition);
1225 *minimum = *natural = requisition.height;
1229 gtk_assistant_size_allocate (GtkWidget *widget,
1230 GtkAllocation *allocation)
1232 GtkAssistant *assistant = GTK_ASSISTANT (widget);
1233 GtkAssistantPrivate *priv = assistant->priv;
1234 GtkRequisition header_requisition, action_requisition, sidebar_requisition;
1235 GtkAllocation child_allocation, header_allocation;
1236 GtkAllocation action_area_allocation, header_image_allocation;
1237 gint header_padding, content_padding;
1242 rtl = (gtk_widget_get_direction (widget) == GTK_TEXT_DIR_RTL);
1243 pages = priv->pages;
1245 gtk_widget_style_get (widget,
1246 "header-padding", &header_padding,
1247 "content-padding", &content_padding,
1250 gtk_widget_set_allocation (widget, allocation);
1251 border_width = gtk_container_get_border_width (GTK_CONTAINER (widget));
1254 gtk_widget_get_preferred_size (priv->header_image,
1255 &header_requisition, NULL);
1257 header_allocation.x = border_width + header_padding;
1258 header_allocation.y = border_width + header_padding;
1259 header_allocation.width = allocation->width - 2 * border_width - 2 * header_padding;
1260 header_allocation.height = header_requisition.height;
1262 gtk_widget_size_allocate (priv->header_image, &header_allocation);
1265 gtk_widget_get_preferred_size (priv->action_area,
1266 &action_requisition, NULL);
1268 child_allocation.x = border_width;
1269 child_allocation.y = allocation->height - border_width - action_requisition.height;
1270 child_allocation.width = allocation->width - 2 * border_width;
1271 child_allocation.height = action_requisition.height;
1273 gtk_widget_size_allocate (priv->action_area, &child_allocation);
1275 gtk_widget_get_allocation (priv->header_image, &header_image_allocation);
1276 gtk_widget_get_allocation (priv->action_area, &action_area_allocation);
1279 gtk_widget_get_preferred_size (priv->sidebar_image,
1280 &sidebar_requisition, NULL);
1283 child_allocation.x = allocation->width - border_width - sidebar_requisition.width;
1285 child_allocation.x = border_width;
1287 child_allocation.y = border_width + header_image_allocation.height + 2 * header_padding;
1288 child_allocation.width = sidebar_requisition.width;
1289 child_allocation.height = allocation->height - 2 * border_width -
1290 header_image_allocation.height - 2 * header_padding - action_area_allocation.height;
1292 gtk_widget_size_allocate (priv->sidebar_image, &child_allocation);
1295 child_allocation.x = border_width + content_padding;
1296 child_allocation.y = border_width +
1297 header_image_allocation.height + 2 * header_padding + content_padding;
1298 child_allocation.width = allocation->width - 2 * border_width - 2 * content_padding;
1299 child_allocation.height = allocation->height - 2 * border_width -
1300 header_image_allocation.height - 2 * header_padding - ACTION_AREA_SPACING - action_area_allocation.height - 2 * content_padding;
1302 if (gtk_widget_get_visible (priv->sidebar_image))
1304 GtkAllocation sidebar_image_allocation;
1306 gtk_widget_get_allocation (priv->sidebar_image, &sidebar_image_allocation);
1309 child_allocation.x += sidebar_image_allocation.width;
1311 child_allocation.width -= sidebar_image_allocation.width;
1316 GtkAssistantPage *page = pages->data;
1318 gtk_widget_size_allocate (page->page, &child_allocation);
1319 gtk_widget_size_allocate (page->title, &header_allocation);
1320 pages = pages->next;
1325 gtk_assistant_map (GtkWidget *widget)
1327 GtkAssistant *assistant = GTK_ASSISTANT (widget);
1328 GtkAssistantPrivate *priv = assistant->priv;
1330 GtkAssistantPage *page;
1332 gtk_widget_set_mapped (widget, TRUE);
1334 gtk_widget_map (priv->header_image);
1335 gtk_widget_map (priv->action_area);
1337 if (gtk_widget_get_visible (priv->sidebar_image) &&
1338 !gtk_widget_get_mapped (priv->sidebar_image))
1339 gtk_widget_map (priv->sidebar_image);
1341 /* if there's no default page, pick the first one */
1343 if (!priv->current_page)
1345 page_node = priv->pages;
1347 while (page_node && !gtk_widget_get_visible (((GtkAssistantPage *) page_node->data)->page))
1348 page_node = page_node->next;
1351 page = page_node->data;
1355 gtk_widget_get_visible (page->page) &&
1356 !gtk_widget_get_mapped (page->page))
1357 set_current_page (assistant, page);
1359 GTK_WIDGET_CLASS (gtk_assistant_parent_class)->map (widget);
1363 gtk_assistant_unmap (GtkWidget *widget)
1365 GtkAssistant *assistant = GTK_ASSISTANT (widget);
1366 GtkAssistantPrivate *priv = assistant->priv;
1368 gtk_widget_set_mapped (widget, FALSE);
1370 gtk_widget_unmap (priv->header_image);
1371 gtk_widget_unmap (priv->action_area);
1373 if (gtk_widget_is_drawable (priv->sidebar_image))
1374 gtk_widget_unmap (priv->sidebar_image);
1376 if (priv->current_page &&
1377 gtk_widget_is_drawable (priv->current_page->page))
1378 gtk_widget_unmap (priv->current_page->page);
1380 g_slist_free (priv->visited_pages);
1381 priv->visited_pages = NULL;
1382 priv->current_page = NULL;
1384 GTK_WIDGET_CLASS (gtk_assistant_parent_class)->unmap (widget);
1388 gtk_assistant_delete_event (GtkWidget *widget,
1391 GtkAssistant *assistant = GTK_ASSISTANT (widget);
1392 GtkAssistantPrivate *priv = assistant->priv;
1394 /* Do not allow cancelling in the middle of a progress page */
1395 if (priv->current_page &&
1396 (priv->current_page->type != GTK_ASSISTANT_PAGE_PROGRESS ||
1397 priv->current_page->complete))
1398 g_signal_emit (widget, signals [CANCEL], 0, NULL);
1404 assistant_paint_colored_box (GtkWidget *widget,
1407 GtkAssistant *assistant = GTK_ASSISTANT (widget);
1408 GtkAssistantPrivate *priv = assistant->priv;
1409 GtkAllocation allocation, action_area_allocation, header_image_allocation;
1411 gint border_width, header_padding, content_padding;
1412 gint content_x, content_width;
1415 rtl = (gtk_widget_get_direction (widget) == GTK_TEXT_DIR_RTL);
1416 border_width = gtk_container_get_border_width (GTK_CONTAINER (widget));
1418 gtk_widget_style_get (widget,
1419 "header-padding", &header_padding,
1420 "content-padding", &content_padding,
1423 style = gtk_widget_get_style (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 gdk_cairo_set_source_color (cr, &style->bg[GTK_STATE_SELECTED]);
1430 cairo_rectangle (cr,
1433 allocation.width - 2 * border_width,
1434 allocation.height - action_area_allocation.height - 2 * border_width - ACTION_AREA_SPACING);
1438 content_x = content_padding + border_width;
1439 content_width = allocation.width - 2 * content_padding - 2 * border_width;
1441 if (gtk_widget_get_visible (priv->sidebar_image))
1443 GtkAllocation sidebar_image_allocation;
1445 gtk_widget_get_allocation (priv->sidebar_image, &sidebar_image_allocation);
1448 content_x += sidebar_image_allocation.width;
1449 content_width -= sidebar_image_allocation.width;
1452 gdk_cairo_set_source_color (cr, &style->bg[GTK_STATE_NORMAL]);
1454 cairo_rectangle (cr,
1456 header_image_allocation.height + content_padding + 2 * header_padding + border_width,
1458 allocation.height - 2 * border_width - action_area_allocation.height -
1459 header_image_allocation.height - 2 * content_padding - 2 * header_padding - ACTION_AREA_SPACING);
1464 gtk_assistant_draw (GtkWidget *widget,
1467 GtkAssistant *assistant = GTK_ASSISTANT (widget);
1468 GtkAssistantPrivate *priv = assistant->priv;
1469 GtkContainer *container = GTK_CONTAINER (widget);
1471 if (GTK_WIDGET_CLASS (gtk_assistant_parent_class)->draw)
1472 GTK_WIDGET_CLASS (gtk_assistant_parent_class)->draw (widget, cr);
1474 assistant_paint_colored_box (widget, cr);
1476 gtk_container_propagate_draw (container, priv->header_image, cr);
1477 gtk_container_propagate_draw (container, priv->sidebar_image, cr);
1478 gtk_container_propagate_draw (container, priv->action_area, cr);
1480 if (priv->current_page)
1482 gtk_container_propagate_draw (container, priv->current_page->page, cr);
1483 gtk_container_propagate_draw (container, priv->current_page->title, cr);
1490 gtk_assistant_focus (GtkWidget *widget,
1491 GtkDirectionType direction)
1493 GtkAssistantPrivate *priv;
1494 GtkContainer *container;
1496 container = GTK_CONTAINER (widget);
1497 priv = GTK_ASSISTANT (widget)->priv;
1499 /* we only have to care about 2 widgets, action area and the current page */
1500 if (gtk_container_get_focus_child (container) == priv->action_area)
1502 if (!gtk_widget_child_focus (priv->action_area, direction) &&
1503 (priv->current_page == NULL ||
1504 !gtk_widget_child_focus (priv->current_page->page, direction)))
1506 /* if we're leaving the action area and the current page hasn't
1507 any focusable widget, clear focus and go back to the action area */
1508 gtk_container_set_focus_child (GTK_CONTAINER (priv->action_area), NULL);
1509 gtk_widget_child_focus (priv->action_area, direction);
1514 if ((priv->current_page == NULL ||
1515 !gtk_widget_child_focus (priv->current_page->page, direction)) &&
1516 !gtk_widget_child_focus (priv->action_area, direction))
1518 /* if we're leaving the current page and there isn't nothing focusable
1519 in the action area, try to clear focus and go back to the page */
1520 gtk_window_set_focus (GTK_WINDOW (widget), NULL);
1521 if (priv->current_page != NULL)
1522 gtk_widget_child_focus (priv->current_page->page, direction);
1530 gtk_assistant_add (GtkContainer *container,
1533 gtk_assistant_append_page (GTK_ASSISTANT (container), page);
1537 gtk_assistant_remove (GtkContainer *container,
1540 GtkAssistant *assistant = (GtkAssistant*) container;
1543 element = find_page (assistant, page);
1547 remove_page (assistant, element);
1548 gtk_widget_queue_resize ((GtkWidget *) container);
1553 gtk_assistant_forall (GtkContainer *container,
1554 gboolean include_internals,
1555 GtkCallback callback,
1556 gpointer callback_data)
1558 GtkAssistant *assistant = (GtkAssistant*) container;
1559 GtkAssistantPrivate *priv = assistant->priv;
1562 if (include_internals)
1564 (*callback) (priv->header_image, callback_data);
1565 (*callback) (priv->sidebar_image, callback_data);
1566 (*callback) (priv->action_area, callback_data);
1569 pages = priv->pages;
1573 GtkAssistantPage *page = (GtkAssistantPage *) pages->data;
1575 (*callback) (page->page, callback_data);
1577 if (include_internals)
1578 (*callback) (page->title, callback_data);
1580 pages = pages->next;
1585 * gtk_assistant_new:
1587 * Creates a new #GtkAssistant.
1589 * Return value: a newly created #GtkAssistant
1594 gtk_assistant_new (void)
1596 GtkWidget *assistant;
1598 assistant = g_object_new (GTK_TYPE_ASSISTANT, NULL);
1604 * gtk_assistant_get_current_page:
1605 * @assistant: a #GtkAssistant
1607 * Returns the page number of the current page
1609 * Return value: The index (starting from 0) of the current page in
1610 * the @assistant, if the @assistant has no pages, -1 will be returned
1615 gtk_assistant_get_current_page (GtkAssistant *assistant)
1617 GtkAssistantPrivate *priv;
1619 g_return_val_if_fail (GTK_IS_ASSISTANT (assistant), -1);
1621 priv = assistant->priv;
1623 if (!priv->pages || !priv->current_page)
1626 return g_list_index (priv->pages, priv->current_page);
1630 * gtk_assistant_set_current_page:
1631 * @assistant: a #GtkAssistant
1632 * @page_num: index of the page to switch to, starting from 0.
1633 * If negative, the last page will be used. If greater
1634 * than the number of pages in the @assistant, nothing
1637 * Switches the page to @page_num. Note that this will only be necessary
1638 * in custom buttons, as the @assistant flow can be set with
1639 * gtk_assistant_set_forward_page_func().
1644 gtk_assistant_set_current_page (GtkAssistant *assistant,
1647 GtkAssistantPrivate *priv;
1648 GtkAssistantPage *page;
1650 g_return_if_fail (GTK_IS_ASSISTANT (assistant));
1652 priv = assistant->priv;
1655 page = (GtkAssistantPage *) g_list_nth_data (priv->pages, page_num);
1657 page = (GtkAssistantPage *) g_list_last (priv->pages)->data;
1659 g_return_if_fail (page != NULL);
1661 if (priv->current_page == page)
1664 /* only add the page to the visited list if the
1665 * assistant is mapped, if not, just use it as an
1666 * initial page setting, for the cases where the
1667 * initial page is != to 0
1669 if (gtk_widget_get_mapped (GTK_WIDGET (assistant)))
1670 priv->visited_pages = g_slist_prepend (priv->visited_pages,
1671 priv->current_page);
1673 set_current_page (assistant, page);
1677 * gtk_assistant_next_page:
1678 * @assistant: a #GtkAssistant
1680 * Navigate to the next page. It is a programming
1681 * error to call this function if there is no next page.
1683 * This function is for use when creating pages of the
1684 * #GTK_ASSISTANT_PAGE_CUSTOM type.
1689 gtk_assistant_next_page (GtkAssistant *assistant)
1691 GtkAssistantPrivate *priv;
1693 g_return_if_fail (GTK_IS_ASSISTANT (assistant));
1695 priv = assistant->priv;
1697 if (!compute_next_step (assistant))
1698 g_critical ("Page flow is broken, you may want to end it with a page of "
1699 "type GTK_ASSISTANT_PAGE_CONFIRM or GTK_ASSISTANT_PAGE_SUMMARY");
1703 * gtk_assistant_previous_page:
1704 * @assistant: a #GtkAssistant
1706 * Navigate to the previous visited page. It is a programming
1707 * error to call this function if no previous page is
1710 * This function is for use when creating pages of the
1711 * #GTK_ASSISTANT_PAGE_CUSTOM type.
1716 gtk_assistant_previous_page (GtkAssistant *assistant)
1718 GtkAssistantPrivate *priv;
1719 GtkAssistantPage *page_info;
1722 g_return_if_fail (GTK_IS_ASSISTANT (assistant));
1724 priv = assistant->priv;
1726 /* skip the progress pages when going back */
1729 page_node = priv->visited_pages;
1731 g_return_if_fail (page_node != NULL);
1733 priv->visited_pages = priv->visited_pages->next;
1734 page_info = (GtkAssistantPage *) page_node->data;
1735 g_slist_free_1 (page_node);
1737 while (page_info->type == GTK_ASSISTANT_PAGE_PROGRESS ||
1738 !gtk_widget_get_visible (page_info->page));
1740 set_current_page (assistant, page_info);
1744 * gtk_assistant_get_n_pages:
1745 * @assistant: a #GtkAssistant
1747 * Returns the number of pages in the @assistant
1749 * Return value: The number of pages in the @assistant.
1754 gtk_assistant_get_n_pages (GtkAssistant *assistant)
1756 GtkAssistantPrivate *priv;
1758 g_return_val_if_fail (GTK_IS_ASSISTANT (assistant), 0);
1760 priv = assistant->priv;
1762 return g_list_length (priv->pages);
1766 * gtk_assistant_get_nth_page:
1767 * @assistant: a #GtkAssistant
1768 * @page_num: The index of a page in the @assistant, or -1 to get the last page;
1770 * Returns the child widget contained in page number @page_num.
1772 * Return value: (transfer none): The child widget, or %NULL
1773 * if @page_num is out of bounds.
1778 gtk_assistant_get_nth_page (GtkAssistant *assistant,
1781 GtkAssistantPrivate *priv;
1782 GtkAssistantPage *page;
1785 g_return_val_if_fail (GTK_IS_ASSISTANT (assistant), NULL);
1786 g_return_val_if_fail (page_num >= -1, NULL);
1788 priv = assistant->priv;
1791 elem = g_list_last (priv->pages);
1793 elem = g_list_nth (priv->pages, page_num);
1798 page = (GtkAssistantPage *) elem->data;
1804 * gtk_assistant_prepend_page:
1805 * @assistant: a #GtkAssistant
1806 * @page: a #GtkWidget
1808 * Prepends a page to the @assistant.
1810 * Return value: the index (starting at 0) of the inserted page
1815 gtk_assistant_prepend_page (GtkAssistant *assistant,
1818 g_return_val_if_fail (GTK_IS_ASSISTANT (assistant), 0);
1819 g_return_val_if_fail (GTK_IS_WIDGET (page), 0);
1821 return gtk_assistant_insert_page (assistant, page, 0);
1825 * gtk_assistant_append_page:
1826 * @assistant: a #GtkAssistant
1827 * @page: a #GtkWidget
1829 * Appends a page to the @assistant.
1831 * Return value: the index (starting at 0) of the inserted page
1836 gtk_assistant_append_page (GtkAssistant *assistant,
1839 g_return_val_if_fail (GTK_IS_ASSISTANT (assistant), 0);
1840 g_return_val_if_fail (GTK_IS_WIDGET (page), 0);
1842 return gtk_assistant_insert_page (assistant, page, -1);
1846 * gtk_assistant_insert_page:
1847 * @assistant: a #GtkAssistant
1848 * @page: a #GtkWidget
1849 * @position: the index (starting at 0) at which to insert the page,
1850 * or -1 to append the page to the @assistant
1852 * Inserts a page in the @assistant at a given position.
1854 * Return value: the index (starting from 0) of the inserted page
1859 gtk_assistant_insert_page (GtkAssistant *assistant,
1863 GtkAssistantPrivate *priv;
1864 GtkAssistantPage *page_info;
1867 g_return_val_if_fail (GTK_IS_ASSISTANT (assistant), 0);
1868 g_return_val_if_fail (GTK_IS_WIDGET (page), 0);
1869 g_return_val_if_fail (gtk_widget_get_parent (page) == NULL, 0);
1870 g_return_val_if_fail (!gtk_widget_is_toplevel (page), 0);
1872 priv = assistant->priv;
1874 page_info = g_slice_new0 (GtkAssistantPage);
1875 page_info->page = page;
1876 page_info->title = gtk_label_new (NULL);
1878 g_signal_connect (G_OBJECT (page), "notify::visible",
1879 G_CALLBACK (on_page_notify_visibility), assistant);
1881 gtk_misc_set_alignment (GTK_MISC (page_info->title), 0.,0.5);
1882 set_title_colors (GTK_WIDGET (assistant), page_info->title);
1883 set_title_font (GTK_WIDGET (assistant), page_info->title);
1884 gtk_widget_show (page_info->title);
1886 n_pages = g_list_length (priv->pages);
1888 if (position < 0 || position > n_pages)
1891 priv->pages = g_list_insert (priv->pages, page_info, position);
1893 gtk_widget_set_child_visible (page_info->page, FALSE);
1894 gtk_widget_set_parent (page_info->page, GTK_WIDGET (assistant));
1895 gtk_widget_set_parent (page_info->title, GTK_WIDGET (assistant));
1897 if (gtk_widget_get_realized (GTK_WIDGET (assistant)))
1899 gtk_widget_realize (page_info->page);
1900 gtk_widget_realize (page_info->title);
1903 gtk_widget_queue_resize (GTK_WIDGET (assistant));
1909 * gtk_assistant_set_forward_page_func:
1910 * @assistant: a #GtkAssistant
1911 * @page_func: (allow-none): the #GtkAssistantPageFunc, or %NULL to use the default one
1912 * @data: user data for @page_func
1913 * @destroy: destroy notifier for @data
1915 * Sets the page forwarding function to be @page_func, this function will
1916 * be used to determine what will be the next page when the user presses
1917 * the forward button. Setting @page_func to %NULL will make the assistant
1918 * to use the default forward function, which just goes to the next visible
1924 gtk_assistant_set_forward_page_func (GtkAssistant *assistant,
1925 GtkAssistantPageFunc page_func,
1927 GDestroyNotify destroy)
1929 GtkAssistantPrivate *priv;
1931 g_return_if_fail (GTK_IS_ASSISTANT (assistant));
1933 priv = assistant->priv;
1935 if (priv->forward_data_destroy &&
1936 priv->forward_function_data)
1937 (*priv->forward_data_destroy) (priv->forward_function_data);
1941 priv->forward_function = page_func;
1942 priv->forward_function_data = data;
1943 priv->forward_data_destroy = destroy;
1947 priv->forward_function = default_forward_function;
1948 priv->forward_function_data = assistant;
1949 priv->forward_data_destroy = NULL;
1952 /* Page flow has possibly changed, so the
1953 buttons state might need to change too */
1954 set_assistant_buttons_state (assistant);
1958 * gtk_assistant_add_action_widget:
1959 * @assistant: a #GtkAssistant
1960 * @child: a #GtkWidget
1962 * Adds a widget to the action area of a #GtkAssistant.
1967 gtk_assistant_add_action_widget (GtkAssistant *assistant,
1970 GtkAssistantPrivate *priv;
1972 g_return_if_fail (GTK_IS_ASSISTANT (assistant));
1973 g_return_if_fail (GTK_IS_WIDGET (child));
1975 priv = assistant->priv;
1977 if (GTK_IS_BUTTON (child))
1978 gtk_size_group_add_widget (priv->size_group, child);
1980 gtk_box_pack_end (GTK_BOX (priv->action_area), child, FALSE, FALSE, 0);
1984 * gtk_assistant_remove_action_widget:
1985 * @assistant: a #GtkAssistant
1986 * @child: a #GtkWidget
1988 * Removes a widget from the action area of a #GtkAssistant.
1993 gtk_assistant_remove_action_widget (GtkAssistant *assistant,
1996 GtkAssistantPrivate *priv;
1998 g_return_if_fail (GTK_IS_ASSISTANT (assistant));
1999 g_return_if_fail (GTK_IS_WIDGET (child));
2001 priv = assistant->priv;
2003 if (GTK_IS_BUTTON (child))
2004 gtk_size_group_remove_widget (priv->size_group, child);
2006 gtk_container_remove (GTK_CONTAINER (priv->action_area), child);
2010 * gtk_assistant_set_page_title:
2011 * @assistant: a #GtkAssistant
2012 * @page: a page of @assistant
2013 * @title: the new title for @page
2015 * Sets a title for @page. The title is displayed in the header
2016 * area of the assistant when @page is the current page.
2021 gtk_assistant_set_page_title (GtkAssistant *assistant,
2025 GtkAssistantPage *page_info;
2028 g_return_if_fail (GTK_IS_ASSISTANT (assistant));
2029 g_return_if_fail (GTK_IS_WIDGET (page));
2031 child = find_page (assistant, page);
2033 g_return_if_fail (child != NULL);
2035 page_info = (GtkAssistantPage*) child->data;
2037 gtk_label_set_text ((GtkLabel*) page_info->title, title);
2038 gtk_widget_queue_resize (GTK_WIDGET (assistant));
2039 gtk_widget_child_notify (page, "title");
2043 * gtk_assistant_get_page_title:
2044 * @assistant: a #GtkAssistant
2045 * @page: a page of @assistant
2047 * Gets the title for @page.
2049 * Return value: the title for @page.
2053 G_CONST_RETURN gchar*
2054 gtk_assistant_get_page_title (GtkAssistant *assistant,
2057 GtkAssistantPage *page_info;
2060 g_return_val_if_fail (GTK_IS_ASSISTANT (assistant), NULL);
2061 g_return_val_if_fail (GTK_IS_WIDGET (page), NULL);
2063 child = find_page (assistant, page);
2065 g_return_val_if_fail (child != NULL, NULL);
2067 page_info = (GtkAssistantPage*) child->data;
2069 return gtk_label_get_text ((GtkLabel*) page_info->title);
2073 * gtk_assistant_set_page_type:
2074 * @assistant: a #GtkAssistant
2075 * @page: a page of @assistant
2076 * @type: the new type for @page
2078 * Sets the page type for @page. The page type determines the page
2079 * behavior in the @assistant.
2084 gtk_assistant_set_page_type (GtkAssistant *assistant,
2086 GtkAssistantPageType type)
2088 GtkAssistantPrivate *priv;
2089 GtkAssistantPage *page_info;
2092 g_return_if_fail (GTK_IS_ASSISTANT (assistant));
2093 g_return_if_fail (GTK_IS_WIDGET (page));
2095 priv = assistant->priv;
2096 child = find_page (assistant, page);
2098 g_return_if_fail (child != NULL);
2100 page_info = (GtkAssistantPage*) child->data;
2102 if (type != page_info->type)
2104 page_info->type = type;
2106 /* backwards compatibility to the era before fixing bug 604289 */
2107 if (type == GTK_ASSISTANT_PAGE_SUMMARY && !page_info->complete_set)
2109 gtk_assistant_set_page_complete (assistant, page, TRUE);
2110 page_info->complete_set = FALSE;
2113 /* Always set buttons state, a change in a future page
2114 might change current page buttons */
2115 set_assistant_buttons_state (assistant);
2117 gtk_widget_child_notify (page, "page-type");
2122 * gtk_assistant_get_page_type:
2123 * @assistant: a #GtkAssistant
2124 * @page: a page of @assistant
2126 * Gets the page type of @page.
2128 * Return value: the page type of @page.
2132 GtkAssistantPageType
2133 gtk_assistant_get_page_type (GtkAssistant *assistant,
2136 GtkAssistantPage *page_info;
2139 g_return_val_if_fail (GTK_IS_ASSISTANT (assistant), GTK_ASSISTANT_PAGE_CONTENT);
2140 g_return_val_if_fail (GTK_IS_WIDGET (page), GTK_ASSISTANT_PAGE_CONTENT);
2142 child = find_page (assistant, page);
2144 g_return_val_if_fail (child != NULL, GTK_ASSISTANT_PAGE_CONTENT);
2146 page_info = (GtkAssistantPage*) child->data;
2148 return page_info->type;
2152 * gtk_assistant_set_page_header_image:
2153 * @assistant: a #GtkAssistant
2154 * @page: a page of @assistant
2155 * @pixbuf: (allow-none): the new header image @page
2157 * Sets a header image for @page. This image is displayed in the header
2158 * area of the assistant when @page is the current page.
2163 gtk_assistant_set_page_header_image (GtkAssistant *assistant,
2167 GtkAssistantPrivate *priv;
2168 GtkAssistantPage *page_info;
2171 g_return_if_fail (GTK_IS_ASSISTANT (assistant));
2172 g_return_if_fail (GTK_IS_WIDGET (page));
2173 g_return_if_fail (pixbuf == NULL || GDK_IS_PIXBUF (pixbuf));
2175 priv = assistant->priv;
2176 child = find_page (assistant, page);
2178 g_return_if_fail (child != NULL);
2180 page_info = (GtkAssistantPage*) child->data;
2182 if (pixbuf != page_info->header_image)
2184 if (page_info->header_image)
2186 g_object_unref (page_info->header_image);
2187 page_info->header_image = NULL;
2191 page_info->header_image = g_object_ref (pixbuf);
2193 if (page_info == priv->current_page)
2194 set_assistant_header_image (assistant);
2196 gtk_widget_child_notify (page, "header-image");
2201 * gtk_assistant_get_page_header_image:
2202 * @assistant: a #GtkAssistant
2203 * @page: a page of @assistant
2205 * Gets the header image for @page.
2207 * Return value: (transfer none): the header image for @page, or %NULL
2208 * if there's no header image for the page.
2213 gtk_assistant_get_page_header_image (GtkAssistant *assistant,
2216 GtkAssistantPage *page_info;
2219 g_return_val_if_fail (GTK_IS_ASSISTANT (assistant), NULL);
2220 g_return_val_if_fail (GTK_IS_WIDGET (page), NULL);
2222 child = find_page (assistant, page);
2224 g_return_val_if_fail (child != NULL, NULL);
2226 page_info = (GtkAssistantPage*) child->data;
2228 return page_info->header_image;
2232 * gtk_assistant_set_page_side_image:
2233 * @assistant: a #GtkAssistant
2234 * @page: a page of @assistant
2235 * @pixbuf: (allow-none): the new header image @page
2237 * Sets a header image for @page. This image is displayed in the side
2238 * area of the assistant when @page is the current page.
2243 gtk_assistant_set_page_side_image (GtkAssistant *assistant,
2247 GtkAssistantPrivate *priv;
2248 GtkAssistantPage *page_info;
2251 g_return_if_fail (GTK_IS_ASSISTANT (assistant));
2252 g_return_if_fail (GTK_IS_WIDGET (page));
2253 g_return_if_fail (pixbuf == NULL || GDK_IS_PIXBUF (pixbuf));
2255 priv = assistant->priv;
2256 child = find_page (assistant, page);
2258 g_return_if_fail (child != NULL);
2260 page_info = (GtkAssistantPage*) child->data;
2262 if (pixbuf != page_info->sidebar_image)
2264 if (page_info->sidebar_image)
2266 g_object_unref (page_info->sidebar_image);
2267 page_info->sidebar_image = NULL;
2271 page_info->sidebar_image = g_object_ref (pixbuf);
2273 if (page_info == priv->current_page)
2274 set_assistant_sidebar_image (assistant);
2276 gtk_widget_child_notify (page, "sidebar-image");
2281 * gtk_assistant_get_page_side_image:
2282 * @assistant: a #GtkAssistant
2283 * @page: a page of @assistant
2285 * Gets the header image for @page.
2287 * Return value: (transfer none): the side image for @page, or %NULL
2288 * if there's no side image for the page.
2293 gtk_assistant_get_page_side_image (GtkAssistant *assistant,
2296 GtkAssistantPage *page_info;
2299 g_return_val_if_fail (GTK_IS_ASSISTANT (assistant), NULL);
2300 g_return_val_if_fail (GTK_IS_WIDGET (page), NULL);
2302 child = find_page (assistant, page);
2304 g_return_val_if_fail (child != NULL, NULL);
2306 page_info = (GtkAssistantPage*) child->data;
2308 return page_info->sidebar_image;
2312 * gtk_assistant_set_page_complete:
2313 * @assistant: a #GtkAssistant
2314 * @page: a page of @assistant
2315 * @complete: the completeness status of the page
2317 * Sets whether @page contents are complete. This will make
2318 * @assistant update the buttons state to be able to continue the task.
2323 gtk_assistant_set_page_complete (GtkAssistant *assistant,
2327 GtkAssistantPrivate *priv;
2328 GtkAssistantPage *page_info;
2331 g_return_if_fail (GTK_IS_ASSISTANT (assistant));
2332 g_return_if_fail (GTK_IS_WIDGET (page));
2334 priv = assistant->priv;
2335 child = find_page (assistant, page);
2337 g_return_if_fail (child != NULL);
2339 page_info = (GtkAssistantPage*) child->data;
2341 if (complete != page_info->complete)
2343 page_info->complete = complete;
2344 page_info->complete_set = TRUE;
2346 /* Always set buttons state, a change in a future page
2347 might change current page buttons */
2348 set_assistant_buttons_state (assistant);
2350 gtk_widget_child_notify (page, "complete");
2355 * gtk_assistant_get_page_complete:
2356 * @assistant: a #GtkAssistant
2357 * @page: a page of @assistant
2359 * Gets whether @page is complete.
2361 * Return value: %TRUE if @page is complete.
2366 gtk_assistant_get_page_complete (GtkAssistant *assistant,
2369 GtkAssistantPage *page_info;
2372 g_return_val_if_fail (GTK_IS_ASSISTANT (assistant), FALSE);
2373 g_return_val_if_fail (GTK_IS_WIDGET (page), FALSE);
2375 child = find_page (assistant, page);
2377 g_return_val_if_fail (child != NULL, FALSE);
2379 page_info = (GtkAssistantPage*) child->data;
2381 return page_info->complete;
2385 * gtk_assistant_update_buttons_state:
2386 * @assistant: a #GtkAssistant
2388 * Forces @assistant to recompute the buttons state.
2390 * GTK+ automatically takes care of this in most situations,
2391 * e.g. when the user goes to a different page, or when the
2392 * visibility or completeness of a page changes.
2394 * One situation where it can be necessary to call this
2395 * function is when changing a value on the current page
2396 * affects the future page flow of the assistant.
2401 gtk_assistant_update_buttons_state (GtkAssistant *assistant)
2403 g_return_if_fail (GTK_IS_ASSISTANT (assistant));
2405 set_assistant_buttons_state (assistant);
2409 * gtk_assistant_commit:
2410 * @assistant: a #GtkAssistant
2412 * Erases the visited page history so the back button is not
2413 * shown on the current page, and removes the cancel button
2414 * from subsequent pages.
2416 * Use this when the information provided up to the current
2417 * page is hereafter deemed permanent and cannot be modified
2418 * or undone. For example, showing a progress page to track
2419 * a long-running, unreversible operation after the user has
2420 * clicked apply on a confirmation page.
2425 gtk_assistant_commit (GtkAssistant *assistant)
2427 g_return_if_fail (GTK_IS_ASSISTANT (assistant));
2429 g_slist_free (assistant->priv->visited_pages);
2430 assistant->priv->visited_pages = NULL;
2432 assistant->priv->committed = TRUE;
2434 set_assistant_buttons_state (assistant);
2439 /* accessible implementation */
2442 gtk_assistant_accessible_get_n_children (AtkObject *accessible)
2444 GtkAssistant *assistant;
2447 widget = gtk_accessible_get_widget (GTK_ACCESSIBLE (accessible));
2452 assistant = GTK_ASSISTANT (widget);
2454 return g_list_length (assistant->priv->pages) + 1;
2459 gtk_assistant_accessible_ref_child (AtkObject *accessible,
2462 GtkAssistant *assistant;
2463 GtkAssistantPrivate *priv;
2464 GtkWidget *widget, *child;
2469 widget = gtk_accessible_get_widget (GTK_ACCESSIBLE (accessible));
2473 assistant = GTK_ASSISTANT (widget);
2474 priv = assistant->priv;
2475 n_pages = g_list_length (priv->pages);
2479 else if (index < n_pages)
2481 GtkAssistantPage *page = g_list_nth_data (priv->pages, index);
2484 title = gtk_assistant_get_page_title (assistant, child);
2486 else if (index == n_pages)
2488 child = priv->action_area;
2494 obj = gtk_widget_get_accessible (child);
2497 atk_object_set_name (obj, title);
2499 return g_object_ref (obj);
2503 gtk_assistant_accessible_class_init (AtkObjectClass *class)
2505 class->get_n_children = gtk_assistant_accessible_get_n_children;
2506 class->ref_child = gtk_assistant_accessible_ref_child;
2510 gtk_assistant_accessible_get_type (void)
2512 static GType type = 0;
2517 * Figure out the size of the class and instance
2518 * we are deriving from
2520 AtkObjectFactory *factory;
2523 GType derived_atk_type;
2525 derived_type = g_type_parent (GTK_TYPE_ASSISTANT);
2526 factory = atk_registry_get_factory (atk_get_default_registry (),
2528 derived_atk_type = atk_object_factory_get_accessible_type (factory);
2529 g_type_query (derived_atk_type, &query);
2531 type = g_type_register_static_simple (derived_atk_type,
2532 I_("GtkAssistantAccessible"),
2534 (GClassInitFunc) gtk_assistant_accessible_class_init,
2535 query.instance_size,
2543 gtk_assistant_accessible_new (GObject *obj)
2545 AtkObject *accessible;
2547 g_return_val_if_fail (GTK_IS_ASSISTANT (obj), NULL);
2549 accessible = g_object_new (gtk_assistant_accessible_get_type (), NULL);
2550 atk_object_initialize (accessible, obj);
2556 gtk_assistant_accessible_factory_get_accessible_type (void)
2558 return gtk_assistant_accessible_get_type ();
2562 gtk_assistant_accessible_factory_create_accessible (GObject *obj)
2564 return gtk_assistant_accessible_new (obj);
2568 gtk_assistant_accessible_factory_class_init (AtkObjectFactoryClass *class)
2570 class->create_accessible = gtk_assistant_accessible_factory_create_accessible;
2571 class->get_accessible_type = gtk_assistant_accessible_factory_get_accessible_type;
2575 gtk_assistant_accessible_factory_get_type (void)
2577 static GType type = 0;
2581 type = g_type_register_static_simple (ATK_TYPE_OBJECT_FACTORY,
2582 I_("GtkAssistantAccessibleFactory"),
2583 sizeof (AtkObjectFactoryClass),
2584 (GClassInitFunc) gtk_assistant_accessible_factory_class_init,
2585 sizeof (AtkObjectFactory),
2593 gtk_assistant_get_accessible (GtkWidget *widget)
2595 static gboolean first_time = TRUE;
2599 AtkObjectFactory *factory;
2600 AtkRegistry *registry;
2602 GType derived_atk_type;
2605 * Figure out whether accessibility is enabled by looking at the
2606 * type of the accessible object which would be created for
2607 * the parent type of GtkAssistant.
2609 derived_type = g_type_parent (GTK_TYPE_ASSISTANT);
2611 registry = atk_get_default_registry ();
2612 factory = atk_registry_get_factory (registry,
2614 derived_atk_type = atk_object_factory_get_accessible_type (factory);
2615 if (g_type_is_a (derived_atk_type, GTK_TYPE_ACCESSIBLE))
2617 atk_registry_set_factory_type (registry,
2619 gtk_assistant_accessible_factory_get_type ());
2624 return GTK_WIDGET_CLASS (gtk_assistant_parent_class)->get_accessible (widget);
2628 static GtkBuildableIface *parent_buildable_iface;
2631 gtk_assistant_buildable_interface_init (GtkBuildableIface *iface)
2633 parent_buildable_iface = g_type_interface_peek_parent (iface);
2634 iface->get_internal_child = gtk_assistant_buildable_get_internal_child;
2635 iface->custom_tag_start = gtk_assistant_buildable_custom_tag_start;
2636 iface->custom_finished = gtk_assistant_buildable_custom_finished;
2640 gtk_assistant_buildable_get_internal_child (GtkBuildable *buildable,
2641 GtkBuilder *builder,
2642 const gchar *childname)
2644 if (strcmp (childname, "action_area") == 0)
2645 return G_OBJECT (GTK_ASSISTANT (buildable)->priv->action_area);
2647 return parent_buildable_iface->get_internal_child (buildable,
2653 gtk_assistant_buildable_custom_tag_start (GtkBuildable *buildable,
2654 GtkBuilder *builder,
2656 const gchar *tagname,
2657 GMarkupParser *parser,
2660 return parent_buildable_iface->custom_tag_start (buildable, builder, child,
2661 tagname, parser, data);
2665 gtk_assistant_buildable_custom_finished (GtkBuildable *buildable,
2666 GtkBuilder *builder,
2668 const gchar *tagname,
2671 parent_buildable_iface->custom_finished (buildable, builder, child,
2672 tagname, user_data);