summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPeter Bloomfield <PeterBloomfield@bellsouth.net>2020-04-26 17:38:49 -0400
committerMatthias Clasen <mclasen@redhat.com>2020-04-27 08:21:45 -0400
commit3b5e10ef4d27471a2ecc8bce2eadb01d09cf8cf1 (patch)
treeca1eb9fbae8981f6080f8d938eb3ee7fd28969f1
parent326077d2edd2450879a58e5b31f554b9084a7bdc (diff)
downloadgtk+-3b5e10ef4d27471a2ecc8bce2eadb01d09cf8cf1.tar.gz
file-system-model: Refactor a helper
Push more common code into the helper for gtk_file_system_model_query_done() and gtk_file_system_model_one_query_done().
-rw-r--r--gtk/gtkfilesystemmodel.c46
1 files changed, 20 insertions, 26 deletions
diff --git a/gtk/gtkfilesystemmodel.c b/gtk/gtkfilesystemmodel.c
index 67a34806e6..0fa44536d9 100644
--- a/gtk/gtkfilesystemmodel.c
+++ b/gtk/gtkfilesystemmodel.c
@@ -1215,16 +1215,31 @@ gtk_file_system_model_got_files (GObject *object, GAsyncResult *res, gpointer da
/* Helper for gtk_file_system_model_query_done and
* gtk_file_system_model_one_query_done */
static void
-query_done_helper (GtkFileSystemModel *model,
- GFile *file,
- GFileInfo *info)
+query_done_helper (GObject * object,
+ GAsyncResult *res,
+ gpointer data,
+ gboolean do_thaw_updates)
{
+ GtkFileSystemModel *model;
+ GFile *file = G_FILE (object);
+ GFileInfo *info;
guint id;
+ info = g_file_query_info_finish (file, res, NULL);
+ if (info == NULL)
+ return;
+
+ model = GTK_FILE_SYSTEM_MODEL (data);
+
_gtk_file_system_model_update_file (model, file, info);
id = node_get_for_file (model, file);
gtk_file_system_model_sort_node (model, id);
+
+ if (do_thaw_updates)
+ thaw_updates (model);
+
+ g_object_unref (info);
}
static void
@@ -1232,18 +1247,9 @@ gtk_file_system_model_query_done (GObject * object,
GAsyncResult *res,
gpointer data)
{
- GFile *file = G_FILE (object);
- GFileInfo *info;
-
- info = g_file_query_info_finish (file, res, NULL);
-
gdk_threads_enter ();
- if (info != NULL)
- {
- query_done_helper (GTK_FILE_SYSTEM_MODEL (data), file, info);
- g_object_unref (info);
- }
+ query_done_helper (object, res, data, FALSE);
gdk_threads_leave ();
}
@@ -2166,19 +2172,7 @@ gtk_file_system_model_one_query_done (GObject * object,
GAsyncResult *res,
gpointer data)
{
- GFile *file = G_FILE (object);
- GFileInfo *info;
-
- info = g_file_query_info_finish (file, res, NULL);
-
- if (info != NULL)
- {
- GtkFileSystemModel *model = GTK_FILE_SYSTEM_MODEL (data);
-
- query_done_helper (model, file, info);
- g_object_unref (info);
- thaw_updates (model);
- }
+ query_done_helper (object, res, data, TRUE);
}
void