]> Pileus Git - ~andy/gtk/blobdiff - gtk/gtknotebook.c
Deprecate widget flag: GTK_WIDGET_MAPPED
[~andy/gtk] / gtk / gtknotebook.c
index d9a585ddbcfe02f52604b2c73d2be42158bc228a..f6e3b9de9018c0014869211a6daa5ff69996fe26 100644 (file)
@@ -127,6 +127,12 @@ enum {
   CHILD_PROP_DETACHABLE
 };
 
+enum {
+  ACTION_WIDGET_START,
+  ACTION_WIDGET_END,
+  N_ACTION_WIDGETS
+};
+
 #define GTK_NOTEBOOK_PAGE(_glist_)         ((GtkNotebookPage *)((GList *)(_glist_))->data)
 
 /* some useful defines for calculating coords */
@@ -194,6 +200,8 @@ struct _GtkNotebookPrivate
 
   guint32 timestamp;
 
+  GtkWidget *action_widget[N_ACTION_WIDGETS];
+
   guint during_reorder : 1;
   guint during_detach  : 1;
   guint has_scrolled   : 1;
@@ -1063,7 +1071,7 @@ gtk_notebook_init (GtkNotebook *notebook)
 {
   GtkNotebookPrivate *priv;
 
-  GTK_WIDGET_SET_FLAGS (notebook, GTK_CAN_FOCUS);
+  gtk_widget_set_can_focus (GTK_WIDGET (notebook), TRUE);
   GTK_WIDGET_SET_FLAGS (notebook, GTK_NO_WINDOW);
 
   priv = GTK_NOTEBOOK_GET_PRIVATE (notebook);
@@ -1140,6 +1148,14 @@ gtk_notebook_buildable_add_child (GtkBuildable  *buildable,
       g_assert (page != NULL);
       gtk_notebook_set_tab_label (notebook, page, GTK_WIDGET (child));
     }
+  else if (type && strcmp (type, "action-start") == 0)
+    {
+      gtk_notebook_set_action_widget (notebook, GTK_WIDGET (child), GTK_PACK_START);
+    }
+  else if (type && strcmp (type, "action-end") == 0)
+    {
+      gtk_notebook_set_action_widget (notebook, GTK_WIDGET (child), GTK_PACK_END);
+    }
   else if (!type)
     gtk_notebook_append_page (notebook, GTK_WIDGET (child), NULL);
   else
@@ -1321,7 +1337,7 @@ gtk_notebook_move_focus_out (GtkNotebook      *notebook,
    * do this by setting a flag, then propagating the focus motion to the notebook.
    */
   toplevel = gtk_widget_get_toplevel (GTK_WIDGET (notebook));
-  if (!GTK_WIDGET_TOPLEVEL (toplevel))
+  if (!gtk_widget_is_toplevel (toplevel))
     return;
 
   g_object_ref (notebook);
@@ -1627,16 +1643,19 @@ static gboolean
 gtk_notebook_get_event_window_position (GtkNotebook  *notebook,
                                        GdkRectangle *rectangle)
 {
+  GtkNotebookPrivate *priv = GTK_NOTEBOOK_GET_PRIVATE (notebook);
   GtkWidget *widget = GTK_WIDGET (notebook);
   gint border_width = GTK_CONTAINER (notebook)->border_width;
   GtkNotebookPage *visible_page = NULL;
   GList *tmp_list;
   gint tab_pos = get_effective_tab_pos (notebook);
+  gboolean is_rtl;
+  gint i;
 
   for (tmp_list = notebook->children; tmp_list; tmp_list = tmp_list->next)
     {
       GtkNotebookPage *page = tmp_list->data;
-      if (GTK_WIDGET_VISIBLE (page->child))
+      if (gtk_widget_get_visible (page->child))
        {
          visible_page = page;
          break;
@@ -1647,9 +1666,10 @@ gtk_notebook_get_event_window_position (GtkNotebook  *notebook,
     {
       if (rectangle)
        {
+         is_rtl = gtk_widget_get_direction (widget) == GTK_TEXT_DIR_RTL;
          rectangle->x = widget->allocation.x + border_width;
          rectangle->y = widget->allocation.y + border_width;
-         
+
          switch (tab_pos)
            {
            case GTK_POS_TOP:
@@ -1658,6 +1678,18 @@ gtk_notebook_get_event_window_position (GtkNotebook  *notebook,
              rectangle->height = visible_page->requisition.height;
              if (tab_pos == GTK_POS_BOTTOM)
                rectangle->y += widget->allocation.height - 2 * border_width - rectangle->height;
+
+              for (i = 0; i < N_ACTION_WIDGETS; i++)
+                {
+                  if (priv->action_widget[i] &&
+                      gtk_widget_get_visible (priv->action_widget[i]))
+                    {
+                      rectangle->width -= priv->action_widget[i]->allocation.width;
+                      if ((!is_rtl && i == ACTION_WIDGET_START) ||
+                          (is_rtl && i == ACTION_WIDGET_END))
+                        rectangle->x += priv->action_widget[i]->allocation.width;
+                    }
+                }
              break;
            case GTK_POS_LEFT:
            case GTK_POS_RIGHT:
@@ -1665,7 +1697,19 @@ gtk_notebook_get_event_window_position (GtkNotebook  *notebook,
              rectangle->height = widget->allocation.height - 2 * border_width;
              if (tab_pos == GTK_POS_RIGHT)
                rectangle->x += widget->allocation.width - 2 * border_width - rectangle->width;
-             break;
+
+              for (i = 0; i < N_ACTION_WIDGETS; i++)
+                {
+                  if (priv->action_widget[i] &&
+                      gtk_widget_get_visible (priv->action_widget[i]))
+                    {
+                      rectangle->height -= priv->action_widget[i]->allocation.height;
+
+                      if (i == ACTION_WIDGET_START)
+                        rectangle->y += priv->action_widget[i]->allocation.height;
+                    }
+                }
+              break;
            }
        }
 
@@ -1686,19 +1730,31 @@ gtk_notebook_get_event_window_position (GtkNotebook  *notebook,
 static void
 gtk_notebook_map (GtkWidget *widget)
 {
+  GtkNotebookPrivate *priv;
   GtkNotebook *notebook;
   GtkNotebookPage *page;
   GList *children;
+  gint i;
 
   GTK_WIDGET_SET_FLAGS (widget, GTK_MAPPED);
 
   notebook = GTK_NOTEBOOK (widget);
+  priv = GTK_NOTEBOOK_GET_PRIVATE (notebook);
 
-  if (notebook->cur_page && 
-      GTK_WIDGET_VISIBLE (notebook->cur_page->child) &&
-      !GTK_WIDGET_MAPPED (notebook->cur_page->child))
+  if (notebook->cur_page &&
+      gtk_widget_get_visible (notebook->cur_page->child) &&
+      !gtk_widget_get_mapped (notebook->cur_page->child))
     gtk_widget_map (notebook->cur_page->child);
 
+  for (i = 0; i < N_ACTION_WIDGETS; i++)
+    {
+      if (priv->action_widget[i] &&
+          gtk_widget_get_visible (priv->action_widget[i]) &&
+          GTK_WIDGET_CHILD_VISIBLE (priv->action_widget[i]) &&
+          !gtk_widget_get_mapped (priv->action_widget[i]))
+        gtk_widget_map (priv->action_widget[i]);
+    }
+
   if (notebook->scrollable)
     gtk_notebook_pages_allocate (notebook);
   else
@@ -1711,8 +1767,8 @@ gtk_notebook_map (GtkWidget *widget)
          children = children->next;
 
          if (page->tab_label &&
-             GTK_WIDGET_VISIBLE (page->tab_label) &&
-             !GTK_WIDGET_MAPPED (page->tab_label))
+             gtk_widget_get_visible (page->tab_label) &&
+             !gtk_widget_get_mapped (page->tab_label))
            gtk_widget_map (page->tab_label);
        }
     }
@@ -1796,10 +1852,12 @@ static void
 gtk_notebook_size_request (GtkWidget      *widget,
                           GtkRequisition *requisition)
 {
+  GtkNotebookPrivate *priv = GTK_NOTEBOOK_GET_PRIVATE (widget);
   GtkNotebook *notebook = GTK_NOTEBOOK (widget);
   GtkNotebookPage *page;
   GList *children;
   GtkRequisition child_requisition;
+  GtkRequisition action_widget_requisition[2] = { { 0 }, { 0 } };
   gboolean switch_page = FALSE;
   gint vis_pages;
   gint focus_width;
@@ -1826,7 +1884,7 @@ gtk_notebook_size_request (GtkWidget      *widget,
     {
       page = children->data;
 
-      if (GTK_WIDGET_VISIBLE (page->child))
+      if (gtk_widget_get_visible (page->child))
        {
          vis_pages++;
          gtk_widget_size_request (page->child, &child_requisition);
@@ -1837,7 +1895,7 @@ gtk_notebook_size_request (GtkWidget      *widget,
                                            child_requisition.height);
 
          if (notebook->menu && page->menu_label->parent &&
-             !GTK_WIDGET_VISIBLE (page->menu_label->parent))
+             !gtk_widget_get_visible (page->menu_label->parent))
            gtk_widget_show (page->menu_label->parent);
        }
       else
@@ -1845,7 +1903,7 @@ gtk_notebook_size_request (GtkWidget      *widget,
          if (page == notebook->cur_page)
            switch_page = TRUE;
          if (notebook->menu && page->menu_label->parent &&
-             GTK_WIDGET_VISIBLE (page->menu_label->parent))
+             gtk_widget_get_visible (page->menu_label->parent))
            gtk_widget_hide (page->menu_label->parent);
        }
     }
@@ -1861,15 +1919,18 @@ gtk_notebook_size_request (GtkWidget      *widget,
          gint tab_height = 0;
          gint tab_max = 0;
          gint padding;
+          gint i;
+          gint action_width = 0;
+          gint action_height = 0;
          
          for (children = notebook->children; children;
               children = children->next)
            {
              page = children->data;
              
-             if (GTK_WIDGET_VISIBLE (page->child))
+             if (gtk_widget_get_visible (page->child))
                {
-                 if (!GTK_WIDGET_VISIBLE (page->tab_label))
+                 if (!gtk_widget_get_visible (page->tab_label))
                    gtk_widget_show (page->tab_label);
 
                  gtk_widget_size_request (page->tab_label,
@@ -1900,7 +1961,7 @@ gtk_notebook_size_request (GtkWidget      *widget,
                      break;
                    }
                }
-             else if (GTK_WIDGET_VISIBLE (page->tab_label))
+             else if (gtk_widget_get_visible (page->tab_label))
                gtk_widget_hide (page->tab_label);
            }
 
@@ -1908,6 +1969,16 @@ gtk_notebook_size_request (GtkWidget      *widget,
 
          if (vis_pages)
            {
+              for (i = 0; i < N_ACTION_WIDGETS; i++)
+                {
+                  if (priv->action_widget[i])
+                    {
+                      gtk_widget_size_request (priv->action_widget[i], &action_widget_requisition[i]);
+                      action_widget_requisition[i].width += widget->style->xthickness;
+                      action_widget_requisition[i].height += widget->style->ythickness;
+                    }
+                }
+
              switch (notebook->tab_pos)
                {
                case GTK_POS_TOP:
@@ -1919,6 +1990,9 @@ gtk_notebook_size_request (GtkWidget      *widget,
                      widget->requisition.width < tab_width)
                    tab_height = MAX (tab_height, scroll_arrow_hlength);
 
+                  tab_height = MAX (tab_height, action_widget_requisition[ACTION_WIDGET_START].height);
+                  tab_height = MAX (tab_height, action_widget_requisition[ACTION_WIDGET_END].height);
+
                  padding = 2 * (tab_curvature + focus_width +
                                 notebook->tab_hborder) - tab_overlap;
                  tab_max += padding;
@@ -1927,7 +2001,7 @@ gtk_notebook_size_request (GtkWidget      *widget,
                      page = children->data;
                      children = children->next;
                  
-                     if (!GTK_WIDGET_VISIBLE (page->child))
+                     if (!gtk_widget_get_visible (page->child))
                        continue;
 
                      if (notebook->homogeneous)
@@ -1943,13 +2017,15 @@ gtk_notebook_size_request (GtkWidget      *widget,
                      widget->requisition.width < tab_width)
                    tab_width = tab_max + 2 * (scroll_arrow_hlength + arrow_spacing);
 
+                 action_width += action_widget_requisition[ACTION_WIDGET_START].width;
+                 action_width += action_widget_requisition[ACTION_WIDGET_END].width;
                   if (notebook->homogeneous && !notebook->scrollable)
                     widget->requisition.width = MAX (widget->requisition.width,
                                                      vis_pages * tab_max +
-                                                     tab_overlap);
+                                                     tab_overlap + action_width);
                   else
                     widget->requisition.width = MAX (widget->requisition.width,
-                                                     tab_width + tab_overlap);
+                                                     tab_width + tab_overlap + action_width);
 
                  widget->requisition.height += tab_height;
                  break;
@@ -1963,6 +2039,9 @@ gtk_notebook_size_request (GtkWidget      *widget,
                    tab_width = MAX (tab_width,
                                      arrow_spacing + 2 * scroll_arrow_vlength);
 
+                 tab_width = MAX (tab_width, action_widget_requisition[ACTION_WIDGET_START].width);
+                 tab_width = MAX (tab_width, action_widget_requisition[ACTION_WIDGET_END].width);
+
                  padding = 2 * (tab_curvature + focus_width +
                                 notebook->tab_vborder) - tab_overlap;
                  tab_max += padding;
@@ -1972,10 +2051,10 @@ gtk_notebook_size_request (GtkWidget      *widget,
                      page = children->data;
                      children = children->next;
 
-                     if (!GTK_WIDGET_VISIBLE (page->child))
+                     if (!gtk_widget_get_visible (page->child))
                        continue;
 
-                     page->requisition.width   = tab_width;
+                     page->requisition.width = tab_width;
 
                      if (notebook->homogeneous)
                        page->requisition.height = tab_max;
@@ -1988,23 +2067,25 @@ gtk_notebook_size_request (GtkWidget      *widget,
                  if (notebook->scrollable && vis_pages > 1 && 
                      widget->requisition.height < tab_height)
                    tab_height = tab_max + (2 * scroll_arrow_vlength + arrow_spacing);
-
-                 widget->requisition.width += tab_width;
+                 action_height += action_widget_requisition[ACTION_WIDGET_START].height;
+                 action_height += action_widget_requisition[ACTION_WIDGET_END].height;
 
                   if (notebook->homogeneous && !notebook->scrollable)
                     widget->requisition.height =
                      MAX (widget->requisition.height,
-                          vis_pages * tab_max + tab_overlap);
+                          vis_pages * tab_max + tab_overlap + action_height);
                   else
                     widget->requisition.height =
                      MAX (widget->requisition.height,
-                          tab_height + tab_overlap);
+                          tab_height + tab_overlap + action_height);
 
                  if (!notebook->homogeneous || notebook->scrollable)
                    vis_pages = 1;
                  widget->requisition.height = MAX (widget->requisition.height,
                                                    vis_pages * tab_max +
                                                    tab_overlap);
+
+                 widget->requisition.width += tab_width;
                  break;
                }
            }
@@ -2016,7 +2097,7 @@ gtk_notebook_size_request (GtkWidget      *widget,
            {
              page = children->data;
              
-             if (page->tab_label && GTK_WIDGET_VISIBLE (page->tab_label))
+             if (page->tab_label && gtk_widget_get_visible (page->tab_label))
                gtk_widget_hide (page->tab_label);
            }
        }
@@ -2033,14 +2114,14 @@ gtk_notebook_size_request (GtkWidget      *widget,
               children = children->next)
            {
              page = children->data;
-             if (GTK_WIDGET_VISIBLE (page->child))
+             if (gtk_widget_get_visible (page->child))
                {
                  gtk_notebook_switch_page (notebook, page);
                  break;
                }
            }
        }
-      else if (GTK_WIDGET_VISIBLE (widget))
+      else if (gtk_widget_get_visible (widget))
        {
          widget->requisition.width = GTK_CONTAINER (widget)->border_width * 2;
          widget->requisition.height= GTK_CONTAINER (widget)->border_width * 2;
@@ -2061,9 +2142,14 @@ static void
 gtk_notebook_size_allocate (GtkWidget     *widget,
                            GtkAllocation *allocation)
 {
+  GtkNotebookPrivate *priv = GTK_NOTEBOOK_GET_PRIVATE (widget);
   GtkNotebook *notebook = GTK_NOTEBOOK (widget);
   gint tab_pos = get_effective_tab_pos (notebook);
+  gboolean is_rtl;
+  gint focus_width;
 
+  gtk_widget_style_get (widget, "focus-line-width", &focus_width, NULL);
+  
   widget->allocation = *allocation;
   if (GTK_WIDGET_REALIZED (widget))
     {
@@ -2074,7 +2160,7 @@ gtk_notebook_size_allocate (GtkWidget     *widget,
          gdk_window_move_resize (notebook->event_window,
                                  position.x, position.y,
                                  position.width, position.height);
-         if (GTK_WIDGET_MAPPED (notebook))
+         if (gtk_widget_get_mapped (GTK_WIDGET (notebook)))
            gdk_window_show_unraised (notebook->event_window);
        }
       else
@@ -2087,6 +2173,7 @@ gtk_notebook_size_allocate (GtkWidget     *widget,
       GtkNotebookPage *page;
       GtkAllocation child_allocation;
       GList *children;
+      gint i;
       
       child_allocation.x = widget->allocation.x + border_width;
       child_allocation.y = widget->allocation.y + border_width;
@@ -2121,6 +2208,55 @@ gtk_notebook_size_allocate (GtkWidget     *widget,
                         notebook->cur_page->requisition.width);
                  break;
                }
+
+              for (i = 0; i < N_ACTION_WIDGETS; i++)
+                {
+                  GtkAllocation widget_allocation;
+
+                  if (!priv->action_widget[i])
+                    continue;
+
+                 widget_allocation.x = widget->allocation.x + border_width;
+                 widget_allocation.y = widget->allocation.y + border_width;
+                 is_rtl = gtk_widget_get_direction (widget) == GTK_TEXT_DIR_RTL;
+
+                 switch (tab_pos)
+                   {
+                   case GTK_POS_BOTTOM:
+                     widget_allocation.y +=
+                       widget->allocation.height - 2 * border_width - notebook->cur_page->requisition.height;
+                     /* fall through */
+                   case GTK_POS_TOP:
+                     widget_allocation.width = priv->action_widget[i]->requisition.width;
+                     widget_allocation.height = notebook->cur_page->requisition.height - widget->style->ythickness;
+
+                     if ((i == ACTION_WIDGET_START && is_rtl) ||
+                          (i == ACTION_WIDGET_END && !is_rtl))
+                       widget_allocation.x +=
+                         widget->allocation.width - 2 * border_width -
+                         priv->action_widget[i]->requisition.width;
+                      if (tab_pos == GTK_POS_TOP) /* no fall through */
+                          widget_allocation.y += 2 * focus_width;
+                     break;
+                   case GTK_POS_RIGHT:
+                     widget_allocation.x +=
+                       widget->allocation.width - 2 * border_width - notebook->cur_page->requisition.width;
+                     /* fall through */
+                   case GTK_POS_LEFT:
+                     widget_allocation.height = priv->action_widget[i]->requisition.height;
+                     widget_allocation.width = notebook->cur_page->requisition.width - widget->style->xthickness;
+
+                      if (i == ACTION_WIDGET_END)
+                        widget_allocation.y +=
+                          widget->allocation.height - 2 * border_width -
+                          priv->action_widget[i]->requisition.height;
+                      if (tab_pos == GTK_POS_LEFT) /* no fall through */  
+                        widget_allocation.x += 2 * focus_width;
+                     break;
+                   }
+
+                 gtk_widget_size_allocate (priv->action_widget[i], &widget_allocation);
+               }
            }
        }
 
@@ -2130,7 +2266,7 @@ gtk_notebook_size_allocate (GtkWidget     *widget,
          page = children->data;
          children = children->next;
          
-         if (GTK_WIDGET_VISIBLE (page->child))
+         if (gtk_widget_get_visible (page->child))
            gtk_widget_size_allocate (page->child, &child_allocation);
        }
 
@@ -2144,6 +2280,7 @@ gtk_notebook_expose (GtkWidget      *widget,
 {
   GtkNotebook *notebook;
   GtkNotebookPrivate *priv;
+  gint i;
 
   notebook = GTK_NOTEBOOK (widget);
   priv = GTK_NOTEBOOK_GET_PRIVATE (widget);
@@ -2174,7 +2311,7 @@ gtk_notebook_expose (GtkWidget      *widget,
       gtk_container_propagate_expose (GTK_CONTAINER (notebook),
                                      notebook->cur_page->tab_label, event);
     }
-  else if (GTK_WIDGET_DRAWABLE (widget))
+  else if (gtk_widget_is_drawable (widget))
     {
       gtk_notebook_paint (widget, &event->area);
       if (notebook->show_tabs)
@@ -2191,7 +2328,7 @@ gtk_notebook_expose (GtkWidget      *widget,
              pages = pages->next;
 
              if (page->tab_label->window == event->window &&
-                 GTK_WIDGET_DRAWABLE (page->tab_label))
+                 gtk_widget_is_drawable (page->tab_label))
                gtk_container_propagate_expose (GTK_CONTAINER (notebook),
                                                page->tab_label, event);
            }
@@ -2201,6 +2338,16 @@ gtk_notebook_expose (GtkWidget      *widget,
        gtk_container_propagate_expose (GTK_CONTAINER (notebook),
                                        notebook->cur_page->child,
                                        event);
+      if (notebook->show_tabs)
+      {
+        for (i = 0; i < N_ACTION_WIDGETS; i++)
+        {
+          if (priv->action_widget[i] &&
+              gtk_widget_is_drawable (priv->action_widget[i]))
+            gtk_container_propagate_expose (GTK_CONTAINER (notebook),
+                                            priv->action_widget[i], event);
+        }
+      }
     }
 
   return FALSE;
@@ -2361,7 +2508,7 @@ gtk_notebook_arrow_button_press (GtkNotebook      *notebook,
   gboolean left = (ARROW_IS_LEFT (arrow) && !is_rtl) || 
                   (!ARROW_IS_LEFT (arrow) && is_rtl);
 
-  if (!GTK_WIDGET_HAS_FOCUS (widget))
+  if (!gtk_widget_has_focus (widget))
     gtk_widget_grab_focus (widget);
   
   notebook->button = button;
@@ -2423,21 +2570,29 @@ static gboolean
 gtk_notebook_scroll (GtkWidget      *widget,
                      GdkEventScroll *event)
 {
+  GtkNotebookPrivate *priv = GTK_NOTEBOOK_GET_PRIVATE (widget);
   GtkNotebook *notebook = GTK_NOTEBOOK (widget);
-
-  GtkWidget* child;
-  GtkWidget* originator;
+  GtkWidget *child, *event_widget;
+  gint i;
 
   if (!notebook->cur_page)
     return FALSE;
 
   child = notebook->cur_page->child;
-  originator = gtk_get_event_widget ((GdkEvent *)event);
+  event_widget = gtk_get_event_widget ((GdkEvent *)event);
 
   /* ignore scroll events from the content of the page */
-  if (!originator || gtk_widget_is_ancestor (originator, child) || originator == child)
+  if (!event_widget || gtk_widget_is_ancestor (event_widget, child) || event_widget == child)
     return FALSE;
-  
+
+  /* nor from the action area */
+  for (i = 0; i < 2; i++)
+    {
+      if (event_widget == priv->action_widget[i] ||
+          gtk_widget_is_ancestor (event_widget, priv->action_widget[i]))
+        return FALSE;
+    }
+
   switch (event->direction)
     {
     case GDK_SCROLL_RIGHT:
@@ -2463,8 +2618,8 @@ get_tab_at_pos (GtkNotebook *notebook, gint x, gint y)
     {
       page = children->data;
       
-      if (GTK_WIDGET_VISIBLE (page->child) &&
-         page->tab_label && GTK_WIDGET_MAPPED (page->tab_label) &&
+      if (gtk_widget_get_visible (page->child) &&
+         page->tab_label && gtk_widget_get_mapped (page->tab_label) &&
          (x >= page->allocation.x) &&
          (y >= page->allocation.y) &&
          (x <= (page->allocation.x + page->allocation.width)) &&
@@ -2635,9 +2790,9 @@ get_drop_position (GtkNotebook *notebook,
       page = children->data;
 
       if ((priv->operation != DRAG_OPERATION_REORDER || page != notebook->cur_page) &&
-         GTK_WIDGET_VISIBLE (page->child) &&
+         gtk_widget_get_visible (page->child) &&
          page->tab_label &&
-         GTK_WIDGET_MAPPED (page->tab_label) &&
+         gtk_widget_get_mapped (page->tab_label) &&
          page->pack == pack)
        {
          switch (notebook->tab_pos)
@@ -2857,24 +3012,27 @@ static GtkNotebookPointerPosition
 get_pointer_position (GtkNotebook *notebook)
 {
   GtkWidget *widget = (GtkWidget *) notebook;
-  GtkContainer *container = (GtkContainer *) notebook;
   GtkNotebookPrivate *priv = GTK_NOTEBOOK_GET_PRIVATE (notebook);
+  gint wx, wy, width, height;
   gboolean is_rtl;
 
   if (!notebook->scrollable)
     return POINTER_BETWEEN;
 
+  gdk_window_get_position (notebook->event_window, &wx, &wy);
+  gdk_drawable_get_size (GDK_DRAWABLE (notebook->event_window), &width, &height);
+
   if (notebook->tab_pos == GTK_POS_TOP ||
       notebook->tab_pos == GTK_POS_BOTTOM)
     {
       gint x;
 
       is_rtl = gtk_widget_get_direction (widget) == GTK_TEXT_DIR_RTL;
-      x = priv->mouse_x - widget->allocation.x;
+      x = priv->mouse_x - wx;
 
-      if (x > widget->allocation.width - 2 * container->border_width - SCROLL_THRESHOLD)
+      if (x > width - SCROLL_THRESHOLD)
        return (is_rtl) ? POINTER_BEFORE : POINTER_AFTER;
-      else if (x < SCROLL_THRESHOLD + container->border_width)
+      else if (x < SCROLL_THRESHOLD)
        return (is_rtl) ? POINTER_AFTER : POINTER_BEFORE;
       else
        return POINTER_BETWEEN;
@@ -2883,10 +3041,10 @@ get_pointer_position (GtkNotebook *notebook)
     {
       gint y;
 
-      y = priv->mouse_y - widget->allocation.y;
-      if (y > widget->allocation.height - 2 * container->border_width - SCROLL_THRESHOLD)
+      y = priv->mouse_y - wy;
+      if (y > height - SCROLL_THRESHOLD)
        return POINTER_AFTER;
-      else if (y < SCROLL_THRESHOLD + container->border_width)
+      else if (y < SCROLL_THRESHOLD)
        return POINTER_BEFORE;
       else
        return POINTER_BETWEEN;
@@ -3086,7 +3244,7 @@ static void
 gtk_notebook_state_changed (GtkWidget    *widget,
                            GtkStateType  previous_state)
 {
-  if (!GTK_WIDGET_IS_SENSITIVE (widget)) 
+  if (!gtk_widget_is_sensitive (widget))
     stop_scrolling (GTK_NOTEBOOK (widget));
 }
 
@@ -3114,7 +3272,7 @@ gtk_notebook_draw_focus (GtkWidget      *widget,
 {
   GtkNotebook *notebook = GTK_NOTEBOOK (widget);
 
-  if (GTK_WIDGET_HAS_FOCUS (widget) && GTK_WIDGET_DRAWABLE (widget) &&
+  if (gtk_widget_has_focus (widget) && gtk_widget_is_drawable (widget) &&
       notebook->show_tabs && notebook->cur_page &&
       notebook->cur_page->tab_label->window == event->window)
     {
@@ -3813,8 +3971,8 @@ focus_tabs_move (GtkNotebook     *notebook,
 }
 
 static gboolean
-focus_child_in (GtkNotebook     *notebook,
-               GtkDirectionType direction)
+focus_child_in (GtkNotebook      *notebook,
+               GtkDirectionType  direction)
 {
   if (notebook->cur_page)
     return gtk_widget_child_focus (notebook->cur_page->child, direction);
@@ -3822,22 +3980,52 @@ focus_child_in (GtkNotebook     *notebook,
     return FALSE;
 }
 
+static gboolean
+focus_action_in (GtkNotebook      *notebook,
+                 gint              action,
+                 GtkDirectionType  direction)
+{
+  GtkNotebookPrivate *priv = GTK_NOTEBOOK_GET_PRIVATE (notebook);
+
+  if (priv->action_widget[action] &&
+      gtk_widget_get_visible (priv->action_widget[action]))
+    return gtk_widget_child_focus (priv->action_widget[action], direction);
+  else
+    return FALSE;
+}
+
 /* Focus in the notebook can either be on the pages, or on
- * the tabs.
+ * the tabs or on the action_widgets.
  */
 static gint
 gtk_notebook_focus (GtkWidget        *widget,
                    GtkDirectionType  direction)
 {
+  GtkNotebookPrivate *priv;
   GtkWidget *old_focus_child;
   GtkNotebook *notebook;
   GtkDirectionType effective_direction;
+  gint first_action;
+  gint last_action;
 
   gboolean widget_is_focus;
   GtkContainer *container;
 
   container = GTK_CONTAINER (widget);
   notebook = GTK_NOTEBOOK (container);
+  priv = GTK_NOTEBOOK_GET_PRIVATE (notebook);
+
+  if (notebook->tab_pos == GTK_POS_TOP ||
+      notebook->tab_pos == GTK_POS_LEFT)
+    {
+      first_action = ACTION_WIDGET_START;
+      last_action = ACTION_WIDGET_END;
+    }
+  else
+    {
+      first_action = ACTION_WIDGET_END;
+      last_action = ACTION_WIDGET_START;
+    }
 
   if (notebook->focus_out)
     {
@@ -3846,42 +4034,104 @@ gtk_notebook_focus (GtkWidget        *widget,
     }
 
   widget_is_focus = gtk_widget_is_focus (widget);
-  old_focus_child = container->focus_child; 
+  old_focus_child = container->focus_child;
 
   effective_direction = get_effective_direction (notebook, direction);
 
-  if (old_focus_child)         /* Focus on page child */
+  if (old_focus_child)         /* Focus on page child or action widget */
     {
       if (gtk_widget_child_focus (old_focus_child, direction))
         return TRUE;
-      
-      switch (effective_direction)
+
+      if (old_focus_child == priv->action_widget[ACTION_WIDGET_START])
        {
-       case GTK_DIR_TAB_BACKWARD:
-       case GTK_DIR_UP:
-         /* Focus onto the tabs */
-         return focus_tabs_in (notebook);
-       case GTK_DIR_DOWN:
-       case GTK_DIR_TAB_FORWARD:
-       case GTK_DIR_LEFT:
-       case GTK_DIR_RIGHT:
-         return FALSE;
+         switch (effective_direction)
+           {
+           case GTK_DIR_DOWN:
+              return focus_child_in (notebook, GTK_DIR_TAB_FORWARD);
+           case GTK_DIR_RIGHT:
+             return focus_tabs_in (notebook);
+           case GTK_DIR_LEFT:
+              return FALSE;
+           case GTK_DIR_UP:
+             return FALSE;
+            default:
+              switch (direction)
+                {
+               case GTK_DIR_TAB_FORWARD:
+                  if ((notebook->tab_pos == GTK_POS_RIGHT || notebook->tab_pos == GTK_POS_BOTTOM) &&
+                      focus_child_in (notebook, direction))
+                    return TRUE;
+                 return focus_tabs_in (notebook);
+                case GTK_DIR_TAB_BACKWARD:
+                  return FALSE;
+                default:
+                  g_assert_not_reached ();
+                }
+           }
+       }
+      else if (old_focus_child == priv->action_widget[ACTION_WIDGET_END])
+       {
+         switch (effective_direction)
+           {
+           case GTK_DIR_DOWN:
+              return focus_child_in (notebook, GTK_DIR_TAB_FORWARD);
+           case GTK_DIR_RIGHT:
+              return FALSE;
+           case GTK_DIR_LEFT:
+             return focus_tabs_in (notebook);
+           case GTK_DIR_UP:
+             return FALSE;
+            default:
+              switch (direction)
+                {
+               case GTK_DIR_TAB_FORWARD:
+                  return FALSE;
+                case GTK_DIR_TAB_BACKWARD:
+                  if ((notebook->tab_pos == GTK_POS_TOP || notebook->tab_pos == GTK_POS_LEFT) &&
+                      focus_child_in (notebook, direction))
+                    return TRUE;
+                 return focus_tabs_in (notebook);
+                default:
+                  g_assert_not_reached ();
+                }
+           }
+       }
+      else
+       {
+         switch (effective_direction)
+           {
+           case GTK_DIR_TAB_BACKWARD:
+           case GTK_DIR_UP:
+             /* Focus onto the tabs */
+             return focus_tabs_in (notebook);
+           case GTK_DIR_DOWN:
+           case GTK_DIR_LEFT:
+           case GTK_DIR_RIGHT:
+             return FALSE;
+           case GTK_DIR_TAB_FORWARD:
+              return focus_action_in (notebook, last_action, direction);
+           }
        }
     }
   else if (widget_is_focus)    /* Focus was on tabs */
     {
       switch (effective_direction)
        {
-       case GTK_DIR_TAB_BACKWARD:
-       case GTK_DIR_UP:
+        case GTK_DIR_TAB_BACKWARD:
+              return focus_action_in (notebook, first_action, direction);
+        case GTK_DIR_UP:
          return FALSE;
-       case GTK_DIR_TAB_FORWARD:
+        case GTK_DIR_TAB_FORWARD:
+          if (focus_child_in (notebook, GTK_DIR_TAB_FORWARD))
+            return TRUE;
+          return focus_action_in (notebook, last_action, direction);
        case GTK_DIR_DOWN:
          /* We use TAB_FORWARD rather than direction so that we focus a more
           * predictable widget for the user; users may be using arrow focusing
           * in this situation even if they don't usually use arrow focusing.
           */
-         return focus_child_in (notebook, GTK_DIR_TAB_FORWARD);
+          return focus_child_in (notebook, GTK_DIR_TAB_FORWARD);
        case GTK_DIR_LEFT:
          return focus_tabs_move (notebook, direction, STEP_PREV);
        case GTK_DIR_RIGHT:
@@ -3894,18 +4144,25 @@ gtk_notebook_focus (GtkWidget        *widget,
        {
        case GTK_DIR_TAB_FORWARD:
        case GTK_DIR_DOWN:
+          if (focus_action_in (notebook, first_action, direction))
+            return TRUE;
          if (focus_tabs_in (notebook))
            return TRUE;
+          if (focus_action_in (notebook, last_action, direction))
+            return TRUE;
          if (focus_child_in (notebook, direction))
            return TRUE;
          return FALSE;
        case GTK_DIR_TAB_BACKWARD:
-       case GTK_DIR_UP:
+          if (focus_action_in (notebook, last_action, direction))
+            return TRUE;
          if (focus_child_in (notebook, direction))
            return TRUE;
          if (focus_tabs_in (notebook))
            return TRUE;
-         return FALSE;
+          if (focus_action_in (notebook, first_action, direction))
+            return TRUE;
+       case GTK_DIR_UP:
        case GTK_DIR_LEFT:
        case GTK_DIR_RIGHT:
          return focus_child_in (notebook, direction);
@@ -3914,7 +4171,7 @@ gtk_notebook_focus (GtkWidget        *widget,
 
   g_assert_not_reached ();
   return FALSE;
-}  
+}
 
 static void
 gtk_notebook_set_focus_child (GtkContainer *container,
@@ -3930,7 +4187,7 @@ gtk_notebook_set_focus_child (GtkContainer *container,
    */
 
   toplevel = gtk_widget_get_toplevel (GTK_WIDGET (container));
-  if (toplevel && GTK_WIDGET_TOPLEVEL (toplevel))
+  if (toplevel && gtk_widget_is_toplevel (toplevel))
     {
       page_child = GTK_WINDOW (toplevel)->focus_widget; 
       while (page_child)
@@ -3988,10 +4245,13 @@ gtk_notebook_forall (GtkContainer *container,
                     GtkCallback   callback,
                     gpointer      callback_data)
 {
+  GtkNotebookPrivate *priv;
   GtkNotebook *notebook;
   GList *children;
+  gint i;
 
   notebook = GTK_NOTEBOOK (container);
+  priv = GTK_NOTEBOOK_GET_PRIVATE (notebook);
 
   children = notebook->children;
   while (children)
@@ -4008,6 +4268,14 @@ gtk_notebook_forall (GtkContainer *container,
            (* callback) (page->tab_label, callback_data);
        }
     }
+
+  if (include_internals) {
+    for (i = 0; i < N_ACTION_WIDGETS; i++)
+      {
+        if (priv->action_widget[i])
+          (* callback) (priv->action_widget[i], callback_data);
+      }
+  }
 }
 
 static GType
@@ -4031,7 +4299,7 @@ page_visible_cb (GtkWidget  *page,
 
   if (notebook->cur_page &&
       notebook->cur_page->child == page &&
-      !GTK_WIDGET_VISIBLE (page))
+      !gtk_widget_get_visible (page))
     {
       list = g_list_find (notebook->children, notebook->cur_page);
       if (list)
@@ -4103,7 +4371,7 @@ gtk_notebook_real_insert_page (GtkNotebook *notebook,
 
   if (tab_label)
     {
-      if (notebook->show_tabs && GTK_WIDGET_VISIBLE (child))
+      if (notebook->show_tabs && gtk_widget_get_visible (child))
        gtk_widget_show (tab_label);
       else
        gtk_widget_hide (tab_label);
@@ -4171,7 +4439,7 @@ gtk_notebook_redraw_tabs (GtkNotebook *notebook)
   widget = GTK_WIDGET (notebook);
   border = GTK_CONTAINER (notebook)->border_width;
 
-  if (!GTK_WIDGET_MAPPED (notebook) || !notebook->first_tab)
+  if (!gtk_widget_get_mapped (widget) || !notebook->first_tab)
     return;
 
   page = notebook->first_tab->data;
@@ -4220,7 +4488,8 @@ gtk_notebook_redraw_tabs (GtkNotebook *notebook)
 static void
 gtk_notebook_redraw_arrows (GtkNotebook *notebook)
 {
-  if (GTK_WIDGET_MAPPED (notebook) && gtk_notebook_show_arrows (notebook))
+  if (gtk_widget_get_mapped (GTK_WIDGET (notebook)) &&
+      gtk_notebook_show_arrows (notebook))
     {
       GdkRectangle rect;
       gint i;
@@ -4372,7 +4641,8 @@ gtk_notebook_real_remove (GtkNotebook *notebook,
   
   g_signal_handler_disconnect (page->child, page->notify_visible_handler); 
 
-  if (GTK_WIDGET_VISIBLE (page->child) && GTK_WIDGET_VISIBLE (notebook))
+  if (gtk_widget_get_visible (page->child) &&
+      gtk_widget_get_visible (GTK_WIDGET (notebook)))
     need_resize = TRUE;
 
   gtk_widget_unparent (page->child);
@@ -4442,11 +4712,11 @@ gtk_notebook_update_labels (GtkNotebook *notebook)
                gtk_label_set_text (GTK_LABEL (page->tab_label), string);
            }
 
-         if (GTK_WIDGET_VISIBLE (page->child) &&
-             !GTK_WIDGET_VISIBLE (page->tab_label))
+         if (gtk_widget_get_visible (page->child) &&
+             !gtk_widget_get_visible (page->tab_label))
            gtk_widget_show (page->tab_label);
-         else if (!GTK_WIDGET_VISIBLE (page->child) &&
-                  GTK_WIDGET_VISIBLE (page->tab_label))
+         else if (!gtk_widget_get_visible (page->child) &&
+                  gtk_widget_get_visible (page->tab_label))
            gtk_widget_hide (page->tab_label);
        }
       if (notebook->menu && page->default_menu)
@@ -4520,7 +4790,7 @@ gtk_notebook_search_page (GtkNotebook *notebook,
          page = list->data;
          if (page->pack == flag &&
              (!find_visible ||
-              (GTK_WIDGET_VISIBLE (page->child) &&
+              (gtk_widget_get_visible (page->child) &&
                (!page->tab_label || NOTEBOOK_IS_TAB_LABEL_PARENT (notebook, page)))))
            return list;
          old_list = list;
@@ -4538,7 +4808,7 @@ gtk_notebook_search_page (GtkNotebook *notebook,
       page = list->data;
       if (page->pack != flag &&
          (!find_visible ||
-          (GTK_WIDGET_VISIBLE (page->child) &&
+          (gtk_widget_get_visible (page->child) &&
            (!page->tab_label || NOTEBOOK_IS_TAB_LABEL_PARENT (notebook, page)))))
        return list;
       old_list = list;
@@ -4569,7 +4839,7 @@ gtk_notebook_paint (GtkWidget    *widget,
   gboolean is_rtl;
   gint tab_pos;
    
-  if (!GTK_WIDGET_DRAWABLE (widget))
+  if (!gtk_widget_is_drawable (widget))
     return;
 
   notebook = GTK_NOTEBOOK (widget);
@@ -4578,7 +4848,7 @@ gtk_notebook_paint (GtkWidget    *widget,
   tab_pos = get_effective_tab_pos (notebook);
 
   if ((!notebook->show_tabs && !notebook->show_border) ||
-      !notebook->cur_page || !GTK_WIDGET_VISIBLE (notebook->cur_page->child))
+      !notebook->cur_page || !gtk_widget_get_visible (notebook->cur_page->child))
     return;
 
   x = widget->allocation.x + border_width;
@@ -4598,7 +4868,7 @@ gtk_notebook_paint (GtkWidget    *widget,
   if (!notebook->first_tab)
     notebook->first_tab = notebook->children;
 
-  if (!GTK_WIDGET_MAPPED (notebook->cur_page->tab_label))
+  if (!gtk_widget_get_mapped (notebook->cur_page->tab_label))
     page = GTK_NOTEBOOK_PAGE (notebook->first_tab);
   else
     page = notebook->cur_page;
@@ -4620,7 +4890,7 @@ gtk_notebook_paint (GtkWidget    *widget,
     }
 
   if (!NOTEBOOK_IS_TAB_LABEL_PARENT (notebook, notebook->cur_page) ||
-      !GTK_WIDGET_MAPPED (notebook->cur_page->tab_label))
+      !gtk_widget_get_mapped (notebook->cur_page->tab_label))
     {
       gap_x = 0;
       gap_width = 0;
@@ -4664,9 +4934,9 @@ gtk_notebook_paint (GtkWidget    *widget,
       page = children->data;
       children = gtk_notebook_search_page (notebook, children,
                                           step, TRUE);
-      if (!GTK_WIDGET_VISIBLE (page->child))
+      if (!gtk_widget_get_visible (page->child))
        continue;
-      if (!GTK_WIDGET_MAPPED (page->tab_label))
+      if (!gtk_widget_get_mapped (page->tab_label))
        showarrow = TRUE;
       else if (page != notebook->cur_page)
        gtk_notebook_draw_tab (notebook, page, area);
@@ -4700,7 +4970,7 @@ gtk_notebook_draw_tab (GtkNotebook     *notebook,
   GtkWidget *widget;
   
   if (!NOTEBOOK_IS_TAB_LABEL_PARENT (notebook, page) ||
-      !GTK_WIDGET_MAPPED (page->tab_label) ||
+      !gtk_widget_get_mapped (page->tab_label) ||
       (page->allocation.width == 0) || (page->allocation.height == 0))
     return;
 
@@ -4746,7 +5016,9 @@ gtk_notebook_draw_arrow (GtkNotebook      *notebook,
   GtkArrowType arrow;
   gboolean is_rtl, left;
 
-  if (GTK_WIDGET_DRAWABLE (notebook))
+  widget = GTK_WIDGET (notebook);
+
+  if (gtk_widget_is_drawable (widget))
     {
       gint scroll_arrow_hlength;
       gint scroll_arrow_vlength;
@@ -4754,8 +5026,6 @@ gtk_notebook_draw_arrow (GtkNotebook      *notebook,
 
       gtk_notebook_get_arrow_rect (notebook, &arrow_rect, nbarrow);
 
-      widget = GTK_WIDGET (notebook);
-
       is_rtl = gtk_widget_get_direction (widget) == GTK_TEXT_DIR_RTL;
       left = (ARROW_IS_LEFT (nbarrow) && !is_rtl) ||
              (!ARROW_IS_LEFT (nbarrow) && is_rtl); 
@@ -4831,10 +5101,13 @@ gtk_notebook_tab_space (GtkNotebook *notebook,
   gint arrow_spacing;
   gint scroll_arrow_hlength;
   gint scroll_arrow_vlength;
+  gboolean is_rtl;
+  gint i;
 
   widget = GTK_WIDGET (notebook);
   priv = GTK_NOTEBOOK_GET_PRIVATE (notebook);
   children = notebook->children;
+  is_rtl = gtk_widget_get_direction (widget) == GTK_TEXT_DIR_RTL;
 
   gtk_widget_style_get (GTK_WIDGET (notebook),
                         "arrow-spacing", &arrow_spacing,
@@ -4849,6 +5122,18 @@ gtk_notebook_tab_space (GtkNotebook *notebook,
       *min = widget->allocation.x + GTK_CONTAINER (notebook)->border_width;
       *max = widget->allocation.x + widget->allocation.width - GTK_CONTAINER (notebook)->border_width;
 
+      for (i = 0; i < N_ACTION_WIDGETS; i++)
+        {
+          if (priv->action_widget[i])
+            {
+              if ((i == ACTION_WIDGET_START && !is_rtl) ||
+                  (i == ACTION_WIDGET_END && is_rtl))
+                *min += priv->action_widget[i]->allocation.width + widget->style->xthickness;
+              else
+                *max -= priv->action_widget[i]->allocation.width + widget->style->xthickness;
+            }
+        }
+
       while (children)
        {
           GtkNotebookPage *page;
@@ -4857,7 +5142,7 @@ gtk_notebook_tab_space (GtkNotebook *notebook,
          children = children->next;
 
          if (NOTEBOOK_IS_TAB_LABEL_PARENT (notebook, page) &&
-             GTK_WIDGET_VISIBLE (page->child))
+             gtk_widget_get_visible (page->child))
            *tab_space += page->requisition.width;
        }
       break;
@@ -4866,6 +5151,17 @@ gtk_notebook_tab_space (GtkNotebook *notebook,
       *min = widget->allocation.y + GTK_CONTAINER (notebook)->border_width;
       *max = widget->allocation.y + widget->allocation.height - GTK_CONTAINER (notebook)->border_width;
 
+      for (i = 0; i < N_ACTION_WIDGETS; i++)
+        {
+          if (priv->action_widget[i])
+            {
+              if (i == ACTION_WIDGET_START)
+                *min += priv->action_widget[i]->allocation.height + widget->style->ythickness;
+              else
+                *max -= priv->action_widget[i]->allocation.height + widget->style->ythickness;
+            }
+        }
+
       while (children)
        {
           GtkNotebookPage *page;
@@ -4874,7 +5170,7 @@ gtk_notebook_tab_space (GtkNotebook *notebook,
          children = children->next;
 
          if (NOTEBOOK_IS_TAB_LABEL_PARENT (notebook, page) &&
-             GTK_WIDGET_VISIBLE (page->child))
+             gtk_widget_get_visible (page->child))
            *tab_space += page->requisition.height;
        }
       break;
@@ -4895,8 +5191,7 @@ gtk_notebook_tab_space (GtkNotebook *notebook,
              *show_arrows = TRUE;
 
              /* take arrows into account */
-             *tab_space = widget->allocation.width - tab_overlap -
-               2 * GTK_CONTAINER (notebook)->border_width;
+             *tab_space = *max - *min - tab_overlap;
 
              if (notebook->has_after_previous)
                {
@@ -4930,8 +5225,7 @@ gtk_notebook_tab_space (GtkNotebook *notebook,
              *show_arrows = TRUE;
 
              /* take arrows into account */
-             *tab_space = widget->allocation.height -
-               tab_overlap - 2 * GTK_CONTAINER (notebook)->border_width;
+             *tab_space = *max - *min - tab_overlap;
 
              if (notebook->has_after_previous || notebook->has_after_next)
                {
@@ -4976,7 +5270,7 @@ gtk_notebook_calculate_shown_tabs (GtkNotebook *notebook,
       *remaining_space = tab_space;
 
       if (NOTEBOOK_IS_TAB_LABEL_PARENT (notebook, notebook->cur_page) &&
-         GTK_WIDGET_VISIBLE (notebook->cur_page->child))
+         gtk_widget_get_visible (notebook->cur_page->child))
        {
          gtk_notebook_calc_tabs (notebook,
                                  notebook->focus_tab,
@@ -4984,7 +5278,7 @@ gtk_notebook_calculate_shown_tabs (GtkNotebook *notebook,
                                  remaining_space, STEP_NEXT);
        }
 
-      if (tab_space <= 0 || *remaining_space < 0)
+      if (tab_space <= 0 || *remaining_space <= 0)
        {
          /* show 1 tab */
          notebook->first_tab = notebook->focus_tab;
@@ -5003,7 +5297,7 @@ gtk_notebook_calculate_shown_tabs (GtkNotebook *notebook,
              /* Is first_tab really predecessor of focus_tab? */
              page = notebook->first_tab->data;
              if (NOTEBOOK_IS_TAB_LABEL_PARENT (notebook, page) &&
-                 GTK_WIDGET_VISIBLE (page->child))
+                 gtk_widget_get_visible (page->child))
                for (children = notebook->focus_tab;
                     children && children != notebook->first_tab;
                     children = gtk_notebook_search_page (notebook,
@@ -5136,7 +5430,7 @@ gtk_notebook_calculate_shown_tabs (GtkNotebook *notebook,
          children = children->next;
 
          if (!NOTEBOOK_IS_TAB_LABEL_PARENT (notebook, page) ||
-             !GTK_WIDGET_VISIBLE (page->child))
+             !gtk_widget_get_visible (page->child))
            continue;
 
          c++;
@@ -5262,7 +5556,7 @@ gtk_notebook_calculate_tabs_allocation (GtkNotebook  *notebook,
        {
          *children = (*children)->next;
 
-          if (page->pack != GTK_PACK_END || !GTK_WIDGET_VISIBLE (page->child))
+          if (page->pack != GTK_PACK_END || !gtk_widget_get_visible (page->child))
            continue;
        }
 
@@ -5575,7 +5869,7 @@ gtk_notebook_page_allocate (GtkNotebook     *notebook,
   gboolean was_visible = page->tab_allocated_visible;
 
   if (!page->tab_label ||
-      !GTK_WIDGET_VISIBLE (page->tab_label) ||
+      !gtk_widget_get_visible (page->tab_label) ||
       !gtk_widget_get_child_visible (page->tab_label))
     {
       page->tab_allocated_visible = FALSE;
@@ -5696,7 +5990,7 @@ gtk_notebook_calc_tabs (GtkNotebook  *notebook,
            {
              page = children->data;
              if (NOTEBOOK_IS_TAB_LABEL_PARENT (notebook, page) &&
-                 GTK_WIDGET_VISIBLE (page->child))
+                 gtk_widget_get_visible (page->child))
                {
                  if (page->pack == pack)
                    {
@@ -5732,7 +6026,7 @@ gtk_notebook_calc_tabs (GtkNotebook  *notebook,
            {
              page = children->data;
              if (NOTEBOOK_IS_TAB_LABEL_PARENT (notebook, page) &&
-                 GTK_WIDGET_VISIBLE (page->child))
+                 gtk_widget_get_visible (page->child))
                {
                  if (page->pack == pack)
                    {
@@ -5801,7 +6095,7 @@ gtk_notebook_real_switch_page (GtkNotebook     *notebook,
 {
   gboolean child_has_focus;
 
-  if (notebook->cur_page == page || !GTK_WIDGET_VISIBLE (page->child))
+  if (notebook->cur_page == page || !gtk_widget_get_visible (page->child))
     return;
 
   /* save the value here, changing visibility changes focus */
@@ -5921,7 +6215,7 @@ gtk_notebook_switch_focus_tab (GtkNotebook *notebook,
     return;
 
   page = notebook->focus_tab->data;
-  if (GTK_WIDGET_MAPPED (page->tab_label))
+  if (gtk_widget_get_mapped (page->tab_label))
     gtk_notebook_redraw_tabs (notebook);
   else
     gtk_notebook_pages_allocate (notebook);
@@ -5988,7 +6282,7 @@ gtk_notebook_menu_item_create (GtkNotebook *notebook,
                         gtk_notebook_real_page_position (notebook, list));
   g_signal_connect (menu_item, "activate",
                    G_CALLBACK (gtk_notebook_menu_switch_page), page);
-  if (GTK_WIDGET_VISIBLE (page->child))
+  if (gtk_widget_get_visible (page->child))
     gtk_widget_show (menu_item);
 }
 
@@ -6039,7 +6333,8 @@ gtk_notebook_set_tab_border_internal (GtkNotebook *notebook,
   notebook->tab_hborder = border_width;
   notebook->tab_vborder = border_width;
 
-  if (GTK_WIDGET_VISIBLE (notebook) && notebook->show_tabs)
+  if (notebook->show_tabs &&
+      gtk_widget_get_visible (GTK_WIDGET (notebook)))
     gtk_widget_queue_resize (GTK_WIDGET (notebook));
 
   g_object_freeze_notify (G_OBJECT (notebook));
@@ -6057,7 +6352,8 @@ gtk_notebook_set_tab_hborder_internal (GtkNotebook *notebook,
 
   notebook->tab_hborder = tab_hborder;
 
-  if (GTK_WIDGET_VISIBLE (notebook) && notebook->show_tabs)
+  if (notebook->show_tabs &&
+      gtk_widget_get_visible (GTK_WIDGET (notebook)))
     gtk_widget_queue_resize (GTK_WIDGET (notebook));
 
   g_object_notify (G_OBJECT (notebook), "tab-hborder");
@@ -6072,7 +6368,8 @@ gtk_notebook_set_tab_vborder_internal (GtkNotebook *notebook,
 
   notebook->tab_vborder = tab_vborder;
 
-  if (GTK_WIDGET_VISIBLE (notebook) && notebook->show_tabs)
+  if (notebook->show_tabs &&
+      gtk_widget_get_visible (GTK_WIDGET (notebook)))
     gtk_widget_queue_resize (GTK_WIDGET (notebook));
 
   g_object_notify (G_OBJECT (notebook), "tab-vborder");
@@ -6092,9 +6389,9 @@ gtk_notebook_set_tab_vborder_internal (GtkNotebook *notebook,
  * gtk_notebook_append_page:
  * @notebook: a #GtkNotebook
  * @child: the #GtkWidget to use as the contents of the page.
- * @tab_label: the #GtkWidget to be used as the label for the page,
+ * @tab_label: (allow-none): the #GtkWidget to be used as the label for the page,
  *             or %NULL to use the default label, 'page N'.
- * 
+ *
  * Appends a page to @notebook.
  *
  * Return value: the index (starting from 0) of the appended
@@ -6116,9 +6413,9 @@ gtk_notebook_append_page (GtkNotebook *notebook,
  * gtk_notebook_append_page_menu:
  * @notebook: a #GtkNotebook
  * @child: the #GtkWidget to use as the contents of the page.
- * @tab_label: the #GtkWidget to be used as the label for the page,
+ * @tab_label: (allow-none): the #GtkWidget to be used as the label for the page,
  *             or %NULL to use the default label, 'page N'.
- * @menu_label: the widget to use as a label for the page-switch
+ * @menu_label: (allow-none): the widget to use as a label for the page-switch
  *              menu, if that is enabled. If %NULL, and @tab_label
  *              is a #GtkLabel or %NULL, then the menu label will be
  *              a newly created label with the same text as @tab_label;
@@ -6149,7 +6446,7 @@ gtk_notebook_append_page_menu (GtkNotebook *notebook,
  * gtk_notebook_prepend_page:
  * @notebook: a #GtkNotebook
  * @child: the #GtkWidget to use as the contents of the page.
- * @tab_label: the #GtkWidget to be used as the label for the page,
+ * @tab_label: (allow-none): the #GtkWidget to be used as the label for the page,
  *             or %NULL to use the default label, 'page N'.
  *
  * Prepends a page to @notebook.
@@ -6173,9 +6470,9 @@ gtk_notebook_prepend_page (GtkNotebook *notebook,
  * gtk_notebook_prepend_page_menu:
  * @notebook: a #GtkNotebook
  * @child: the #GtkWidget to use as the contents of the page.
- * @tab_label: the #GtkWidget to be used as the label for the page,
+ * @tab_label: (allow-none): the #GtkWidget to be used as the label for the page,
  *             or %NULL to use the default label, 'page N'.
- * @menu_label: the widget to use as a label for the page-switch
+ * @menu_label: (allow-none): the widget to use as a label for the page-switch
  *              menu, if that is enabled. If %NULL, and @tab_label
  *              is a #GtkLabel or %NULL, then the menu label will be
  *              a newly created label with the same text as @tab_label;
@@ -6206,11 +6503,11 @@ gtk_notebook_prepend_page_menu (GtkNotebook *notebook,
  * gtk_notebook_insert_page:
  * @notebook: a #GtkNotebook
  * @child: the #GtkWidget to use as the contents of the page.
- * @tab_label: the #GtkWidget to be used as the label for the page,
+ * @tab_label: (allow-none): the #GtkWidget to be used as the label for the page,
  *             or %NULL to use the default label, 'page N'.
  * @position: the index (starting at 0) at which to insert the page,
  *            or -1 to append the page after all other pages.
- * 
+ *
  * Insert a page into @notebook at the given position.
  *
  * Return value: the index (starting from 0) of the inserted
@@ -6263,9 +6560,9 @@ gtk_notebook_mnemonic_activate_switch_page (GtkWidget *child,
  * gtk_notebook_insert_page_menu:
  * @notebook: a #GtkNotebook
  * @child: the #GtkWidget to use as the contents of the page.
- * @tab_label: the #GtkWidget to be used as the label for the page,
+ * @tab_label: (allow-none): the #GtkWidget to be used as the label for the page,
  *             or %NULL to use the default label, 'page N'.
- * @menu_label: the widget to use as a label for the page-switch
+ * @menu_label: (allow-none): the widget to use as a label for the page-switch
  *              menu, if that is enabled. If %NULL, and @tab_label
  *              is a #GtkLabel or %NULL, then the menu label will be
  *              a newly created label with the same text as @tab_label;
@@ -6362,8 +6659,8 @@ gtk_notebook_get_current_page (GtkNotebook *notebook)
  *            to get the last page.
  * 
  * Returns the child widget contained in page number @page_num.
- * 
- * Return value: the child widget, or %NULL if @page_num is
+ *
+ * Return value: (transfer none): the child widget, or %NULL if @page_num is
  * out of bounds.
  **/
 GtkWidget*
@@ -6554,7 +6851,7 @@ gtk_notebook_set_show_border (GtkNotebook *notebook,
     {
       notebook->show_border = show_border;
 
-      if (GTK_WIDGET_VISIBLE (notebook))
+      if (gtk_widget_get_visible (GTK_WIDGET (notebook)))
        gtk_widget_queue_resize (GTK_WIDGET (notebook));
       
       g_object_notify (G_OBJECT (notebook), "show-border");
@@ -6589,11 +6886,15 @@ void
 gtk_notebook_set_show_tabs (GtkNotebook *notebook,
                            gboolean     show_tabs)
 {
+  GtkNotebookPrivate *priv;
   GtkNotebookPage *page;
   GList *children;
+  gint i;
 
   g_return_if_fail (GTK_IS_NOTEBOOK (notebook));
 
+  priv = GTK_NOTEBOOK_GET_PRIVATE (notebook);
+
   show_tabs = show_tabs != FALSE;
 
   if (notebook->show_tabs == show_tabs)
@@ -6604,8 +6905,8 @@ gtk_notebook_set_show_tabs (GtkNotebook *notebook,
 
   if (!show_tabs)
     {
-      GTK_WIDGET_UNSET_FLAGS (notebook, GTK_CAN_FOCUS);
-      
+      gtk_widget_set_can_focus (GTK_WIDGET (notebook), FALSE);
+
       while (children)
        {
          page = children->data;
@@ -6621,9 +6922,16 @@ gtk_notebook_set_show_tabs (GtkNotebook *notebook,
     }
   else
     {
-      GTK_WIDGET_SET_FLAGS (notebook, GTK_CAN_FOCUS);
+      gtk_widget_set_can_focus (GTK_WIDGET (notebook), TRUE);
       gtk_notebook_update_labels (notebook);
     }
+
+  for (i = 0; i < N_ACTION_WIDGETS; i++)
+    {
+      if (priv->action_widget[i])
+        gtk_widget_set_child_visible (priv->action_widget[i], show_tabs);
+    }
+
   gtk_widget_queue_resize (GTK_WIDGET (notebook));
 
   g_object_notify (G_OBJECT (notebook), "show-tabs");
@@ -6663,7 +6971,7 @@ gtk_notebook_set_tab_pos (GtkNotebook     *notebook,
   if (notebook->tab_pos != pos)
     {
       notebook->tab_pos = pos;
-      if (GTK_WIDGET_VISIBLE (notebook))
+      if (gtk_widget_get_visible (GTK_WIDGET (notebook)))
        gtk_widget_queue_resize (GTK_WIDGET (notebook));
     }
 
@@ -6774,7 +7082,7 @@ gtk_notebook_set_scrollable (GtkNotebook *notebook,
     {
       notebook->scrollable = scrollable;
 
-      if (GTK_WIDGET_VISIBLE (notebook))
+      if (gtk_widget_get_visible (GTK_WIDGET (notebook)))
        gtk_widget_queue_resize (GTK_WIDGET (notebook));
 
       g_object_notify (G_OBJECT (notebook), "scrollable");
@@ -6881,8 +7189,8 @@ gtk_notebook_popup_disable  (GtkNotebook *notebook)
  * Returns the tab label widget for the page @child. %NULL is returned
  * if @child is not in @notebook or if no tab label has specifically
  * been set for @child.
- * 
- * Return value: the tab label
+ *
+ * Return value: (transfer none): the tab label
  **/
 GtkWidget *
 gtk_notebook_get_tab_label (GtkNotebook *notebook,
@@ -6907,9 +7215,9 @@ gtk_notebook_get_tab_label (GtkNotebook *notebook,
  * gtk_notebook_set_tab_label:
  * @notebook: a #GtkNotebook
  * @child: the page
- * @tab_label: the tab label widget to use, or %NULL for default tab
+ * @tab_label: (allow-none): the tab label widget to use, or %NULL for default tab
  *             label.
- * 
+ *
  * Changes the tab label for @child. If %NULL is specified
  * for @tab_label, then the page will have the label 'page N'.
  **/
@@ -6968,7 +7276,7 @@ gtk_notebook_set_tab_label (GtkNotebook *notebook,
                        G_CALLBACK (gtk_notebook_mnemonic_activate_switch_page),
                        notebook);
 
-  if (notebook->show_tabs && GTK_WIDGET_VISIBLE (child))
+  if (notebook->show_tabs && gtk_widget_get_visible (child))
     {
       gtk_widget_show (page->tab_label);
       gtk_widget_queue_resize (GTK_WIDGET (notebook));
@@ -7066,9 +7374,9 @@ gtk_notebook_get_menu_label (GtkNotebook *notebook,
  * gtk_notebook_set_menu_label:
  * @notebook: a #GtkNotebook
  * @child: the child widget
- * @menu_label: the menu label, or NULL for default
- * 
- * Changes the menu label for the page containing @child. 
+ * @menu_label: (allow-none): the menu label, or NULL for default
+ *
+ * Changes the menu label for the page containing @child.
  **/
 void
 gtk_notebook_set_menu_label (GtkNotebook *notebook,
@@ -7199,7 +7507,8 @@ gtk_notebook_child_reordered (GtkNotebook     *notebook,
  * containing @child. See gtk_box_pack_start() for the exact meaning
  * of the parameters.
  *
- * Deprecated: 2.20: Modify the expand and fill child properties instead.
+ * Deprecated: 2.20: Modify the #GtkNotebook:tab-expand and
+ *   #GtkNotebook:tab-fill child properties instead.
  **/
 void
 gtk_notebook_set_tab_label_packing (GtkNotebook *notebook,
@@ -7252,7 +7561,8 @@ gtk_notebook_set_tab_label_packing (GtkNotebook *notebook,
  * Query the packing attributes for the tab label of the page
  * containing @child.
  *
- * Deprecated: 2.20: Modify the "expand" and "fill" child properties instead.
+ * Deprecated: 2.20: Modify the #GtkNotebook:tab-expand and
+ *   #GtkNotebook:tab-fill child properties instead.
  **/
 void
 gtk_notebook_query_tab_label_packing (GtkNotebook *notebook,
@@ -7348,9 +7658,9 @@ gtk_notebook_reorder_child (GtkNotebook *notebook,
 
 /**
  * gtk_notebook_set_window_creation_hook:
- * @func: the #GtkNotebookWindowCreationFunc, or %NULL
+ * @func: (allow-none): the #GtkNotebookWindowCreationFunc, or %NULL
  * @data: user data for @func
- * @destroy: Destroy notifier for @data, or %NULL
+ * @destroy: (allow-none): Destroy notifier for @data, or %NULL
  *
  * Installs a global function used to create a window
  * when a detached tab is dropped in an empty area.
@@ -7399,7 +7709,7 @@ gtk_notebook_set_group_id (GtkNotebook *notebook,
 /**
  * gtk_notebook_set_group:
  * @notebook: a #GtkNotebook
- * @group: a pointer to identify the notebook group, or %NULL to unset it
+ * @group: (allow-none): a pointer to identify the notebook group, or %NULL to unset it
  *
  * Sets a group identificator pointer for @notebook, notebooks sharing
  * the same group identificator pointer will be able to exchange tabs
@@ -7623,5 +7933,71 @@ gtk_notebook_set_tab_detachable (GtkNotebook *notebook,
     }
 }
 
+/**
+ * gtk_notebook_get_action_widget:
+ * @notebook: a #GtkNotebook
+ * @pack_type: pack type of the action widget to receive
+ *
+ * Gets one of the action widgets. See gtk_notebook_set_action_widget().
+ *
+ * Returns: The action widget with the given @pack_type or
+ *     %NULL when this action widget has not been set
+ *
+ * Since: 2.20
+ */
+GtkWidget*
+gtk_notebook_get_action_widget (GtkNotebook *notebook,
+                                GtkPackType  pack_type)
+{
+  GtkNotebookPrivate *priv;
+
+  g_return_val_if_fail (GTK_IS_NOTEBOOK (notebook), NULL);
+
+  priv = GTK_NOTEBOOK_GET_PRIVATE (notebook);
+  return priv->action_widget[pack_type];
+}
+
+/**
+ * gtk_notebook_set_action_widget:
+ * @notebook: a #GtkNotebook
+ * @widget: a #GtkWidget
+ * @pack_type: pack type of the action widget
+ *
+ * Sets @widget as one of the action widgets. Depending on the pack type
+ * the widget will be placed before or after the tabs. You can use
+ * a #GtkBox if you need to pack more than one widget on the same side.
+ *
+ * Note that action widgets are "internal" children of the notebook and thus
+ * not included in the list returned from gtk_container_foreach().
+ *
+ * Since: 2.20
+ */
+void
+gtk_notebook_set_action_widget (GtkNotebook *notebook,
+                               GtkWidget   *widget,
+                                GtkPackType  pack_type)
+{
+  GtkNotebookPrivate *priv;
+
+  g_return_if_fail (GTK_IS_NOTEBOOK (notebook));
+  g_return_if_fail (!widget || GTK_IS_WIDGET (widget));
+  g_return_if_fail (!widget || widget->parent == NULL);
+
+  priv = GTK_NOTEBOOK_GET_PRIVATE (notebook);
+
+  if (priv->action_widget[pack_type])
+    gtk_widget_unparent (priv->action_widget[pack_type]);
+
+  priv->action_widget[pack_type] = widget;
+
+  if (widget)
+    {
+      gtk_widget_set_child_visible (widget, notebook->show_tabs);
+      gtk_widget_set_parent (widget, GTK_WIDGET (notebook));
+    }
+
+  gtk_widget_queue_resize (GTK_WIDGET (notebook));
+}
+
 #define __GTK_NOTEBOOK_C__
 #include "gtkaliasdef.c"