[gthumb] copy files: make directories asynchronously
- From: Paolo Bacchilega <paobac src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gthumb] copy files: make directories asynchronously
- Date: Wed, 18 Apr 2018 19:35:48 +0000 (UTC)
commit 0bda98d9c2744a6af1f3d43de790940e232b3065
Author: Paolo Bacchilega <paobac src gnome org>
Date: Tue Apr 17 10:03:30 2018 +0200
copy files: make directories asynchronously
require glib 2.38 in order to use g_file_make_directory_async
gthumb/gio-utils.c | 39 +++++++++++++++++++++++++--------------
meson.build | 2 +-
2 files changed, 26 insertions(+), 15 deletions(-)
---
diff --git a/gthumb/gio-utils.c b/gthumb/gio-utils.c
index b1e18f4..034724b 100644
--- a/gthumb/gio-utils.c
+++ b/gthumb/gio-utils.c
@@ -1384,6 +1384,24 @@ _g_copy_file_to_destination_call_ready_callback (gpointer user_data)
static void
+make_directory_ready_cb (GObject *source_object,
+ GAsyncResult *result,
+ gpointer user_data)
+{
+ CopyFileData *copy_file_data = user_data;
+ GError *error = NULL;
+
+ if (! g_file_make_directory_finish (G_FILE (source_object), result, &error))
+ /* ignore this kind of errors */
+ if (g_error_matches (error, G_IO_ERROR, G_IO_ERROR_EXISTS))
+ g_clear_error (&error);
+
+ copy_file_data->ready_callback (copy_file_data->default_response, error, copy_file_data->user_data);
+ copy_file_data_free (copy_file_data);
+}
+
+
+static void
_g_copy_file_to_destination (CopyFileData *copy_file_data,
GFile *destination,
GFileCopyFlags flags)
@@ -1439,20 +1457,13 @@ _g_copy_file_to_destination (CopyFileData *copy_file_data,
g_object_unref (destination_parent);
}
- if (g_file_info_get_file_type (copy_file_data->source->info) == G_FILE_TYPE_DIRECTORY) {
- GError *error = NULL;
-
- /* FIXME: use the async version, available since glib 2.38 */
+ if (g_file_info_get_file_type (copy_file_data->source->info) == G_FILE_TYPE_DIRECTORY)
/* FIXME: handle the GTH_FILE_COPY_RENAME_SAME_FILE flag for directories */
-
- if (! g_file_make_directory (copy_file_data->current_destination,
copy_file_data->cancellable, &error)) {
- if (g_error_matches (error, G_IO_ERROR, G_IO_ERROR_EXISTS))
- g_clear_error (&error);
- }
- copy_file_data->ready_callback (copy_file_data->default_response, error,
copy_file_data->user_data);
- copy_file_data_free (copy_file_data);
- return;
- }
+ g_file_make_directory_async (copy_file_data->current_destination,
+ copy_file_data->io_priority,
+ copy_file_data->cancellable,
+ make_directory_ready_cb,
+ copy_file_data);
else
g_file_copy_async (copy_file_data->source->file,
copy_file_data->current_destination,
@@ -1796,7 +1807,7 @@ _g_copy_files_async (GList *sources, /* GFile list */
0.0,
copy_data->progress_callback_data);
- /* for each directory in 'source' this query will add all of its content
+ /* for each directory in 'sources' this query will add all of its content
* to the file list. */
_g_query_info_async (sources,
GTH_LIST_RECURSIVE,
diff --git a/meson.build b/meson.build
index d0aaa4f..174eb71 100644
--- a/meson.build
+++ b/meson.build
@@ -4,7 +4,7 @@ project('gthumb', ['c', 'cpp'],
meson_version : '>=0.42.1'
)
-glib_version = '>=2.36.0'
+glib_version = '>=2.38.0'
gtk_version = '>=3.16'
exiv2_version = '>=0.21'
clutter_version = '>=1.12.0'
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]