gtkfilesystemmodel: keep nodes by stable ID and show files while loading

Files go to an unsorted tail and are merged into the sorted rows in short
slices, so a folder shows up while it is still loading. Filtering and
sorting run in the background as well; _gtk_file_system_model_flush()
brings the rows up to date where the chooser needs them right away.
This commit is contained in:
Daemonratte 2026-10-13 13:53:28 +02:00
commit 76887647a1
3 changed files with 1616 additions and 647 deletions

View file

@ -7586,6 +7586,10 @@ show_and_select_files (GtkFileChooserDefault *impl,
g_assert (fsmodel == impl->browse_files_model);
/* The model adds files and filters in the background; the visibility
* checks below need the rows as they are now. */
_gtk_file_system_model_flush (fsmodel);
enabled_hidden = impl->show_hidden;
removed_filters = (impl->current_filter == NULL);
@ -7616,6 +7620,7 @@ show_and_select_files (GtkFileChooserDefault *impl,
if (!enabled_hidden && (is_hidden || is_backup))
{
g_object_set (impl, "show-hidden", TRUE, NULL);
_gtk_file_system_model_flush (fsmodel);
enabled_hidden = TRUE;
}
}
@ -7631,6 +7636,7 @@ show_and_select_files (GtkFileChooserDefault *impl,
if (!removed_filters)
{
set_current_filter (impl, NULL);
_gtk_file_system_model_flush (fsmodel);
removed_filters = TRUE;
}
}
@ -8185,7 +8191,10 @@ set_list_model (GtkFileChooserDefault *impl,
gtk_tree_sortable_set_sort_func (GTK_TREE_SORTABLE (impl->browse_files_model), MODEL_COL_SIZE, size_sort_func, impl, NULL);
gtk_tree_sortable_set_sort_func (GTK_TREE_SORTABLE (impl->browse_files_model), MODEL_COL_MTIME, mtime_sort_func, impl, NULL);
gtk_tree_sortable_set_default_sort_func (GTK_TREE_SORTABLE (impl->browse_files_model), NULL, NULL, NULL);
set_sort_column (impl);
/* Sort from the start: the model sorts files as it adds them, while
* resorting rows that are already shown takes extra work. */
gtk_tree_sortable_set_sort_column_id (GTK_TREE_SORTABLE (impl->browse_files_model),
impl->sort_column, impl->sort_order);
impl->list_sort_ascending = TRUE;
g_signal_connect (impl->browse_files_model, "sort-column-changed",
G_CALLBACK (list_sort_column_changed_cb), impl);

File diff suppressed because it is too large Load diff

View file

@ -94,6 +94,7 @@ void _gtk_file_system_model_set_filter (GtkFileSystemModel
void _gtk_file_system_model_add_editable (GtkFileSystemModel *model,
GtkTreeIter *iter);
void _gtk_file_system_model_remove_editable (GtkFileSystemModel *model);
void _gtk_file_system_model_flush (GtkFileSystemModel *model);
G_END_DECLS