summaryrefslogtreecommitdiff
path: root/gtk/gtkfilesystemmodel.c
diff options
context:
space:
mode:
authorMatthias Clasen <mclasen@redhat.com>2015-06-18 12:19:06 -0400
committerMatthias Clasen <mclasen@redhat.com>2015-06-18 13:11:30 -0400
commitb2ceadb057011a120ff271c74bff5d2cbd6572bd (patch)
treecc9b0281dcdb7d0db49b270795108aa21b2c7598 /gtk/gtkfilesystemmodel.c
parent9590879e2f550a29d230099680081a9d3a90d414 (diff)
downloadgtk+-b2ceadb057011a120ff271c74bff5d2cbd6572bd.tar.gz
file system model: Add batched insertion
Add a batched version of gtk_file_system_model_add_and_query_file that takes a list of files and avoids resorting the model for each individual insertion. The querying is still done one-file-at-a-time, so more optimization is certainly possible.
Diffstat (limited to 'gtk/gtkfilesystemmodel.c')
-rw-r--r--gtk/gtkfilesystemmodel.c36
1 files changed, 36 insertions, 0 deletions
diff --git a/gtk/gtkfilesystemmodel.c b/gtk/gtkfilesystemmodel.c
index a92be1f5b1..096836bb64 100644
--- a/gtk/gtkfilesystemmodel.c
+++ b/gtk/gtkfilesystemmodel.c
@@ -2129,3 +2129,39 @@ _gtk_file_system_model_add_and_query_file (GtkFileSystemModel *model,
gtk_file_system_model_query_done,
model);
}
+
+static void
+gtk_file_system_model_one_query_done (GObject * object,
+ GAsyncResult *res,
+ gpointer data)
+{
+ GtkFileSystemModel *model = data; /* only a valid pointer if not cancelled */
+
+ gtk_file_system_model_query_done (object, res, data);
+ thaw_updates (model);
+}
+
+void
+_gtk_file_system_model_add_and_query_files (GtkFileSystemModel *model,
+ GList *list,
+ const char *attributes)
+{
+ GList *l;
+ GFile *file;
+
+ g_return_if_fail (GTK_IS_FILE_SYSTEM_MODEL (model));
+ g_return_if_fail (attributes != NULL);
+
+ for (l = list; l; l = l->next)
+ {
+ file = (GFile *)l->data;
+ freeze_updates (model);
+ g_file_query_info_async (file,
+ attributes,
+ G_FILE_QUERY_INFO_NONE,
+ IO_PRIORITY,
+ model->cancellable,
+ gtk_file_system_model_one_query_done,
+ model);
+ }
+}