[gtk] box: Avoid position in the reorder api
- From: Matthias Clasen <matthiasc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk] box: Avoid position in the reorder api
- Date: Thu, 24 Jan 2019 02:17:39 +0000 (UTC)
commit f3f5a896de2ce9bb7661ae70ce7cd69d19299994
Author: Matthias Clasen <mclasen redhat com>
Date: Tue Jan 22 18:44:34 2019 -0500
box: Avoid position in the reorder api
Change the reorder api to insert after a 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.
docs/reference/gtk/gtk4-sections.txt | 3 +-
gtk/gtkactionbar.c | 6 +-
gtk/gtkassistant.c | 19 +++--
gtk/gtkbbox.c | 4 +-
gtk/gtkbox.c | 146 ++++++++++++++++++-----------------
gtk/gtkbox.h | 10 ++-
gtk/gtkcolorchooserwidget.c | 3 +-
gtk/gtkcombobox.c | 7 +-
gtk/gtkfilechooserwidget.c | 9 +--
gtk/gtkheaderbar.c | 2 +-
gtk/gtkmenusectionbox.c | 20 +++--
gtk/gtkmodelmenuitem.c | 3 +-
gtk/gtknotebook.c | 15 ++--
gtk/gtkscalebutton.c | 11 +--
gtk/gtkspinbutton.c | 8 +-
gtk/gtkstackswitcher.c | 11 ++-
gtk/gtktreeviewcolumn.c | 4 +-
17 files changed, 150 insertions(+), 131 deletions(-)
---
diff --git a/docs/reference/gtk/gtk4-sections.txt b/docs/reference/gtk/gtk4-sections.txt
index b2faa749db..353de84d48 100644
--- a/docs/reference/gtk/gtk4-sections.txt
+++ b/docs/reference/gtk/gtk4-sections.txt
@@ -323,9 +323,10 @@ gtk_box_get_homogeneous
gtk_box_set_homogeneous
gtk_box_get_spacing
gtk_box_set_spacing
-gtk_box_reorder_child
gtk_box_get_baseline_position
gtk_box_set_baseline_position
+gtk_box_insert_child_after
+gtk_box_reorder_child_after
<SUBSECTION Standard>
GTK_BOX
GTK_IS_BOX
diff --git a/gtk/gtkactionbar.c b/gtk/gtkactionbar.c
index 039e22ddd0..f54308d611 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_insert_child_after (GTK_BOX (priv->end_box), child, NULL);
g_object_unref (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_insert_child_after (GTK_BOX (priv->end_box), child, NULL);
}
/**
diff --git a/gtk/gtkassistant.c b/gtk/gtkassistant.c
index 39b0a6ccbd..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), -1);
+ gtk_box_reorder_child_after (GTK_BOX (priv->action_area), GTK_WIDGET (l->data), NULL);
g_list_free (buttons);
}
@@ -1644,6 +1644,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 +1687,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_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 fb3400675c..c9bccc0c6a 100644
--- a/gtk/gtkbbox.c
+++ b/gtk/gtkbbox.c
@@ -386,9 +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 ? 0 : -1);
- }
+ 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 4fc004b740..2e952a5af0 100644
--- a/gtk/gtkbox.c
+++ b/gtk/gtkbox.c
@@ -35,8 +35,9 @@
* the children to influence their allocation.
*
* Use repeated calls to gtk_container_add() to pack widgets into a
- * GtkBox from start to end. Use gtk_container_remove()
- * to remove widgets from the GtkBox.
+ * GtkBox from start to end. Use gtk_container_remove() to remove widgets
+ * from the GtkBox. gtk_box_insert_child_after() can be used to add a child
+ * at a particular position.
*
* Use gtk_box_set_homogeneous() to specify whether or not all children
* of the GtkBox are forced to get the same amount of space.
@@ -45,7 +46,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 child to a different
* place in the box.
*
* # CSS nodes
@@ -1047,75 +1048,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)
@@ -1164,3 +1096,73 @@ _gtk_box_get_children (GtkBox *box)
return g_list_reverse (retval);
}
+
+/**
+ * gtk_box_insert_child_after:
+ * @box: a #GtkBox
+ * @child: the #GtkWidget to insert
+ * @sibling: (nullable): the sibling to move @child after, or %NULL
+ *
+ * Inserts @child in the position after @sibling in the list
+ * of @box children. If @sibling is %NULL, insert @child at
+ * the first position.
+ */
+void
+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);
+}
+
+/**
+ * gtk_box_reorder_child_after:
+ * @box: a #GtkBox
+ * @child: the #GtkWidget to move, must be a child of @box
+ * @sibling: (nullable): the sibling to move @child after, or %NULL
+ *
+ * Moves @child to the position after @sibling in the list
+ * of @box children. If @sibling is %NULL, move @child to
+ * the first position.
+ */
+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_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 fd98927e2e..eb5146a15f 100644
--- a/gtk/gtkbox.h
+++ b/gtk/gtkbox.h
@@ -92,9 +92,15 @@ GDK_AVAILABLE_IN_ALL
GtkBaselinePosition gtk_box_get_baseline_position (GtkBox *box);
GDK_AVAILABLE_IN_ALL
-void gtk_box_reorder_child (GtkBox *box,
+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,
- gint position);
+ GtkWidget *sibling);
+
G_END_DECLS
diff --git a/gtk/gtkcolorchooserwidget.c b/gtk/gtkcolorchooserwidget.c
index 2afc0187cd..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, 1);
+ 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 8adddcfe2f..b47ffe50f6 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_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);
}
}
@@ -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_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 d7ccf53e1d..d52fd98dfd 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_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);
}
@@ -958,9 +957,6 @@ set_preview_widget (GtkFileChooserWidget *impl,
{
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);
}
update_preview_widget_visibility (impl);
@@ -2607,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, 0);
+ 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 c86ea2757e..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, 0);
+ 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 81aa08638d..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, 0);
- }
+ gtk_box_insert_child_after (GTK_BOX (box), box->separator, NULL);
else
gtk_container_remove (GTK_CONTAINER (box), box->separator);
}
@@ -333,7 +330,17 @@ gtk_menu_section_box_insert_func (GtkMenuTrackerItem *item,
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_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 = 1; i < position; i++)
+ sibling = gtk_widget_get_next_sibling (sibling);
+ gtk_box_reorder_child_after (GTK_BOX (box->item_box), widget, sibling);
+ }
gtk_menu_section_box_schedule_separator_sync (box);
}
@@ -457,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, 0);
+ 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 ffa8ad9635..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, 0);
+ 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 c3aa646546..8c52b52012 100644
--- a/gtk/gtknotebook.c
+++ b/gtk/gtknotebook.c
@@ -6204,7 +6204,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, 0);
+ 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);
@@ -6216,7 +6216,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, 1);
+ 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);
@@ -6228,7 +6228,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, 0);
+ 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);
@@ -6240,7 +6240,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, 1);
+ 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);
@@ -7147,10 +7147,11 @@ 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_reorder_child_after (GTK_BOX (priv->header_widget), widget, NULL);
+ else
+ 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 9102b333c1..c7b8a4865a 100644
--- a/gtk/gtkscalebutton.c
+++ b/gtk/gtkscalebutton.c
@@ -727,16 +727,13 @@ apply_orientation (GtkScaleButton *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_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, 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_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 52c9a78df2..181b91cd48 100644
--- a/gtk/gtkspinbutton.c
+++ b/gtk/gtkspinbutton.c
@@ -868,6 +868,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);
@@ -1051,13 +1052,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->entry, 0);
- gtk_box_reorder_child (GTK_BOX (priv->box), priv->down_button, 1);
+ 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->up_button, 0);
+ 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 53faf59b05..50cdcecb55 100644
--- a/gtk/gtkstackswitcher.c
+++ b/gtk/gtkstackswitcher.c
@@ -235,7 +235,16 @@ on_position_updated (GtkWidget *widget,
"position", &position,
NULL);
- gtk_box_reorder_child (GTK_BOX (self), button, position);
+ if (position == 0)
+ 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 = 1; i < position; i++)
+ sibling = gtk_widget_get_next_sibling (sibling);
+ gtk_box_reorder_child_after (GTK_BOX (self), button, sibling);
+ }
}
static void
diff --git a/gtk/gtktreeviewcolumn.c b/gtk/gtktreeviewcolumn.c
index 338d691d38..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, 1);
+ gtk_box_reorder_child_after (GTK_BOX (hbox), arrow, gtk_widget_get_last_child (hbox));
else
- gtk_box_reorder_child (GTK_BOX (hbox), arrow, 0);
+ 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]