[gthumb] gio: use a custom enum for file copy flags



commit f4a0d3efc3667cc270fb4d92545f300adc784849
Author: Paolo Bacchilega <paobac src gnome org>
Date:   Sun Mar 23 13:06:10 2014 +0100

    gio: use a custom enum for file copy flags

 extensions/catalogs/gth-file-source-catalogs.c |    2 +-
 extensions/file_manager/gth-duplicate-task.c   |    2 +-
 extensions/webalbums/gth-web-exporter.c        |    4 ++--
 gthumb/gio-utils.c                             |   24 +++++++++++++-----------
 gthumb/gio-utils.h                             |    9 +++++++--
 gthumb/gth-file-source-vfs.c                   |    2 +-
 gthumb/gth-main-default-hooks.c                |    2 +-
 7 files changed, 26 insertions(+), 19 deletions(-)
---
diff --git a/extensions/catalogs/gth-file-source-catalogs.c b/extensions/catalogs/gth-file-source-catalogs.c
index 6c78238..9313023 100644
--- a/extensions/catalogs/gth-file-source-catalogs.c
+++ b/extensions/catalogs/gth-file-source-catalogs.c
@@ -1021,7 +1021,7 @@ _gth_file_source_catalogs_copy_catalog (CopyCatalogData      *ccd,
        _g_copy_files_async (gio_list,
                             gio_destination,
                             ccd->move,
-                            G_FILE_COPY_NONE,
+                            GTH_FILE_COPY_DEFAULT,
                             default_response,
                             G_PRIORITY_DEFAULT,
                             gth_file_source_get_cancellable (ccd->file_source),
diff --git a/extensions/file_manager/gth-duplicate-task.c b/extensions/file_manager/gth-duplicate-task.c
index 76c2a13..9c6459d 100644
--- a/extensions/file_manager/gth-duplicate-task.c
+++ b/extensions/file_manager/gth-duplicate-task.c
@@ -121,7 +121,7 @@ duplicate_current_file (GthDuplicateTask *self)
        _g_copy_file_async (file_data,
                            self->priv->destination,
                            FALSE,
-                           G_FILE_COPY_ALL_METADATA,
+                           GTH_FILE_COPY_ALL_METADATA,
                            GTH_OVERWRITE_RESPONSE_ALWAYS_NO,
                            G_PRIORITY_DEFAULT,
                            gth_task_get_cancellable (GTH_TASK (self)),
diff --git a/extensions/webalbums/gth-web-exporter.c b/extensions/webalbums/gth-web-exporter.c
index e1aee40..f37b7d3 100644
--- a/extensions/webalbums/gth-web-exporter.c
+++ b/extensions/webalbums/gth-web-exporter.c
@@ -1951,7 +1951,7 @@ save_other_files_ready_cb (GError   *error,
                _g_copy_files_async (files,
                                     self->priv->target_dir,
                                     FALSE,
-                                    G_FILE_COPY_NONE,
+                                    GTH_FILE_COPY_DEFAULT,
                                     GTH_OVERWRITE_RESPONSE_UNSPECIFIED,
                                     G_PRIORITY_DEFAULT,
                                     gth_task_get_cancellable (GTH_TASK (self)),
@@ -2026,7 +2026,7 @@ save_other_files (GthWebExporter *self)
                _g_copy_files_async (files,
                                     theme_dir,
                                     FALSE,
-                                    G_FILE_COPY_NONE,
+                                    GTH_FILE_COPY_DEFAULT,
                                     GTH_OVERWRITE_RESPONSE_UNSPECIFIED,
                                     G_PRIORITY_DEFAULT,
                                     gth_task_get_cancellable (GTH_TASK (self)),
diff --git a/gthumb/gio-utils.c b/gthumb/gio-utils.c
index bfd71e1..95f226f 100644
--- a/gthumb/gio-utils.c
+++ b/gthumb/gio-utils.c
@@ -1096,7 +1096,7 @@ typedef struct {
        GthFileData          *source;
        GFile                *destination;
        gboolean              move;
-       GFileCopyFlags        flags;
+       GthFileCopyFlags      flags;
        int                   io_priority;
        goffset               tot_size;
        goffset               copied_size;
@@ -1262,7 +1262,7 @@ copy_file__overwrite_dialog_response_cb (GtkDialog *dialog,
 
                        parent = g_file_get_parent (copy_file_data->current_destination);
                        new_destination = g_file_get_child_for_display_name (parent, 
gth_overwrite_dialog_get_filename (GTH_OVERWRITE_DIALOG (dialog)), NULL);
-                       _g_copy_file_to_destination (copy_file_data, new_destination, 0);
+                       _g_copy_file_to_destination (copy_file_data, new_destination, G_FILE_COPY_NONE);
 
                        g_object_unref (new_destination);
                        g_object_unref (parent);
@@ -1319,7 +1319,7 @@ copy_file_ready_cb (GObject      *source_object,
        _g_object_list_unref (copy_file_data->destination_sidecars);
        copy_file_data->source_sidecars = NULL;
        copy_file_data->destination_sidecars = NULL;
-       if (copy_file_data->flags && G_FILE_COPY_ALL_METADATA) {
+       if (copy_file_data->flags & GTH_FILE_COPY_ALL_METADATA) {
                gth_hook_invoke ("add-sidecars", copy_file_data->source->file, 
&copy_file_data->source_sidecars);
                gth_hook_invoke ("add-sidecars", copy_file_data->destination, 
&copy_file_data->destination_sidecars);
                copy_file_data->source_sidecars = g_list_reverse (copy_file_data->source_sidecars);
@@ -1372,7 +1372,9 @@ _g_copy_file_to_destination (CopyFileData   *copy_file_data,
        copy_file_data->current_destination = g_file_dup (destination);
 
        if (copy_file_data->default_response == GTH_OVERWRITE_RESPONSE_ALWAYS_YES)
-               flags = G_FILE_COPY_OVERWRITE;
+               flags |= G_FILE_COPY_OVERWRITE;
+       if (copy_file_data->flags & GTH_FILE_COPY_ALL_METADATA)
+               flags |= G_FILE_COPY_ALL_METADATA;
 
        if (copy_file_data->progress_callback != NULL) {
                GFile *destination_parent;
@@ -1407,7 +1409,7 @@ _g_copy_file_to_destination (CopyFileData   *copy_file_data,
        else
                g_file_copy_async (copy_file_data->source->file,
                                   copy_file_data->current_destination,
-                                  copy_file_data->flags | flags,
+                                  flags,
                                   copy_file_data->io_priority,
                                   copy_file_data->cancellable,
                                   copy_file_progress_cb,
@@ -1421,7 +1423,7 @@ static void
 _g_copy_file_async_private (GthFileData           *source,
                            GFile                 *destination,
                            gboolean               move,
-                           GFileCopyFlags         flags,
+                           GthFileCopyFlags       flags,
                            GthOverwriteResponse   default_response,
                            int                    io_priority,
                            goffset                tot_size,
@@ -1455,7 +1457,7 @@ _g_copy_file_async_private (GthFileData           *source,
        copy_file_data->user_data = user_data;
        copy_file_data->default_response = default_response;
 
-       _g_copy_file_to_destination (copy_file_data, copy_file_data->destination, 0);
+       _g_copy_file_to_destination (copy_file_data, copy_file_data->destination, G_FILE_COPY_NONE);
 }
 
 
@@ -1463,7 +1465,7 @@ void
 _g_copy_file_async (GthFileData           *source,
                    GFile                 *destination,
                    gboolean               move,
-                   GFileCopyFlags         flags,
+                   GthFileCopyFlags       flags,
                    GthOverwriteResponse   default_response,
                    int                    io_priority,
                    GCancellable          *cancellable,
@@ -1519,7 +1521,7 @@ typedef struct {
        GthOverwriteResponse  default_response;
 
        gboolean              move;
-       GFileCopyFlags        flags;
+       GthFileCopyFlags      flags;
        int                   io_priority;
        GCancellable         *cancellable;
        ProgressCallback      progress_callback;
@@ -1712,7 +1714,7 @@ void
 _g_copy_files_async (GList                *sources, /* GFile list */
                     GFile                *destination,
                     gboolean              move,
-                    GFileCopyFlags        flags,
+                    GthFileCopyFlags      flags,
                     GthOverwriteResponse  default_response,
                     int                   io_priority,
                     GCancellable         *cancellable,
@@ -1789,7 +1791,7 @@ _g_move_file (GFile                 *source,
                return FALSE;
        }
 
-       if (flags && G_FILE_COPY_ALL_METADATA == 0)
+       if ((flags & G_FILE_COPY_ALL_METADATA) == 0)
                return TRUE;
 
        /* move the metadata sidecars if requested */
diff --git a/gthumb/gio-utils.h b/gthumb/gio-utils.h
index b96edfb..aee5d8c 100644
--- a/gthumb/gio-utils.h
+++ b/gthumb/gio-utils.h
@@ -46,6 +46,11 @@ typedef enum {
        GTH_LIST_NO_HIDDEN_FILES = 1 << 3
 } GthListFlags;
 
+typedef enum { /*< skip >*/
+  GTH_FILE_COPY_DEFAULT            = 0,
+  GTH_FILE_COPY_ALL_METADATA       = (1 << 1)
+} GthFileCopyFlags;
+
 typedef DirOp (*StartDirCallback)    (GFile                *directory,
                                      GFileInfo            *info,
                                      GError              **error,
@@ -106,7 +111,7 @@ void     _g_dummy_file_op_async      (ReadyFunc              callback,
 void     _g_copy_file_async          (GthFileData           *source,
                                      GFile                 *destination,
                                      gboolean               move,
-                                     GFileCopyFlags         flags,
+                                     GthFileCopyFlags       flags,
                                      GthOverwriteResponse   default_response,
                                      int                    io_priority,
                                      GCancellable          *cancellable,
@@ -119,7 +124,7 @@ void     _g_copy_file_async          (GthFileData           *source,
 void     _g_copy_files_async         (GList                 *sources,
                                      GFile                 *destination,
                                      gboolean               move,
-                                     GFileCopyFlags         flags,
+                                     GthFileCopyFlags       flags,
                                      GthOverwriteResponse   default_response,
                                      int                    io_priority,
                                      GCancellable          *cancellable,
diff --git a/gthumb/gth-file-source-vfs.c b/gthumb/gth-file-source-vfs.c
index adc6769..6971bd1 100644
--- a/gthumb/gth-file-source-vfs.c
+++ b/gthumb/gth-file-source-vfs.c
@@ -380,7 +380,7 @@ gth_file_source_vfs_copy (GthFileSource    *file_source,
        _g_copy_files_async (file_list,
                             destination->file,
                             move,
-                            G_FILE_COPY_ALL_METADATA,
+                            GTH_FILE_COPY_ALL_METADATA,
                             GTH_OVERWRITE_RESPONSE_UNSPECIFIED,
                             G_PRIORITY_DEFAULT,
                             gth_file_source_get_cancellable (file_source),
diff --git a/gthumb/gth-main-default-hooks.c b/gthumb/gth-main-default-hooks.c
index b402f82..c1d9c09 100644
--- a/gthumb/gth-main-default-hooks.c
+++ b/gthumb/gth-main-default-hooks.c
@@ -211,7 +211,7 @@ gth_main_register_default_hooks (void)
 
        /**
         * Called when copying files in _g_copy_files_async with the
-        * G_FILE_COPY_ALL_METADATA flag activated and when deleting file
+        * GTH_FILE_COPY_ALL_METADATA flag activated and when deleting file
         * with _g_delete_files.  Used to add sidecar files that contain
         * file metadata.
         *


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]