]> Pileus Git - ~andy/gtk/blobdiff - gtk/gtkassistant.c
gtk: remove "gboolean homogeneous" from gtk_box_new()
[~andy/gtk] / gtk / gtkassistant.c
index 69e573c385134ae06126e4353607194380634162..4374f1f5bc087f2414f5658c45e61727b5c1d709 100644 (file)
  * Boston, MA 02111-1307, USA.
  */
 
+/**
+ * SECTION:gtkassistant
+ * @Short_description: A widget used to guide users through multi-step operations
+ * @Title: GtkAssistant
+ *
+ * A #GtkAssistant is a widget used to represent a generally complex
+ * operation splitted in several steps, guiding the user through its pages
+ * and controlling the page flow to collect the necessary data.
+ *
+ * The design of GtkAssistant is that it controls what buttons to show and
+ * to make sensitive, based on what it knows about the page sequence and
+ * the <link linkend="GtkAssistantPageType">type</link> of each page, in
+ * addition to state information like the page
+ * <link linkend="gtk-assistant-set-page-complete">completion</link> and
+ * <link linkend="gtk-assistant-commit">committed</link> status.
+ *
+ * <refsect2 id="GtkAssistant-BUILDER-UI">
+ * <title>GtkAssistant as GtkBuildable</title>
+ * <para>
+ * The GtkAssistant implementation of the GtkBuildable interface exposes the
+ * @action_area as internal children with the name "action_area".
+ *
+ * To add pages to an assistant in GtkBuilder, simply add it as a
+ * &lt;child&gt; to the GtkAssistant object, and set its child properties
+ * as necessary.
+ * </para>
+ * </refsect2>
+ */
+
 #include "config.h"
 
 #include <atk/atk.h>
 #include "gtkimage.h"
 #include "gtklabel.h"
 #include "gtksizegroup.h"
+#include "gtksizerequest.h"
 #include "gtkstock.h"
 
 #include "gtkintl.h"
 #include "gtkprivate.h"
 #include "gtkbuildable.h"
 
-#include "gtkalias.h"
-
-#define GTK_ASSISTANT_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), GTK_TYPE_ASSISTANT, GtkAssistantPrivate))
 
 #define HEADER_SPACING 12
 #define ACTION_AREA_SPACING 12
@@ -65,6 +92,13 @@ struct _GtkAssistantPage
 
 struct _GtkAssistantPrivate
 {
+  GtkWidget *cancel;
+  GtkWidget *forward;
+  GtkWidget *back;
+  GtkWidget *apply;
+  GtkWidget *close;
+  GtkWidget *last;
+
   GtkWidget *header_image;
   GtkWidget *sidebar_image;
 
@@ -81,23 +115,29 @@ struct _GtkAssistantPrivate
   GtkAssistantPageFunc forward_function;
   gpointer forward_function_data;
   GDestroyNotify forward_data_destroy;
+
+  guint committed : 1;
 };
 
 static void     gtk_assistant_class_init         (GtkAssistantClass *class);
 static void     gtk_assistant_init               (GtkAssistant      *assistant);
-static void     gtk_assistant_destroy            (GtkObject         *object);
+static void     gtk_assistant_destroy            (GtkWidget         *widget);
 static void     gtk_assistant_style_set          (GtkWidget         *widget,
                                                  GtkStyle          *old_style);
-static void     gtk_assistant_size_request       (GtkWidget         *widget,
-                                                 GtkRequisition    *requisition);
+static void     gtk_assistant_get_preferred_width  (GtkWidget        *widget,
+                                                    gint             *minimum,
+                                                    gint             *natural);
+static void     gtk_assistant_get_preferred_height (GtkWidget        *widget,
+                                                    gint             *minimum,
+                                                    gint             *natural);
 static void     gtk_assistant_size_allocate      (GtkWidget         *widget,
                                                  GtkAllocation     *allocation);
 static void     gtk_assistant_map                (GtkWidget         *widget);
 static void     gtk_assistant_unmap              (GtkWidget         *widget);
 static gboolean gtk_assistant_delete_event       (GtkWidget         *widget,
                                                  GdkEventAny       *event);
