]> Pileus Git - ~andy/gtk/blobdiff - gtk/gtkassistant.c
Include "config.h" instead of <config.h> Command used: find -name
[~andy/gtk] / gtk / gtkassistant.c
index 9451107a0da12232d4ea674e14c5c039def7628b..289718df43d9735bc481a7f0531bf8136f43afb2 100644 (file)
@@ -23,7 +23,7 @@
  * Boston, MA 02111-1307, USA.
  */
 
-#include <config.h>
+#include "config.h"
 
 #include <atk/atk.h>
 
@@ -457,6 +457,9 @@ set_assistant_buttons_state (GtkAssistant *assistant)
 {
   GtkAssistantPrivate *priv = assistant->priv;
 
+  if (!priv->current_page)
+    return;
+  
   switch (priv->current_page->type)
     {
     case GTK_ASSISTANT_PAGE_INTRO:
@@ -678,6 +681,8 @@ gtk_assistant_init (GtkAssistant *assistant)
 
   priv = assistant->priv = GTK_ASSISTANT_GET_PRIVATE (assistant);
 
+  gtk_container_set_reallocate_redraws (GTK_CONTAINER (assistant), TRUE);
+
   gtk_widget_push_composite_child ();
 
   /* Header */
@@ -723,10 +728,10 @@ gtk_assistant_init (GtkAssistant *assistant)
     {
       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->last, 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->forward, 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_widget_set_parent (priv->action_area, GTK_WIDGET (assistant));
@@ -847,12 +852,32 @@ remove_page (GtkAssistant *assistant,
 {
   GtkAssistantPrivate *priv = assistant->priv;
   GtkAssistantPage *page_info;
+  GList *page_node;
 
   page_info = element->data;
 
-  /* If we are mapped and visible, we want to deal with changing the page. */
-  if ((GTK_WIDGET_MAPPED (page_info->page)) && (page_info == priv->current_page))
-    compute_next_step (assistant);
+  /* If this is the current page, we need to switch away. */
+  if (page_info == priv->current_page)
+    {
+      if (!compute_next_step (assistant))
+        {
+         /* The best we can do at this point is probably to pick the first
+          * visible page.
+          */
+         page_node = priv->pages;
+
+         while (page_node && !GTK_WIDGET_VISIBLE (((GtkAssistantPage *) page_node->data)->page))
+           page_node = page_node->next;
+
+          if (page_node == element)
+            page_node = page_node->next;
+
+         if (page_node)
+           priv->current_page = page_node->data;
+         else
+           priv->current_page = NULL;
+        }
+    }
 
   priv->pages = g_list_remove_link (priv->pages, element);
   priv->visited_pages = g_slist_remove_all (priv->visited_pages, page_info);
@@ -1088,16 +1113,16 @@ gtk_assistant_size_allocate (GtkWidget      *widget,
   /* Header */
   gtk_widget_get_child_requisition (priv->header_image, &header_requisition);
 
-  header_allocation.x = allocation->x + GTK_CONTAINER (widget)->border_width + header_padding;
-  header_allocation.y = allocation->y + GTK_CONTAINER (widget)->border_width + header_padding;
+  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.height = header_requisition.height;
 
   gtk_widget_size_allocate (priv->header_image, &header_allocation);
 
   /* Action area */
-  child_allocation.x = allocation->x + GTK_CONTAINER (widget)->border_width;
-  child_allocation.y = allocation->y + allocation->height -
+  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;
@@ -1106,12 +1131,12 @@ gtk_assistant_size_allocate (GtkWidget      *widget,
 
   /* Sidebar */
   if (rtl)
-    child_allocation.x = allocation->x + allocation->width -
+    child_allocation.x = allocation->width -
       GTK_CONTAINER (widget)->border_width - priv->sidebar_image->requisition.width;
   else
-    child_allocation.x = allocation->x + GTK_CONTAINER (widget)->border_width;
+    child_allocation.x = GTK_CONTAINER (widget)->border_width;
 
-  child_allocation.y = allocation->y + GTK_CONTAINER (widget)->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 -
@@ -1120,8 +1145,8 @@ gtk_assistant_size_allocate (GtkWidget      *widget,
   gtk_widget_size_allocate (priv->sidebar_image, &child_allocation);
 
   /* Pages */
-  child_allocation.x = allocation->x + GTK_CONTAINER (widget)->border_width + content_padding;
-  child_allocation.y = allocation->y + GTK_CONTAINER (widget)->border_width +
+  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 -
@@ -1355,8 +1380,6 @@ static void
 gtk_assistant_add (GtkContainer *container,
                   GtkWidget    *page)
 {
-  g_return_if_fail (GTK_IS_WIDGET (page));
-
   gtk_assistant_append_page (GTK_ASSISTANT (container), page);
 }
 
@@ -1364,11 +1387,9 @@ static void
 gtk_assistant_remove (GtkContainer *container,
                      GtkWidget    *page)
 {
-  GtkAssistant *assistant;
+  GtkAssistant *assistant = (GtkAssistant*) container;
   GList *element;
 
-  assistant = (GtkAssistant*) container;
-
   element = find_page (assistant, page);
 
   if (element)
@@ -1497,7 +1518,8 @@ gtk_assistant_set_current_page (GtkAssistant *assistant,
    * initial page is != to 0
    */
   if (GTK_WIDGET_MAPPED (assistant))
-    priv->visited_pages = g_slist_prepend (priv->visited_pages, page);
+    priv->visited_pages = g_slist_prepend (priv->visited_pages,
+                                          priv->current_page);
 
   set_current_page (assistant, page);
 }
@@ -1708,8 +1730,7 @@ gtk_assistant_set_forward_page_func (GtkAssistant         *assistant,
 
   /* Page flow has possibly changed, so the
      buttons state might need to change too */
-  if (priv->current_page)
-    set_assistant_buttons_state (assistant);
+  set_assistant_buttons_state (assistant);
 }
 
 /**
@@ -1780,14 +1801,12 @@ gtk_assistant_set_page_title (GtkAssistant *assistant,
                              GtkWidget    *page,
                              const gchar  *title)
 {
-  GtkAssistantPrivate *priv;
   GtkAssistantPage *page_info;
   GList *child;
 
   g_return_if_fail (GTK_IS_ASSISTANT (assistant));
   g_return_if_fail (GTK_IS_WIDGET (page));
 
-  priv = assistant->priv;
   child = find_page (assistant, page);
 
   g_return_if_fail (child != NULL);
@@ -1814,14 +1833,12 @@ G_CONST_RETURN gchar*
 gtk_assistant_get_page_title (GtkAssistant *assistant,
                              GtkWidget    *page)
 {
-  GtkAssistantPrivate *priv;
   GtkAssistantPage *page_info;
   GList *child;
 
   g_return_val_if_fail (GTK_IS_ASSISTANT (assistant), NULL);
   g_return_val_if_fail (GTK_IS_WIDGET (page), NULL);
 
-  priv = assistant->priv;
   child = find_page (assistant, page);
 
   g_return_val_if_fail (child != NULL, NULL);
@@ -1867,8 +1884,7 @@ gtk_assistant_set_page_type (GtkAssistant         *assistant,
 
       /* Always set buttons state, a change in a future page
         might change current page buttons */
-      if (priv->current_page)
-       set_assistant_buttons_state (assistant);
+      set_assistant_buttons_state (assistant);
 
       gtk_widget_child_notify (page, "page-type");
     }
@@ -1889,14 +1905,12 @@ GtkAssistantPageType
 gtk_assistant_get_page_type (GtkAssistant *assistant,
                             GtkWidget    *page)
 {
-  GtkAssistantPrivate *priv;
   GtkAssistantPage *page_info;
   GList *child;
 
   g_return_val_if_fail (GTK_IS_ASSISTANT (assistant), GTK_ASSISTANT_PAGE_CONTENT);
   g_return_val_if_fail (GTK_IS_WIDGET (page), GTK_ASSISTANT_PAGE_CONTENT);
 
-  priv = assistant->priv;
   child = find_page (assistant, page);
 
   g_return_val_if_fail (child != NULL, GTK_ASSISTANT_PAGE_CONTENT);
@@ -1971,14 +1985,12 @@ GdkPixbuf*
 gtk_assistant_get_page_header_image (GtkAssistant *assistant,
                                     GtkWidget    *page)
 {
-  GtkAssistantPrivate *priv;
   GtkAssistantPage *page_info;
   GList *child;
 
   g_return_val_if_fail (GTK_IS_ASSISTANT (assistant), NULL);
   g_return_val_if_fail (GTK_IS_WIDGET (page), NULL);
 
-  priv = assistant->priv;
   child = find_page (assistant, page);
 
   g_return_val_if_fail (child != NULL, NULL);
@@ -2053,14 +2065,12 @@ GdkPixbuf*
 gtk_assistant_get_page_side_image (GtkAssistant *assistant,
                                   GtkWidget    *page)
 {
-  GtkAssistantPrivate *priv;
   GtkAssistantPage *page_info;
   GList *child;
 
   g_return_val_if_fail (GTK_IS_ASSISTANT (assistant), NULL);
   g_return_val_if_fail (GTK_IS_WIDGET (page), NULL);
 
-  priv = assistant->priv;
   child = find_page (assistant, page);
 
   g_return_val_if_fail (child != NULL, NULL);
@@ -2106,8 +2116,7 @@ gtk_assistant_set_page_complete (GtkAssistant *assistant,
 
       /* Always set buttons state, a change in a future page
         might change current page buttons */
-      if (priv->current_page)
-       set_assistant_buttons_state (assistant);
+      set_assistant_buttons_state (assistant);
 
       gtk_widget_child_notify (page, "complete");
     }
@@ -2128,14 +2137,12 @@ gboolean
 gtk_assistant_get_page_complete (GtkAssistant *assistant,
                                 GtkWidget    *page)
 {
-  GtkAssistantPrivate *priv;
   GtkAssistantPage *page_info;
   GList *child;
 
   g_return_val_if_fail (GTK_IS_ASSISTANT (assistant), FALSE);
   g_return_val_if_fail (GTK_IS_WIDGET (page), FALSE);
 
-  priv = assistant->priv;
   child = find_page (assistant, page);
 
   g_return_val_if_fail (child != NULL, FALSE);
@@ -2258,7 +2265,7 @@ gtk_assistant_accessible_get_type (void)
       g_type_query (derived_atk_type, &query);
       
       type = g_type_register_static_simple (derived_atk_type, 
-                                           "GtkAssistantAccessible"
+                                           I_("GtkAssistantAccessible")
                                            query.class_size,
                                            (GClassInitFunc) gtk_assistant_accessible_class_init,
                                            query.instance_size,
@@ -2308,7 +2315,7 @@ gtk_assistant_accessible_factory_get_type (void)
   if (!type) 
     {
       type = g_type_register_static_simple (ATK_TYPE_OBJECT_FACTORY, 
-                                           "GtkAssistantAccessibleFactory",
+                                           I_("GtkAssistantAccessibleFactory"),
                                            sizeof (AtkObjectFactoryClass),
                                            (GClassInitFunc) gtk_assistant_accessible_factory_class_init,
                                            sizeof (AtkObjectFactory),