[gtk/wip/matthiasc/box3: 3/4] box: Remove gtk_box_reorder_child



commit 2132dfce57ab9fc7720c773d130d8ea44f1d376c
Author: Matthias Clasen <mclasen redhat com>
Date:   Tue Jan 22 20:06:02 2019 -0500

    box: Remove gtk_box_reorder_child
    
    This function is defined in terms of child positions,
    and we've dropped the position child property, so this
    function does not fit well anymore.
    
    Update all callers to do things differently.

 gtk/gtkactionbar.c          | 10 +++----
 gtk/gtkassistant.c          | 25 ++++++++++++----
 gtk/gtkbbox.c               |  8 ++++-
 gtk/gtkbox.c                | 72 ---------------------------------------------
 gtk/gtkbox.h                |  5 ----
 gtk/gtkcolorchooserwidget.c |  3 +-
 gtk/gtkcombobox.c           |  7 ++---
 gtk/gtkfilechooserwidget.c  | 14 ++++-----
 gtk/gtkheaderbar.c          |  5 ++--
 gtk/gtkmenusectionbox.c     | 20 ++++++++-----
 gtk/gtkmodelmenuitem.c      |  3 +-
 gtk/gtknotebook.c           | 23 +++++++--------
 gtk/gtkscalebutton.c        | 17 ++++++-----
 gtk/gtkspinbutton.c         | 14 +++++++--
 gtk/gtkstackswitcher.c      | 14 ++++++++-
 gtk/gtktreeviewcolumn.c     |  7 +++--
 16 files changed, 106 insertions(+), 141 deletions(-)
---
diff --git a/gtk/gtkactionbar.c b/gtk/gtkactionbar.c
index 039e22ddd0..11726bcc41 100644
--- a/gtk/gtkactionbar.c
+++ b/gtk/gtkactionbar.c
@@ -210,8 +210,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, 0);
+              gtk_box_prepend (GTK_BOX (priv->end_box), child);
               g_object_unref (child);
             }
         }
@@ -221,7 +220,7 @@ gtk_action_bar_set_child_property (GtkContainer *container,
             {
               g_object_ref (child);
               gtk_container_remove (GTK_CONTAINER (priv->end_box), child);
-              gtk_container_add (GTK_CONTAINER (priv->start_box), child);
+              gtk_box_append (GTK_BOX (priv->start_box), child);
               g_object_unref (child);
             }
         }
