[easytag/wip/glist: 6/7] Refactor list handling in picture.c



commit 9e21c7555b2b90505a67464b1834d1b72fb376fa
Author: David King <amigadave amigadave com>
Date:   Wed May 22 21:17:18 2013 +0100

    Refactor list handling in picture.c

 src/picture.c |   31 +++++++++++++------------------
 1 files changed, 13 insertions(+), 18 deletions(-)
---
diff --git a/src/picture.c b/src/picture.c
index b559c41..85d7e97 100644
--- a/src/picture.c
+++ b/src/picture.c
@@ -120,36 +120,33 @@ Picture_Selection_Changed_cb (GtkTreeSelection *selection, gpointer data)
 
 void Picture_Clear_Button_Clicked (GObject *object)
 {
-    GList *paths, *refs = NULL, *node = NULL;
+    GList *paths, *refs = NULL;
+    GList *l;
     GtkTreeSelection *selection;
     GtkTreeModel *model;
     GtkTreeIter iter;
-    gpointer proxy;
-    gint n = 0;
 
     g_return_if_fail (PictureEntryView != NULL);
 
     model = gtk_tree_view_get_model(GTK_TREE_VIEW(PictureEntryView));
     selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(PictureEntryView));
-    paths = gtk_tree_selection_get_selected_rows(selection, 0);
-    proxy = g_object_newv(G_TYPE_OBJECT, 0, NULL);
+    paths = gtk_tree_selection_get_selected_rows (selection, NULL);
 
-    // List of items to delete
-    for (node = paths; node; node = node->next)
+    /* List of items to delete. */
+    for (l = paths; l != NULL; l = g_list_next (l))
     {
-        refs = g_list_append(refs, gtk_tree_row_reference_new_proxy(proxy, model, node->data));
-        gtk_tree_path_free(node->data);
+        refs = g_list_append (refs, gtk_tree_row_reference_new (model,
+                                                                l->data));
     }
-    g_list_free(paths);
 
-    for (node = refs; node; node = node->next)
+    g_list_free_full (paths, (GDestroyNotify)gtk_tree_path_free);
+
+    for (l = refs; l != NULL; l = g_list_next (l))
     {
-        GtkTreePath *path = gtk_tree_row_reference_get_path(node->data);
+        GtkTreePath *path = gtk_tree_row_reference_get_path (l->data);
         Picture *pic;
-        gboolean valid;
 
-        valid = gtk_tree_model_get_iter(model, &iter, path);
-        if (valid)
+        if (gtk_tree_model_get_iter (model, &iter, path))
         {
             gtk_tree_model_get(model, &iter, PICTURE_COLUMN_DATA, &pic,-1);
             Picture_Free(pic);
@@ -157,10 +154,8 @@ void Picture_Clear_Button_Clicked (GObject *object)
             gtk_list_store_remove(GTK_LIST_STORE(model), &iter);
         }
 
-        gtk_tree_row_reference_deleted(proxy, path);
         gtk_tree_path_free(path);
-        gtk_tree_row_reference_free(node->data);
-        n++;
+        gtk_tree_row_reference_free (l->data);
     }
 
     if (ETCore->ETFileDisplayed)


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