]> Pileus Git - ~andy/gtk/blobdiff - gtk/gtknotebook.c
Add GtkScrollable interface
[~andy/gtk] / gtk / gtknotebook.c
index dd769bde46919d13415439b0ab26f834c8fa4678..2827645f9661bc99da8d0bde5453491a7b051710 100644 (file)
@@ -38,7 +38,6 @@
 #include "gtkmenu.h"
 #include "gtkmenuitem.h"
 #include "gtklabel.h"
-#include "gtksizerequest.h"
 #include "gtkintl.h"
 #include "gtkmarshalers.h"
 #include "gtkbindings.h"
 #include "gtkdnd.h"
 #include "gtkbuildable.h"
 
+
+/**
+ * SECTION:gtknotebook
+ * @Short_description: A tabbed notebook container
+ * @Title: GtkNotebook
+ * @See_also: #GtkContainer
+ *
+ * The #GtkNotebook widget is a #GtkContainer whose children are pages that
+ * can be switched between using tab labels along one edge.
+ *
+ * There are many configuration options for GtkNotebook. Among other
+ * things, you can choose on which edge the tabs appear
+ * (see gtk_notebook_set_tab_pos()), whether, if there are too many
+ * tabs to fit the notebook should be made bigger or scrolling
+ * arrows added (see gtk_notebook_set_scrollable()), and whether there
+ * will be a popup menu allowing the users to switch pages.
+ * (see gtk_notebook_popup_enable(), gtk_notebook_popup_disable())
+ *
+ * <refsect2 id="GtkNotebook-BUILDER-UI">
+ * <title>GtkNotebook as GtkBuildable</title>
+ * <para>
+ * The GtkNotebook implementation of the #GtkBuildable interface
+ * supports placing children into tabs by specifying "tab" as the
+ * "type" attribute of a &lt;child&gt; element. Note that the content
+ * of the tab must be created before the tab can be filled.
+ * A tab child can be specified without specifying a &lt;child&gt;
+ * type attribute.
+ *
+ * To add a child widget in the notebooks action area, specify
+ * "action-start" or "action-end" as the "type" attribute of the &lt;child&gt;
+ * element.
+ * </para>
+ * <example>
+ * <title>A UI definition fragment with GtkNotebook</title>
+ * <programlisting><![CDATA[
+ * <object class="GtkNotebook">
+ *   <child>
+ *     <object class="GtkLabel" id="notebook-content">
+ *       <property name="label">Content</property>
+ *     </object>
+ *   </child>
+ *   <child type="tab">
+ *     <object class="GtkLabel" id="notebook-tab">
+ *       <property name="label">Tab</property>
+ *     </object>
+ *   </child>
+ * </object>
+ * ]]></programlisting>
+ * </example>
+ * </refsect2>
+ */
+
+
 #define SCROLL_DELAY_FACTOR   5
 #define SCROLL_THRESHOLD      12
 #define DND_THRESHOLD_MULTIPLIER 4
@@ -263,8 +315,7 @@ static void     gtk_notebook_query_tab_label_packing (GtkNotebook  *notebook,
                                                       gboolean     *fill,
                                                       GtkPackType  *pack_type);
 