@@ -462,7 +461,7 @@ gtk_action_bar_pack_start (GtkActionBar *action_bar,
 {
   GtkActionBarPrivate *priv = gtk_action_bar_get_instance_private (action_bar);
 
-  gtk_container_add (GTK_CONTAINER (priv->start_box), child);
+  gtk_box_append (GTK_BOX (priv->start_box), child);
 }
 
 /**
@@ -479,8 +478,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, 0);
+  gtk_box_prepend (GTK_BOX (priv->end_box), child);
 }
 
 /**
diff --git a/gtk/gtkassistant.c b/gtk/gtkassistant.c
index 39b0a6ccbd..9b3189524f 100644
--- a/gtk/gtkassistant.c
+++ b/gtk/gtkassistant.c
@@ -1125,7 +1125,13 @@ 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), -1);
+        {
+          GtkWidget *child = l->data;
+          g_object_ref (child);
+          gtk_container_remove (GTK_CONTAINER (priv->action_area), child);
+          gtk_box_prepend (GTK_BOX (priv->action_area), child);
+          g_object_unref (child);
+        }
 
       g_list_free (buttons);
     }
@@ -1644,6 +1650,7 @@ gtk_assistant_insert_page (GtkAssistant *assistant,
   gint n_pages;
   GtkStyleContext *context;
   GtkWidget *box;
+  GtkWidget *sibling;
 
   g_return_val_if_fail (GTK_IS_ASSISTANT (assistant), 0);
   g_return_val_if_fail (GTK_IS_WIDGET (page), 0);
@@ -1686,10 +1693,18 @@ gtk_assistant_insert_page (GtkAssistant *assistant,
 
   priv->pages = g_list_insert (priv->pages, page_info, position);
 
-  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, 2 * position);
-  gtk_box_reorder_child (GTK_BOX (priv->sidebar), page_info->current_title, 2 * position + 1);
+  if (position == 0)
+    sibling = NULL;
+  else
+    {
+      int i;
+      sibling = gtk_widget_get_first_child (priv->sidebar);
+      for (i = 1; i < 2 * position; i++)
+        sibling = gtk_widget_get_next_sibling (sibling);
+    }
+
+  gtk_box_insert_after (GTK_BOX (priv->sidebar), page_info->regular_title, sibling);
+  gtk_box_insert_after (GTK_BOX (priv->sidebar), page_info->current_title,  page_info->regular_title);
 
   box = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 0);
   gtk_widget_show (box);
diff --git a/gtk/gtkbbox.c b/gtk/gtkbbox.c
index fb3400675c..1107638888 100644
--- a/gtk/gtkbbox.c
+++ b/gtk/gtkbbox.c
@@ -387,7 +387,13 @@ gtk_button_box_set_child_secondary (GtkButtonBox *widget,
 
   if (bbox->priv->layout_style == GTK_BUTTONBOX_EXPAND)
     {
-      gtk_box_reorder_child (GTK_BOX (bbox), child, is_secondary ? 0 : -1);
+      g_object_ref (child);
+      gtk_container_remove (GTK_CONTAINER (bbox), child);
+      if (is_secondary)
+        gtk_box_prepend (GTK_CONTAINER (bbox), child);
+      else
+        gtk_box_append (GTK_CONTAINER (bbox), child);
+      g_object_unref (child);
     }
 
   if (gtk_widget_get_visible (GTK_WIDGET (widget)) &&
diff --git a/gtk/gtkbox.c b/gtk/gtkbox.c
index d952eb7e53..b59e244ae4 100644
--- a/gtk/gtkbox.c
+++ b/gtk/gtkbox.c
@@ -45,9 +45,6 @@
  * 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
- * place in the box.
- *
  * # CSS nodes
  *
  * GtkBox uses a single CSS node with name box.
@@ -1047,75 +1044,6 @@ gtk_box_get_baseline_position (GtkBox *box)
   return priv->baseline_pos;
 }
 
-/**
- * gtk_box_reorder_child:
- * @box: a #GtkBox
- * @child: the #GtkWidget to move
- * @position: the new position for @child in the list of children
- *   of @box, starting from 0. If negative, indicates the end of
- *   the list
- *
- * Moves @child to a new @position in the list of @box children.
- */
-void
-gtk_box_reorder_child (GtkBox    *box,
-                      GtkWidget *child,
-                      gint       position)
-{
-  GtkWidget *widget;
-
-  g_return_if_fail (GTK_IS_BOX (box));
-  g_return_if_fail (GTK_IS_WIDGET (child));
-
-  widget = GTK_WIDGET (box);
-
-  if (position == 0)
-    {
-      gtk_widget_insert_after (child, widget, NULL);
-      gtk_css_node_insert_after (gtk_widget_get_css_node (widget),
-                                 gtk_widget_get_css_node (child),
-                                 NULL);
-    }
-  else if (position < 0)
-    {
-      gtk_widget_insert_before (child, widget, NULL);
-      gtk_css_node_insert_before (gtk_widget_get_css_node (widget),
-                                  gtk_widget_get_css_node (child),
-                                  NULL);
-    }
-  else
-    {
-      int i = 0;
-      int old_pos = -1;
-      GtkWidget *p;
-      GtkWidget *new_next_sibling = NULL;
-
-
-      for (p = _gtk_widget_get_first_child (widget);
-           p != NULL;
-           p = _gtk_widget_get_next_sibling (p))
-        {
-          if (p == child)
-            old_pos = i;
-
-          if (i == position + 1)
-            {
-              new_next_sibling = p;
-            }
-
-          i ++;
-        }
-
-      if (position == old_pos)
-        return;
-
-      gtk_widget_insert_before (child, widget, new_next_sibling);
-      gtk_css_node_insert_before (gtk_widget_get_css_node (widget),
-                                  gtk_widget_get_css_node (child),
-                                  new_next_sibling ? gtk_widget_get_css_node (new_next_sibling) : NULL);
-    }
-}
-
 static void
 gtk_box_add (GtkContainer *container,
              GtkWidget    *child)
diff --git a/gtk/gtkbox.h b/gtk/gtkbox.h
index bcf7ebd109..c746ab64bf 100644
--- a/gtk/gtkbox.h
+++ b/gtk/gtkbox.h
@@ -91,11 +91,6 @@ void        gtk_box_set_baseline_position (GtkBox             *box,
 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,
-                                         gint            position);
-
 GDK_AVAILABLE_IN_ALL
 void        gtk_box_prepend             (GtkBox         *box,
                                          GtkWidget      *child);
diff --git a/gtk/gtkcolorchooserwidget.c b/gtk/gtkcolorchooserwidget.c
index 2afc0187cd..e028d96ade 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, 1);
+  gtk_box_insert_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 8adddcfe2f..e9e705f872 100644
--- a/gtk/gtkcombobox.c
+++ b/gtk/gtkcombobox.c
@@ -1156,9 +1156,7 @@ gtk_combo_box_create_child (GtkComboBox *combo_box)
       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);
