filesystemmodel: Always set standard::file attribute

This will help us greatly when porting GtkFileSystemModel to
GtkDirectoryList.
This commit is contained in:
Georges Basile Stavracas Neto 2022-10-09 18:50:23 -03:00 committed by Matthias Clasen
parent 8a24fdea38
commit 4e3fbd0b0f
2 changed files with 8 additions and 6 deletions

View File

@ -197,7 +197,6 @@ match_func (GtkEntryCompletion *compl,
* current file filter (e.g. just jpg files) here. */ * current file filter (e.g. just jpg files) here. */
if (chooser_entry->current_filter != NULL) if (chooser_entry->current_filter != NULL)
{ {
GFile *file;
GFileInfo *info; GFileInfo *info;
file = _gtk_file_system_model_get_file (GTK_FILE_SYSTEM_MODEL (chooser_entry->completion_store), 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) if (g_file_info_get_file_type (info) != G_FILE_TYPE_REGULAR)
return TRUE; return TRUE;
if (!g_file_info_has_attribute (info, "standard::file")) g_assert (g_file_info_has_attribute (info, "standard::file"));
g_file_info_set_attribute_object (info, "standard::file", G_OBJECT (file));
return gtk_filter_match (GTK_FILTER (chooser_entry->current_filter), info); return gtk_filter_match (GTK_FILTER (chooser_entry->current_filter), info);
} }

View File

@ -366,8 +366,7 @@ node_should_be_filtered_out (GtkFileSystemModel *model, guint id)
if (model->filter == NULL) if (model->filter == NULL)
return FALSE; return FALSE;
if (!g_file_info_has_attribute (node->info, "standard::file")) g_assert (g_file_info_has_attribute (node->info, "standard::file"));
g_file_info_set_attribute_object (node->info, "standard::file", G_OBJECT (node->file));
return !gtk_filter_match (GTK_FILTER (model->filter), node->info); 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 = g_slice_alloc0 (model->node_size);
node->file = g_object_ref (file); node->file = g_object_ref (file);
if (info) if (info)
{
g_file_info_set_attribute_object (info, "standard::file", G_OBJECT (file));
node->info = g_object_ref (info); node->info = g_object_ref (info);
}
node->frozen_add = model->frozen ? TRUE : FALSE; node->frozen_add = model->frozen ? TRUE : FALSE;
g_array_append_vals (model->files, node, 1); 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_value_unset (&node->values[i]);
} }
g_file_info_set_attribute_object (info, "standard::file", G_OBJECT (file));
if (node->visible) if (node->visible)
emit_row_changed_for_node (model, id); emit_row_changed_for_node (model, id);
} }