[gtk/wip/matthiasc/box3] Redo in terms of reorder_after / insert_after



commit 88a4ee13528048e44e8aed1e8d397b0955adc4c0
Author: Matthias Clasen <mclasen redhat com>
Date:   Tue Jan 22 23:08:26 2019 -0500

    Redo in terms of reorder_after / insert_after
    
    Change the reorder api to insert after the sibling,
    so that moving to first place becomes reorder (... NULL).
    And add a insert_after api that can replace the common
    container_add / reorder_after (... NULL) combination.
    
    Update all callers.

 gtk/gtkactionbar.c          |  6 ++----
 gtk/gtkassistant.c          | 10 ++++-----
 gtk/gtkbbox.c               |  2 +-
 gtk/gtkbox.c                | 50 +++++++++++++++++++++++++++++++++++++--------
 gtk/gtkbox.h                | 11 +++++++---
 gtk/gtkcolorchooserwidget.c |  3 +--
 gtk/gtkcombobox.c           |  8 ++------
 gtk/gtkfilechooserwidget.c  |  6 ++----
 gtk/gtkheaderbar.c          |  2 +-
 gtk/gtkmenusectionbox.c     | 14 +++++--------
 gtk/gtkmodelmenuitem.c      |  3 +--
 gtk/gtknotebook.c           | 12 +++++------
 gtk/gtkscalebutton.c        |  8 ++++----
 gtk/gtkspinbutton.c         |  8 ++++----
 gtk/gtkstackswitcher.c      |  6 +++---
 gtk/gtktreeviewcolumn.c     |  4 ++--
 16 files changed, 88 insertions(+), 65 deletions(-)
---
diff --git a/gtk/gtkactionbar.c b/gtk/gtkactionbar.c
index 4a6aee147b..599ecf43a1 100644
--- a/gtk/gtkactionbar.c
+++ b/gtk/gtkactionbar.c
@@ -184,8 +184,7 @@ gtk_action_bar_set_child_property (GtkContainer *container,
             {
               g_object_ref (child);
               gtk_container_remove (GTK_CONTAINER (priv->start_box), child);
-              gtk_container_add (GTK_CONTAINER (priv->end_box), child);
-              gtk_box_reorder_child (GTK_BOX (priv->end_box), child, gtk_widget_get_first_child 
(priv->end_box));
+              gtk_box_insert_child_after (GTK_BOX (priv->end_box), child, NULL);
               g_object_unref (child);
             }
         }
