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




commit 39065621bc55bc219e0947b8e82888cab8d4594d
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 | 19 +++----------------
 1 file changed, 3 insertions(+), 16 deletions(-)
---
diff --git a/src/nautilus-view-model.c b/src/nautilus-view-model.c
index e2c5caeca..84c40302d 100644
--- a/src/nautilus-view-model.c
+++ b/src/nautilus-view-model.c
@@ -266,26 +266,13 @@ 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 i;
 
-    if (item_model != NULL)
+    if (g_list_store_find (self->internal_model, item, &i))
     {
         NautilusFile *file;
 
-        file = nautilus_view_item_model_get_file (item_model);
+        file = nautilus_view_item_model_get_file (item);
         g_list_store_remove (self->internal_model, i);
         g_hash_table_remove (self->map_files_to_model, file);
     }


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