-      gtk_container_add (GTK_CONTAINER (gtk_widget_get_parent (priv->arrow)),
-                         priv->cell_view);
-      gtk_box_reorder_child (GTK_BOX (gtk_widget_get_parent (priv->arrow)), priv->cell_view, 0);
+      gtk_box_prepend (GTK_BOX (gtk_widget_get_parent (priv->arrow)), priv->cell_view);
       _gtk_bin_set_child (GTK_BIN (combo_box), priv->cell_view);
     }
 }
@@ -1193,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, 0);
+  gtk_box_prepend (GTK_BOX (priv->box), widget);
   _gtk_bin_set_child (GTK_BIN (container), widget);
 
   if (priv->has_entry)
diff --git a/gtk/gtkfilechooserwidget.c b/gtk/gtkfilechooserwidget.c
index 83fef49db6..b7babfbf78 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, 0);
+          gtk_box_prepend (GTK_BOX (priv->preview_box), priv->preview_label);
           gtk_label_set_ellipsize (GTK_LABEL (priv->preview_label), PANGO_ELLIPSIZE_MIDDLE);
           gtk_widget_show (priv->preview_label);
         }
@@ -957,10 +956,10 @@ set_preview_widget (GtkFileChooserWidget *impl,
   if (priv->preview_widget)
     {
       gtk_widget_show (priv->preview_widget);
-      gtk_container_add (GTK_CONTAINER (priv->preview_box), priv->preview_widget);
-      gtk_box_reorder_child (GTK_BOX (priv->preview_box),
-                             priv->preview_widget,
-                             (priv->use_preview_label && priv->preview_label) ? 1 : 0);
+      if (priv->use_preview_label && priv->preview_label)
+        gtk_box_insert_after (GTK_BOX (priv->preview_box), priv->preview_widget, priv->preview_label);
+      else
+        gtk_box_prepend (GTK_BOX (priv->preview_box), priv->preview_widget);
     }
 
   update_preview_widget_visibility (impl);
@@ -2607,8 +2606,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, 0);
+  gtk_box_prepend (GTK_BOX (priv->box), priv->save_widgets);
   gtk_widget_show (priv->save_widgets);
 }
 
diff --git a/gtk/gtkheaderbar.c b/gtk/gtkheaderbar.c
index c86ea2757e..4a61a6e9c7 100644
--- a/gtk/gtkheaderbar.c
+++ b/gtk/gtkheaderbar.c
@@ -468,9 +468,10 @@ _gtk_header_bar_update_window_buttons (GtkHeaderBar *bar)
               continue;
             }
 
-          gtk_container_add (GTK_CONTAINER (box), separator);
           if (i == 1)
