[gtk+/wip/baedert/drawing: 122/143] notebook: Replace all gadgets with widgets



commit 682cefc5124d8dd94370b10d57095812c4777a6c
Author: Timm Bäder <mail baedert org>
Date:   Sat May 13 11:38:30 2017 +0200

    notebook: Replace all gadgets with widgets

 gtk/gtknotebook.c |  509 ++++++++++++++++++++---------------------------------
 1 files changed, 194 insertions(+), 315 deletions(-)
---
diff --git a/gtk/gtknotebook.c b/gtk/gtknotebook.c
index 9e9d581..3b6ae1f 100644
--- a/gtk/gtknotebook.c
+++ b/gtk/gtknotebook.c
@@ -43,9 +43,7 @@
 #include "gtkbuildable.h"
 #include "gtktypebuiltins.h"
 #include "gtkwidgetpath.h"
-#include "gtkboxgadgetprivate.h"
 #include "gtkbuiltiniconprivate.h"
-#include "gtkcsscustomgadgetprivate.h"
 #include "gtkcssstylepropertyprivate.h"
 #include "gtksizerequest.h"
 #include "gtkstylecontextprivate.h"
@@ -181,9 +179,9 @@ struct _GtkNotebookPrivate
   GdkWindow               *drag_window;
   GdkWindow               *event_window;
 
-  GtkCssGadget              *gadget;
-  GtkCssGadget              *stack_gadget;
-  GtkCssGadget              *header_gadget;
+  GtkWidget                 *box;
+  GtkWidget                 *stack_widget;
+  GtkWidget                 *header_widget;
   GtkWidget                 *tabs_widget;
   GtkWidget                 *arrow_widget[4];
 
