[gtk+/wip/baedert/drawing: 107/129] listbox: Remove rows directly when binding model



commit be831bcf97aba7f328b58a0480aa5dfcbc22654b
Author: Timm Bäder <mail baedert org>
Date:   Wed May 24 10:00:15 2017 +0200

    listbox: Remove rows directly when binding model
    
    Instead of hopping through 7 different functions to do that, just
    remove all rows directly. This also mean we'll only remove rows and not
    other children that've been added like placeholders.

 gtk/gtklistbox.c |   10 +++++++++-
 1 files changed, 9 insertions(+), 1 deletions(-)
---
diff --git a/gtk/gtklistbox.c b/gtk/gtklistbox.c
index 74ed373..6f3c42b 100644
--- a/gtk/gtklistbox.c
+++ b/gtk/gtklistbox.c
@@ -3703,6 +3703,7 @@ gtk_list_box_bind_model (GtkListBox                 *box,
                          GDestroyNotify              user_data_free_func)
 {
   GtkListBoxPrivate *priv = BOX_PRIV (box);
+  GSequenceIter *iter;
 
   g_return_if_fail (GTK_IS_LIST_BOX (box));
   g_return_if_fail (model == NULL || G_IS_LIST_MODEL (model));
@@ -3717,7 +3718,14 @@ gtk_list_box_bind_model (GtkListBox                 *box,
       g_clear_object (&priv->bound_model);
     }
 
-  gtk_list_box_forall (GTK_CONTAINER (box), (GtkCallback) gtk_widget_destroy, NULL);
+  iter = g_sequence_get_begin_iter (priv->children);
+  while (!g_sequence_iter_is_end (iter))
+    {
+      GtkWidget *row = g_sequence_get (iter);
+      iter = g_sequence_iter_next (iter);
+      gtk_list_box_remove (GTK_CONTAINER (box), row);
+    }
+
 
   if (model == NULL)
     return;


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