-            gtk_box_reorder_child (GTK_BOX (box), separator, 0);
+            gtk_box_prepend (GTK_BOX (box), separator);
+          else
+            gtk_box_append (GTK_BOX (box), separator);
 
           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 81aa08638d..98d2b71843 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, 0);
-    }
+    gtk_box_prepend (GTK_BOX (box), box->separator);
   else
     gtk_container_remove (GTK_CONTAINER (box), box->separator);
 }
@@ -332,8 +329,16 @@ gtk_menu_section_box_insert_func (GtkMenuTrackerItem *item,
   g_object_set_data_full (G_OBJECT (widget), "GtkMenuTrackerItem", g_object_ref (item), g_object_unref);
 
   gtk_widget_set_halign (widget, GTK_ALIGN_FILL);
-  gtk_container_add (GTK_CONTAINER (box->item_box), widget);
-  gtk_box_reorder_child (GTK_BOX (box->item_box), widget, position);
+  if (position == 0)
+    gtk_box_prepend (GTK_BOX (box->item_box), widget);
+  else
+    {
+      GtkWidget *sibling = gtk_widget_get_first_child (GTK_WIDGET (box->item_box));
+      int i;
+      for (i = 1; i < position; i++)
+        sibling = gtk_widget_get_next_sibling (sibling);
+      gtk_box_insert_after (GTK_BOX (box->item_box), widget, sibling);
+    }
 
   gtk_menu_section_box_schedule_separator_sync (box);
 }
@@ -457,8 +462,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, 0);
+  gtk_box_prepend (GTK_BOX (box), button);
 
   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 ffa8ad9635..ef927fa8d2 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, 0);
+      gtk_box_prepend (GTK_BOX (child), image);
     }
 
   g_object_notify (G_OBJECT (item), "icon");
diff --git a/gtk/gtknotebook.c b/gtk/gtknotebook.c
index 1ed14d842f..3d50a98f4d 100644
--- a/gtk/gtknotebook.c
+++ b/gtk/gtknotebook.c
@@ -6198,6 +6198,8 @@ gtk_notebook_update_tab_pos (GtkNotebook *notebook)
                                         tab_pos_names[i]);
     }
 
+  g_object_ref (priv->header_widget);
+  gtk_container_remove (GTK_CONTAINER (priv->box), priv->header_widget);
   switch (tab_pos)
     {
     case GTK_POS_TOP:
@@ -6205,8 +6207,7 @@ gtk_notebook_update_tab_pos (GtkNotebook *notebook)
       gtk_widget_set_vexpand (priv->tabs_widget, FALSE);
       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, 0);
+      gtk_box_prepend (GTK_BOX (priv->box), priv->header_widget);
 
       gtk_orientable_set_orientation (GTK_ORIENTABLE (priv->box), GTK_ORIENTATION_VERTICAL);
       gtk_orientable_set_orientation (GTK_ORIENTABLE (priv->header_widget), GTK_ORIENTATION_HORIZONTAL);
@@ -6217,8 +6218,7 @@ gtk_notebook_update_tab_pos (GtkNotebook *notebook)
       gtk_widget_set_vexpand (priv->tabs_widget, FALSE);
       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, 1);
+      gtk_box_append (GTK_BOX (priv->box), priv->header_widget);
 
       gtk_orientable_set_orientation (GTK_ORIENTABLE (priv->box), GTK_ORIENTATION_VERTICAL);
       gtk_orientable_set_orientation (GTK_ORIENTABLE (priv->header_widget), GTK_ORIENTATION_HORIZONTAL);
@@ -6229,8 +6229,7 @@ gtk_notebook_update_tab_pos (GtkNotebook *notebook)
       gtk_widget_set_vexpand (priv->tabs_widget, TRUE);
       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, 0);
+      gtk_box_prepend (GTK_BOX (priv->box), priv->header_widget);
 
       gtk_orientable_set_orientation (GTK_ORIENTABLE (priv->box), GTK_ORIENTATION_HORIZONTAL);
       gtk_orientable_set_orientation (GTK_ORIENTABLE (priv->header_widget), GTK_ORIENTATION_VERTICAL);
