Commit a504e62e authored by Owen Taylor's avatar Owen Taylor Committed by Owen Taylor

Clean up the code so < 0 == end wasn't just a side effect, remove most of

Tue Feb 26 22:22:37 2002  Owen Taylor  <otaylor@redhat.com>

	* gtk/gtkbox.c (gtk_box_reorder_child): Clean up
	the code so < 0 == end wasn't just a side effect,
	remove most of the manual linked list manipulation
	code in favor of g_list_* functions.

Tue Feb 26 22:01:59 2002  Owen Taylor  <otaylor@redhat.com>

	* gtk/tmpl/gtkbox.sgml: Fix docs to correspond to the code -
	negative @position indicates the end of the list.
parent 0205a7bd
Tue Feb 26 22:22:37 2002 Owen Taylor <otaylor@redhat.com>
* gtk/gtkbox.c (gtk_box_reorder_child): Clean up
the code so < 0 == end wasn't just a side effect,
remove most of the manual linked list manipulation
code in favor of g_list_* functions.
Tue Feb 26 21:44:01 2002 Owen Taylor <otaylor@redhat.com>
* config.status config.guess: Remove these files
......
Tue Feb 26 22:22:37 2002 Owen Taylor <otaylor@redhat.com>
* gtk/gtkbox.c (gtk_box_reorder_child): Clean up
the code so < 0 == end wasn't just a side effect,
remove most of the manual linked list manipulation
code in favor of g_list_* functions.
Tue Feb 26 21:44:01 2002 Owen Taylor <otaylor@redhat.com>
* config.status config.guess: Remove these files
......
Tue Feb 26 22:22:37 2002 Owen Taylor <otaylor@redhat.com>
* gtk/gtkbox.c (gtk_box_reorder_child): Clean up
the code so < 0 == end wasn't just a side effect,
remove most of the manual linked list manipulation
code in favor of g_list_* functions.
Tue Feb 26 21:44:01 2002 Owen Taylor <otaylor@redhat.com>
* config.status config.guess: Remove these files
......
Tue Feb 26 22:22:37 2002 Owen Taylor <otaylor@redhat.com>
* gtk/gtkbox.c (gtk_box_reorder_child): Clean up
the code so < 0 == end wasn't just a side effect,
remove most of the manual linked list manipulation
code in favor of g_list_* functions.
Tue Feb 26 21:44:01 2002 Owen Taylor <otaylor@redhat.com>
* config.status config.guess: Remove these files
......
Tue Feb 26 22:22:37 2002 Owen Taylor <otaylor@redhat.com>
* gtk/gtkbox.c (gtk_box_reorder_child): Clean up
the code so < 0 == end wasn't just a side effect,
remove most of the manual linked list manipulation
code in favor of g_list_* functions.
Tue Feb 26 21:44:01 2002 Owen Taylor <otaylor@redhat.com>
* config.status config.guess: Remove these files
......
Tue Feb 26 22:22:37 2002 Owen Taylor <otaylor@redhat.com>
* gtk/gtkbox.c (gtk_box_reorder_child): Clean up
the code so < 0 == end wasn't just a side effect,
remove most of the manual linked list manipulation
code in favor of g_list_* functions.
Tue Feb 26 21:44:01 2002 Owen Taylor <otaylor@redhat.com>
* config.status config.guess: Remove these files
......
Tue Feb 26 22:22:37 2002 Owen Taylor <otaylor@redhat.com>
* gtk/gtkbox.c (gtk_box_reorder_child): Clean up
the code so < 0 == end wasn't just a side effect,
remove most of the manual linked list manipulation
code in favor of g_list_* functions.
Tue Feb 26 21:44:01 2002 Owen Taylor <otaylor@redhat.com>
* config.status config.guess: Remove these files
......
Tue Feb 26 22:01:59 2002 Owen Taylor <otaylor@redhat.com>
* gtk/tmpl/gtkbox.sgml: Fix docs to correspond to the code -
negative @position indicates the end of the list.
2002-02-26 Matthias Clasen <maclas@gmx.de>
Fixes for #72478:
......
......@@ -326,15 +326,14 @@ were added to @box.
A widget's position in the @box children list determines where the
widget is packed into @box. A child widget at some position in the
list will be packed just after all other widgets of the same packing
type that appear earlier in the list. A negative value of @position is
interpreted as position 0.
type that appear earlier in the list.
</para>
@box: a #GtkBox.
@child: the #GtkWidget to move.
@position: the new position for @child in the
<structfield>children</structfield> list of #GtkBox-struct, starting
from 0.
from 0. If negative, indicates the end of the list.
<!-- ##### FUNCTION gtk_box_query_child_packing ##### -->
......
......@@ -496,62 +496,43 @@ gtk_box_reorder_child (GtkBox *box,
GtkWidget *child,
gint position)
{
GList *list;
GList *old_link;
GList *new_link;
GtkBoxChild *child_info = NULL;
gint old_position;
g_return_if_fail (GTK_IS_BOX (box));
g_return_if_fail (GTK_IS_WIDGET (child));
list = box->children;
while (list)
old_link = box->children;
old_position = 0;
while (old_link)
{
GtkBoxChild *child_info;
child_info = list->data;
child_info = old_link->data;
if (child_info->widget == child)
break;
list = list->next;
old_link = old_link->next;
old_position++;
}
if (list && box->children->next)
{
GList *tmp_list;
g_return_if_fail (old_link != NULL);
if (list->next)
list->next->prev = list->prev;
if (list->prev)
list->prev->next = list->next;
else
box->children = list->next;
if (position == old_position)
return;
tmp_list = box->children;
while (position && tmp_list->next)
{
position--;
tmp_list = tmp_list->next;
}
box->children = g_list_delete_link (box->children, old_link);
if (position)
{
tmp_list->next = list;
list->prev = tmp_list;
list->next = NULL;
}
else
{
if (tmp_list->prev)
tmp_list->prev->next = list;
else
box->children = list;
list->prev = tmp_list->prev;
tmp_list->prev = list;
list->next = tmp_list;
}
if (position < 0)
new_link = NULL;
else
new_link = g_list_nth (box->children, position);
gtk_widget_child_notify (child, "position");
if (GTK_WIDGET_VISIBLE (child) && GTK_WIDGET_VISIBLE (box))
gtk_widget_queue_resize (child);
}
box->children = g_list_insert_before (box->children, new_link, child_info);
gtk_widget_child_notify (child, "position");
if (GTK_WIDGET_VISIBLE (child) && GTK_WIDGET_VISIBLE (box))
gtk_widget_queue_resize (child);
}
void
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment