[gtk/gbsneto/filechooser-column-view: 39/74] filesystemmodel: Always set standard::file attribute




commit 4e3fbd0b0fedc225c6b3e7dca56f0a336bbe84f7
Author: Georges Basile Stavracas Neto <georges stavracas gmail com>
Date:   Sun Oct 9 18:50:23 2022 -0300

    filesystemmodel: Always set standard::file attribute
    
    This will help us greatly when porting GtkFileSystemModel to
    GtkDirectoryList.

 gtk/gtkfilechooserentry.c |  4 +---
 gtk/gtkfilesystemmodel.c  | 10 +++++++---
 2 files changed, 8 insertions(+), 6 deletions(-)
---
diff --git a/gtk/gtkfilechooserentry.c b/gtk/gtkfilechooserentry.c
index 84916500be..5621e7b625 100644
--- a/gtk/gtkfilechooserentry.c
+++ b/gtk/gtkfilechooserentry.c
@@ -197,7 +197,6 @@ match_func (GtkEntryCompletion *compl,
    * current file filter (e.g. just jpg files) here. */
   if (chooser_entry->current_filter != NULL)
     {
-      GFile *file;
       GFileInfo *info;
 
       file = _gtk_file_system_model_get_file (GTK_FILE_SYSTEM_MODEL (chooser_entry->completion_store),
@@ -209,8 +208,7 @@ match_func (GtkEntryCompletion *compl,
       if (g_file_info_get_file_type (info) != G_FILE_TYPE_REGULAR)
         return TRUE;
 
-      if (!g_file_info_has_attribute (info, "standard::file"))
-        g_file_info_set_attribute_object (info, "standard::file", G_OBJECT (file));
+      g_assert (g_file_info_has_attribute (info, "standard::file"));
 
       return gtk_filter_match (GTK_FILTER (chooser_entry->current_filter), info);
     }
diff --git a/gtk/gtkfilesystemmodel.c b/gtk/gtkfilesystemmodel.c
index 06fa65808a..9989c23534 100644
--- a/gtk/gtkfilesystemmodel.c
+++ b/gtk/gtkfilesystemmodel.c
@@ -366,8 +366,7 @@ node_should_be_filtered_out (GtkFileSystemModel *model, guint id)
   if (model->filter == NULL)
     return FALSE;
 
-  if (!g_file_info_has_attribute (node->info, "standard::file"))
-    g_file_info_set_attribute_object (node->info, "standard::file", G_OBJECT (node->file));
+  g_assert (g_file_info_has_attribute (node->info, "standard::file"));
 
   return !gtk_filter_match (GTK_FILTER (model->filter), node->info);
 }
@@ -1612,7 +1611,10 @@ add_file (GtkFileSystemModel *model,
   node = g_slice_alloc0 (model->node_size);
   node->file = g_object_ref (file);
   if (info)
-    node->info = g_object_ref (info);
+    {
+      g_file_info_set_attribute_object (info, "standard::file", G_OBJECT (file));
+      node->info = g_object_ref (info);
+    }
   node->frozen_add = model->frozen ? TRUE : FALSE;
 
   g_array_append_vals (model->files, node, 1);
@@ -1722,6 +1724,8 @@ _gtk_file_system_model_update_file (GtkFileSystemModel *model,
         g_value_unset (&node->values[i]);
     }
 
+  g_file_info_set_attribute_object (info, "standard::file", G_OBJECT (file));
+
   if (node->visible)
     emit_row_changed_for_node (model, id);
 }


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