@@ -292,7 +290,8 @@ enum {
 #define GTK_NOTEBOOK_PAGE(_glist_)         ((GtkNotebookPage *)(_glist_)->data)
 
 /* some useful defines for calculating coords */
-#define NOTEBOOK_IS_TAB_LABEL_PARENT(_notebook_,_page_) (gtk_widget_get_parent ((_page_)->tab_label) == 
(GTK_WIDGET (_notebook_)))
+#define NOTEBOOK_IS_TAB_LABEL_PARENT(_notebook_,_page_) \
+  (gtk_widget_get_parent (gtk_widget_get_parent (gtk_widget_get_parent (gtk_widget_get_parent 
(gtk_widget_get_parent ((_page_)->tab_label))))) == (GTK_WIDGET (_notebook_)))
 
 struct _GtkNotebookPage
 {
@@ -301,7 +300,7 @@ struct _GtkNotebookPage
   GtkWidget *menu_label;
   GtkWidget *last_focus_child;  /* Last descendant of the page that had focus */
 
-  GtkWidget *widget;            /* widget used for the tab itself */
+  GtkWidget *tab_widget;        /* widget used for the tab itself */
 
   guint default_menu : 1;       /* If true, we create the menu label ourself */
   guint default_tab  : 1;       /* If true, we create the tab label ourself */
@@ -358,6 +357,7 @@ static void gtk_notebook_get_property        (GObject         *object,
                                               GValue          *value,
                                               GParamSpec      *pspec);
 static void gtk_notebook_finalize            (GObject         *object);
+static void gtk_notebook_dispose             (GObject         *object);
 
 /*** GtkWidget Methods ***/
 static void gtk_notebook_destroy             (GtkWidget        *widget);
@@ -465,7 +465,6 @@ static GtkNotebook *gtk_notebook_create_window (GtkNotebook    *notebook,
                                                 gint            x,
                                                 gint            y);
 
-/*** Gadget Functions ***/
 static void gtk_notebook_measure_tabs        (GtkGizmo         *gizmo,
                                               GtkOrientation    orientation,
                                               gint              for_size,
@@ -479,26 +478,6 @@ static void gtk_notebook_allocate_tabs       (GtkGizmo            *gizmo,
                                               GtkAllocation    *out_clip);
 static gboolean gtk_notebook_snapshot_tabs   (GtkGizmo         *gizmo,
                                               GtkSnapshot      *snapshot);
-static void gtk_notebook_measure_stack       (GtkCssGadget     *gadget,
-                                              GtkOrientation    orientation,
-                                              gint              for_size,
-                                              gint             *minimum,
-                                              gint             *natural,
-                                              gint             *minimum_baseline,
-                                              gint             *natural_baseline,
-                                              gpointer          data);
-static void gtk_notebook_allocate_stack      (GtkCssGadget     *gadget,
-                                              const GtkAllocation *allocation,
-                                              int               baseline,
-                                              GtkAllocation    *out_clip,
-                                              gpointer          data);
-static gboolean gtk_notebook_snapshot_stack  (GtkCssGadget     *gadget,
-                                              GtkSnapshot      *snapshot,
-                                              int               x,
-                                              int               y,
-                                              int               width,
-                                              int               height,
-                                              gpointer          data);
 
 /*** GtkNotebook Private Functions ***/
 static void gtk_notebook_redraw_arrows       (GtkNotebook      *notebook);
@@ -595,6 +574,14 @@ G_DEFINE_TYPE_WITH_CODE (GtkNotebook, gtk_notebook, GTK_TYPE_CONTAINER,
                                                 gtk_notebook_buildable_init))
 
 static void
+child_notify (GtkNotebook *notebook,
+              GtkWidget   *child,
+              const char  *prop_name)
+{
+  gtk_container_child_notify (GTK_CONTAINER (notebook), child, prop_name);
+}
+
+static void
 add_tab_bindings (GtkBindingSet    *binding_set,
                   GdkModifierType   modifiers,
                   GtkDirectionType  direction)
@@ -700,6 +687,7 @@ gtk_notebook_class_init (GtkNotebookClass *class)
   gobject_class->set_property = gtk_notebook_set_property;
   gobject_class->get_property = gtk_notebook_get_property;
   gobject_class->finalize = gtk_notebook_finalize;
+  gobject_class->dispose = gtk_notebook_dispose;
 
   widget_class->destroy = gtk_notebook_destroy;
   widget_class->map = gtk_notebook_map;
@@ -1150,7 +1138,6 @@ static void
 gtk_notebook_init (GtkNotebook *notebook)
 {
   GtkNotebookPrivate *priv;
-  GtkCssNode *widget_node;
 
   gtk_widget_set_can_focus (GTK_WIDGET (notebook), TRUE);
   gtk_widget_set_has_window (GTK_WIDGET (notebook), FALSE);
@@ -1196,44 +1183,37 @@ gtk_notebook_init (GtkNotebook *notebook)
 
   gtk_drag_dest_set_track_motion (GTK_WIDGET (notebook), TRUE);
 
-  widget_node = gtk_widget_get_css_node (GTK_WIDGET (notebook));
-  priv->gadget = gtk_box_gadget_new_for_node (widget_node,
-                                              GTK_WIDGET (notebook));
-  gtk_css_gadget_add_class (priv->gadget, GTK_STYLE_CLASS_FRAME);
-  gtk_box_gadget_set_orientation (GTK_BOX_GADGET (priv->gadget), GTK_ORIENTATION_VERTICAL);
-  gtk_box_gadget_set_draw_reverse (GTK_BOX_GADGET (priv->gadget), TRUE);
-
-  priv->stack_gadget = gtk_css_custom_gadget_new ("stack",
-                                                  GTK_WIDGET (notebook),
-                                                  priv->gadget,
-                                                  NULL,
-                                                  gtk_notebook_measure_stack,
-                                                  gtk_notebook_allocate_stack,
-                                                  gtk_notebook_snapshot_stack,
-                                                  NULL,
-                                                  NULL);
-  gtk_css_gadget_set_state (priv->stack_gadget, gtk_css_node_get_state (widget_node));
-  gtk_box_gadget_insert_gadget (GTK_BOX_GADGET (priv->gadget), -1, priv->stack_gadget, TRUE, GTK_ALIGN_FILL);
-
-  priv->header_gadget = gtk_box_gadget_new ("header",
-                                            GTK_WIDGET (notebook),
-                                            priv->gadget,
-                                            priv->stack_gadget);
-  gtk_css_gadget_add_class (priv->header_gadget, GTK_STYLE_CLASS_TOP);
-  gtk_css_gadget_set_state (priv->header_gadget, gtk_css_node_get_state (widget_node));
-  gtk_css_gadget_set_visible (priv->header_gadget, FALSE);
-  gtk_box_gadget_insert_gadget (GTK_BOX_GADGET (priv->gadget), 0, priv->header_gadget, FALSE, 
GTK_ALIGN_FILL);
+  priv->box = gtk_box_new (GTK_ORIENTATION_VERTICAL, 0);
+  gtk_widget_set_parent (priv->box, GTK_WIDGET (notebook));
+
+
+  priv->header_widget = g_object_new (GTK_TYPE_BOX,
+                                      "css-name", "header",
+                                      NULL);
+  gtk_style_context_add_class (gtk_widget_get_style_context (priv->header_widget),
+                               GTK_STYLE_CLASS_TOP);
+  gtk_widget_hide (priv->header_widget);
+  gtk_container_add (GTK_CONTAINER (priv->box), priv->header_widget);
 
   priv->tabs_widget = gtk_gizmo_new ("tabs",
                                      gtk_notebook_measure_tabs,
                                      gtk_notebook_allocate_tabs,
                                      gtk_notebook_snapshot_tabs);
-  gtk_box_gadget_insert_widget (GTK_BOX_GADGET (priv->header_gadget), 0, priv->tabs_widget);
-  gtk_widget_set_parent (priv->tabs_widget, GTK_WIDGET (notebook));
+  gtk_widget_set_hexpand (priv->tabs_widget, TRUE);
+  gtk_container_add (GTK_CONTAINER (priv->header_widget), priv->tabs_widget);
+
+  priv->stack_widget = gtk_stack_new ();
+  gtk_widget_set_hexpand (priv->stack_widget, TRUE);
+  gtk_widget_set_vexpand (priv->stack_widget, TRUE);
+  gtk_container_add (GTK_CONTAINER (priv->box), priv->stack_widget);
 
   priv->press_gesture = gtk_gesture_multi_press_new (GTK_WIDGET (notebook));
   g_signal_connect (priv->press_gesture, "pressed", G_CALLBACK (gtk_notebook_gesture_pressed), notebook);
   g_signal_connect (priv->press_gesture, "released", G_CALLBACK (gtk_notebook_gesture_released), notebook);
+
+
+  gtk_style_context_add_class (gtk_widget_get_style_context (GTK_WIDGET (notebook)),
+                               GTK_STYLE_CLASS_FRAME);
 }
 
 static void
@@ -1544,7 +1524,7 @@ gtk_notebook_reorder_tab (GtkNotebook      *notebook,
   for (element = priv->children, i = 0; element; element = element->next, i++)
     {
       if (MIN (old_page_num, page_num) <= i && i <= MAX (old_page_num, page_num))
-        gtk_widget_child_notify (((GtkNotebookPage *) element->data)->child, "position");
+        child_notify (notebook, ((GtkNotebookPage *) element->data)->child, "position");
     }
   g_signal_emit (notebook,
                  notebook_signals[PAGE_REORDERED],
@@ -1659,7 +1639,6 @@ gtk_notebook_get_property (GObject         *object,
  * gtk_notebook_map
  * gtk_notebook_unmap
  * gtk_notebook_realize
- * gtk_notebook_size_allocate
  * gtk_notebook_snapshot
  * gtk_notebook_scroll
  * gtk_notebook_popup_menu
@@ -1695,18 +1674,6 @@ gtk_notebook_destroy (GtkWidget *widget)
   GtkNotebook *notebook = GTK_NOTEBOOK (widget);
   GtkNotebookPrivate *priv = notebook->priv;
 
-  if (priv->action_widget[GTK_PACK_START])
-    {
-      gtk_widget_unparent (priv->action_widget[GTK_PACK_START]);
-      priv->action_widget[GTK_PACK_START] = NULL;
-    }
-
-  if (priv->action_widget[GTK_PACK_END])
-    {
-      gtk_widget_unparent (priv->action_widget[GTK_PACK_END]);
-      priv->action_widget[GTK_PACK_END] = NULL;
-    }
-
   if (priv->menu)
     gtk_notebook_popup_disable (notebook);
 
@@ -1727,15 +1694,31 @@ gtk_notebook_finalize (GObject *object)
   GtkNotebook *notebook = GTK_NOTEBOOK (object);
   GtkNotebookPrivate *priv = notebook->priv;
 
-  g_clear_object (&priv->gadget);
-  g_clear_object (&priv->header_gadget);
-  g_clear_object (&priv->stack_gadget);
   g_clear_object (&priv->press_gesture);
+  gtk_widget_unparent (priv->box);
 
   G_OBJECT_CLASS (gtk_notebook_parent_class)->finalize (object);
 }
 
 static void
+gtk_notebook_dispose (GObject *object)
+{
+  GtkNotebook *notebook = GTK_NOTEBOOK (object);
+  GtkNotebookPrivate *priv = notebook->priv;
+  GList *l = priv->children;
+
+  while (l != NULL)
+    {
+      GtkNotebookPage *page = l->data;
+      l = l->next;
+
+      gtk_notebook_remove (GTK_CONTAINER (notebook), page->child);
+    }
+
+  G_OBJECT_CLASS (gtk_notebook_parent_class)->dispose (object);
+}
+
+static void
 update_node_ordering (GtkNotebook *notebook)
 {
   GtkNotebookPrivate *priv = notebook->priv;
@@ -1747,7 +1730,6 @@ update_node_ordering (GtkNotebook *notebook)
   if ((reverse_tabs && !priv->tabs_reversed) ||
       (!reverse_tabs && priv->tabs_reversed))
     {
-      gtk_box_gadget_reverse_children (GTK_BOX_GADGET (priv->header_gadget));
       gtk_css_node_reverse_children (gtk_widget_get_css_node (priv->tabs_widget));
       priv->tabs_reversed = reverse_tabs;
     }
@@ -1771,7 +1753,7 @@ gtk_notebook_get_event_window_position (GtkNotebook  *notebook,
   if (priv->show_tabs && gtk_notebook_has_current_page (notebook))
     {
       if (rectangle)
-        gtk_css_gadget_get_border_allocation (priv->header_gadget, rectangle, NULL);
+        gtk_widget_get_border_allocation (priv->header_widget, rectangle);
 
       return TRUE;
     }
@@ -1821,7 +1803,7 @@ gtk_notebook_realize (GtkWidget *widget)
 
   GTK_WIDGET_CLASS (gtk_notebook_parent_class)->realize (widget);
 
-  gtk_css_gadget_get_border_allocation (priv->header_gadget, &event_window_pos, NULL);
+  gtk_widget_get_border_allocation (priv->header_widget, &event_window_pos);
 
   priv->event_window = gdk_window_new_input (gtk_widget_get_window (widget),
                                              gtk_widget_get_events (widget)
@@ -2013,12 +1995,12 @@ gtk_notebook_get_preferred_tabs_size (GtkNotebook    *notebook,
           if (!gtk_widget_get_visible (page->tab_label))
             gtk_widget_show (page->tab_label);
 
-          gtk_widget_measure (page->widget,
+          gtk_widget_measure (page->tab_widget,
                               GTK_ORIENTATION_HORIZONTAL,
                               -1,
                               &page->requisition.width, NULL,
                               NULL, NULL);
-          gtk_widget_measure (page->widget,
+          gtk_widget_measure (page->tab_widget,
                               GTK_ORIENTATION_VERTICAL,
                               page->requisition.width,
                               &page->requisition.height, NULL,
@@ -2191,8 +2173,8 @@ gtk_notebook_measure_tabs (GtkGizmo       *gizmo,
                            gint           *minimum_baseline,
                            gint           *natural_baseline)
 {
-  GtkWidget *widget = GTK_WIDGET (gtk_widget_get_parent (GTK_WIDGET (gizmo)));
-  GtkNotebook *notebook = GTK_NOTEBOOK (widget);
+  GtkWidget *widget = gtk_widget_get_parent (gtk_widget_get_parent (GTK_WIDGET (gizmo)));
+  GtkNotebook *notebook = GTK_NOTEBOOK (gtk_widget_get_parent (widget));
   GtkRequisition tabs_requisition = { 0 };
 
   gtk_notebook_get_preferred_tabs_size (notebook, &tabs_requisition);
@@ -2209,44 +2191,6 @@ gtk_notebook_measure_tabs (GtkGizmo       *gizmo,
 }
 
 static void
-gtk_notebook_measure_stack (GtkCssGadget   *gadget,
-                            GtkOrientation  orientation,
-                            gint            size,
-                            gint           *minimum,
-                            gint           *natural,
-                            gint           *minimum_baseline,
-                            gint           *natural_baseline,
-                            gpointer        unused)
-{
-  GtkWidget *widget = gtk_css_gadget_get_owner (gadget);
-  GtkNotebook *notebook = GTK_NOTEBOOK (widget);
-  GtkNotebookPrivate *priv = notebook->priv;
-  GList *children;
-  gint child_minimum, child_natural;
-
-  *minimum = 0;
-  *natural = 0;
-
-  for (children = priv->children;
-       children;
-       children = children->next)
-    {
-      GtkNotebookPage *page = children->data;
-
-      if (gtk_widget_get_visible (page->child))
-        {
-          gtk_widget_measure (page->child,
-                              orientation,
-                              size,
-                              &child_minimum, &child_natural,
-                              NULL, NULL);
-
-          *minimum = MAX (*minimum, child_minimum);
-          *natural = MAX (*natural, child_natural);
-        }
-    }
-}
-static void
 gtk_notebook_measure (GtkWidget      *widget,
                       GtkOrientation  orientation,
                       int             for_size,
@@ -2258,11 +2202,11 @@ gtk_notebook_measure (GtkWidget      *widget,
   GtkNotebook *notebook = GTK_NOTEBOOK (widget);
   GtkNotebookPrivate *priv = notebook->priv;
 
-  gtk_css_gadget_get_preferred_size (priv->gadget,
-                                     orientation,
-                                     for_size,
-                                     minimum, natural,
-                                     minimum_baseline, natural_baseline);
+  gtk_widget_measure (priv->box,
+                      orientation,
+                      for_size,
+                      minimum, natural,
+                      minimum_baseline, natural_baseline);
 }
 
 static void
@@ -2271,39 +2215,13 @@ gtk_notebook_allocate_tabs (GtkGizmo            *gizmo,
                             int                  baseline,
                             GtkAllocation       *out_clip)
 {
-  GtkWidget *widget = GTK_WIDGET (gtk_widget_get_parent (GTK_WIDGET (gizmo)));
-  GtkNotebook *notebook = GTK_NOTEBOOK (widget);
+  GtkWidget *widget = gtk_widget_get_parent (gtk_widget_get_parent (GTK_WIDGET (gizmo)));
+  GtkNotebook *notebook = GTK_NOTEBOOK (gtk_widget_get_parent (widget));
 
   gtk_notebook_pages_allocate (notebook, allocation);
 }
 
 static void
-gtk_notebook_allocate_stack (GtkCssGadget        *gadget,
-                             const GtkAllocation *allocation,
-                             int                  baseline,
-                             GtkAllocation       *out_clip,
-                             gpointer             unused)
-{
-  GtkWidget *widget = gtk_css_gadget_get_owner (gadget);
-  GtkNotebook *notebook = GTK_NOTEBOOK (widget);
-  GtkNotebookPrivate *priv = notebook->priv;
-  GList *children;
-
-  for (children = priv->children;
-       children;
-       children = children->next)
-    {
-      GtkNotebookPage *page = children->data;
-
-      if (gtk_widget_get_visible (page->child))
-        gtk_widget_size_allocate_with_baseline (page->child, (GtkAllocation *) allocation, baseline);
-    }
-
-  if (gtk_notebook_has_current_page (notebook))
-    gtk_widget_get_clip (priv->cur_page->child, out_clip);
-}
-
-static void
 gtk_notebook_size_allocate (GtkWidget     *widget,
                             GtkAllocation *allocation)
 {
@@ -2311,10 +2229,8 @@ gtk_notebook_size_allocate (GtkWidget     *widget,
   GtkNotebookPrivate *priv = notebook->priv;
   GtkAllocation clip = *allocation;
 
-  gtk_css_gadget_allocate (priv->gadget,
-                           allocation,
-                           gtk_widget_get_allocated_baseline (widget),
-                           &clip);
+  gtk_widget_size_allocate (priv->box, allocation);
+  gtk_widget_get_clip (priv->box, &clip);
 
   gtk_widget_set_clip (widget, &clip);
 
@@ -2335,27 +2251,6 @@ gtk_notebook_size_allocate (GtkWidget     *widget,
     }
 }
 
-static gboolean
-gtk_notebook_snapshot_stack (GtkCssGadget *gadget,
-                             GtkSnapshot  *snapshot,
-                             int           x,
-                             int           y,
-                             int           width,
-                             int           height,
-                             gpointer      unused)
-{
-  GtkWidget *widget = gtk_css_gadget_get_owner (gadget);
-  GtkNotebook *notebook = GTK_NOTEBOOK (widget);
-  GtkNotebookPrivate *priv = notebook->priv;
-
-  if (gtk_notebook_has_current_page (notebook))
-    gtk_widget_snapshot_child (widget,
-                               priv->cur_page->child,
-                               snapshot);
-
-  return FALSE;
-}
-
 static void
 gtk_notebook_snapshot (GtkWidget   *widget,
                        GtkSnapshot *snapshot)
@@ -2363,10 +2258,10 @@ gtk_notebook_snapshot (GtkWidget   *widget,
   GtkNotebook *notebook = GTK_NOTEBOOK (widget);
   GtkNotebookPrivate *priv = notebook->priv;
 
-  gtk_css_gadget_snapshot (priv->gadget, snapshot);
+  gtk_widget_snapshot_child (widget, priv->box, snapshot);
 
-  if (priv->operation == DRAG_OPERATION_REORDER)
-    gtk_widget_snapshot (priv->cur_page->widget, snapshot);
+  /*if (priv->operation == DRAG_OPERATION_REORDER)*/
+    /*gtk_widget_snapshot (priv->cur_page->tab_widget, snapshot);*/
 }
 
 static gboolean
@@ -2553,7 +2448,7 @@ get_tab_at_pos (GtkNotebook *notebook,
       if (!gtk_notebook_page_tab_label_is_visible (page))
         continue;
 
-      gtk_widget_get_border_allocation (page->widget, &allocation);
+      gtk_widget_get_border_allocation (page->tab_widget, &allocation);
       if ((x >= allocation.x) &&
           (y >= allocation.y) &&
           (x <= (allocation.x + allocation.width)) &&
@@ -2633,7 +2528,7 @@ gtk_notebook_gesture_pressed (GtkGestureMultiPress *gesture,
           priv->drag_begin_x = priv->mouse_x;
           priv->drag_begin_y = priv->mouse_y;
 
-          gtk_widget_get_margin_allocation (page->widget, &allocation);
+          gtk_widget_get_margin_allocation (page->tab_widget, &allocation);
 
           priv->drag_offset_x = priv->drag_begin_x - allocation.x;
           priv->drag_offset_y = priv->drag_begin_y - allocation.y;
@@ -2736,7 +2631,7 @@ get_drop_position (GtkNotebook *notebook)
         {
           GtkAllocation allocation;
 
-          gtk_widget_get_border_allocation (page->widget, &allocation);
+          gtk_widget_get_border_allocation (page->tab_widget, &allocation);
 
           switch (priv->tab_pos)
             {
@@ -2791,7 +2686,7 @@ show_drag_window (GtkNotebook        *notebook,
     {
       GtkAllocation allocation;
 
-      gtk_widget_get_margin_allocation (page->widget, &allocation);
+      gtk_widget_get_margin_allocation (page->tab_widget, &allocation);
       allocation.x = priv->drag_window_x;
       allocation.y = priv->drag_window_y;
 
@@ -2806,7 +2701,7 @@ show_drag_window (GtkNotebook        *notebook,
   gtk_widget_set_parent_window (page->tab_label, priv->drag_window);
   gtk_widget_set_child_visible (page->tab_label, TRUE);
 
-  gtk_style_context_add_class (gtk_widget_get_style_context (page->widget), GTK_STYLE_CLASS_DND);
+  gtk_style_context_add_class (gtk_widget_get_style_context (page->tab_widget), GTK_STYLE_CLASS_DND);
 
   /* the grab will dissapear when the window is hidden */
   gdk_seat_grab (gdk_device_get_seat (device), priv->drag_window,
@@ -2828,7 +2723,7 @@ hide_drag_window (GtkNotebook        *notebook,
     {
       g_object_ref (page->tab_label);
       gtk_container_remove (GTK_CONTAINER (gtk_widget_get_parent (page->tab_label)), page->tab_label);
-      gtk_widget_set_parent (page->tab_label, page->widget);
+      gtk_widget_set_parent (page->tab_label, page->tab_widget);
       g_object_unref (page->tab_label);
     }
   else if (gtk_widget_get_window (page->tab_label) != gtk_widget_get_window (widget))
@@ -2839,7 +2734,7 @@ hide_drag_window (GtkNotebook        *notebook,
       gtk_widget_set_child_visible (page->tab_label, TRUE);
     }
 
-  gtk_style_context_remove_class (gtk_widget_get_style_context (page->widget), GTK_STYLE_CLASS_DND);
+  gtk_style_context_remove_class (gtk_widget_get_style_context (page->tab_widget), GTK_STYLE_CLASS_DND);
 
   if (priv->drag_window &&
       gdk_window_is_visible (priv->drag_window))
@@ -2879,7 +2774,7 @@ gtk_notebook_stop_reorder (GtkNotebook *notebook)
               for (element = priv->children, i = 0; element; element = element->next, i++)
                 {
                   if (MIN (old_page_num, page_num) <= i && i <= MAX (old_page_num, page_num))
-                    gtk_widget_child_notify (((GtkNotebookPage *) element->data)->child, "position");
+                    child_notify (notebook, ((GtkNotebookPage *) element->data)->child, "position");
                 }
               g_signal_emit (notebook,
                              notebook_signals[PAGE_REORDERED], 0,
@@ -2947,10 +2842,10 @@ update_prelight_tab (GtkNotebook     *notebook,
     return;
 
   if (priv->prelight_tab)
-    gtk_widget_unset_state_flags (priv->prelight_tab->widget, GTK_STATE_FLAG_PRELIGHT);
+    gtk_widget_unset_state_flags (priv->prelight_tab->tab_widget, GTK_STATE_FLAG_PRELIGHT);
 
   if (page)
-    gtk_widget_set_state_flags (page->widget, GTK_STATE_FLAG_PRELIGHT, TRUE);
+    gtk_widget_set_state_flags (page->tab_widget, GTK_STATE_FLAG_PRELIGHT, FALSE);
 
   priv->prelight_tab = page;
 }
@@ -3230,9 +3125,6 @@ update_tab_state (GtkNotebook *notebook)
 
   state = state & ~GTK_STATE_FLAG_FOCUSED;
 
-  gtk_css_gadget_set_state (priv->stack_gadget, state);
-  gtk_css_gadget_set_state (priv->header_gadget, state);
-
   for (l = priv->children; l; l = l->next)
     {
       GtkNotebookPage *page = l->data;
@@ -3244,7 +3136,7 @@ update_tab_state (GtkNotebook *notebook)
       if (page == priv->prelight_tab)
         tab_state |= GTK_STATE_FLAG_PRELIGHT;
 
-      gtk_widget_set_state_flags (page->widget, tab_state, TRUE);
+      gtk_widget_set_state_flags (page->tab_widget, tab_state, TRUE);
     }
 }
 
@@ -3330,10 +3222,7 @@ update_arrow_nodes (GtkNotebook *notebook)
   GtkNotebookPrivate *priv = notebook->priv;
   gboolean arrow[4];
   GtkCssImageBuiltinType up_image_type, down_image_type;
-  GtkCssNode *tabs_node;
   gint i;
- 
-  tabs_node = gtk_widget_get_css_node (priv->tabs_widget);
 
   if (priv->tab_pos == GTK_POS_LEFT ||
       priv->tab_pos == GTK_POS_RIGHT)
@@ -3375,11 +3264,9 @@ update_arrow_nodes (GtkNotebook *notebook)
                 case 1:
                   if (priv->children)
                     {
-#if 0
                       GtkNotebookPage *page = priv->children->data;
-                      next_widget = page->widget;
+                      next_widget = page->tab_widget;
                       break;
-#endif
                     }
                   if (priv->arrow_widget[2])
                     {
@@ -3504,7 +3391,7 @@ gtk_notebook_drag_begin (GtkWidget        *widget,
   gtk_window_set_screen (GTK_WINDOW (priv->dnd_window),
                          gtk_widget_get_screen (widget));
   gtk_container_add (GTK_CONTAINER (priv->dnd_window), tab_label);
-  gtk_widget_get_margin_allocation (priv->detached_tab->widget, &allocation);
+  gtk_widget_get_margin_allocation (priv->detached_tab->tab_widget, &allocation);
   gtk_widget_set_size_request (priv->dnd_window,
                                allocation.width,
                                allocation.height);
@@ -4065,7 +3952,7 @@ gtk_notebook_remove (GtkContainer *container,
 
   while (list)
     {
-      gtk_widget_child_notify (((GtkNotebookPage *)list->data)->child, "position");
+      child_notify (notebook, ((GtkNotebookPage *)list->data)->child, "position");
       list = list->next;
     }
 
@@ -4451,9 +4338,9 @@ page_visible_cb (GtkWidget  *child,
           if (next)
             gtk_notebook_switch_page (notebook, GTK_NOTEBOOK_PAGE (next));
         }
-      gtk_css_gadget_set_visible (priv->header_gadget, priv->show_tabs && gtk_notebook_has_current_page 
(notebook));
+      gtk_widget_set_visible (priv->header_widget, priv->show_tabs && gtk_notebook_has_current_page 
(notebook));
     }
-  
+
   if (!gtk_notebook_has_current_page (notebook) && gtk_widget_get_visible (child))
     {
       gtk_notebook_switch_page (notebook, page);
@@ -4471,16 +4358,16 @@ measure_tab (GtkGizmo       *gizmo,
              gint           *minimum_baseline,
              gint           *natural_baseline)
 {
-  GtkWidget *header_widget = gtk_widget_get_parent (GTK_WIDGET (gizmo));
+  GtkWidget *header_widget = gtk_widget_get_parent (gtk_widget_get_parent (gtk_widget_get_parent (GTK_WIDGET 
(gizmo))));
   GtkNotebook *notebook = GTK_NOTEBOOK (gtk_widget_get_parent (header_widget));
   GtkNotebookPrivate *priv = notebook->priv;
   GList *l;
-  GtkNotebookPage *page = NULL;;
+  GtkNotebookPage *page = NULL;
 
   for (l = priv->children; l; l = l->next)
     {
       GtkNotebookPage *p = GTK_NOTEBOOK_PAGE (l);
-      if (p->widget == GTK_WIDGET (gizmo))
+      if (p->tab_widget == GTK_WIDGET (gizmo))
         {
           page = p;
           break;
@@ -4502,17 +4389,17 @@ allocate_tab (GtkGizmo            *gizmo,
               int                  baseline,
               GtkAllocation       *out_clip)
 {
-  GtkWidget *header_widget = gtk_widget_get_parent (GTK_WIDGET (gizmo));
-  GtkNotebook *notebook = GTK_NOTEBOOK (gtk_widget_get_parent (header_widget));
+  GtkWidget *header_widget = gtk_widget_get_parent (gtk_widget_get_parent (GTK_WIDGET (gizmo)));
+  GtkNotebook *notebook = GTK_NOTEBOOK (gtk_widget_get_parent (gtk_widget_get_parent (header_widget)));
   GtkNotebookPrivate *priv = notebook->priv;
   GList *l;
-  GtkNotebookPage *page = NULL;;
+  GtkNotebookPage *page = NULL;
   GtkAllocation child_allocation;
 
   for (l = priv->children; l; l = l->next)
     {
       GtkNotebookPage *p = GTK_NOTEBOOK_PAGE (l);
-      if (p->widget == GTK_WIDGET (gizmo))
+      if (p->tab_widget == GTK_WIDGET (gizmo))
         {
           page = p;
           break;
@@ -4523,7 +4410,6 @@ allocate_tab (GtkGizmo            *gizmo,
 
 
   child_allocation = *allocation;
-
   if (page == priv->cur_page && priv->operation == DRAG_OPERATION_REORDER)
     {
       /* needs to be allocated for the drag window */
@@ -4588,11 +4474,11 @@ gtk_notebook_real_insert_page (GtkNotebook *notebook,
   if (priv->tabs_reversed)
     gtk_css_node_reverse_children (gtk_widget_get_css_node (priv->tabs_widget));
 
-  page->widget = gtk_gizmo_new ("tab",
-                                measure_tab,
-                                allocate_tab,
-                                NULL);
-  gtk_widget_set_parent (page->widget, priv->tabs_widget);
+  page->tab_widget = gtk_gizmo_new ("tab",
+                                    measure_tab,
+                                    allocate_tab,
+                                    NULL);
+  gtk_widget_set_parent (page->tab_widget, priv->tabs_widget);
 
   if (priv->tabs_reversed)
     gtk_css_node_reverse_children (gtk_widget_get_css_node (priv->tabs_widget));
@@ -4614,13 +4500,10 @@ gtk_notebook_real_insert_page (GtkNotebook *notebook,
     gtk_notebook_menu_item_create (notebook,
                                    g_list_find (priv->children, page));
 
-  /* child visible will be turned on by switch_page below */
-  gtk_widget_set_child_visible (child, FALSE);
+  gtk_container_add (GTK_CONTAINER (priv->stack_widget), child);
 
-  gtk_css_node_set_parent (gtk_widget_get_css_node (child), gtk_css_gadget_get_node (priv->stack_gadget));
-  gtk_widget_set_parent (child, GTK_WIDGET (notebook));
   if (tab_label)
-    gtk_widget_set_parent (tab_label, page->widget);
+    gtk_widget_set_parent (tab_label, page->tab_widget);
 
   gtk_notebook_update_labels (notebook);
 
@@ -4660,15 +4543,15 @@ gtk_notebook_real_insert_page (GtkNotebook *notebook,
   if (priv->scrollable)
     gtk_notebook_redraw_arrows (notebook);
 
-  gtk_widget_child_notify (child, "tab-expand");
-  gtk_widget_child_notify (child, "tab-fill");
-  gtk_widget_child_notify (child, "tab-label");
-  gtk_widget_child_notify (child, "menu-label");
+  child_notify (notebook, child, "tab-expand");
+  child_notify (notebook, child, "tab-fill");
+  child_notify (notebook, child, "tab-label");
+  child_notify (notebook, child, "menu-label");
 
   list = g_list_nth (priv->children, position);
   while (list)
     {
-      gtk_widget_child_notify (((GtkNotebookPage *)list->data)->child, "position");
+      child_notify (notebook, ((GtkNotebookPage *)list->data)->child, "position");
       list = list->next;
     }
 
@@ -4859,7 +4742,7 @@ gtk_notebook_real_remove (GtkNotebook *notebook,
       gtk_widget_get_visible (GTK_WIDGET (notebook)))
     need_resize = TRUE;
 
-  gtk_widget_unparent (page->child);
+  gtk_container_remove (GTK_CONTAINER (priv->stack_widget), page->child);
 
   tab_label = page->tab_label;
   if (tab_label)
@@ -4891,7 +4774,7 @@ gtk_notebook_real_remove (GtkNotebook *notebook,
       page->last_focus_child = NULL;
     }
 
-  gtk_widget_unparent (page->widget);
+  gtk_widget_unparent (page->tab_widget);
 
   g_slice_free (GtkNotebookPage, page);
 
@@ -4927,7 +4810,7 @@ gtk_notebook_update_labels (GtkNotebook *notebook)
               if (!page->tab_label)
                 {
                   page->tab_label = gtk_label_new (string);
-                  gtk_widget_set_parent (page->tab_label, page->widget);
+                  gtk_widget_set_parent (page->tab_label, page->tab_widget);
                 }
               else
                 gtk_label_set_text (GTK_LABEL (page->tab_label), string);
@@ -5008,8 +4891,8 @@ static gboolean
 gtk_notebook_snapshot_tabs (GtkGizmo    *gizmo,
                             GtkSnapshot *snapshot)
 {
-  GtkWidget *widget = GTK_WIDGET (gtk_widget_get_parent (GTK_WIDGET (gizmo)));
-  GtkNotebook *notebook = GTK_NOTEBOOK (widget);
+  GtkWidget *widget = gtk_widget_get_parent (gtk_widget_get_parent (GTK_WIDGET (gizmo)));
+  GtkNotebook *notebook = GTK_NOTEBOOK (gtk_widget_get_parent (widget));
   GtkNotebookPrivate *priv = notebook->priv;
   GtkNotebookPage *page;
   GList *children;
@@ -5076,7 +4959,7 @@ gtk_notebook_snapshot_tabs (GtkGizmo    *gizmo,
       if (!gtk_notebook_page_tab_label_is_visible (page))
         continue;
 
-      gtk_widget_snapshot (page->widget, snapshot);
+      gtk_widget_snapshot_child (GTK_WIDGET (gizmo), page->tab_widget, snapshot);
     }
 
   if (children != NULL)
@@ -5099,7 +4982,7 @@ gtk_notebook_snapshot_tabs (GtkGizmo    *gizmo,
       for (children = other_order; children; children = children->next)
         {
           page = children->data;
-          gtk_widget_snapshot (page->widget, snapshot);
+          gtk_widget_snapshot_child (GTK_WIDGET (gizmo), page->tab_widget, snapshot);
         }
 
       g_list_free (other_order);
@@ -5112,22 +4995,20 @@ gtk_notebook_snapshot_tabs (GtkGizmo    *gizmo,
           if (priv->arrow_widget[i] == NULL)
             continue;
 
-          gtk_widget_snapshot (priv->arrow_widget[i], snapshot);
+          gtk_widget_snapshot_child (GTK_WIDGET (gizmo), priv->arrow_widget[i], snapshot);
         }
     }
 
   if (priv->operation != DRAG_OPERATION_DETACH)
-    gtk_widget_snapshot (priv->cur_page->widget, snapshot);
+    gtk_widget_snapshot_child (GTK_WIDGET (gizmo), priv->cur_page->tab_widget, snapshot);
 
   return FALSE;
 }
 
 /* Private GtkNotebook Size Allocate Functions:
  *
- * gtk_notebook_tab_space
  * gtk_notebook_calculate_shown_tabs
  * gtk_notebook_calculate_tabs_allocation
- * gtk_notebook_pages_allocate
  * gtk_notebook_calc_tabs
  */
 static void
@@ -5459,7 +5340,7 @@ gtk_notebook_calculate_shown_tabs (GtkNotebook          *notebook,
 
           if (page->tab_label &&
               NOTEBOOK_IS_TAB_LABEL_PARENT (notebook, page))
-            gtk_widget_set_child_visible (page->tab_label, FALSE);
+            gtk_widget_set_child_visible (page->tab_widget, FALSE);
         }
 
       for (children = *last_child; children;
@@ -5470,7 +5351,7 @@ gtk_notebook_calculate_shown_tabs (GtkNotebook          *notebook,
 
           if (page->tab_label &&
               NOTEBOOK_IS_TAB_LABEL_PARENT (notebook, page))
-            gtk_widget_set_child_visible (page->tab_label, FALSE);
+            gtk_widget_set_child_visible (page->tab_widget, FALSE);
         }
     }
   else /* !show_arrows */
@@ -5583,7 +5464,7 @@ gtk_notebook_calculate_tabs_allocation (GtkNotebook          *notebook,
       break;
     }
 
-  gtk_widget_get_margin_allocation (priv->cur_page->widget, &drag_allocation);
+  gtk_widget_get_margin_allocation (priv->cur_page->tab_widget, &drag_allocation);
   left_x   = CLAMP (priv->mouse_x - priv->drag_offset_x,
                     allocation->x, allocation->x + allocation->width - drag_allocation.width);
   top_y    = CLAMP (priv->mouse_y - priv->drag_offset_y,
@@ -5728,22 +5609,22 @@ gtk_notebook_calculate_tabs_allocation (GtkNotebook          *notebook,
           gdk_window_move_resize (priv->drag_window,
                                   priv->drag_window_x, priv->drag_window_y,
                                   child_allocation.width, child_allocation.height);
-          gtk_widget_size_allocate (page->widget, &fixed_allocation);
-          gtk_widget_get_clip (page->widget, &page_clip);
+          gtk_widget_size_allocate (page->tab_widget, &fixed_allocation);
+          gtk_widget_get_clip (page->tab_widget, &page_clip);
         }
       else if (page == priv->detached_tab && priv->operation == DRAG_OPERATION_DETACH)
         {
           /* needs to be allocated at 0,0
            * to be shown in the drag window */
           GtkAllocation fixed_allocation = { 0, 0, child_allocation.width, child_allocation.height };
-          gtk_widget_size_allocate (page->widget, &fixed_allocation);
-          gtk_widget_get_clip (page->widget, &page_clip);
+          gtk_widget_size_allocate (page->tab_widget, &fixed_allocation);
+          gtk_widget_get_clip (page->tab_widget, &page_clip);
         }
-      else
+      else if (gtk_widget_is_drawable (page->tab_widget) &&
+               gtk_widget_is_drawable (page->tab_label))
         {
-          gtk_widget_size_allocate (page->widget, &child_allocation);
-          gtk_widget_get_clip (page->widget, &page_clip);
-
+          gtk_widget_size_allocate (page->tab_widget, &child_allocation);
+          gtk_widget_get_clip (page->tab_widget, &page_clip);
         }
 
       /* calculate whether to leave a gap based on reorder operation or not */
@@ -5797,7 +5678,7 @@ gtk_notebook_calculate_tabs_allocation (GtkNotebook          *notebook,
 
       /* set child visible */
       if (page->tab_label)
-        gtk_widget_set_child_visible (page->tab_label, TRUE);
+        gtk_widget_set_child_visible (page->tab_widget, TRUE);
     }
 
   /* Don't move the current tab past the last position during tabs reordering */
@@ -5868,8 +5749,6 @@ gtk_notebook_pages_allocate (GtkNotebook         *notebook,
 
   if (!priv->first_tab)
     priv->first_tab = priv->children;
-
-  gtk_widget_queue_draw (priv->tabs_widget);
 }
 
 static void
@@ -5978,21 +5857,18 @@ gtk_notebook_real_switch_page (GtkNotebook     *notebook,
   child_has_focus = priv->child_has_focus;
 
   if (priv->cur_page)
-    {
-      gtk_widget_set_child_visible (priv->cur_page->child, FALSE);
-      gtk_widget_unset_state_flags (priv->cur_page->widget, GTK_STATE_FLAG_CHECKED);
-    }
+    gtk_widget_unset_state_flags (priv->cur_page->tab_widget, GTK_STATE_FLAG_CHECKED);
 
   priv->cur_page = page;
-  gtk_widget_set_state_flags (page->widget, GTK_STATE_FLAG_CHECKED, TRUE);
-  gtk_css_gadget_set_visible (priv->header_gadget, priv->show_tabs);
+  gtk_widget_set_state_flags (page->tab_widget, GTK_STATE_FLAG_CHECKED, FALSE);
+  gtk_widget_set_visible (priv->header_widget, priv->show_tabs);
 
   if (!priv->focus_tab ||
       priv->focus_tab->data != (gpointer) priv->cur_page)
     priv->focus_tab =
       g_list_find (priv->children, priv->cur_page);
 
-  gtk_widget_set_child_visible (priv->cur_page->child, TRUE);
+  gtk_stack_set_visible_child (GTK_STACK (priv->stack_widget), priv->cur_page->child);
 
   /* If the focus was on the previous page, move it to the first
    * element on the new page, if possible, or if not, to the
@@ -6689,7 +6565,6 @@ gtk_notebook_set_show_border (GtkNotebook *notebook,
                               gboolean     show_border)
 {
   GtkNotebookPrivate *priv;
-  GtkCssNode *node;
 
   g_return_if_fail (GTK_IS_NOTEBOOK (notebook));
 
@@ -6697,16 +6572,13 @@ gtk_notebook_set_show_border (GtkNotebook *notebook,
 
   if (priv->show_border != show_border)
     {
+      GtkStyleContext *context = gtk_widget_get_style_context (GTK_WIDGET (notebook));
       priv->show_border = show_border;
 
-      node = gtk_widget_get_css_node (GTK_WIDGET (notebook));
       if (show_border)
-        gtk_css_node_add_class (node, g_quark_from_static_string (GTK_STYLE_CLASS_FRAME));
+        gtk_style_context_add_class (context, GTK_STYLE_CLASS_FRAME);
       else
-        gtk_css_node_remove_class (node, g_quark_from_static_string (GTK_STYLE_CLASS_FRAME));
-
-      if (gtk_widget_get_visible (GTK_WIDGET (notebook)))
-        gtk_widget_queue_resize (GTK_WIDGET (notebook));
+        gtk_style_context_remove_class (context, GTK_STYLE_CLASS_FRAME);
 
       g_object_notify_by_pspec (G_OBJECT (notebook), properties[PROP_SHOW_BORDER]);
     }
@@ -6773,14 +6645,14 @@ gtk_notebook_set_show_tabs (GtkNotebook *notebook,
           else
             gtk_widget_hide (page->tab_label);
         }
-      gtk_css_gadget_set_visible (priv->header_gadget,
-                                  gtk_notebook_has_current_page (notebook));
+      gtk_widget_set_visible (priv->header_widget,
+                              gtk_notebook_has_current_page (notebook));
     }
   else
     {
       gtk_widget_set_can_focus (GTK_WIDGET (notebook), TRUE);
       gtk_notebook_update_labels (notebook);
-      gtk_css_gadget_set_visible (priv->header_gadget, TRUE);
+      gtk_widget_show (priv->header_widget);
     }
 
   for (i = 0; i < N_ACTION_WIDGETS; i++)
@@ -6831,44 +6703,58 @@ gtk_notebook_update_tab_pos (GtkNotebook *notebook)
   for (i = 0; i < G_N_ELEMENTS (tab_pos_names); i++)
     {
       if (tab_pos == i)
-        gtk_css_gadget_add_class (priv->header_gadget, tab_pos_names[i]);
+        gtk_style_context_add_class (gtk_widget_get_style_context (priv->header_widget),
+                                     tab_pos_names[i]);
       else
-        gtk_css_gadget_remove_class (priv->header_gadget, tab_pos_names[i]);
+        gtk_style_context_remove_class (gtk_widget_get_style_context (priv->header_widget),
+                                        tab_pos_names[i]);
     }
 
-  gtk_box_gadget_remove_gadget (GTK_BOX_GADGET (priv->gadget), priv->header_gadget);
   switch (tab_pos)
     {
     case GTK_POS_TOP:
       if (priv->show_tabs)
-        gtk_box_gadget_insert_gadget (GTK_BOX_GADGET (priv->gadget), 0, priv->header_gadget, FALSE, 
GTK_ALIGN_FILL);
-      gtk_box_gadget_set_draw_reverse (GTK_BOX_GADGET (priv->gadget), TRUE);
-      gtk_box_gadget_set_orientation (GTK_BOX_GADGET (priv->gadget), GTK_ORIENTATION_VERTICAL);
-      gtk_box_gadget_set_orientation (GTK_BOX_GADGET (priv->header_gadget), GTK_ORIENTATION_HORIZONTAL);
+        {
+          gtk_box_reorder_child (GTK_BOX (priv->box), priv->header_widget, 0);
+          gtk_widget_set_hexpand (priv->header_widget, TRUE);
+          gtk_widget_set_vexpand (priv->header_widget, FALSE);
+        }
+      gtk_orientable_set_orientation (GTK_ORIENTABLE (priv->box), GTK_ORIENTATION_VERTICAL);
+      gtk_orientable_set_orientation (GTK_ORIENTABLE (priv->header_widget), GTK_ORIENTATION_HORIZONTAL);
       break;
 
     case GTK_POS_BOTTOM:
       if (priv->show_tabs)
-        gtk_box_gadget_insert_gadget (GTK_BOX_GADGET (priv->gadget), 1, priv->header_gadget, FALSE, 
GTK_ALIGN_FILL);
-      gtk_box_gadget_set_draw_reverse (GTK_BOX_GADGET (priv->gadget), FALSE);
-      gtk_box_gadget_set_orientation (GTK_BOX_GADGET (priv->gadget), GTK_ORIENTATION_VERTICAL);
-      gtk_box_gadget_set_orientation (GTK_BOX_GADGET (priv->header_gadget), GTK_ORIENTATION_HORIZONTAL);
+        {
+          gtk_box_reorder_child (GTK_BOX (priv->box), priv->header_widget, 1);
+          gtk_widget_set_hexpand (priv->header_widget, TRUE);
+          gtk_widget_set_vexpand (priv->header_widget, FALSE);
+        }
+      gtk_orientable_set_orientation (GTK_ORIENTABLE (priv->box), GTK_ORIENTATION_VERTICAL);
+      gtk_orientable_set_orientation (GTK_ORIENTABLE (priv->header_widget), GTK_ORIENTATION_HORIZONTAL);
       break;
 
     case GTK_POS_LEFT:
       if (priv->show_tabs)
-        gtk_box_gadget_insert_gadget (GTK_BOX_GADGET (priv->gadget), 0, priv->header_gadget, FALSE, 
GTK_ALIGN_FILL);
-      gtk_box_gadget_set_draw_reverse (GTK_BOX_GADGET (priv->gadget), TRUE);
-      gtk_box_gadget_set_orientation (GTK_BOX_GADGET (priv->gadget), GTK_ORIENTATION_HORIZONTAL);
-      gtk_box_gadget_set_orientation (GTK_BOX_GADGET (priv->header_gadget), GTK_ORIENTATION_VERTICAL);
+        {
+          gtk_box_reorder_child (GTK_BOX (priv->box), priv->header_widget, 0);
+          gtk_widget_set_hexpand (priv->header_widget, FALSE);
+          gtk_widget_set_vexpand (priv->header_widget, TRUE);
+        }
+
+      gtk_orientable_set_orientation (GTK_ORIENTABLE (priv->box), GTK_ORIENTATION_HORIZONTAL);
+      gtk_orientable_set_orientation (GTK_ORIENTABLE (priv->header_widget), GTK_ORIENTATION_VERTICAL);
       break;
 
     case GTK_POS_RIGHT:
       if (priv->show_tabs)
-        gtk_box_gadget_insert_gadget (GTK_BOX_GADGET (priv->gadget), 1, priv->header_gadget, FALSE, 
GTK_ALIGN_FILL);
-      gtk_box_gadget_set_draw_reverse (GTK_BOX_GADGET (priv->gadget), FALSE);
-      gtk_box_gadget_set_orientation (GTK_BOX_GADGET (priv->gadget), GTK_ORIENTATION_HORIZONTAL);
-      gtk_box_gadget_set_orientation (GTK_BOX_GADGET (priv->header_gadget), GTK_ORIENTATION_VERTICAL);
+        {
+          gtk_box_reorder_child (GTK_BOX (priv->box), priv->header_widget, 1);
+          gtk_widget_set_hexpand (priv->header_widget, FALSE);
+          gtk_widget_set_vexpand (priv->header_widget, TRUE);
+        }
+      gtk_orientable_set_orientation (GTK_ORIENTABLE (priv->box), GTK_ORIENTATION_HORIZONTAL);
+      gtk_orientable_set_orientation (GTK_ORIENTABLE (priv->header_widget), GTK_ORIENTATION_VERTICAL);
       break;
     }
 
@@ -7130,7 +7016,7 @@ gtk_notebook_set_tab_label (GtkNotebook *notebook,
     {
       page->default_tab = FALSE;
       page->tab_label = tab_label;
-      gtk_widget_set_parent (page->tab_label, page->widget);
+      gtk_widget_set_parent (page->tab_label, page->tab_widget);
     }
   else
     {
@@ -7144,7 +7030,7 @@ gtk_notebook_set_tab_label (GtkNotebook *notebook,
           g_snprintf (string, sizeof(string), _("Page %u"),
                       g_list_position (priv->children, list));
           page->tab_label = gtk_label_new (string);
-          gtk_widget_set_parent (page->tab_label, page->widget);
+          gtk_widget_set_parent (page->tab_label, page->tab_widget);
         }
     }
 
@@ -7161,7 +7047,7 @@ gtk_notebook_set_tab_label (GtkNotebook *notebook,
       gtk_widget_queue_resize (GTK_WIDGET (notebook));
     }
 
-  gtk_widget_child_notify (child, "tab-label");
+  child_notify (notebook, child, "tab-label");
 }
 
 /**
@@ -7185,7 +7071,7 @@ gtk_notebook_set_tab_label_text (GtkNotebook *notebook,
   if (tab_text)
     tab_label = gtk_label_new (tab_text);
   gtk_notebook_set_tab_label (notebook, child, tab_label);
-  gtk_widget_child_notify (child, "tab-label");
+  child_notify (notebook, child, "tab-label");
 }
 
 /**
@@ -7293,7 +7179,7 @@ gtk_notebook_set_menu_label (GtkNotebook *notebook,
 
   if (priv->menu)
     gtk_notebook_menu_item_create (notebook, list);
-  gtk_widget_child_notify (child, "menu-label");
+  child_notify (notebook, child, "menu-label");
 }
 
 /**
@@ -7320,7 +7206,7 @@ gtk_notebook_set_menu_label_text (GtkNotebook *notebook,
       gtk_widget_set_valign (menu_label, GTK_ALIGN_CENTER);
     }
   gtk_notebook_set_menu_label (notebook, child, menu_label);
-  gtk_widget_child_notify (child, "menu-label");
+  child_notify (notebook, child, "menu-label");
 }
 
 /**
@@ -7376,7 +7262,7 @@ gtk_notebook_child_reordered (GtkNotebook     *notebook,
     }
 
   if (list->prev)
-    sibling = gtk_widget_get_css_node (GTK_NOTEBOOK_PAGE (list->prev)->widget);
+    sibling = gtk_widget_get_css_node (GTK_NOTEBOOK_PAGE (list->prev)->tab_widget);
   else if (priv->arrow_widget[ARROW_RIGHT_BEFORE])
     sibling = gtk_widget_get_css_node (priv->arrow_widget[ARROW_RIGHT_BEFORE]);
   else if (priv->arrow_widget[ARROW_LEFT_BEFORE])
@@ -7385,7 +7271,7 @@ gtk_notebook_child_reordered (GtkNotebook     *notebook,
     sibling = NULL;
 
   gtk_css_node_insert_after (gtk_widget_get_css_node (priv->tabs_widget),
-                             gtk_widget_get_css_node (page->widget),
+                             gtk_widget_get_css_node (page->tab_widget),
                              sibling);
   gtk_notebook_update_labels (notebook);
   gtk_widget_queue_allocate (priv->tabs_widget);
@@ -7417,10 +7303,10 @@ gtk_notebook_set_tab_label_packing (GtkNotebook *notebook,
 
   gtk_widget_freeze_child_notify (child);
   page->expand = expand;
-  gtk_widget_child_notify (child, "tab-expand");
+  child_notify (notebook, child, "tab-expand");
   page->fill = fill;
-  gtk_widget_child_notify (child, "tab-fill");
-  gtk_widget_child_notify (child, "position");
+  child_notify (notebook, child, "tab-fill");
+  child_notify (notebook, child, "position");
   if (priv->show_tabs)
     gtk_widget_queue_resize (GTK_WIDGET (notebook));
   gtk_widget_thaw_child_notify (child);
@@ -7506,7 +7392,7 @@ gtk_notebook_reorder_child (GtkNotebook *notebook,
   for (list = priv->children, i = 0; list; list = list->next, i++)
     {
       if (MIN (old_pos, position) <= i && i <= MAX (old_pos, position))
-       gtk_widget_child_notify (((GtkNotebookPage *) list->data)->child, "position");
+        child_notify (notebook, ((GtkNotebookPage *) list->data)->child, "position");
     }
 
   gtk_widget_thaw_child_notify (child);
@@ -7629,12 +7515,12 @@ gtk_notebook_set_tab_reorderable (GtkNotebook *notebook,
     {
       page->reorderable = reorderable;
       if (reorderable)
-        gtk_style_context_add_class (gtk_widget_get_style_context (page->widget),
+        gtk_style_context_add_class (gtk_widget_get_style_context (page->tab_widget),
                                      "reorderable-page");
       else
-        gtk_style_context_remove_class (gtk_widget_get_style_context (page->widget),
+        gtk_style_context_remove_class (gtk_widget_get_style_context (page->tab_widget),
                                         "reorderable-page");
-      gtk_widget_child_notify (child, "reorderable");
+      child_notify (notebook, child, "reorderable");
     }
 }
 
@@ -7735,7 +7621,7 @@ gtk_notebook_set_tab_detachable (GtkNotebook *notebook,
   if (GTK_NOTEBOOK_PAGE (list)->detachable != detachable)
     {
       GTK_NOTEBOOK_PAGE (list)->detachable = detachable;
-      gtk_widget_child_notify (child, "detachable");
+      child_notify (notebook, child, "detachable");
     }
 }
 
@@ -7789,11 +7675,7 @@ gtk_notebook_set_action_widget (GtkNotebook *notebook,
   priv = notebook->priv;
 
   if (priv->action_widget[pack_type])
-    {
-      gtk_box_gadget_remove_widget (GTK_BOX_GADGET (priv->header_gadget),
-                                    priv->action_widget[pack_type]);
-      gtk_widget_unparent (priv->action_widget[pack_type]);
-    }
+    gtk_container_remove (GTK_CONTAINER (priv->header_widget), priv->action_widget[pack_type]);
 
   priv->action_widget[pack_type] = widget;
 
@@ -7801,17 +7683,14 @@ gtk_notebook_set_action_widget (GtkNotebook *notebook,
     {
       int pos;
 
-      gtk_css_node_set_parent (gtk_widget_get_css_node (widget),
-                               gtk_css_gadget_get_node (priv->header_gadget));
-
       if (priv->tabs_reversed)
         pos = pack_type == GTK_PACK_START ? -1 : 0;
       else
         pos = pack_type == GTK_PACK_START ? 0 : -1;
 
-      gtk_box_gadget_insert_widget (GTK_BOX_GADGET (priv->header_gadget), pos, widget);
+      gtk_container_add (GTK_CONTAINER (priv->header_widget), widget);
+      gtk_box_reorder_child (GTK_BOX (priv->header_widget), widget, pos);
       gtk_widget_set_child_visible (widget, priv->show_tabs);
-      gtk_widget_set_parent (widget, GTK_WIDGET (notebook));
     }
 
   gtk_widget_queue_resize (GTK_WIDGET (notebook));


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]