-/*** GtkObject Methods ***/
-static void gtk_notebook_destroy             (GtkObject        *object);
+/*** GObject Methods ***/
 static void gtk_notebook_set_property       (GObject         *object,
                                              guint            prop_id,
                                              const GValue    *value,
@@ -275,6 +326,7 @@ static void gtk_notebook_get_property            (GObject         *object,
                                              GParamSpec      *pspec);
 
 /*** GtkWidget Methods ***/
+static void gtk_notebook_destroy             (GtkWidget        *widget);
 static void gtk_notebook_map                 (GtkWidget        *widget);
 static void gtk_notebook_unmap               (GtkWidget        *widget);
 static void gtk_notebook_realize             (GtkWidget        *widget);
@@ -283,8 +335,8 @@ static void gtk_notebook_size_request        (GtkWidget        *widget,
                                              GtkRequisition   *requisition);
 static void gtk_notebook_size_allocate       (GtkWidget        *widget,
                                              GtkAllocation    *allocation);
-static gint gtk_notebook_expose              (GtkWidget        *widget,
-                                             GdkEventExpose   *event);
+static gint gtk_notebook_draw                (GtkWidget        *widget,
+                                              cairo_t          *cr);
 static gint gtk_notebook_button_press        (GtkWidget        *widget,
                                              GdkEventButton   *event);
 static gint gtk_notebook_button_release      (GtkWidget        *widget,
@@ -401,7 +453,7 @@ static void  gtk_notebook_child_reordered    (GtkNotebook      *notebook,
 
 /*** GtkNotebook Drawing Functions ***/
 static void gtk_notebook_paint               (GtkWidget        *widget,
-                                             GdkRectangle     *area);
+                                             cairo_t          *cr);
 static void gtk_notebook_draw_tab            (GtkNotebook      *notebook,
                                              GtkNotebookPage  *page,
                                              cairo_t          *cr);
@@ -534,26 +586,58 @@ gtk_object_handled_accumulator (GSignalInvocationHint *ihint,
   return continue_emission;
 }
 
+static void
+gtk_notebook_compute_expand (GtkWidget *widget,
+                             gboolean  *hexpand_p,
+                             gboolean  *vexpand_p)
+{
+  GtkNotebook *notebook = GTK_NOTEBOOK (widget);
+  GtkNotebookPrivate *priv = notebook->priv;
+  gboolean hexpand;
+  gboolean vexpand;
+  GList *list;
+  GtkNotebookPage *page;
+
+  hexpand = FALSE;
+  vexpand = FALSE;
+
+  for (list = priv->children; list; list = list->next)
+    {
+      page = list->data;
+
+      hexpand = hexpand ||
+        gtk_widget_compute_expand (page->child, GTK_ORIENTATION_HORIZONTAL);
+
+      vexpand = vexpand ||
+        gtk_widget_compute_expand (page->child, GTK_ORIENTATION_VERTICAL);
+
+      if (hexpand & vexpand)
+        break;
+    }
+
+  *hexpand_p = hexpand;
+  *vexpand_p = vexpand;
+}
+
 static void
 gtk_notebook_class_init (GtkNotebookClass *class)
 {
   GObjectClass   *gobject_class = G_OBJECT_CLASS (class);
-  GtkObjectClass *object_class = GTK_OBJECT_CLASS (class);
   GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (class);
   GtkContainerClass *container_class = GTK_CONTAINER_CLASS (class);
   GtkBindingSet *binding_set;
   
   gobject_class->set_property = gtk_notebook_set_property;
   gobject_class->get_property = gtk_notebook_get_property;
-  object_class->destroy = gtk_notebook_destroy;
 
+  widget_class->destroy = gtk_notebook_destroy;
   widget_class->map = gtk_notebook_map;
   widget_class->unmap = gtk_notebook_unmap;
   widget_class->realize = gtk_notebook_realize;
   widget_class->unrealize = gtk_notebook_unrealize;
   widget_class->size_request = gtk_notebook_size_request;
   widget_class->size_allocate = gtk_notebook_size_allocate;
-  widget_class->expose_event = gtk_notebook_expose;
+  widget_class->draw = gtk_notebook_draw;
   widget_class->button_press_event = gtk_notebook_button_press;
   widget_class->button_release_event = gtk_notebook_button_release;
   widget_class->popup_menu = gtk_notebook_popup_menu;
@@ -572,6 +656,7 @@ gtk_notebook_class_init (GtkNotebookClass *class)
   widget_class->drag_drop = gtk_notebook_drag_drop;
   widget_class->drag_data_get = gtk_notebook_drag_data_get;
   widget_class->drag_data_received = gtk_notebook_drag_data_received;
+  widget_class->compute_expand = gtk_notebook_compute_expand;
 
   container_class->add = gtk_notebook_add;
   container_class->remove = gtk_notebook_remove;
@@ -687,6 +772,13 @@ gtk_notebook_class_init (GtkNotebookClass *class)
                                                                    P_("Whether the child's tab should fill the allocated area"),
                                                                    TRUE,
                                                                    GTK_PARAM_READWRITE));
+
+  /**
+   * GtkNotebook:tab-pack:
+   *
+   *  Deprecated: 2.20: The tab packing functionality of children should not
+   *  be used anymore and support will be removed in the future.
+   */
   gtk_container_class_install_child_property (container_class,
                                              CHILD_PROP_TAB_PACK,
                                              g_param_spec_enum ("tab-pack", 
@@ -821,6 +913,14 @@ gtk_notebook_class_init (GtkNotebookClass *class)
                                                              0,
                                                              GTK_PARAM_READABLE));
 
+  /**
+   * GtkNotebook::switch-page:
+   * @notebook: the object which received the signal.
+   * @page: the new current page
+   * @page_num: the index of the page
+   *
+   * Emitted when the user or a function changes the current page.
+   */
   notebook_signals[SWITCH_PAGE] =
     g_signal_new (I_("switch-page"),
                  G_TYPE_FROM_CLASS (gobject_class),
@@ -892,11 +992,12 @@ gtk_notebook_class_init (GtkNotebookClass *class)
     g_signal_new (I_("page-reordered"),
                   G_TYPE_FROM_CLASS (gobject_class),
                   G_SIGNAL_RUN_LAST,
-                  0, NULL, NULL,
-                 _gtk_marshal_VOID__OBJECT_UINT,
+                  G_STRUCT_OFFSET (GtkNotebookClass, page_reordered),
+                  NULL, NULL,
+                  _gtk_marshal_VOID__OBJECT_UINT,
                   G_TYPE_NONE, 2,
-                 GTK_TYPE_WIDGET,
-                 G_TYPE_UINT);
+                  GTK_TYPE_WIDGET,
+                  G_TYPE_UINT);
   /**
    * GtkNotebook::page-removed:
    * @notebook: the #GtkNotebook
@@ -912,11 +1013,12 @@ gtk_notebook_class_init (GtkNotebookClass *class)
     g_signal_new (I_("page-removed"),
                   G_TYPE_FROM_CLASS (gobject_class),
                   G_SIGNAL_RUN_LAST,
-                  0, NULL, NULL,
-                 _gtk_marshal_VOID__OBJECT_UINT,
+                  G_STRUCT_OFFSET (GtkNotebookClass, page_removed),
+                  NULL, NULL,
+                  _gtk_marshal_VOID__OBJECT_UINT,
                   G_TYPE_NONE, 2,
-                 GTK_TYPE_WIDGET,
-                 G_TYPE_UINT);
+                  GTK_TYPE_WIDGET,
+                  G_TYPE_UINT);
   /**
    * GtkNotebook::page-added:
    * @notebook: the #GtkNotebook
@@ -932,11 +1034,12 @@ gtk_notebook_class_init (GtkNotebookClass *class)
     g_signal_new (I_("page-added"),
                   G_TYPE_FROM_CLASS (gobject_class),
                   G_SIGNAL_RUN_LAST,
-                  0, NULL, NULL,
-                 _gtk_marshal_VOID__OBJECT_UINT,
+                  G_STRUCT_OFFSET (GtkNotebookClass, page_added),
+                  NULL, NULL,
+                  _gtk_marshal_VOID__OBJECT_UINT,
                   G_TYPE_NONE, 2,
-                 GTK_TYPE_WIDGET,
-                 G_TYPE_UINT);
+                  GTK_TYPE_WIDGET,
+                  G_TYPE_UINT);
 
   /**
    * GtkNotebook::create-window:
@@ -1454,36 +1557,11 @@ gtk_notebook_new (void)
   return g_object_new (GTK_TYPE_NOTEBOOK, NULL);
 }
 
-/* Private GtkObject Methods :
- * 
- * gtk_notebook_destroy
- * gtk_notebook_set_arg
- * gtk_notebook_get_arg
+/* Private GObject Methods :
+ *
+ * gtk_notebook_set_property
+ * gtk_notebook_get_property
  */
-static void
-gtk_notebook_destroy (GtkObject *object)
-{
-  GtkNotebook *notebook = GTK_NOTEBOOK (object);
-  GtkNotebookPrivate *priv = notebook->priv;
-
-  if (priv->menu)
-    gtk_notebook_popup_disable (notebook);
-
-  if (priv->source_targets)
-    {
-      gtk_target_list_unref (priv->source_targets);
-      priv->source_targets = NULL;
-    }
-
-  if (priv->switch_tab_timer)
-    {
-      g_source_remove (priv->switch_tab_timer);
-      priv->switch_tab_timer = 0;
-    }
-
-  GTK_OBJECT_CLASS (gtk_notebook_parent_class)->destroy (object);
-}
-
 static void
 gtk_notebook_set_property (GObject         *object,
                           guint            prop_id,
@@ -1565,13 +1643,14 @@ gtk_notebook_get_property (GObject         *object,
 }
 
 /* Private GtkWidget Methods :
- * 
+ *
+ * gtk_notebook_destroy
  * gtk_notebook_map
  * gtk_notebook_unmap
  * gtk_notebook_realize
  * gtk_notebook_size_request
  * gtk_notebook_size_allocate
- * gtk_notebook_expose
+ * gtk_notebook_draw
  * gtk_notebook_scroll
  * gtk_notebook_button_press
  * gtk_notebook_button_release
@@ -1589,6 +1668,30 @@ gtk_notebook_get_property (GObject         *object,
  * gtk_notebook_drag_data_get
  * gtk_notebook_drag_data_received
  */
+static void
+gtk_notebook_destroy (GtkWidget *widget)
+{
+  GtkNotebook *notebook = GTK_NOTEBOOK (widget);
+  GtkNotebookPrivate *priv = notebook->priv;
+
+  if (priv->menu)
+    gtk_notebook_popup_disable (notebook);
+
+  if (priv->source_targets)
+    {
+      gtk_target_list_unref (priv->source_targets);
+      priv->source_targets = NULL;
+    }
+
+  if (priv->switch_tab_timer)
+    {
+      g_source_remove (priv->switch_tab_timer);
+      priv->switch_tab_timer = 0;
+    }
+
+  GTK_WIDGET_CLASS (gtk_notebook_parent_class)->destroy (widget);
+}
+
 static gboolean
 gtk_notebook_get_event_window_position (GtkNotebook  *notebook,
                                        GdkRectangle *rectangle)
@@ -1704,7 +1807,7 @@ gtk_notebook_map (GtkWidget *widget)
     {
       if (priv->action_widget[i] &&
           gtk_widget_get_visible (priv->action_widget[i]) &&
-          GTK_WIDGET_CHILD_VISIBLE (priv->action_widget[i]) &&
+          gtk_widget_get_child_visible (priv->action_widget[i]) &&
           !gtk_widget_get_mapped (priv->action_widget[i]))
         gtk_widget_map (priv->action_widget[i]);
     }
@@ -1844,8 +1947,8 @@ gtk_notebook_size_request (GtkWidget      *widget,
       if (gtk_widget_get_visible (page->child))
        {
          vis_pages++;
-          gtk_size_request_get_size (GTK_SIZE_REQUEST (page->child),
-                                     &child_requisition, NULL);
+          gtk_widget_get_preferred_size (page->child,
+                                         &child_requisition, NULL);
 
          requisition->width = MAX (requisition->width,
                                           child_requisition.width);
@@ -1902,8 +2005,8 @@ gtk_notebook_size_request (GtkWidget      *widget,
                  if (!gtk_widget_get_visible (page->tab_label))
                    gtk_widget_show (page->tab_label);
 
-                  gtk_size_request_get_size (GTK_SIZE_REQUEST (page->tab_label),
-                                             &child_requisition, NULL);
+                  gtk_widget_get_preferred_size (page->tab_label,
+                                                 &child_requisition, NULL);
 
                   page->requisition.width = child_requisition.width + 2 * style->xthickness;
                  page->requisition.height = child_requisition.height + 2 * style->ythickness;
@@ -1938,8 +2041,8 @@ gtk_notebook_size_request (GtkWidget      *widget,
                 {
                   if (priv->action_widget[i])
                     {
-                      gtk_size_request_get_size (GTK_SIZE_REQUEST (priv->action_widget[i]),
-                                                 &action_widget_requisition[i], NULL);
+                      gtk_widget_get_preferred_size (priv->action_widget[i],
+                                                     &action_widget_requisition[i], NULL);
                       action_widget_requisition[i].width += style->xthickness;
                       action_widget_requisition[i].height += style->ythickness;
                     }
@@ -2191,8 +2294,8 @@ gtk_notebook_size_allocate (GtkWidget     *widget,
                  widget_allocation.y = allocation->y + border_width;
                  is_rtl = gtk_widget_get_direction (widget) == GTK_TEXT_DIR_RTL;
 
-                  gtk_size_request_get_size (GTK_SIZE_REQUEST (priv->action_widget[i]),
-                                             &requisition, NULL);
+                  gtk_widget_get_preferred_size (priv->action_widget[i],
+                                                 &requisition, NULL);
 
                  switch (tab_pos)
                    {
@@ -2243,16 +2346,27 @@ gtk_notebook_size_allocate (GtkWidget     *widget,
 }
 
 static gint
-gtk_notebook_expose (GtkWidget      *widget,
-                    GdkEventExpose *event)
+gtk_notebook_draw (GtkWidget *widget,
+                   cairo_t   *cr)
 {
   GtkNotebook *notebook = GTK_NOTEBOOK (widget);
   GtkNotebookPrivate *priv = notebook->priv;
+  GtkAllocation allocation;
+  GdkWindow *window;
   gint i;
 
-  if (gtk_widget_is_drawable (widget))
+  gtk_widget_get_allocation (widget, &allocation);
+
+  window = gtk_widget_get_window (widget);
+  if (gtk_cairo_should_draw_window (cr, window))
     {
-      gtk_notebook_paint (widget, &event->area);
+      cairo_save (cr);
+
+      cairo_translate (cr, -allocation.x, -allocation.y);
+      gtk_notebook_paint (widget, cr);
+
+      cairo_restore (cr);
+
       if (priv->show_tabs)
        {
          GtkNotebookPage *page;
@@ -2262,32 +2376,32 @@ gtk_notebook_expose (GtkWidget      *widget,
             {
              page = GTK_NOTEBOOK_PAGE (pages);
 
-             if (gtk_widget_get_window (page->tab_label) == event->window &&
-                 gtk_widget_is_drawable (page->tab_label))
-               gtk_container_propagate_expose (GTK_CONTAINER (notebook),
-                                               page->tab_label, event);
+              if (gtk_widget_get_parent (page->tab_label) == widget)
+                gtk_container_propagate_draw (GTK_CONTAINER (notebook),
+                                              page->tab_label, cr);
            }
        }
 
-      if (priv->cur_page)
-       gtk_container_propagate_expose (GTK_CONTAINER (notebook),
-                                       priv->cur_page->child,
-                                       event);
+      if (priv->cur_page && priv->operation != DRAG_OPERATION_REORDER)
+       gtk_container_propagate_draw (GTK_CONTAINER (notebook),
+                                      priv->cur_page->child,
+                                      cr);
       if (priv->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);
+          if (priv->action_widget[i])
+            gtk_container_propagate_draw (GTK_CONTAINER (notebook),
+                                          priv->action_widget[i], cr);
         }
       }
     }
 
-  if (event->window == priv->drag_window)
+  if (priv->operation == DRAG_OPERATION_REORDER &&
+      gtk_cairo_should_draw_window (cr, priv->drag_window))
     {
-      cairo_t *cr;
+      cairo_save (cr);
+      gtk_cairo_transform_to_window (cr, widget, priv->drag_window);
 
       /* FIXME: This is a workaround to make tabs reordering work better
        * with engines with rounded tabs. If the drag window background
@@ -2296,16 +2410,17 @@ gtk_notebook_expose (GtkWidget      *widget,
        * Ideally, these corners should be made transparent, Either by using
        * ARGB visuals or shape windows.
        */
-      cr = gdk_cairo_create (priv->drag_window);
       gdk_cairo_set_source_color (cr, &gtk_widget_get_style (widget)->bg [GTK_STATE_NORMAL]);
       cairo_paint (cr);
 
       gtk_notebook_draw_tab (notebook,
                             priv->cur_page,
                             cr);
-      cairo_destroy (cr);
-      gtk_container_propagate_expose (GTK_CONTAINER (notebook),
-                                     priv->cur_page->tab_label, event);
+
+      cairo_restore (cr);
+
+      gtk_container_propagate_draw (GTK_CONTAINER (notebook),
+                                   priv->cur_page->tab_label, cr);
     }
   
   return FALSE;
@@ -2651,8 +2766,8 @@ popup_position_func (GtkMenu  *menu,
   gdk_window_get_origin (gtk_widget_get_window (w), x, y);
 
   gtk_widget_get_allocation (w, &allocation);
-  gtk_size_request_get_size (GTK_SIZE_REQUEST (menu),
-                             &requisition, NULL);
+  gtk_widget_get_preferred_size (GTK_WIDGET (menu),
+                                 &requisition, NULL);
 
   if (gtk_widget_get_direction (w) == GTK_TEXT_DIR_RTL)
     *x += allocation.x + allocation.width - requisition.width;
@@ -2950,7 +3065,8 @@ get_pointer_position (GtkNotebook *notebook)
     return POINTER_BETWEEN;
 
   gdk_window_get_position (priv->event_window, &wx, &wy);
-  gdk_drawable_get_size (GDK_DRAWABLE (priv->event_window), &width, &height);
+  width = gdk_window_get_width (priv->event_window);
+  height = gdk_window_get_height (priv->event_window);
 
   if (priv->tab_pos == GTK_POS_TOP ||
       priv->tab_pos == GTK_POS_BOTTOM)
@@ -3031,7 +3147,8 @@ check_threshold (GtkNotebook *notebook,
   dnd_threshold *= DND_THRESHOLD_MULTIPLIER;
 
   gdk_window_get_position (priv->event_window, &rectangle.x, &rectangle.y);
-  gdk_drawable_get_size (GDK_DRAWABLE (priv->event_window), &rectangle.width, &rectangle.height);
+  rectangle.width = gdk_window_get_width (priv->event_window);
+  rectangle.height = gdk_window_get_height (priv->event_window);
 
   rectangle.x -= dnd_threshold;
   rectangle.width += 2 * dnd_threshold;
@@ -3224,9 +3341,9 @@ gtk_notebook_style_set  (GtkWidget *widget,
 }
 
 static gboolean
-on_drag_icon_expose (GtkWidget      *widget,
-                    GdkEventExpose *event,
-                    gpointer        data)
+on_drag_icon_draw (GtkWidget *widget,
+                  cairo_t   *cr,
+                  gpointer   data)
 {
   GtkWidget *notebook, *child;
   GtkRequisition requisition;
@@ -3235,19 +3352,19 @@ on_drag_icon_expose (GtkWidget      *widget,
   notebook = GTK_WIDGET (data);
   child = gtk_bin_get_child (GTK_BIN (widget));
 
-  gtk_size_request_get_size (GTK_SIZE_REQUEST (widget),
-                             &requisition, NULL);
+  gtk_widget_get_preferred_size (widget,
+                                 &requisition, NULL);
   gap_pos = get_tab_gap_pos (GTK_NOTEBOOK (notebook));
 
   gtk_paint_extension (gtk_widget_get_style (notebook),
-                       gtk_widget_get_window (widget),
+                       cr,
                       GTK_STATE_NORMAL, GTK_SHADOW_OUT,
-                      NULL, widget, "tab",
+                      widget, "tab",
                       0, 0,
                       requisition.width, requisition.height,
                       gap_pos);
   if (child)
-    gtk_container_propagate_expose (GTK_CONTAINER (widget), child, event);
+    gtk_container_propagate_draw (GTK_CONTAINER (widget), child, cr);
 
   return TRUE;
 }
@@ -3284,8 +3401,8 @@ gtk_notebook_drag_begin (GtkWidget        *widget,
                               priv->detached_tab->allocation.height);
   g_object_unref (tab_label);
 
-  g_signal_connect (G_OBJECT (priv->dnd_window), "expose-event",
-                   G_CALLBACK (on_drag_icon_expose), notebook);
+  g_signal_connect (G_OBJECT (priv->dnd_window), "draw",
+                   G_CALLBACK (on_drag_icon_draw), notebook);
 
   gtk_drag_set_icon_widget (context, priv->dnd_window, -2, -2);
 }
@@ -4515,10 +4632,9 @@ gtk_notebook_real_remove (GtkNotebook *notebook,
   GList * next_list;
   gint need_resize = FALSE;
   GtkWidget *tab_label;
-
   gboolean destroying;
 
-  destroying = GTK_OBJECT_FLAGS (notebook) & GTK_IN_DESTRUCTION;
+  destroying = gtk_widget_in_destruction (GTK_WIDGET (notebook));
 
   next_list = gtk_notebook_search_page (notebook, list, STEP_NEXT, TRUE);
   if (!next_list)
@@ -4735,7 +4851,7 @@ gtk_notebook_search_page (GtkNotebook *notebook,
  */
 static void
 gtk_notebook_paint (GtkWidget    *widget,
-                   GdkRectangle *area)
+                   cairo_t      *cr)
 {
   GtkNotebook *notebook;
   GtkNotebookPrivate *priv;
@@ -4749,7 +4865,6 @@ gtk_notebook_paint (GtkWidget    *widget,
   gint gap_x = 0, gap_width = 0, step = STEP_PREV;
   gboolean is_rtl;
   gint tab_pos;
-  cairo_t *cr;
    
   notebook = GTK_NOTEBOOK (widget);
   priv = notebook->priv;
@@ -4769,10 +4884,9 @@ gtk_notebook_paint (GtkWidget    *widget,
 
   if (priv->show_border && (!priv->show_tabs || !priv->children))
     {
-      gtk_paint_box (gtk_widget_get_style (widget),
-                     gtk_widget_get_window (widget),
+      gtk_paint_box (gtk_widget_get_style (widget), cr,
                     GTK_STATE_NORMAL, GTK_SHADOW_OUT,
-                    area, widget, "notebook",
+                    widget, "notebook",
                     x, y, width, height);
       return;
     }
@@ -4833,17 +4947,12 @@ gtk_notebook_paint (GtkWidget    *widget,
          break;
        }
     }
-  gtk_paint_box_gap (gtk_widget_get_style (widget),
-                     gtk_widget_get_window (widget),
+  gtk_paint_box_gap (gtk_widget_get_style (widget), cr,
                     GTK_STATE_NORMAL, GTK_SHADOW_OUT,
-                    area, widget, "notebook",
+                    widget, "notebook",
                     x, y, width, height,
                     tab_pos, gap_x, gap_width);
 
-  cr = gdk_cairo_create (gtk_widget_get_window (widget));
-  gdk_cairo_rectangle (cr, area);
-  cairo_clip (cr);
-
   showarrow = FALSE;
   children = gtk_notebook_search_page (notebook, NULL, step, TRUE);
   while (children)
@@ -4873,8 +4982,6 @@ gtk_notebook_paint (GtkWidget    *widget,
 
   if (priv->operation != DRAG_OPERATION_REORDER)
     gtk_notebook_draw_tab (notebook, priv->cur_page, cr);
-
-  cairo_destroy (cr);
 }
 
 static void
@@ -4899,7 +5006,7 @@ gtk_notebook_draw_tab (GtkNotebook     *notebook,
   else 
     state_type = GTK_STATE_ACTIVE;
 
-  gtk_cairo_paint_extension (gtk_widget_get_style (widget), cr,
+  gtk_paint_extension (gtk_widget_get_style (widget), cr,
                        state_type, GTK_SHADOW_OUT,
                        widget, "tab",
                        page->allocation.x,
@@ -4917,7 +5024,7 @@ gtk_notebook_draw_tab (GtkNotebook     *notebook,
       gtk_widget_get_allocation (page->tab_label, &allocation);
       gtk_widget_style_get (widget, "focus-line-width", &focus_width, NULL);
 
-      gtk_cairo_paint_focus (gtk_widget_get_style (widget), cr,
+      gtk_paint_focus (gtk_widget_get_style (widget), cr,
                        gtk_widget_get_state (widget), widget, "tab",
                        allocation.x - focus_width,
                        allocation.y - focus_width,
@@ -4938,67 +5045,63 @@ gtk_notebook_draw_arrow (GtkNotebook      *notebook,
   GdkRectangle arrow_rect;
   GtkArrowType arrow;
   gboolean is_rtl, left;
+  gint scroll_arrow_hlength;
+  gint scroll_arrow_vlength;
+  gint arrow_size;
 
   widget = GTK_WIDGET (notebook);
 
-  if (gtk_widget_is_drawable (widget))
-    {
-      gint scroll_arrow_hlength;
-      gint scroll_arrow_vlength;
-      gint arrow_size;
-
-      gtk_notebook_get_arrow_rect (notebook, &arrow_rect, nbarrow);
+  gtk_notebook_get_arrow_rect (notebook, &arrow_rect, nbarrow);
 
-      is_rtl = gtk_widget_get_direction (widget) == GTK_TEXT_DIR_RTL;
-      left = (ARROW_IS_LEFT (nbarrow) && !is_rtl) ||
-             (!ARROW_IS_LEFT (nbarrow) && is_rtl); 
-
-      gtk_widget_style_get (widget,
-                            "scroll-arrow-hlength", &scroll_arrow_hlength,
-                            "scroll-arrow-vlength", &scroll_arrow_vlength,
-                            NULL);
+  is_rtl = gtk_widget_get_direction (widget) == GTK_TEXT_DIR_RTL;
+  left = (ARROW_IS_LEFT (nbarrow) && !is_rtl) ||
+         (!ARROW_IS_LEFT (nbarrow) && is_rtl); 
 
-      if (priv->in_child == nbarrow)
-        {
-          if (priv->click_child == nbarrow)
-            state_type = GTK_STATE_ACTIVE;
-          else
-            state_type = GTK_STATE_PRELIGHT;
-        }
-      else
-        state_type = gtk_widget_get_state (widget);
+  gtk_widget_style_get (widget,
+                        "scroll-arrow-hlength", &scroll_arrow_hlength,
+                        "scroll-arrow-vlength", &scroll_arrow_vlength,
+                        NULL);
 
+  if (priv->in_child == nbarrow)
+    {
       if (priv->click_child == nbarrow)
-        shadow_type = GTK_SHADOW_IN;
+        state_type = GTK_STATE_ACTIVE;
       else
-        shadow_type = GTK_SHADOW_OUT;
+        state_type = GTK_STATE_PRELIGHT;
+    }
+  else
+    state_type = gtk_widget_get_state (widget);
 
-      if (priv->focus_tab &&
-         !gtk_notebook_search_page (notebook, priv->focus_tab,
-                                    left ? STEP_PREV : STEP_NEXT, TRUE))
-       {
-         shadow_type = GTK_SHADOW_ETCHED_IN;
-         state_type = GTK_STATE_INSENSITIVE;
-       }
-      
-      if (priv->tab_pos == GTK_POS_LEFT ||
-         priv->tab_pos == GTK_POS_RIGHT)
-        {
-          arrow = (ARROW_IS_LEFT (nbarrow) ? GTK_ARROW_UP : GTK_ARROW_DOWN);
-          arrow_size = scroll_arrow_vlength;
-        }
-      else
-        {
-          arrow = (ARROW_IS_LEFT (nbarrow) ? GTK_ARROW_LEFT : GTK_ARROW_RIGHT);
-          arrow_size = scroll_arrow_hlength;
-        }
-     
-      gtk_cairo_paint_arrow (gtk_widget_get_style (widget),
-                       cr, state_type, 
-                      shadow_type, widget, "notebook",
-                      arrow, TRUE, arrow_rect.x, arrow_rect.y, 
-                      arrow_size, arrow_size);
+  if (priv->click_child == nbarrow)
+    shadow_type = GTK_SHADOW_IN;
+  else
+    shadow_type = GTK_SHADOW_OUT;
+
+  if (priv->focus_tab &&
+      !gtk_notebook_search_page (notebook, priv->focus_tab,
+                                 left ? STEP_PREV : STEP_NEXT, TRUE))
+    {
+      shadow_type = GTK_SHADOW_ETCHED_IN;
+      state_type = GTK_STATE_INSENSITIVE;
     }
+  
+  if (priv->tab_pos == GTK_POS_LEFT ||
+      priv->tab_pos == GTK_POS_RIGHT)
+    {
+      arrow = (ARROW_IS_LEFT (nbarrow) ? GTK_ARROW_UP : GTK_ARROW_DOWN);
+      arrow_size = scroll_arrow_vlength;
+    }
+  else
+    {
+      arrow = (ARROW_IS_LEFT (nbarrow) ? GTK_ARROW_LEFT : GTK_ARROW_RIGHT);
+      arrow_size = scroll_arrow_hlength;
+    }
+  gtk_paint_arrow (gtk_widget_get_style (widget),
+                   cr, state_type, 
+                   shadow_type, widget, "notebook",
+                   arrow, TRUE, arrow_rect.x, arrow_rect.y, 
+                   arrow_size, arrow_size);
 }
 
 /* Private GtkNotebook Size Allocate Functions:
@@ -5354,9 +5457,14 @@ gtk_notebook_calculate_shown_tabs (GtkNotebook *notebook,
     }
   else /* !show_arrows */
     {
+      GtkOrientation tab_expand_orientation;
       gint c = 0;
       *n = 0;
 
+      if (priv->tab_pos == GTK_POS_TOP || priv->tab_pos == GTK_POS_BOTTOM)
+        tab_expand_orientation = GTK_ORIENTATION_HORIZONTAL;
+      else
+        tab_expand_orientation = GTK_ORIENTATION_VERTICAL;
       *remaining_space = max - min - tab_overlap - tab_space;
       children = priv->children;
       priv->first_tab = gtk_notebook_search_page (notebook, NULL,
@@ -5372,7 +5480,8 @@ gtk_notebook_calculate_shown_tabs (GtkNotebook *notebook,
 
          c++;
 
-         if (page->expand)
+         if (page->expand ||
+              (gtk_widget_compute_expand (page->tab_label, tab_expand_orientation)))
            (*n)++;
        }
 
@@ -5432,6 +5541,7 @@ gtk_notebook_calculate_tabs_allocation (GtkNotebook  *notebook,
   guint border_width;
   gboolean gap_left, packing_changed;
   GtkAllocation child_allocation = { 0, };
+  GtkOrientation tab_expand_orientation;
 
   widget = GTK_WIDGET (notebook);
   container = GTK_CONTAINER (notebook);
@@ -5481,6 +5591,11 @@ gtk_notebook_calculate_tabs_allocation (GtkNotebook  *notebook,
   bottom_y = top_y + priv->cur_page->allocation.height;
   gap_left = packing_changed = FALSE;
 
+  if (priv->tab_pos == GTK_POS_TOP || priv->tab_pos == GTK_POS_BOTTOM)
+    tab_expand_orientation = GTK_ORIENTATION_HORIZONTAL;
+  else
+    tab_expand_orientation = GTK_ORIENTATION_VERTICAL;
+
   while (*children && *children != last_child)
     {
       page = (*children)->data;
@@ -5507,7 +5622,7 @@ gtk_notebook_calculate_tabs_allocation (GtkNotebook  *notebook,
        continue;
 
       tab_extra_space = 0;
-      if (*expanded_tabs && (showarrow || page->expand || priv->homogeneous))
+      if (*expanded_tabs && (showarrow || page->expand || gtk_widget_compute_expand (page->tab_label, tab_expand_orientation) || priv->homogeneous))
        {
          tab_extra_space = *remaining_space / *expanded_tabs;
          *remaining_space -= tab_extra_space;
@@ -5824,8 +5939,7 @@ gtk_notebook_page_allocate (GtkNotebook     *notebook,
   xthickness = style->xthickness;
   ythickness = style->ythickness;
 
-  gtk_size_request_get_size (GTK_SIZE_REQUEST (page->tab_label),
-                             &tab_requisition, NULL);
+  gtk_widget_get_preferred_size (page->tab_label, &tab_requisition, NULL);
   gtk_widget_style_get (widget,
                        "focus-line-width", &focus_width,
                        "tab-curvature", &tab_curvature,
@@ -7549,7 +7663,8 @@ gtk_notebook_reorder_child (GtkNotebook *notebook,
 /**
  * gtk_notebook_set_group_name:
  * @notebook: a #GtkNotebook
- * @name: (allow-none): the name of the notebook group, or %NULL to unset it
+ * @group_name: (allow-none): the name of the notebook group,
+ *     or %NULL to unset it
  *
  * Sets a group name for @notebook.
  *