[nautilus/wip/antoniof/flow-box-preparation: 2/13] view-model: Use GListStore::find()




commit c1eb594bb5e7498be4f380754758a230947c47a4
Author: António Fernandes <antoniof gnome org>
Date:   Tue Aug 17 21:22:52 2021 +0100

    view-model: Use GListStore::find()
    
    It's functionally equivalent, but more compact.

 src/nautilus-view-model.c | 21 ++++-----------------
 1 file changed, 4 insertions(+), 17 deletions(-)
---
diff --git a/src/nautilus-view-model.c b/src/nautilus-view-model.c
index 538745850..68a55f7d8 100644
--- a/src/nautilus-view-model.c
+++ b/src/nautilus-view-model.c
@@ -267,27 +267,14 @@ void
 nautilus_view_model_remove_item (NautilusViewModel     *self,
                                  NautilusViewItemModel *item)
 {
-    NautilusViewItemModel *item_model;
-    gint i;
-
-    i = 0;
-    item_model = NULL;
-    while ((item_model = g_list_model_get_item (G_LIST_MODEL (self->internal_model), i)))
-    {
-        if (item_model == item)
-        {
-            break;
-        }
-
-        i++;
-    }
+    guint index;
 
-    if (item_model != NULL)
+    if (g_list_store_find (self->internal_model, item, &index))
     {
         NautilusFile *file;
 
-        file = nautilus_view_item_model_get_file (item_model);
-        g_list_store_remove (self->internal_model, i);
+        file = nautilus_view_item_model_get_file (item);
+        g_list_store_remove (self->internal_model, index);
         g_hash_table_remove (self->map_files_to_model, file);
     }
 }


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