@@ -6241,8 +6240,7 @@ gtk_notebook_update_tab_pos (GtkNotebook *notebook)
       gtk_widget_set_vexpand (priv->tabs_widget, TRUE);
       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, 1);
+      gtk_box_append (GTK_BOX (priv->box), priv->header_widget);
 
       gtk_orientable_set_orientation (GTK_ORIENTABLE (priv->box), GTK_ORIENTATION_HORIZONTAL);
       gtk_orientable_set_orientation (GTK_ORIENTABLE (priv->header_widget), GTK_ORIENTATION_VERTICAL);
@@ -6251,6 +6249,7 @@ gtk_notebook_update_tab_pos (GtkNotebook *notebook)
       g_assert_not_reached ();
       break;
     }
+  g_object_unref (priv->header_widget);
 }
 
 /**
@@ -7149,10 +7148,10 @@ gtk_notebook_set_action_widget (GtkNotebook *notebook,
 
   if (widget)
     {
-      int pos = pack_type == GTK_PACK_START ? 0 : -1;
-
-      gtk_container_add (GTK_CONTAINER (priv->header_widget), widget);
-      gtk_box_reorder_child (GTK_BOX (priv->header_widget), widget, pos);
+      if (pack_type == GTK_PACK_START)
+        gtk_box_prepend (GTK_BOX (priv->header_widget), widget);
+      else
+        gtk_box_append (GTK_BOX (priv->header_widget), widget);
       gtk_widget_set_child_visible (widget, priv->show_tabs);
     }
 
diff --git a/gtk/gtkscalebutton.c b/gtk/gtkscalebutton.c
index 9102b333c1..924cf9715f 100644
--- a/gtk/gtkscalebutton.c
+++ b/gtk/gtkscalebutton.c
@@ -725,19 +725,22 @@ apply_orientation (GtkScaleButton *button,
       priv->applied_orientation = orientation;
       gtk_orientable_set_orientation (GTK_ORIENTABLE (priv->box), orientation);
 
+      g_object_ref (priv->minus_button);
+      g_object_ref (priv->plus_button);
+      gtk_container_remove (GTK_CONTAINER (priv->box), priv->minus_button);
+      gtk_container_remove (GTK_CONTAINER (priv->box), priv->plus_button);
       if (orientation == GTK_ORIENTATION_HORIZONTAL)
         {
-          gtk_box_reorder_child (GTK_BOX (priv->box), priv->scale, 0);
-          gtk_box_reorder_child (GTK_BOX (priv->box), priv->minus_button, 1);
-          gtk_box_reorder_child (GTK_BOX (priv->box), priv->plus_button, 2);
+          gtk_box_insert_after (GTK_BOX (priv->box), priv->minus_button, priv->scale);
+          gtk_box_insert_after (GTK_BOX (priv->box), priv->plus_button, priv->minus_button);
         }
       else
         {
-          gtk_box_reorder_child (GTK_BOX (priv->box), priv->scale, 1);
-          gtk_box_reorder_child (GTK_BOX (priv->box), priv->minus_button, 2);
-          gtk_box_reorder_child (GTK_BOX (priv->box), priv->plus_button, 0);
-
+          gtk_box_insert_after (GTK_BOX (priv->box), priv->minus_button, priv->scale);
+          gtk_box_insert_before (GTK_BOX (priv->box), priv->plus_button, priv->scale);
         }
+      g_object_unref (priv->plus_button);
+      g_object_unref (priv->minus_button);
 
       gtk_orientable_set_orientation (GTK_ORIENTABLE (priv->scale), orientation);
 
diff --git a/gtk/gtkspinbutton.c b/gtk/gtkspinbutton.c
index 5bf431ee8e..27c58406e1 100644
--- a/gtk/gtkspinbutton.c
+++ b/gtk/gtkspinbutton.c
@@ -865,6 +865,7 @@ gtk_spin_button_init (GtkSpinButton *spin_button)
 
   priv->box = gtk_box_new (priv->orientation, 0);
   gtk_widget_set_parent (priv->box, GTK_WIDGET (spin_button));
+
   priv->entry = gtk_entry_new ();
   gtk_entry_set_width_chars (GTK_ENTRY (priv->entry), 0);
   gtk_entry_set_max_width_chars (GTK_ENTRY (priv->entry), 0);
@@ -1036,17 +1037,24 @@ gtk_spin_button_set_orientation (GtkSpinButton  *spin,
            gtk_entry_get_alignment (entry) == 0.5)
     gtk_entry_set_alignment (entry, 0.0);
 
+  g_object_ref (priv->up_button);
+  g_object_ref (priv->down_button);
+  gtk_container_remove (GTK_CONTAINER (priv->box), priv->up_button);
+  gtk_container_remove (GTK_CONTAINER (priv->box), priv->down_button);
   if (priv->orientation == GTK_ORIENTATION_HORIZONTAL)
     {
       /* Current orientation of the box is vertical! */
