[gtk+] listbox: Reorder code



commit 653fc4fd4bce18d2a25558f8ddcfce3b91c4167e
Author: Kalev Lember <kalevlember gmail com>
Date:   Thu Aug 8 08:06:27 2013 +0200

    listbox: Reorder code
    
    This just moves the gtk_list_box_insert function to where the rest of the
    public API is defined.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=705558

 gtk/gtklistbox.c |  132 +++++++++++++++++++++++++++---------------------------
 1 files changed, 66 insertions(+), 66 deletions(-)
---
diff --git a/gtk/gtklistbox.c b/gtk/gtklistbox.c
index 79c4403..f9545a5 100644
--- a/gtk/gtklistbox.c
+++ b/gtk/gtklistbox.c
@@ -1671,72 +1671,6 @@ gtk_list_box_row_visibility_changed (GtkListBox    *list_box,
     }
 }
 
-/**
- * gtk_list_box_insert:
- * @list_box: a #GtkListBox.
- * @child: the #GtkWidget to add
- * @position: the position to insert @child in
- *
- * Insert the @child into the @list_box at @position. If a sort function is
- * set, the widget will actually be inserted at the calculated position and
- * this function has the same effect of gtk_container_add().
- *
- * If @position is -1, or larger than the total number of items in the
- * @list_box, then the @child will be appended to the end.
- *
- * Since: 3.10
- */
-void
-gtk_list_box_insert (GtkListBox *list_box,
-                     GtkWidget  *child,
-                     gint        position)
-{
-  GtkListBoxPrivate *priv = gtk_list_box_get_instance_private (list_box);
-  GtkListBoxRow *row;
-  GSequenceIter* iter = NULL;
-
-  g_return_if_fail (list_box != NULL);
-  g_return_if_fail (child != NULL);
-
-  if (GTK_IS_LIST_BOX_ROW (child))
-    row = GTK_LIST_BOX_ROW (child);
-  else
-    {
-      row = GTK_LIST_BOX_ROW (gtk_list_box_row_new ());
-      gtk_widget_show (GTK_WIDGET (row));
-      gtk_container_add (GTK_CONTAINER (row), child);
-    }
-
-  if (priv->sort_func != NULL)
-    iter = g_sequence_insert_sorted (priv->children, row,
-                                     (GCompareDataFunc)do_sort, list_box);
-  else if (position == 0)
-    iter = g_sequence_prepend (priv->children, row);
-  else if (position == -1)
-    iter = g_sequence_append (priv->children, row);
-  else
-    {
-      GSequenceIter *current_iter;
-
-      current_iter = g_sequence_get_iter_at_pos (priv->children, position);
-      iter = g_sequence_insert_before (current_iter, row);
-    }
-
-  ROW_PRIV (row)->iter = iter;
-  gtk_widget_set_parent (GTK_WIDGET (row), GTK_WIDGET (list_box));
-  gtk_widget_set_child_visible (GTK_WIDGET (row), TRUE);
-  ROW_PRIV (row)->visible = gtk_widget_get_visible (GTK_WIDGET (row));
-  if (ROW_PRIV (row)->visible)
-    list_box_add_visible_rows (list_box, 1);
-  gtk_list_box_apply_filter (list_box, row);
-  if (gtk_widget_get_visible (GTK_WIDGET (list_box)))
-    {
-      gtk_list_box_update_header (list_box, ROW_PRIV (row)->iter);
-      gtk_list_box_update_header (list_box,
-                                  gtk_list_box_get_next_visible (list_box, ROW_PRIV (row)->iter));
-    }
-}
-
 static void
 gtk_list_box_real_add (GtkContainer *container,
                        GtkWidget    *child)
@@ -2098,6 +2032,72 @@ gtk_list_box_prepend (GtkListBox *list_box,
 }
 
 /**
+ * gtk_list_box_insert:
+ * @list_box: a #GtkListBox.
+ * @child: the #GtkWidget to add
+ * @position: the position to insert @child in
+ *
+ * Insert the @child into the @list_box at @position. If a sort function is
+ * set, the widget will actually be inserted at the calculated position and
+ * this function has the same effect of gtk_container_add().
+ *
+ * If @position is -1, or larger than the total number of items in the
+ * @list_box, then the @child will be appended to the end.
+ *
+ * Since: 3.10
+ */
+void
+gtk_list_box_insert (GtkListBox *list_box,
+                     GtkWidget  *child,
+                     gint        position)
+{
+  GtkListBoxPrivate *priv = gtk_list_box_get_instance_private (list_box);
+  GtkListBoxRow *row;
+  GSequenceIter *iter = NULL;
+
+  g_return_if_fail (list_box != NULL);
+  g_return_if_fail (child != NULL);
+
+  if (GTK_IS_LIST_BOX_ROW (child))
+    row = GTK_LIST_BOX_ROW (child);
+  else
+    {
+      row = GTK_LIST_BOX_ROW (gtk_list_box_row_new ());
+      gtk_widget_show (GTK_WIDGET (row));
+      gtk_container_add (GTK_CONTAINER (row), child);
+    }
+
+  if (priv->sort_func != NULL)
+    iter = g_sequence_insert_sorted (priv->children, row,
+                                     (GCompareDataFunc)do_sort, list_box);
+  else if (position == 0)
+    iter = g_sequence_prepend (priv->children, row);
+  else if (position == -1)
+    iter = g_sequence_append (priv->children, row);
+  else
+    {
+      GSequenceIter *current_iter;
+
+      current_iter = g_sequence_get_iter_at_pos (priv->children, position);
+      iter = g_sequence_insert_before (current_iter, row);
+    }
+
+  ROW_PRIV (row)->iter = iter;
+  gtk_widget_set_parent (GTK_WIDGET (row), GTK_WIDGET (list_box));
+  gtk_widget_set_child_visible (GTK_WIDGET (row), TRUE);
+  ROW_PRIV (row)->visible = gtk_widget_get_visible (GTK_WIDGET (row));
+  if (ROW_PRIV (row)->visible)
+    list_box_add_visible_rows (list_box, 1);
+  gtk_list_box_apply_filter (list_box, row);
+  if (gtk_widget_get_visible (GTK_WIDGET (list_box)))
+    {
+      gtk_list_box_update_header (list_box, ROW_PRIV (row)->iter);
+      gtk_list_box_update_header (list_box,
+                                  gtk_list_box_get_next_visible (list_box, ROW_PRIV (row)->iter));
+    }
+}
+
+/**
  * gtk_list_box_drag_unhighlight_row:
  * @list_box: An #GtkListBox.
  *


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