-static gboolean gtk_assistant_expose             (GtkWidget         *widget,
-                                                 GdkEventExpose    *event);
+static gboolean gtk_assistant_draw               (GtkWidget         *widget,
+                                                 cairo_t           *cr);
 static gboolean gtk_assistant_focus              (GtkWidget         *widget,
                                                  GtkDirectionType   direction);
 static void     gtk_assistant_add                (GtkContainer      *container,
@@ -171,24 +211,22 @@ static void
 gtk_assistant_class_init (GtkAssistantClass *class)
 {
   GObjectClass *gobject_class;
-  GtkObjectClass *object_class;
   GtkWidgetClass *widget_class;
   GtkContainerClass *container_class;
 
   gobject_class   = (GObjectClass *) class;
-  object_class    = (GtkObjectClass *) class;
   widget_class    = (GtkWidgetClass *) class;
   container_class = (GtkContainerClass *) class;
 
-  object_class->destroy = gtk_assistant_destroy;
-
+  widget_class->destroy = gtk_assistant_destroy;
   widget_class->style_set = gtk_assistant_style_set;
-  widget_class->size_request = gtk_assistant_size_request;
+  widget_class->get_preferred_width = gtk_assistant_get_preferred_width;
+  widget_class->get_preferred_height = gtk_assistant_get_preferred_height;
   widget_class->size_allocate = gtk_assistant_size_allocate;
   widget_class->map = gtk_assistant_map;
   widget_class->unmap = gtk_assistant_unmap;
   widget_class->delete_event = gtk_assistant_delete_event;
-  widget_class->expose_event = gtk_assistant_expose;
+  widget_class->draw = gtk_assistant_draw;
   widget_class->focus = gtk_assistant_focus;
   widget_class->get_accessible = gtk_assistant_get_accessible;
 
@@ -237,7 +275,7 @@ gtk_assistant_class_init (GtkAssistantClass *class)
 
   /**
    * GtkAssistant::apply:
-   * @assistant: the @GtkAssistant
+   * @assistant: the #GtkAssistant
    *
    * The ::apply signal is emitted when the apply button is clicked. The default
    * behavior of the #GtkAssistant is to switch to the page after the current
@@ -245,7 +283,7 @@ gtk_assistant_class_init (GtkAssistantClass *class)
    *
    * A handler for the ::apply signal should carry out the actions for which
    * the wizard has collected data. If the action takes a long time to complete,
-   * you might consider to put a page of type %GTK_ASSISTANT_PAGE_PROGRESS
+   * you might consider putting a page of type %GTK_ASSISTANT_PAGE_PROGRESS
    * after the confirmation page and handle this operation within the
    * #GtkAssistant::prepare signal of the progress page.
    *
@@ -442,12 +480,29 @@ compute_last_button_state (GtkAssistant *assistant)
       (page_info->type == GTK_ASSISTANT_PAGE_CONFIRM ||
        page_info->type == GTK_ASSISTANT_PAGE_SUMMARY))
     {
-      gtk_widget_show (assistant->last);
-      gtk_widget_set_sensitive (assistant->last,
+      gtk_widget_show (priv->last);
+      gtk_widget_set_sensitive (priv->last,
                                current_page_info->complete);
     }
   else
-    gtk_widget_hide (assistant->last);
+    gtk_widget_hide (priv->last);
+}
+
+static void
+compute_progress_state (GtkAssistant *assistant)
+{
+  GtkAssistantPrivate *priv = assistant->priv;
+  gint page_num, n_pages;
+
+  n_pages = gtk_assistant_get_n_pages (assistant);
+  page_num = gtk_assistant_get_current_page (assistant);
+
+  page_num = (priv->forward_function) (page_num, priv->forward_function_data);
+
+  if (page_num >= 0 && page_num < n_pages)
+    gtk_widget_show (priv->forward);
+  else
+    gtk_widget_hide (priv->forward);
 }
 
 static void
@@ -484,70 +539,81 @@ set_assistant_buttons_state (GtkAssistant *assistant)
   switch (priv->current_page->type)
     {
     case GTK_ASSISTANT_PAGE_INTRO:
-      gtk_widget_set_sensitive (assistant->cancel, TRUE);
-      gtk_widget_set_sensitive (assistant->forward, priv->current_page->complete);
-      gtk_widget_grab_default (assistant->forward);
-      gtk_widget_show (assistant->cancel);
-      gtk_widget_show (assistant->forward);
-      gtk_widget_hide (assistant->back);
-      gtk_widget_hide (assistant->apply);
-      gtk_widget_hide (assistant->close);
+      gtk_widget_set_sensitive (priv->cancel, TRUE);
+      gtk_widget_set_sensitive (priv->forward, priv->current_page->complete);
+      gtk_widget_grab_default (priv->forward);
+      gtk_widget_show (priv->forward);
+      gtk_widget_hide (priv->back);
+      gtk_widget_hide (priv->apply);
+      gtk_widget_hide (priv->close);
       compute_last_button_state (assistant);
       break;
     case GTK_ASSISTANT_PAGE_CONFIRM:
-      gtk_widget_set_sensitive (assistant->cancel, TRUE);
-      gtk_widget_set_sensitive (assistant->back, TRUE);
-      gtk_widget_set_sensitive (assistant->apply, priv->current_page->complete);
-      gtk_widget_grab_default (assistant->apply);
-      gtk_widget_show (assistant->cancel);
-      gtk_widget_show (assistant->back);
-      gtk_widget_show (assistant->apply);
-      gtk_widget_hide (assistant->forward);
-      gtk_widget_hide (assistant->close);
-      gtk_widget_hide (assistant->last);
+      gtk_widget_set_sensitive (priv->cancel, TRUE);
+      gtk_widget_set_sensitive (priv->back, TRUE);
+      gtk_widget_set_sensitive (priv->apply, priv->current_page->complete);
+      gtk_widget_grab_default (priv->apply);
+      gtk_widget_show (priv->back);
+      gtk_widget_show (priv->apply);
+      gtk_widget_hide (priv->forward);
+      gtk_widget_hide (priv->close);
+      gtk_widget_hide (priv->last);
       break;
     case GTK_ASSISTANT_PAGE_CONTENT:
-      gtk_widget_set_sensitive (assistant->cancel, TRUE);
-      gtk_widget_set_sensitive (assistant->back, TRUE);
-      gtk_widget_set_sensitive (assistant->forward, priv->current_page->complete);
-      gtk_widget_grab_default (assistant->forward);
-      gtk_widget_show (assistant->cancel);
-      gtk_widget_show (assistant->back);
-      gtk_widget_show (assistant->forward);
-      gtk_widget_hide (assistant->apply);
-      gtk_widget_hide (assistant->close);
+      gtk_widget_set_sensitive (priv->cancel, TRUE);
+      gtk_widget_set_sensitive (priv->back, TRUE);
+      gtk_widget_set_sensitive (priv->forward, priv->current_page->complete);
+      gtk_widget_grab_default (priv->forward);
+      gtk_widget_show (priv->back);
+      gtk_widget_show (priv->forward);
+      gtk_widget_hide (priv->apply);
+      gtk_widget_hide (priv->close);
       compute_last_button_state (assistant);
       break;
     case GTK_ASSISTANT_PAGE_SUMMARY:
-      gtk_widget_set_sensitive (assistant->close, priv->current_page->complete);
-      gtk_widget_grab_default (assistant->close);
-      gtk_widget_show (assistant->close);
-      gtk_widget_hide (assistant->cancel);
-      gtk_widget_hide (assistant->back);
-      gtk_widget_hide (assistant->forward);
-      gtk_widget_hide (assistant->apply);
-      gtk_widget_hide (assistant->last);
+      gtk_widget_set_sensitive (priv->close, priv->current_page->complete);
+      gtk_widget_grab_default (priv->close);
+      gtk_widget_show (priv->close);
+      gtk_widget_hide (priv->back);
+      gtk_widget_hide (priv->forward);
+      gtk_widget_hide (priv->apply);
+      gtk_widget_hide (priv->last);
       break;
     case GTK_ASSISTANT_PAGE_PROGRESS:
-      gtk_widget_set_sensitive (assistant->cancel, priv->current_page->complete);
-      gtk_widget_set_sensitive (assistant->back, priv->current_page->complete);
-      gtk_widget_set_sensitive (assistant->forward, priv->current_page->complete);
-      gtk_widget_grab_default (assistant->forward);
-      gtk_widget_show (assistant->cancel);
-      gtk_widget_show (assistant->back);
-      gtk_widget_show (assistant->forward);
-      gtk_widget_hide (assistant->apply);
-      gtk_widget_hide (assistant->close);
-      gtk_widget_hide (assistant->last);
+      gtk_widget_set_sensitive (priv->cancel, priv->current_page->complete);
+      gtk_widget_set_sensitive (priv->back, priv->current_page->complete);
+      gtk_widget_set_sensitive (priv->forward, priv->current_page->complete);
+      gtk_widget_grab_default (priv->forward);
+      gtk_widget_show (priv->back);
+      gtk_widget_hide (priv->apply);
+      gtk_widget_hide (priv->close);
+      gtk_widget_hide (priv->last);
+      compute_progress_state (assistant);
+      break;
+    case GTK_ASSISTANT_PAGE_CUSTOM:
+      gtk_widget_hide (priv->cancel);
+      gtk_widget_hide (priv->back);
+      gtk_widget_hide (priv->forward);
+      gtk_widget_hide (priv->apply);
+      gtk_widget_hide (priv->last);
+      gtk_widget_hide (priv->close);
       break;
     default:
       g_assert_not_reached ();
     }
 
+  if (priv->committed)
+    gtk_widget_hide (priv->cancel);
+  else if (priv->current_page->type == GTK_ASSISTANT_PAGE_SUMMARY ||
+           priv->current_page->type == GTK_ASSISTANT_PAGE_CUSTOM)
+    gtk_widget_hide (priv->cancel);
+  else
+    gtk_widget_show (priv->cancel);
+
   /* this is quite general, we don't want to
    * go back if it's the first page */
   if (!priv->visited_pages)
-    gtk_widget_hide (assistant->back);
+    gtk_widget_hide (priv->back);
 }
 
 static void
@@ -591,12 +657,12 @@ set_current_page (GtkAssistant     *assistant,
       gint i;
 
       /* find the best button to focus */
-      button[0] = assistant->apply;
-      button[1] = assistant->close;
-      button[2] = assistant->forward;
-      button[3] = assistant->back;
-      button[4] = assistant->cancel;
-      button[5] = assistant->last;
+      button[0] = priv->apply;
+      button[1] = priv->close;
+      button[2] = priv->forward;
+      button[3] = priv->back;
+      button[4] = priv->cancel;
+      button[5] = priv->last;
       for (i = 0; i < 6; i++)
         {
           if (gtk_widget_get_visible (button[i]) && gtk_widget_get_sensitive (button[i]))
@@ -663,34 +729,14 @@ static void
 on_assistant_forward (GtkWidget    *widget,
                       GtkAssistant *assistant)
 {
-  if (!compute_next_step (assistant))
-    g_critical ("Page flow is broken, you may want to end it with a page of "
-               "type GTK_ASSISTANT_PAGE_CONFIRM or GTK_ASSISTANT_PAGE_SUMMARY");
+  gtk_assistant_next_page (assistant);
 }
 
 static void
 on_assistant_back (GtkWidget    *widget,
                    GtkAssistant *assistant)
 {
-  GtkAssistantPrivate *priv = assistant->priv;
-  GtkAssistantPage *page_info;
-  GSList *page_node;
-
-  /* skip the progress pages when going back */
-  do
-    {
-      page_node = priv->visited_pages;
-
-      g_return_if_fail (page_node != NULL);
-
-      priv->visited_pages = priv->visited_pages->next;
-      page_info = (GtkAssistantPage *) page_node->data;
-      g_slist_free_1 (page_node);
-    }
-  while (page_info->type == GTK_ASSISTANT_PAGE_PROGRESS ||
-        !gtk_widget_get_visible (page_info->page));
-
-  set_current_page (assistant, page_info);
+  gtk_assistant_previous_page (assistant);
 }
 
 static void
@@ -732,7 +778,10 @@ gtk_assistant_init (GtkAssistant *assistant)
 {
   GtkAssistantPrivate *priv;
 
-  priv = assistant->priv = GTK_ASSISTANT_GET_PRIVATE (assistant);
+  assistant->priv = G_TYPE_INSTANCE_GET_PRIVATE (assistant,
+                                                 GTK_TYPE_ASSISTANT,
+                                                 GtkAssistantPrivate);
+  priv = assistant->priv;
 
   gtk_container_set_reallocate_redraws (GTK_CONTAINER (assistant), TRUE);
   gtk_container_set_border_width (GTK_CONTAINER (assistant), 12);
@@ -752,49 +801,49 @@ gtk_assistant_init (GtkAssistant *assistant)
   gtk_widget_show (priv->sidebar_image);
 
   /* Action area  */
-  priv->action_area  = gtk_hbox_new (FALSE, 6);
-  
-  assistant->close   = gtk_button_new_from_stock (GTK_STOCK_CLOSE);
-  assistant->apply   = gtk_button_new_from_stock (GTK_STOCK_APPLY);
-  assistant->forward = gtk_button_new_from_stock (GTK_STOCK_GO_FORWARD);
-  assistant->back    = gtk_button_new_from_stock (GTK_STOCK_GO_BACK);
-  assistant->cancel  = gtk_button_new_from_stock (GTK_STOCK_CANCEL);
-  assistant->last    = gtk_button_new_from_stock (GTK_STOCK_GOTO_LAST);
-  gtk_widget_set_can_default (assistant->close, TRUE);
-  gtk_widget_set_can_default (assistant->apply, TRUE);
-  gtk_widget_set_can_default (assistant->forward, TRUE);
+  priv->action_area  = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 6);
+
+  priv->close   = gtk_button_new_from_stock (GTK_STOCK_CLOSE);
+  priv->apply   = gtk_button_new_from_stock (GTK_STOCK_APPLY);
+  priv->forward = gtk_button_new_from_stock (GTK_STOCK_GO_FORWARD);
+  priv->back    = gtk_button_new_from_stock (GTK_STOCK_GO_BACK);
+  priv->cancel  = gtk_button_new_from_stock (GTK_STOCK_CANCEL);
+  priv->last    = gtk_button_new_from_stock (GTK_STOCK_GOTO_LAST);
+  gtk_widget_set_can_default (priv->close, TRUE);
+  gtk_widget_set_can_default (priv->apply, TRUE);
+  gtk_widget_set_can_default (priv->forward, TRUE);
 
   priv->size_group   = gtk_size_group_new (GTK_SIZE_GROUP_HORIZONTAL);
-  gtk_size_group_add_widget (priv->size_group, assistant->close);
-  gtk_size_group_add_widget (priv->size_group, assistant->apply);
-  gtk_size_group_add_widget (priv->size_group, assistant->forward);
-  gtk_size_group_add_widget (priv->size_group, assistant->back);
-  gtk_size_group_add_widget (priv->size_group, assistant->cancel);
-  gtk_size_group_add_widget (priv->size_group, assistant->last);
+  gtk_size_group_add_widget (priv->size_group, priv->close);
+  gtk_size_group_add_widget (priv->size_group, priv->apply);
+  gtk_size_group_add_widget (priv->size_group, priv->forward);
+  gtk_size_group_add_widget (priv->size_group, priv->back);
+  gtk_size_group_add_widget (priv->size_group, priv->cancel);
+  gtk_size_group_add_widget (priv->size_group, priv->last);
 
   if (!alternative_button_order (assistant))
     {
-      gtk_box_pack_end (GTK_BOX (priv->action_area), assistant->apply, FALSE, FALSE, 0);
-      gtk_box_pack_end (GTK_BOX (priv->action_area), assistant->forward, FALSE, FALSE, 0);
-      gtk_box_pack_end (GTK_BOX (priv->action_area), assistant->back, FALSE, FALSE, 0);
-      gtk_box_pack_end (GTK_BOX (priv->action_area), assistant->last, FALSE, FALSE, 0);
-      gtk_box_pack_end (GTK_BOX (priv->action_area), assistant->cancel, FALSE, FALSE, 0);
-      gtk_box_pack_end (GTK_BOX (priv->action_area), assistant->close, FALSE, FALSE, 0);
+      gtk_box_pack_end (GTK_BOX (priv->action_area), priv->apply, FALSE, FALSE, 0);
+      gtk_box_pack_end (GTK_BOX (priv->action_area), priv->forward, FALSE, FALSE, 0);
+      gtk_box_pack_end (GTK_BOX (priv->action_area), priv->back, FALSE, FALSE, 0);
+      gtk_box_pack_end (GTK_BOX (priv->action_area), priv->last, FALSE, FALSE, 0);
+      gtk_box_pack_end (GTK_BOX (priv->action_area), priv->cancel, FALSE, FALSE, 0);
+      gtk_box_pack_end (GTK_BOX (priv->action_area), priv->close, FALSE, FALSE, 0);
     }
   else
     {
-      gtk_box_pack_end (GTK_BOX (priv->action_area), assistant->close, FALSE, FALSE, 0);
-      gtk_box_pack_end (GTK_BOX (priv->action_area), assistant->cancel, FALSE, FALSE, 0);
-      gtk_box_pack_end (GTK_BOX (priv->action_area), assistant->apply, FALSE, FALSE, 0);
-      gtk_box_pack_end (GTK_BOX (priv->action_area), assistant->forward, FALSE, FALSE, 0);
-      gtk_box_pack_end (GTK_BOX (priv->action_area), assistant->back, FALSE, FALSE, 0);
-      gtk_box_pack_end (GTK_BOX (priv->action_area), assistant->last, FALSE, FALSE, 0);
+      gtk_box_pack_end (GTK_BOX (priv->action_area), priv->close, FALSE, FALSE, 0);
+      gtk_box_pack_end (GTK_BOX (priv->action_area), priv->cancel, FALSE, FALSE, 0);
+      gtk_box_pack_end (GTK_BOX (priv->action_area), priv->apply, FALSE, FALSE, 0);
+      gtk_box_pack_end (GTK_BOX (priv->action_area), priv->forward, FALSE, FALSE, 0);
+      gtk_box_pack_end (GTK_BOX (priv->action_area), priv->back, FALSE, FALSE, 0);
+      gtk_box_pack_end (GTK_BOX (priv->action_area), priv->last, FALSE, FALSE, 0);
     }
 
   gtk_widget_set_parent (priv->action_area, GTK_WIDGET (assistant));
-  gtk_widget_show (assistant->forward);
-  gtk_widget_show (assistant->back);
-  gtk_widget_show (assistant->cancel);
+  gtk_widget_show (priv->forward);
+  gtk_widget_show (priv->back);
+  gtk_widget_show (priv->cancel);
   gtk_widget_show (priv->action_area);
 
   gtk_widget_pop_composite_child ();
@@ -807,17 +856,17 @@ gtk_assistant_init (GtkAssistant *assistant)
   priv->forward_function_data = assistant;
   priv->forward_data_destroy = NULL;
 
-  g_signal_connect (G_OBJECT (assistant->close), "clicked",
+  g_signal_connect (G_OBJECT (priv->close), "clicked",
                    G_CALLBACK (on_assistant_close), assistant);
-  g_signal_connect (G_OBJECT (assistant->apply), "clicked",
+  g_signal_connect (G_OBJECT (priv->apply), "clicked",
                    G_CALLBACK (on_assistant_apply), assistant);
-  g_signal_connect (G_OBJECT (assistant->forward), "clicked",
+  g_signal_connect (G_OBJECT (priv->forward), "clicked",
                    G_CALLBACK (on_assistant_forward), assistant);
-  g_signal_connect (G_OBJECT (assistant->back), "clicked",
+  g_signal_connect (G_OBJECT (priv->back), "clicked",
                    G_CALLBACK (on_assistant_back), assistant);
-  g_signal_connect (G_OBJECT (assistant->cancel), "clicked",
+  g_signal_connect (G_OBJECT (priv->cancel), "clicked",
                    G_CALLBACK (on_assistant_cancel), assistant);
-  g_signal_connect (G_OBJECT (assistant->last), "clicked",
+  g_signal_connect (G_OBJECT (priv->last), "clicked",
                    G_CALLBACK (on_assistant_last), assistant);
 }
 
@@ -954,9 +1003,9 @@ remove_page (GtkAssistant *assistant,
 }
 
 static void
-gtk_assistant_destroy (GtkObject *object)
+gtk_assistant_destroy (GtkWidget *widget)
 {
-  GtkAssistant *assistant = GTK_ASSISTANT (object);
+  GtkAssistant *assistant = GTK_ASSISTANT (widget);
   GtkAssistantPrivate *priv = assistant->priv;
 
   if (priv->header_image)
@@ -1005,9 +1054,9 @@ gtk_assistant_destroy (GtkObject *object)
   priv->current_page = NULL;
 
   while (priv->pages)
-    remove_page (GTK_ASSISTANT (object), priv->pages);
-      
-  GTK_OBJECT_CLASS (gtk_assistant_parent_class)->destroy (object);
+    remove_page (assistant, priv->pages);
+
+  GTK_WIDGET_CLASS (gtk_assistant_parent_class)->destroy (widget);
 }
 
 static GList*
@@ -1051,7 +1100,7 @@ set_title_font (GtkWidget *assistant,
   gint size;
 
   desc = pango_font_description_new ();
-  size = pango_font_description_get_size (assistant->style->font_desc);
+  size = pango_font_description_get_size (gtk_widget_get_style (assistant)->font_desc);
 
   pango_font_description_set_weight (desc, PANGO_WEIGHT_ULTRABOLD);
   pango_font_description_set_size   (desc, size * PANGO_SCALE_XX_LARGE);
@@ -1090,6 +1139,7 @@ gtk_assistant_size_request (GtkWidget      *widget,
   GtkRequisition child_requisition;
   gint header_padding, content_padding;
   gint width, height, header_width, header_height;
+  guint border_width;
   GList *list;
 
   gtk_widget_style_get (widget,
@@ -1105,11 +1155,13 @@ gtk_assistant_size_request (GtkWidget      *widget,
       GtkAssistantPage *page = list->data;
       gint w, h;
 
-      gtk_widget_size_request (page->page, &child_requisition);
+      gtk_widget_get_preferred_size (page->page,
+                                     &child_requisition, NULL);
       width  = MAX (width,  child_requisition.width);
       height = MAX (height, child_requisition.height);
 
-      gtk_widget_size_request (page->title, &child_requisition);
+      gtk_widget_get_preferred_size (page->title,
+                                     &child_requisition, NULL);
       w = child_requisition.width;
       h = child_requisition.height;
 
@@ -1125,35 +1177,65 @@ gtk_assistant_size_request (GtkWidget      *widget,
       list = list->next;
     }
 
-  gtk_widget_size_request (priv->sidebar_image, &child_requisition);
+  gtk_widget_get_preferred_size (priv->sidebar_image,
+                                 &child_requisition, NULL);
   width  += child_requisition.width;
   height  = MAX (height, child_requisition.height);
 
   gtk_widget_set_size_request (priv->header_image, header_width, header_height);
-  gtk_widget_size_request (priv->header_image, &child_requisition);
+  gtk_widget_get_preferred_size (priv->header_image,
+                                 &child_requisition, NULL);
   width   = MAX (width, header_width) + 2 * header_padding;
   height += header_height + 2 * header_padding;
 
-  gtk_widget_size_request (priv->action_area, &child_requisition);
+  gtk_widget_get_preferred_size (priv->action_area,
+                                 &child_requisition, NULL);
   width   = MAX (width, child_requisition.width);
   height += child_requisition.height + ACTION_AREA_SPACING;
 
-  width += GTK_CONTAINER (widget)->border_width * 2 + content_padding * 2;
-  height += GTK_CONTAINER (widget)->border_width * 2 + content_padding * 2;
+  border_width = gtk_container_get_border_width (GTK_CONTAINER (widget));
+  width += border_width * 2 + content_padding * 2;
+  height += border_width * 2 + content_padding * 2;
 
   requisition->width = width;
   requisition->height = height;
 }
 
+static void
+gtk_assistant_get_preferred_width (GtkWidget *widget,
+                                   gint      *minimum,
+                                   gint      *natural)
+{
+  GtkRequisition requisition;
+
+  gtk_assistant_size_request (widget, &requisition);
+
+  *minimum = *natural = requisition.width;
+}
+
+static void
+gtk_assistant_get_preferred_height (GtkWidget *widget,
+                                    gint      *minimum,
+                                    gint      *natural)
+{
+  GtkRequisition requisition;
+
+  gtk_assistant_size_request (widget, &requisition);
+
+  *minimum = *natural = requisition.height;
+}
+
 static void
 gtk_assistant_size_allocate (GtkWidget      *widget,
                             GtkAllocation  *allocation)
 {
   GtkAssistant *assistant = GTK_ASSISTANT (widget);
   GtkAssistantPrivate *priv = assistant->priv;
-  GtkRequisition header_requisition;
+  GtkRequisition header_requisition, action_requisition, sidebar_requisition;
   GtkAllocation child_allocation, header_allocation;
+  GtkAllocation action_area_allocation, header_image_allocation;
   gint header_padding, content_padding;
+  guint border_width;
   gboolean rtl;
   GList *pages;
 
@@ -1165,56 +1247,68 @@ gtk_assistant_size_allocate (GtkWidget      *widget,
                        "content-padding", &content_padding,
                        NULL);
 
-  widget->allocation = *allocation;
+  gtk_widget_set_allocation (widget, allocation);
+  border_width = gtk_container_get_border_width (GTK_CONTAINER (widget));
 
   /* Header */
-  gtk_widget_get_child_requisition (priv->header_image, &header_requisition);
+  gtk_widget_get_preferred_size (priv->header_image,
+                                 &header_requisition, NULL);
 
-  header_allocation.x = GTK_CONTAINER (widget)->border_width + header_padding;
-  header_allocation.y = GTK_CONTAINER (widget)->border_width + header_padding;
-  header_allocation.width  = allocation->width - 2 * GTK_CONTAINER (widget)->border_width - 2 * header_padding;
+  header_allocation.x = border_width + header_padding;
+  header_allocation.y = border_width + header_padding;
+  header_allocation.width  = allocation->width - 2 * border_width - 2 * header_padding;
   header_allocation.height = header_requisition.height;
 
   gtk_widget_size_allocate (priv->header_image, &header_allocation);
 
   /* Action area */
-  child_allocation.x = GTK_CONTAINER (widget)->border_width;
-  child_allocation.y = allocation->height -
-    GTK_CONTAINER (widget)->border_width - priv->action_area->requisition.height;
-  child_allocation.width  = allocation->width - 2 * GTK_CONTAINER (widget)->border_width;
-  child_allocation.height = priv->action_area->requisition.height;
+  gtk_widget_get_preferred_size (priv->action_area,
+                                 &action_requisition, NULL);
+
+  child_allocation.x = border_width;
+  child_allocation.y = allocation->height - border_width - action_requisition.height;
+  child_allocation.width  = allocation->width - 2 * border_width;
+  child_allocation.height = action_requisition.height;
 
   gtk_widget_size_allocate (priv->action_area, &child_allocation);
 
+  gtk_widget_get_allocation (priv->header_image, &header_image_allocation);
+  gtk_widget_get_allocation (priv->action_area, &action_area_allocation);
+
   /* Sidebar */
+  gtk_widget_get_preferred_size (priv->sidebar_image,
+                                 &sidebar_requisition, NULL);
+
   if (rtl)
-    child_allocation.x = allocation->width -
-      GTK_CONTAINER (widget)->border_width - priv->sidebar_image->requisition.width;
+    child_allocation.x = allocation->width - border_width - sidebar_requisition.width;
   else
-    child_allocation.x = GTK_CONTAINER (widget)->border_width;
+    child_allocation.x = border_width;
 
-  child_allocation.y = GTK_CONTAINER (widget)->border_width +
-    priv->header_image->allocation.height + 2 * header_padding;
-  child_allocation.width = priv->sidebar_image->requisition.width;
-  child_allocation.height = allocation->height - 2 * GTK_CONTAINER (widget)->border_width -
-    priv->header_image->allocation.height - 2 * header_padding - priv->action_area->allocation.height;
+  child_allocation.y = border_width + header_image_allocation.height + 2 * header_padding;
+  child_allocation.width = sidebar_requisition.width;
+  child_allocation.height = allocation->height - 2 * border_width -
+    header_image_allocation.height - 2 * header_padding - action_area_allocation.height;
 
   gtk_widget_size_allocate (priv->sidebar_image, &child_allocation);
 
   /* Pages */
-  child_allocation.x = GTK_CONTAINER (widget)->border_width + content_padding;
-  child_allocation.y = GTK_CONTAINER (widget)->border_width +
-    priv->header_image->allocation.height + 2 * header_padding + content_padding;
-  child_allocation.width  = allocation->width - 2 * GTK_CONTAINER (widget)->border_width - 2 * content_padding;
-  child_allocation.height = allocation->height - 2 * GTK_CONTAINER (widget)->border_width -
-    priv->header_image->allocation.height - 2 * header_padding - ACTION_AREA_SPACING - priv->action_area->allocation.height - 2 * content_padding;
+  child_allocation.x = border_width + content_padding;
+  child_allocation.y = border_width +
+    header_image_allocation.height + 2 * header_padding + content_padding;
+  child_allocation.width  = allocation->width - 2 * border_width - 2 * content_padding;
+  child_allocation.height = allocation->height - 2 * border_width -
+    header_image_allocation.height - 2 * header_padding - ACTION_AREA_SPACING - action_area_allocation.height - 2 * content_padding;
 
   if (gtk_widget_get_visible (priv->sidebar_image))
     {
+      GtkAllocation sidebar_image_allocation;
+
+      gtk_widget_get_allocation (priv->sidebar_image, &sidebar_image_allocation);
+
       if (!rtl)
-       child_allocation.x += priv->sidebar_image->allocation.width;
+       child_allocation.x += sidebar_image_allocation.width;
 
-      child_allocation.width -= priv->sidebar_image->allocation.width;
+      child_allocation.width -= sidebar_image_allocation.width;
     }
 
   while (pages)
@@ -1235,7 +1329,7 @@ gtk_assistant_map (GtkWidget *widget)
   GList *page_node;
   GtkAssistantPage *page;
 
-  GTK_WIDGET_SET_FLAGS (widget, GTK_MAPPED);
+  gtk_widget_set_mapped (widget, TRUE);
 
   gtk_widget_map (priv->header_image);
   gtk_widget_map (priv->action_area);
@@ -1271,7 +1365,7 @@ gtk_assistant_unmap (GtkWidget *widget)
   GtkAssistant *assistant = GTK_ASSISTANT (widget);
   GtkAssistantPrivate *priv = assistant->priv;
 
-  GTK_WIDGET_UNSET_FLAGS (widget, GTK_MAPPED);
+  gtk_widget_set_mapped (widget, FALSE);
 
   gtk_widget_unmap (priv->header_image);
   gtk_widget_unmap (priv->action_area);
@@ -1307,16 +1401,17 @@ gtk_assistant_delete_event (GtkWidget   *widget,
 }
 
 static void
-assistant_paint_colored_box (GtkWidget *widget)
+assistant_paint_colored_box (GtkWidget *widget,
+                             cairo_t   *cr)
 {
   GtkAssistant *assistant = GTK_ASSISTANT (widget);
   GtkAssistantPrivate *priv = assistant->priv;
+  GtkAllocation allocation, action_area_allocation, header_image_allocation;
+  GtkStyle *style;
   gint border_width, header_padding, content_padding;
-  cairo_t *cr;
   gint content_x, content_width;
   gboolean rtl;
 
-  cr   = gdk_cairo_create (widget->window);
   rtl  = (gtk_widget_get_direction (widget) == GTK_TEXT_DIR_RTL);
   border_width = gtk_container_get_border_width (GTK_CONTAINER (widget));
 
@@ -1325,62 +1420,67 @@ assistant_paint_colored_box (GtkWidget *widget)
                        "content-padding", &content_padding,
                        NULL);
 
+  style = gtk_widget_get_style (widget);
+  gtk_widget_get_allocation (widget, &allocation);
+  gtk_widget_get_allocation (priv->action_area, &action_area_allocation);
+  gtk_widget_get_allocation (priv->header_image, &header_image_allocation);
+
   /* colored box */
-  gdk_cairo_set_source_color (cr, &widget->style->bg[GTK_STATE_SELECTED]);
+  gdk_cairo_set_source_color (cr, &style->bg[GTK_STATE_SELECTED]);
   cairo_rectangle (cr,
                   border_width,
                   border_width,
-                  widget->allocation.width - 2 * border_width,
-                  widget->allocation.height - priv->action_area->allocation.height - 2 * border_width - ACTION_AREA_SPACING);
+                   allocation.width - 2 * border_width,
+                   allocation.height - action_area_allocation.height - 2 * border_width - ACTION_AREA_SPACING);
   cairo_fill (cr);
 
   /* content box */
   content_x = content_padding + border_width;
-  content_width = widget->allocation.width - 2 * content_padding - 2 * border_width;
+  content_width = allocation.width - 2 * content_padding - 2 * border_width;
 
   if (gtk_widget_get_visible (priv->sidebar_image))
     {
+      GtkAllocation sidebar_image_allocation;
+
+      gtk_widget_get_allocation (priv->sidebar_image, &sidebar_image_allocation);
+
       if (!rtl)
-       content_x += priv->sidebar_image->allocation.width;
-      content_width -= priv->sidebar_image->allocation.width;
+       content_x += sidebar_image_allocation.width;
+      content_width -= sidebar_image_allocation.width;
     }
-  
-  gdk_cairo_set_source_color (cr, &widget->style->bg[GTK_STATE_NORMAL]);
+
+  gdk_cairo_set_source_color (cr, &style->bg[GTK_STATE_NORMAL]);
 
   cairo_rectangle (cr,
                   content_x,
-                  priv->header_image->allocation.height + content_padding + 2 * header_padding + border_width,
+                  header_image_allocation.height + content_padding + 2 * header_padding + border_width,
                   content_width,
-                  widget->allocation.height - 2 * border_width - priv->action_area->allocation.height -
-                  priv->header_image->allocation.height - 2 * content_padding - 2 * header_padding - ACTION_AREA_SPACING);
+                  allocation.height - 2 * border_width - action_area_allocation.height -
+                  header_image_allocation.height - 2 * content_padding - 2 * header_padding - ACTION_AREA_SPACING);
   cairo_fill (cr);
-
-  cairo_destroy (cr);
 }
 
 static gboolean
-gtk_assistant_expose (GtkWidget      *widget,
-                     GdkEventExpose *event)
+gtk_assistant_draw (GtkWidget *widget,
+                   cairo_t   *cr)
 {
   GtkAssistant *assistant = GTK_ASSISTANT (widget);
   GtkAssistantPrivate *priv = assistant->priv;
-  GtkContainer *container;
+  GtkContainer *container = GTK_CONTAINER (widget);
 
-  if (gtk_widget_is_drawable (widget))
-    {
-      container = GTK_CONTAINER (widget);
+  if (GTK_WIDGET_CLASS (gtk_assistant_parent_class)->draw)
+    GTK_WIDGET_CLASS (gtk_assistant_parent_class)->draw (widget, cr);
 
-      assistant_paint_colored_box (widget);
+  assistant_paint_colored_box (widget, cr);
 
-      gtk_container_propagate_expose (container, priv->header_image, event);
-      gtk_container_propagate_expose (container, priv->sidebar_image, event);
-      gtk_container_propagate_expose (container, priv->action_area, event);
+  gtk_container_propagate_draw (container, priv->header_image, cr);
+  gtk_container_propagate_draw (container, priv->sidebar_image, cr);
+  gtk_container_propagate_draw (container, priv->action_area, cr);
 
-      if (priv->current_page)
-       {
-         gtk_container_propagate_expose (container, priv->current_page->page, event);
-         gtk_container_propagate_expose (container, priv->current_page->title, event);
-       }
+  if (priv->current_page)
+    {
+      gtk_container_propagate_draw (container, priv->current_page->page, cr);
+      gtk_container_propagate_draw (container, priv->current_page->title, cr);
     }
 
   return FALSE;
@@ -1397,7 +1497,7 @@ gtk_assistant_focus (GtkWidget        *widget,
   priv = GTK_ASSISTANT (widget)->priv;
 
   /* we only have to care about 2 widgets, action area and the current page */
-  if (container->focus_child == priv->action_area)
+  if (gtk_container_get_focus_child (container) == priv->action_area)
     {
       if (!gtk_widget_child_focus (priv->action_area, direction) &&
          (priv->current_page == NULL ||
@@ -1573,6 +1673,73 @@ gtk_assistant_set_current_page (GtkAssistant *assistant,
   set_current_page (assistant, page);
 }
 
+/**
+ * gtk_assistant_next_page:
+ * @assistant: a #GtkAssistant
+ *
+ * Navigate to the next page. It is a programming
+ *  error to call this function if there is no next page.
+ *
+ * This function is for use when creating pages of the
+ *  #GTK_ASSISTANT_PAGE_CUSTOM type.
+ *
+ * Since: 3.0
+ **/
+void
+gtk_assistant_next_page (GtkAssistant *assistant)
+{
+  GtkAssistantPrivate *priv;
+
+  g_return_if_fail (GTK_IS_ASSISTANT (assistant));
+
+  priv = assistant->priv;
+
+  if (!compute_next_step (assistant))
+    g_critical ("Page flow is broken, you may want to end it with a page of "
+               "type GTK_ASSISTANT_PAGE_CONFIRM or GTK_ASSISTANT_PAGE_SUMMARY");
+}
+
+/**
+ * gtk_assistant_previous_page:
+ * @assistant: a #GtkAssistant
+ *
+ * Navigate to the previous visited page. It is a programming
+ *  error to call this function if no previous page is
+ *  available.
+ *
+ * This function is for use when creating pages of the
+ *  #GTK_ASSISTANT_PAGE_CUSTOM type.
+ *
+ * Since: 3.0
+ **/
+void
+gtk_assistant_previous_page (GtkAssistant *assistant)
+{
+  GtkAssistantPrivate *priv;
+  GtkAssistantPage *page_info;
+  GSList *page_node;
+
+  g_return_if_fail (GTK_IS_ASSISTANT (assistant));
+
+  priv = assistant->priv;
+
+  /* skip the progress pages when going back */
+  do
+    {
+      page_node = priv->visited_pages;
+
+      g_return_if_fail (page_node != NULL);
+
+      priv->visited_pages = priv->visited_pages->next;
+      page_info = (GtkAssistantPage *) page_node->data;
+      g_slist_free_1 (page_node);
+    }
+  while (page_info->type == GTK_ASSISTANT_PAGE_PROGRESS ||
+        !gtk_widget_get_visible (page_info->page));
+
+  set_current_page (assistant, page_info);
+}
+
 /**
  * gtk_assistant_get_n_pages:
  * @assistant: a #GtkAssistant
@@ -1602,7 +1769,8 @@ gtk_assistant_get_n_pages (GtkAssistant *assistant)
  *
  * Returns the child widget contained in page number @page_num.
  *
- * Return value: The child widget, or %NULL if @page_num is out of bounds.
+ * Return value: (transfer none): The child widget, or %NULL
+ *     if @page_num is out of bounds.
  *
  * Since: 2.10
  **/
@@ -1698,7 +1866,7 @@ gtk_assistant_insert_page (GtkAssistant *assistant,
 
   g_return_val_if_fail (GTK_IS_ASSISTANT (assistant), 0);
   g_return_val_if_fail (GTK_IS_WIDGET (page), 0);
-  g_return_val_if_fail (page->parent == NULL, 0);
+  g_return_val_if_fail (gtk_widget_get_parent (page) == NULL, 0);
   g_return_val_if_fail (!gtk_widget_is_toplevel (page), 0);
 
   priv = assistant->priv;
@@ -1726,7 +1894,7 @@ gtk_assistant_insert_page (GtkAssistant *assistant,
   gtk_widget_set_parent (page_info->page,  GTK_WIDGET (assistant));
   gtk_widget_set_parent (page_info->title, GTK_WIDGET (assistant));
 
-  if (GTK_WIDGET_REALIZED (GTK_WIDGET (assistant)))
+  if (gtk_widget_get_realized (GTK_WIDGET (assistant)))
     {
       gtk_widget_realize (page_info->page);
       gtk_widget_realize (page_info->title);
@@ -2033,11 +2201,11 @@ gtk_assistant_set_page_header_image (GtkAssistant *assistant,
  * gtk_assistant_get_page_header_image:
  * @assistant: a #GtkAssistant
  * @page: a page of @assistant
- * 
- * Gets the header image for @page. 
- * 
- * Return value: the header image for @page, or %NULL
- * if there's no header image for the page.
+ *
+ * Gets the header image for @page.
+ *
+ * Return value: (transfer none): the header image for @page, or %NULL
+ *     if there's no header image for the page.
  *
  * Since: 2.10
  **/
@@ -2113,11 +2281,11 @@ gtk_assistant_set_page_side_image (GtkAssistant *assistant,
  * gtk_assistant_get_page_side_image:
  * @assistant: a #GtkAssistant
  * @page: a page of @assistant
- * 
- * Gets the header image for @page. 
- * 
- * Return value: the side image for @page, or %NULL
- * if there's no side image for the page.
+ *
+ * Gets the header image for @page.
+ *
+ * Return value: (transfer none): the side image for @page, or %NULL
+ *     if there's no side image for the page.
  *
  * Since: 2.10
  **/
@@ -2237,6 +2405,35 @@ gtk_assistant_update_buttons_state (GtkAssistant *assistant)
   set_assistant_buttons_state (assistant);
 }
 
+/**
+ * gtk_assistant_commit:
+ * @assistant: a #GtkAssistant
+ *
+ * Erases the visited page history so the back button is not
+ * shown on the current page, and removes the cancel button
+ * from subsequent pages.
+ *
+ * Use this when the information provided up to the current
+ * page is hereafter deemed permanent and cannot be modified
+ * or undone.  For example, showing a progress page to track
+ * a long-running, unreversible operation after the user has
+ * clicked apply on a confirmation page.
+ *
+ * Since: 2.22
+ **/
+void
+gtk_assistant_commit (GtkAssistant *assistant)
+{
+  g_return_if_fail (GTK_IS_ASSISTANT (assistant));
+
+  g_slist_free (assistant->priv->visited_pages);
+  assistant->priv->visited_pages = NULL;
+
+  assistant->priv->committed = TRUE;
+
+  set_assistant_buttons_state (assistant);
+}
+
 
 
 /* accessible implementation */
@@ -2247,7 +2444,7 @@ gtk_assistant_accessible_get_n_children (AtkObject *accessible)
   GtkAssistant *assistant;
   GtkWidget *widget;
 
-  widget = GTK_ACCESSIBLE (accessible)->widget;
+  widget = gtk_accessible_get_widget (GTK_ACCESSIBLE (accessible));
 
   if (!widget)
     return 0;
@@ -2269,7 +2466,7 @@ gtk_assistant_accessible_ref_child (AtkObject *accessible,
   AtkObject *obj;
   const gchar *title;
 
-  widget = GTK_ACCESSIBLE (accessible)->widget;
+  widget = gtk_accessible_get_widget (GTK_ACCESSIBLE (accessible));
   if (!widget)
     return NULL;
 
@@ -2474,7 +2671,3 @@ gtk_assistant_buildable_custom_finished (GtkBuildable *buildable,
   parent_buildable_iface->custom_finished (buildable, builder, child,
                                            tagname, user_data);
 }
-
-
-#define __GTK_ASSISTANT_C__
-#include "gtkaliasdef.c"