]> Pileus Git - ~andy/gtk/commitdiff
Clean up the code so < 0 == end wasn't just a side effect, remove most of
authorOwen Taylor <otaylor@redhat.com>
Wed, 27 Feb 2002 03:35:05 +0000 (03:35 +0000)
committerOwen Taylor <otaylor@src.gnome.org>
Wed, 27 Feb 2002 03:35:05 +0000 (03:35 +0000)
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.

ChangeLog
ChangeLog.pre-2-0
ChangeLog.pre-2-10
ChangeLog.pre-2-2
ChangeLog.pre-2-4
ChangeLog.pre-2-6
ChangeLog.pre-2-8
docs/reference/ChangeLog
docs/reference/gtk/tmpl/gtkbox.sgml
gtk/gtkbox.c

index 84beffbc845c3270c52e276a741e8e2c20a64082..4e1f61af9f25ff9e7fc2b8ddbb4be82e1b048146 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+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
index 84beffbc845c3270c52e276a741e8e2c20a64082..4e1f61af9f25ff9e7fc2b8ddbb4be82e1b048146 100644 (file)
@@ -1,3 +1,10 @@
+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
index 84beffbc845c3270c52e276a741e8e2c20a64082..4e1f61af9f25ff9e7fc2b8ddbb4be82e1b048146 100644 (file)
@@ -1,3 +1,10 @@
+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
index 84beffbc845c3270c52e276a741e8e2c20a64082..4e1f61af9f25ff9e7fc2b8ddbb4be82e1b048146 100644 (file)
@@ -1,3 +1,10 @@
+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
index 84beffbc845c3270c52e276a741e8e2c20a64082..4e1f61af9f25ff9e7fc2b8ddbb4be82e1b048146 100644 (file)
@@ -1,3 +1,10 @@
+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
index 84beffbc845c3270c52e276a741e8e2c20a64082..4e1f61af9f25ff9e7fc2b8ddbb4be82e1b048146 100644 (file)
@@ -1,3 +1,10 @@
+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
index 84beffbc845c3270c52e276a741e8e2c20a64082..4e1f61af9f25ff9e7fc2b8ddbb4be82e1b048146 100644 (file)
@@ -1,3 +1,10 @@
+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
index 3ccf8db2715de5a318c1cd618a57c1fe2096177b..cdae15cf5b47a87c5ba3f74c364cf8f357108435 100644 (file)
@@ -1,3 +1,8 @@
+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:
index 01dfc126ce727fffd7cd19f5f5ab15359d78a420..09c0cec70975e8b9c1e745b639045c4d172bdd42 100644 (file)
@@ -326,15 +326,14 @@ were added to @box.
 A widget's position in the @box children list determines where the\r
 widget is packed into @box.  A child widget at some position in the\r
 list will be packed just after all other widgets of the same packing\r
-type that appear earlier in the list.  A negative value of @position is\r
-interpreted as position 0.\r
+type that appear earlier in the list.
 </para>
 
 @box: a #GtkBox.
 @child: the #GtkWidget to move.
 @position: the new position for @child in the\r
 <structfield>children</structfield> list of #GtkBox-struct, starting\r
-from 0.
+from 0. If negative, indicates the end of the list.
 
 
 <!-- ##### FUNCTION gtk_box_query_child_packing ##### -->
index 82e8aed048747af5f9767e94a89540e8b49f007d..cc0f356702fb09e2a87adca336613193c60f6592 100644 (file)
@@ -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