@@ -425,8 +424,7 @@ gtk_action_bar_pack_end (GtkActionBar *action_bar,
 {
   GtkActionBarPrivate *priv = gtk_action_bar_get_instance_private (action_bar);
 
-  gtk_container_add (GTK_CONTAINER (priv->end_box), child);
-  gtk_box_reorder_child (GTK_BOX (priv->end_box), child, gtk_widget_get_first_child (priv->end_box));
+  gtk_box_insert_child_after (GTK_BOX (priv->end_box), child, NULL);
 }
 
 /**
diff --git a/gtk/gtkassistant.c b/gtk/gtkassistant.c
index c37f4e7da6..81d632d909 100644
--- a/gtk/gtkassistant.c
+++ b/gtk/gtkassistant.c
@@ -1125,7 +1125,7 @@ gtk_assistant_init (GtkAssistant *assistant)
       buttons = gtk_container_get_children (GTK_CONTAINER (priv->action_area));
 
       for (l = buttons; l; l = l->next)
-        gtk_box_reorder_child (GTK_BOX (priv->action_area), GTK_WIDGET (l->data), NULL);
+        gtk_box_reorder_child_after (GTK_BOX (priv->action_area), GTK_WIDGET (l->data), NULL);
 
       g_list_free (buttons);
     }
@@ -1693,14 +1693,12 @@ gtk_assistant_insert_page (GtkAssistant *assistant,
     {
       int i;
       sibling = gtk_widget_get_first_child (priv->sidebar);
-      for (i = 0; i < 2 * position; i++)
+      for (i = 1; i < 2 * position; i++)
         sibling = gtk_widget_get_next_sibling (sibling);
     }
 
-  gtk_container_add (GTK_CONTAINER (priv->sidebar), page_info->regular_title);
-  gtk_container_add (GTK_CONTAINER (priv->sidebar), page_info->current_title);
-  gtk_box_reorder_child (GTK_BOX (priv->sidebar), page_info->regular_title, sibling);
-  gtk_box_reorder_child (GTK_BOX (priv->sidebar), page_info->current_title, sibling);
+  gtk_box_insert_child_after (GTK_BOX (priv->sidebar), page_info->current_title, sibling);
+  gtk_box_insert_child_after (GTK_BOX (priv->sidebar), page_info->regular_title, sibling);
 
   box = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 0);
   gtk_widget_show (box);
diff --git a/gtk/gtkbbox.c b/gtk/gtkbbox.c
index 31e4926ff6..c9bccc0c6a 100644
--- a/gtk/gtkbbox.c
+++ b/gtk/gtkbbox.c
@@ -386,7 +386,7 @@ gtk_button_box_set_child_secondary (GtkButtonBox *widget,
   gtk_widget_child_notify (child, "secondary");
 
   if (bbox->priv->layout_style == GTK_BUTTONBOX_EXPAND)
-    gtk_box_reorder_child (GTK_BOX (bbox), child, is_secondary ? gtk_widget_get_first_child (GTK_WIDGET 
(bbox)) : NULL);
+    gtk_box_reorder_child_after (GTK_BOX (bbox), child, is_secondary ? NULL : gtk_widget_get_last_child 
(GTK_WIDGET (bbox)));
 
   if (gtk_widget_get_visible (GTK_WIDGET (widget)) &&
       gtk_widget_get_visible (child))
diff --git a/gtk/gtkbox.c b/gtk/gtkbox.c
index 5c7cb64f0a..55ef051f11 100644
--- a/gtk/gtkbox.c
+++ b/gtk/gtkbox.c
@@ -45,7 +45,7 @@
  * minimally placed between all children in the GtkBox. Note that
  * spacing is added between the children.
  *
- * Use gtk_box_reorder_child() to move a GtkBox child to a different
+ * Use gtk_box_reorder_child_after() to move a GtkBox child to a different
  * place in the box.
  *
  * # CSS nodes
@@ -1097,17 +1097,51 @@ _gtk_box_get_children (GtkBox *box)
 }
 
 void
-gtk_box_reorder_child (GtkBox    *box,
-                       GtkWidget *child,
-                       GtkWidget *sibling)
+gtk_box_insert_child_after (GtkBox    *box,
+                            GtkWidget *child,
+                            GtkWidget *sibling)
 {
   GtkWidget *widget = GTK_WIDGET (box);
 
+  g_return_if_fail (GTK_IS_BOX (box));
+  g_return_if_fail (GTK_IS_WIDGET (child));
+  g_return_if_fail (gtk_widget_get_parent (child) == NULL);
+  if (sibling)
+    {
+      g_return_if_fail (GTK_IS_WIDGET (sibling));
+      g_return_if_fail (gtk_widget_get_parent (sibling) == widget);
+    }
+
+  if (child == sibling)
+    return;
+
+  gtk_widget_insert_after (child, widget, sibling);
+  gtk_css_node_insert_after (gtk_widget_get_css_node (widget),
+                             gtk_widget_get_css_node (child),
+                             sibling ? gtk_widget_get_css_node (sibling) : NULL);
+}
+
+void
+gtk_box_reorder_child_after (GtkBox    *box,
+                             GtkWidget *child,
+                             GtkWidget *sibling)
+{
+  GtkWidget *widget = GTK_WIDGET (box);
+
+  g_return_if_fail (GTK_IS_BOX (box));
+  g_return_if_fail (GTK_IS_WIDGET (child));
+  g_return_if_fail (gtk_widget_get_parent (child) == widget);
+  if (sibling)
+    {
+      g_return_if_fail (GTK_IS_WIDGET (sibling));
+      g_return_if_fail (gtk_widget_get_parent (sibling) == widget);
+    }
+
   if (child == sibling)
     return;
 
-  gtk_widget_insert_before (child, widget, sibling);
-  gtk_css_node_insert_before (gtk_widget_get_css_node (widget),
-                              gtk_widget_get_css_node (child),
-                              sibling ? gtk_widget_get_css_node (sibling) : NULL);
+  gtk_widget_insert_after (child, widget, sibling);
+  gtk_css_node_insert_after (gtk_widget_get_css_node (widget),
+                             gtk_widget_get_css_node (child),
+                             sibling ? gtk_widget_get_css_node (sibling) : NULL);
 }
diff --git a/gtk/gtkbox.h b/gtk/gtkbox.h
index 911015e219..eb5146a15f 100644
--- a/gtk/gtkbox.h
+++ b/gtk/gtkbox.h
@@ -92,9 +92,14 @@ GDK_AVAILABLE_IN_ALL
 GtkBaselinePosition gtk_box_get_baseline_position (GtkBox         *box);
 
 GDK_AVAILABLE_IN_ALL
-void        gtk_box_reorder_child (GtkBox         *box,
-                                   GtkWidget      *child,
-                                   GtkWidget      *sibling);
+void        gtk_box_insert_child_after (GtkBox         *box,
+                                        GtkWidget      *child,
+                                        GtkWidget      *sibling);
+
+GDK_AVAILABLE_IN_ALL
+void        gtk_box_reorder_child_after (GtkBox         *box,
+                                         GtkWidget      *child,
+                                         GtkWidget      *sibling);
 
 
 G_END_DECLS
diff --git a/gtk/gtkcolorchooserwidget.c b/gtk/gtkcolorchooserwidget.c
index e6b0290a61..9f2d286017 100644
--- a/gtk/gtkcolorchooserwidget.c
+++ b/gtk/gtkcolorchooserwidget.c
@@ -745,8 +745,7 @@ add_custom_color (GtkColorChooserWidget *cc,
   gtk_color_swatch_set_can_drop (GTK_COLOR_SWATCH (p), TRUE);
   connect_custom_signals (p, cc);
 
-  gtk_container_add (GTK_CONTAINER (cc->priv->custom), p);
-  gtk_box_reorder_child (GTK_BOX (cc->priv->custom), p, gtk_widget_get_next_sibling 
(gtk_widget_get_first_child (cc->priv->custom)));
+  gtk_box_insert_child_after (GTK_BOX (cc->priv->custom), p, gtk_widget_get_first_child (cc->priv->custom));
   gtk_widget_show (p);
 
   select_swatch (cc, GTK_COLOR_SWATCH (p));
diff --git a/gtk/gtkcombobox.c b/gtk/gtkcombobox.c
index c5342beac6..b47ffe50f6 100644
--- a/gtk/gtkcombobox.c
+++ b/gtk/gtkcombobox.c
@@ -1151,15 +1151,12 @@ gtk_combo_box_create_child (GtkComboBox *combo_box)
     }
   else
     {
-      GtkWidget *parent; 
       child = gtk_cell_view_new_with_context (priv->area, NULL);
       priv->cell_view = child;
       gtk_widget_set_hexpand (child, TRUE);
       gtk_cell_view_set_fit_model (GTK_CELL_VIEW (priv->cell_view), TRUE);
       gtk_cell_view_set_model (GTK_CELL_VIEW (priv->cell_view), priv->model);
-      parent = gtk_widget_get_parent (priv->arrow);
-      gtk_container_add (GTK_CONTAINER (parent), priv->cell_view);
-      gtk_box_reorder_child (GTK_BOX (parent), priv->cell_view, gtk_widget_get_first_child (parent));
+      gtk_box_insert_child_after (GTK_BOX (gtk_widget_get_parent (priv->arrow)), priv->cell_view, NULL);
       _gtk_bin_set_child (GTK_BIN (combo_box), priv->cell_view);
     }
 }
@@ -1194,8 +1191,7 @@ gtk_combo_box_add (GtkContainer *container,
     }
 
   gtk_widget_set_hexpand (widget, TRUE);
-  gtk_container_add (GTK_CONTAINER (priv->box), widget);
-  gtk_box_reorder_child (GTK_BOX (priv->box), widget, gtk_widget_get_first_child (priv->box));
+  gtk_box_insert_child_after (GTK_BOX (priv->box), widget, NULL);
   _gtk_bin_set_child (GTK_BIN (container), widget);
 
   if (priv->has_entry)
diff --git a/gtk/gtkfilechooserwidget.c b/gtk/gtkfilechooserwidget.c
index 5ee15f7c8f..fd5fd4813d 100644
--- a/gtk/gtkfilechooserwidget.c
+++ b/gtk/gtkfilechooserwidget.c
@@ -916,8 +916,7 @@ update_preview_widget_visibility (GtkFileChooserWidget *impl)
       if (!priv->preview_label)
         {
           priv->preview_label = gtk_label_new (priv->preview_display_name);
-          gtk_container_add (GTK_CONTAINER (priv->preview_box), priv->preview_label);
-          gtk_box_reorder_child (GTK_BOX (priv->preview_box), priv->preview_label, 
gtk_widget_get_first_child (priv->preview_box));
+          gtk_box_insert_child_after (GTK_BOX (priv->preview_box), priv->preview_label, NULL);
           gtk_label_set_ellipsize (GTK_LABEL (priv->preview_label), PANGO_ELLIPSIZE_MIDDLE);
           gtk_widget_show (priv->preview_label);
         }
@@ -2604,8 +2603,7 @@ save_widgets_create (GtkFileChooserWidget *impl)
   gtk_label_set_mnemonic_widget (GTK_LABEL (widget), priv->location_entry);
 
   priv->save_widgets = vbox;
-  gtk_container_add (GTK_CONTAINER (priv->box), priv->save_widgets);
-  gtk_box_reorder_child (GTK_BOX (priv->box), priv->save_widgets, gtk_widget_get_first_child (priv->box));
+  gtk_box_insert_child_after (GTK_BOX (priv->box), priv->save_widgets, NULL);
   gtk_widget_show (priv->save_widgets);
 }
 
diff --git a/gtk/gtkheaderbar.c b/gtk/gtkheaderbar.c
index 3070b56f5b..2cc15a1c14 100644
--- a/gtk/gtkheaderbar.c
+++ b/gtk/gtkheaderbar.c
@@ -470,7 +470,7 @@ _gtk_header_bar_update_window_buttons (GtkHeaderBar *bar)
 
           gtk_container_add (GTK_CONTAINER (box), separator);
           if (i == 1)
-            gtk_box_reorder_child (GTK_BOX (box), separator, gtk_widget_get_first_child (box));
+            gtk_box_reorder_child_after (GTK_BOX (box), separator, NULL);
 
           if (i == 0)
             gtk_style_context_add_class (gtk_widget_get_style_context (box), GTK_STYLE_CLASS_LEFT);
diff --git a/gtk/gtkmenusectionbox.c b/gtk/gtkmenusectionbox.c
index a24e8cc64d..f87259e3bb 100644
--- a/gtk/gtkmenusectionbox.c
+++ b/gtk/gtkmenusectionbox.c
@@ -134,10 +134,7 @@ gtk_menu_section_box_sync_separators (GtkMenuSectionBox *box,
     return;
 
   if (should_have_separator)
-    {
-      gtk_container_add (GTK_CONTAINER (box), box->separator);
-      gtk_box_reorder_child (GTK_BOX (box), box->separator, gtk_widget_get_first_child (GTK_WIDGET (box)));
-    }
+    gtk_box_insert_child_after (GTK_BOX (box), box->separator, NULL);
   else
     gtk_container_remove (GTK_CONTAINER (box), box->separator);
 }
@@ -335,14 +332,14 @@ gtk_menu_section_box_insert_func (GtkMenuTrackerItem *item,
   gtk_container_add (GTK_CONTAINER (box->item_box), widget);
 
   if (position == 0)
-    gtk_box_reorder_child (GTK_BOX (box->item_box), widget, gtk_widget_get_first_child (GTK_WIDGET 
(box->item_box)));
+    gtk_box_reorder_child_after (GTK_BOX (box->item_box), widget, NULL);
   else
     {
       GtkWidget *sibling = gtk_widget_get_first_child (GTK_WIDGET (box->item_box));
       int i;
-      for (i = 0; i < position; i++)
+      for (i = 1; i < position; i++)
         sibling = gtk_widget_get_next_sibling (sibling);
-      gtk_box_reorder_child (GTK_BOX (box->item_box), widget, sibling);
+      gtk_box_reorder_child_after (GTK_BOX (box->item_box), widget, sibling);
     }
 
   gtk_menu_section_box_schedule_separator_sync (box);
@@ -467,8 +464,7 @@ gtk_menu_section_box_new_submenu (GtkMenuTrackerItem *item,
   g_object_set_data (G_OBJECT (button), "focus", focus);
   g_object_set_data (G_OBJECT (focus), "focus", button);
 
-  gtk_container_add (GTK_CONTAINER (box), button);
-  gtk_box_reorder_child (GTK_BOX (box), button, gtk_widget_get_first_child (GTK_WIDGET (box)));
+  gtk_box_insert_child_after (GTK_BOX (box), button, NULL);
 
   g_signal_connect (focus, "clicked", G_CALLBACK (open_submenu), item);
   g_signal_connect (button, "clicked", G_CALLBACK (close_submenu), item);
diff --git a/gtk/gtkmodelmenuitem.c b/gtk/gtkmodelmenuitem.c
index ca300d2150..5d7637219f 100644
--- a/gtk/gtkmodelmenuitem.c
+++ b/gtk/gtkmodelmenuitem.c
@@ -191,8 +191,7 @@ gtk_model_menu_item_set_icon (GtkModelMenuItem *item,
 
       image = gtk_image_new_from_gicon (icon);
       gtk_image_set_pixel_size (GTK_IMAGE (image), 16);
-      gtk_container_add (GTK_CONTAINER (child), image);
-      gtk_box_reorder_child (GTK_BOX (child), image, gtk_widget_get_first_child (child));
+      gtk_box_insert_child_after (GTK_BOX (child), image, NULL);
     }
 
   g_object_notify (G_OBJECT (item), "icon");
diff --git a/gtk/gtknotebook.c b/gtk/gtknotebook.c
index f2d59620b8..5fb98d96fb 100644
--- a/gtk/gtknotebook.c
+++ b/gtk/gtknotebook.c
@@ -6206,7 +6206,7 @@ gtk_notebook_update_tab_pos (GtkNotebook *notebook)
       gtk_widget_set_hexpand (priv->header_widget, TRUE);
       gtk_widget_set_vexpand (priv->header_widget, FALSE);
       if (priv->show_tabs)
-        gtk_box_reorder_child (GTK_BOX (priv->box), priv->header_widget, gtk_widget_get_first_child 
(priv->box));
+        gtk_box_reorder_child_after (GTK_BOX (priv->box), priv->header_widget, NULL);
 
       gtk_orientable_set_orientation (GTK_ORIENTABLE (priv->box), GTK_ORIENTATION_VERTICAL);
       gtk_orientable_set_orientation (GTK_ORIENTABLE (priv->header_widget), GTK_ORIENTATION_HORIZONTAL);
@@ -6218,7 +6218,7 @@ gtk_notebook_update_tab_pos (GtkNotebook *notebook)
       gtk_widget_set_hexpand (priv->header_widget, TRUE);
       gtk_widget_set_vexpand (priv->header_widget, FALSE);
       if (priv->show_tabs)
-        gtk_box_reorder_child (GTK_BOX (priv->box), priv->header_widget, NULL);
+        gtk_box_reorder_child_after (GTK_BOX (priv->box), priv->header_widget, gtk_widget_get_last_child 
(priv->box));
 
       gtk_orientable_set_orientation (GTK_ORIENTABLE (priv->box), GTK_ORIENTATION_VERTICAL);
       gtk_orientable_set_orientation (GTK_ORIENTABLE (priv->header_widget), GTK_ORIENTATION_HORIZONTAL);
@@ -6230,7 +6230,7 @@ gtk_notebook_update_tab_pos (GtkNotebook *notebook)
       gtk_widget_set_hexpand (priv->header_widget, FALSE);
       gtk_widget_set_vexpand (priv->header_widget, TRUE);
       if (priv->show_tabs)
-        gtk_box_reorder_child (GTK_BOX (priv->box), priv->header_widget, gtk_widget_get_first_child 
(priv->box));
+        gtk_box_reorder_child_after (GTK_BOX (priv->box), priv->header_widget, NULL);
 
       gtk_orientable_set_orientation (GTK_ORIENTABLE (priv->box), GTK_ORIENTATION_HORIZONTAL);
       gtk_orientable_set_orientation (GTK_ORIENTABLE (priv->header_widget), GTK_ORIENTATION_VERTICAL);
@@ -6242,7 +6242,7 @@ gtk_notebook_update_tab_pos (GtkNotebook *notebook)
       gtk_widget_set_hexpand (priv->header_widget, FALSE);
       gtk_widget_set_vexpand (priv->header_widget, TRUE);
       if (priv->show_tabs)
-        gtk_box_reorder_child (GTK_BOX (priv->box), priv->header_widget, NULL);
+        gtk_box_reorder_child_after (GTK_BOX (priv->box), priv->header_widget, gtk_widget_get_last_child 
(priv->box));
 
       gtk_orientable_set_orientation (GTK_ORIENTABLE (priv->box), GTK_ORIENTATION_HORIZONTAL);
       gtk_orientable_set_orientation (GTK_ORIENTABLE (priv->header_widget), GTK_ORIENTATION_VERTICAL);
@@ -7151,9 +7151,9 @@ gtk_notebook_set_action_widget (GtkNotebook *notebook,
     {
       gtk_container_add (GTK_CONTAINER (priv->header_widget), widget);
       if (pack_type == GTK_PACK_START)
-        gtk_box_reorder_child (GTK_BOX (priv->header_widget), widget, gtk_widget_get_first_child 
(priv->header_widget));
+        gtk_box_reorder_child_after (GTK_BOX (priv->header_widget), widget, NULL);
       else
-        gtk_box_reorder_child (GTK_BOX (priv->header_widget), widget, NULL);
+        gtk_box_reorder_child_after (GTK_BOX (priv->header_widget), widget, gtk_widget_get_last_child 
(priv->header_widget));
       gtk_widget_set_child_visible (widget, priv->show_tabs);
     }
 
diff --git a/gtk/gtkscalebutton.c b/gtk/gtkscalebutton.c
index 343e4712cc..c7b8a4865a 100644
--- a/gtk/gtkscalebutton.c
+++ b/gtk/gtkscalebutton.c
@@ -727,13 +727,13 @@ apply_orientation (GtkScaleButton *button,
 
       if (orientation == GTK_ORIENTATION_HORIZONTAL)
         {
-          gtk_box_reorder_child (GTK_BOX (priv->box), priv->minus_button, NULL);
-          gtk_box_reorder_child (GTK_BOX (priv->box), priv->plus_button, NULL);
+          gtk_box_reorder_child_after (GTK_BOX (priv->box), priv->plus_button, NULL);
+          gtk_box_reorder_child_after (GTK_BOX (priv->box), priv->scale, NULL);
         }
       else
         {
-          gtk_box_reorder_child (GTK_BOX (priv->box), priv->scale, NULL);
-          gtk_box_reorder_child (GTK_BOX (priv->box), priv->minus_button, NULL);
+          gtk_box_reorder_child_after (GTK_BOX (priv->box), priv->scale, NULL);
+          gtk_box_reorder_child_after (GTK_BOX (priv->box), priv->plus_button, NULL);
         }
 
       gtk_orientable_set_orientation (GTK_ORIENTABLE (priv->scale), orientation);
diff --git a/gtk/gtkspinbutton.c b/gtk/gtkspinbutton.c
index 084aa676eb..08b7544812 100644
--- a/gtk/gtkspinbutton.c
+++ b/gtk/gtkspinbutton.c
@@ -1040,14 +1040,14 @@ gtk_spin_button_set_orientation (GtkSpinButton  *spin,
   if (priv->orientation == GTK_ORIENTATION_HORIZONTAL)
     {
       /* Current orientation of the box is vertical! */
-      gtk_box_reorder_child (GTK_BOX (priv->box), priv->down_button, NULL);
-      gtk_box_reorder_child (GTK_BOX (priv->box), priv->up_button, NULL);
+      gtk_box_reorder_child_after (GTK_BOX (priv->box), priv->up_button, NULL);
+      gtk_box_reorder_child_after (GTK_BOX (priv->box), priv->entry, NULL);
     }
   else
     {
       /* Current orientation of the box is horizontal! */
-      gtk_box_reorder_child (GTK_BOX (priv->box), priv->entry, NULL);
-      gtk_box_reorder_child (GTK_BOX (priv->box), priv->down_button, NULL);
+      gtk_box_reorder_child_after (GTK_BOX (priv->box), priv->entry, NULL);
+      gtk_box_reorder_child_after (GTK_BOX (priv->box), priv->up_button, NULL);
     }
 
   gtk_orientable_set_orientation (GTK_ORIENTABLE (priv->box), priv->orientation);
diff --git a/gtk/gtkstackswitcher.c b/gtk/gtkstackswitcher.c
index 7e8145077a..50cdcecb55 100644
--- a/gtk/gtkstackswitcher.c
+++ b/gtk/gtkstackswitcher.c
@@ -236,14 +236,14 @@ on_position_updated (GtkWidget        *widget,
                            NULL);
 
   if (position == 0)
-    gtk_box_reorder_child (GTK_BOX (self), button, gtk_widget_get_first_child (GTK_WIDGET (self)));
+    gtk_box_reorder_child_after (GTK_BOX (self), button, NULL);
   else
     {
       GtkWidget *sibling = gtk_widget_get_first_child (GTK_WIDGET (self));
       int i;
-      for (i = 0; i < position; i++)
+      for (i = 1; i < position; i++)
         sibling = gtk_widget_get_next_sibling (sibling);
-      gtk_box_reorder_child (GTK_BOX (self), button, sibling);
+      gtk_box_reorder_child_after (GTK_BOX (self), button, sibling);
     }
 }
 
diff --git a/gtk/gtktreeviewcolumn.c b/gtk/gtktreeviewcolumn.c
index 233aa55037..aa730c8f9b 100644
--- a/gtk/gtktreeviewcolumn.c
+++ b/gtk/gtktreeviewcolumn.c
@@ -964,9 +964,9 @@ gtk_tree_view_column_update_button (GtkTreeViewColumn *tree_column)
    * reverse things
    */
   if (priv->xalign <= 0.5)
-    gtk_box_reorder_child (GTK_BOX (hbox), arrow, NULL);
+    gtk_box_reorder_child_after (GTK_BOX (hbox), arrow, gtk_widget_get_last_child (hbox));
   else
-    gtk_box_reorder_child (GTK_BOX (hbox), arrow, gtk_widget_get_first_child (hbox));
+    gtk_box_reorder_child_after (GTK_BOX (hbox), arrow, NULL);
 
   if (priv->show_sort_indicator
       || (GTK_IS_TREE_SORTABLE (model) && priv->sort_column_id >= 0))


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