-      gtk_box_reorder_child (GTK_BOX (priv->box), priv->entry, 0);
-      gtk_box_reorder_child (GTK_BOX (priv->box), priv->down_button, 1);
+      gtk_box_insert_after (GTK_BOX (priv->box), priv->up_button, priv->entry);
+      gtk_box_insert_after (GTK_BOX (priv->box), priv->down_button, priv->up_button);
     }
   else
     {
       /* Current orientation of the box is horizontal! */
-      gtk_box_reorder_child (GTK_BOX (priv->box), priv->up_button, 0);
+      gtk_box_insert_before (GTK_BOX (priv->box), priv->up_button, priv->entry);
+      gtk_box_insert_after (GTK_BOX (priv->box), priv->down_button, priv->entry);
     }
+  g_object_unref (priv->up_button);
+  g_object_unref (priv->down_button);
 
   gtk_orientable_set_orientation (GTK_ORIENTABLE (priv->box), priv->orientation);
 
diff --git a/gtk/gtkstackswitcher.c b/gtk/gtkstackswitcher.c
index 53faf59b05..0e9e11689f 100644
--- a/gtk/gtkstackswitcher.c
+++ b/gtk/gtkstackswitcher.c
@@ -235,7 +235,19 @@ on_position_updated (GtkWidget        *widget,
                            "position", &position,
                            NULL);
 
-  gtk_box_reorder_child (GTK_BOX (self), button, position);
+  g_object_ref (button);
+  gtk_container_remove (GTK_BOX (self), button);
+  if (position == 0)
+    gtk_box_prepend (GTK_BOX (self), button);
+  else
+    {
+      GtkWidget *sibling = gtk_widget_get_first_child (GTK_WIDGET (self));
+      int i;
+      for (i = 0; i < position; i++)
+        sibling = gtk_widget_get_next_sibling (sibling);
+      gtk_box_insert_before (GTK_BOX (self), button, sibling);
+    }
+  g_object_unref (button);
 }
 
 static void
diff --git a/gtk/gtktreeviewcolumn.c b/gtk/gtktreeviewcolumn.c
index 338d691d38..e1f7047840 100644
--- a/gtk/gtktreeviewcolumn.c
+++ b/gtk/gtktreeviewcolumn.c
@@ -963,10 +963,13 @@ gtk_tree_view_column_update_button (GtkTreeViewColumn *tree_column)
    * left otherwise; do this by packing boxes, so flipping text direction will
    * reverse things
    */
+  g_object_ref (arrow);
+  gtk_container_remove (GTK_BOX (hbox), arrow);
   if (priv->xalign <= 0.5)
-    gtk_box_reorder_child (GTK_BOX (hbox), arrow, 1);
+    gtk_box_append (GTK_BOX (hbox), arrow);
   else
-    gtk_box_reorder_child (GTK_BOX (hbox), arrow, 0);
+    gtk_box_prepend (GTK_BOX (hbox), arrow);
+  g_object_unref (arrow);
 
   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]