[gthumb] import task: use the new importer preferences



commit 9c16ed9a9e3f93583cfd0abc9d6fb3f7c1ad47e7
Author: Paolo Bacchilega <paobac src gnome org>
Date:   Wed Jun 2 12:48:29 2021 +0200

    import task: use the new importer preferences

 extensions/flicker_utils/dlg-import-from-flickr.c | 22 +++++----------
 extensions/importer/gth-import-task.c             | 34 ++++++-----------------
 extensions/importer/gth-import-task.h             |  5 +---
 extensions/photo_importer/dlg-photo-importer.c    | 23 +++++----------
 4 files changed, 23 insertions(+), 61 deletions(-)
---
diff --git a/extensions/flicker_utils/dlg-import-from-flickr.c 
b/extensions/flicker_utils/dlg-import-from-flickr.c
index 53243e89..fdc03770 100644
--- a/extensions/flicker_utils/dlg-import-from-flickr.c
+++ b/extensions/flicker_utils/dlg-import-from-flickr.c
@@ -135,28 +135,19 @@ import_dialog_response_cb (GtkDialog *dialog,
 
                        file_list = get_files_to_download (data);
                        if (file_list != NULL) {
-                               GSettings           *settings;
-                               GFile               *destination;
-                               gboolean             single_subfolder;
-                               GthSubfolderType     subfolder_type;
-                               GthSubfolderFormat   subfolder_format;
-                               char                *custom_format;
-                               GthTask             *task;
+                               GSettings *settings;
+                               GFile     *destination;
+                               char      *subfolder_template;
+                               GthTask   *task;
 
                                settings = g_settings_new (GTHUMB_IMPORTER_SCHEMA);
                                destination = gth_import_preferences_get_destination ();
-                               subfolder_type = g_settings_get_enum (settings, PREF_IMPORTER_SUBFOLDER_TYPE);
-                               subfolder_format = g_settings_get_enum (settings, 
PREF_IMPORTER_SUBFOLDER_FORMAT);
-                               single_subfolder = g_settings_get_boolean (settings, 
PREF_IMPORTER_SUBFOLDER_SINGLE);
-                               custom_format = g_settings_get_string (settings, 
PREF_IMPORTER_SUBFOLDER_CUSTOM_FORMAT);
+                               subfolder_template = g_settings_get_string (settings, 
PREF_IMPORTER_SUBFOLDER_TEMPLATE);
 
                                task = gth_import_task_new (data->browser,
                                                            file_list,
                                                            destination,
-                                                           subfolder_type,
-                                                           subfolder_format,
-                                                           single_subfolder,
-                                                           custom_format,
+                                                           subfolder_template,
                                                            (photoset->title != NULL ? photoset->title : ""),
                                                            NULL,
                                                            FALSE,
@@ -166,6 +157,7 @@ import_dialog_response_cb (GtkDialog *dialog,
                                gtk_widget_destroy (data->dialog);
 
                                g_object_unref (task);
+                               g_free (subfolder_template);
                                _g_object_unref (destination);
                                g_object_unref (settings);
                        }
diff --git a/extensions/importer/gth-import-task.c b/extensions/importer/gth-import-task.c
index eb0ec642..a6f3e0ef 100644
--- a/extensions/importer/gth-import-task.c
+++ b/extensions/importer/gth-import-task.c
@@ -38,10 +38,7 @@ struct _GthImportTaskPrivate {
        GList               *files;
        GFile               *destination;
        GHashTable          *destinations;
-       GthSubfolderType     subfolder_type;
-       GthSubfolderFormat   subfolder_format;
-       gboolean             single_subfolder;
-       char                *custom_format;
+       char                *subfolder_template;;
        char                *event_name;
        char               **tags;
        GTimeVal             import_start_time;
@@ -85,7 +82,7 @@ gth_import_task_finalize (GObject *object)
        _g_object_list_unref (self->priv->files);
        g_object_unref (self->priv->destination);
        _g_object_unref (self->priv->destination_file);
-       g_free (self->priv->custom_format);
+       g_free (self->priv->subfolder_template);
        g_free (self->priv->event_name);
        if (self->priv->tags != NULL)
                g_strfreev (self->priv->tags);
@@ -285,10 +282,7 @@ overwrite_dialog_response_cb (GtkDialog *dialog,
                        file_data = self->priv->current->data;
                        destination_folder = gth_import_utils_get_file_destination (file_data,
                                                                                    self->priv->destination,
-                                                                                   
self->priv->subfolder_type,
-                                                                                   
self->priv->subfolder_format,
-                                                                                   
self->priv->single_subfolder,
-                                                                                   self->priv->custom_format,
+                                                                                   
self->priv->subfolder_template,
                                                                                    self->priv->event_name,
                                                                                    
self->priv->import_start_time);
                        new_destination = g_file_get_child_for_display_name (destination_folder, 
gth_overwrite_dialog_get_filename (GTH_OVERWRITE_DIALOG (dialog)), NULL);
@@ -534,10 +528,7 @@ get_destination_file (GthImportTask *self,
 
        destination = gth_import_utils_get_file_destination (file_data,
                                                             self->priv->destination,
-                                                            self->priv->subfolder_type,
-                                                            self->priv->subfolder_format,
-                                                            self->priv->single_subfolder,
-                                                            self->priv->custom_format,
+                                                            self->priv->subfolder_template,
                                                             self->priv->event_name,
                                                             self->priv->import_start_time);
        if (! g_file_make_directory_with_parents (destination, gth_task_get_cancellable (GTH_TASK (self)), 
&error)) {
@@ -636,7 +627,7 @@ import_current_file (GthImportTask *self)
                else {
                        GSettings *settings;
 
-                       if ((self->priv->subfolder_type != GTH_SUBFOLDER_TYPE_NONE) && 
(self->priv->imported_catalog != NULL))
+                       if (! _g_str_empty (self->priv->subfolder_template) && (self->priv->imported_catalog 
!= NULL))
                                gth_browser_go_to (self->priv->browser, self->priv->imported_catalog, NULL);
                        else
                                gth_browser_go_to (self->priv->browser, self->priv->destination, NULL);
@@ -671,7 +662,7 @@ import_current_file (GthImportTask *self)
        self->priv->current_file_size = g_file_info_get_size (file_data->info);
 
        adjust_image_orientation = self->priv->adjust_orientation && gth_main_extension_is_active 
("image_rotation");
-       need_image_metadata = (self->priv->subfolder_type == GTH_SUBFOLDER_TYPE_FILE_DATE) || 
adjust_image_orientation;
+       need_image_metadata = (_g_utf8_find_str (self->priv->subfolder_template, "%D") != NULL) || 
adjust_image_orientation;
 
        if (_g_mime_type_is_image (gth_file_data_get_mime_type (file_data)) && need_image_metadata) {
                gth_task_progress (GTH_TASK (self),
@@ -792,10 +783,7 @@ GthTask *
 gth_import_task_new (GthBrowser         *browser,
                     GList              *files,
                     GFile              *destination,
-                    GthSubfolderType    subfolder_type,
-                    GthSubfolderFormat  subfolder_format,
-                    gboolean            single_subfolder,
-                    const char         *custom_format,
+                    const char         *subfolder_template,
                     const char         *event_name,
                     char              **tags,
                     gboolean            delete_imported,
@@ -808,13 +796,7 @@ gth_import_task_new (GthBrowser         *browser,
        self->priv->browser = g_object_ref (browser);
        self->priv->files = _g_object_list_ref (files);
        self->priv->destination = g_file_dup (destination);
-       self->priv->subfolder_type = subfolder_type;
-       self->priv->subfolder_format = subfolder_format;
-       self->priv->single_subfolder = single_subfolder;
-       if (custom_format != NULL)
-               self->priv->custom_format = g_strdup (custom_format);
-       else
-               self->priv->custom_format = NULL;
+       self->priv->subfolder_template = g_strdup (subfolder_template);
        self->priv->event_name = g_strdup (event_name);
        self->priv->tags = g_strdupv (tags);
        self->priv->delete_imported = delete_imported;
diff --git a/extensions/importer/gth-import-task.h b/extensions/importer/gth-import-task.h
index feec59c0..a1c1a949 100644
--- a/extensions/importer/gth-import-task.h
+++ b/extensions/importer/gth-import-task.h
@@ -52,10 +52,7 @@ GType       gth_import_task_get_type         (void);
 GthTask *   gth_import_task_new              (GthBrowser         *browser,
                                              GList              *files, /* GthFileData list */
                                              GFile              *destination,
-                                             GthSubfolderType    subfolder_type,
-                                             GthSubfolderFormat  subfolder_format,
-                                             gboolean            single_subfolder,
-                                             const char         *custom_format,
+                                             const char         *subfolder_template,
                                              const char         *event_name,
                                              char              **tags,
                                              gboolean            delete_imported,
diff --git a/extensions/photo_importer/dlg-photo-importer.c b/extensions/photo_importer/dlg-photo-importer.c
index b941ef33..b4a57799 100644
--- a/extensions/photo_importer/dlg-photo-importer.c
+++ b/extensions/photo_importer/dlg-photo-importer.c
@@ -102,20 +102,14 @@ destroy_dialog (gpointer user_data)
        g_settings_set_boolean (data->settings, PREF_PHOTO_IMPORTER_DELETE_FROM_DEVICE, delete_imported);
 
        if (data->import) {
-               GSettings          *importer_settings;
-               GFile              *destination;
-               gboolean            single_subfolder;
-               GthSubfolderType    subfolder_type;
-               GthSubfolderFormat  subfolder_format;
-               char               *custom_format;
-               GList              *file_list;
+               GSettings *importer_settings;
+               GFile     *destination;
+               char      *subfolder_template;
+               GList     *file_list;
 
                importer_settings = g_settings_new (GTHUMB_IMPORTER_SCHEMA);
                destination = gth_import_preferences_get_destination ();
-               single_subfolder = g_settings_get_boolean (importer_settings, PREF_IMPORTER_SUBFOLDER_SINGLE);
-               subfolder_type = g_settings_get_enum (importer_settings, PREF_IMPORTER_SUBFOLDER_TYPE);
-               subfolder_format = g_settings_get_enum (importer_settings, PREF_IMPORTER_SUBFOLDER_FORMAT);
-               custom_format = g_settings_get_string (importer_settings, 
PREF_IMPORTER_SUBFOLDER_CUSTOM_FORMAT);
+               subfolder_template = g_settings_get_string (importer_settings, 
PREF_IMPORTER_SUBFOLDER_TEMPLATE);
 
                file_list = get_selected_file_list (data);
                if (file_list != NULL) {
@@ -126,10 +120,7 @@ destroy_dialog (gpointer user_data)
                        task = gth_import_task_new (data->browser,
                                                    file_list,
                                                    destination,
-                                                   subfolder_type,
-                                                   subfolder_format,
-                                                   single_subfolder,
-                                                   custom_format,
+                                                   subfolder_template,
                                                    gtk_entry_get_text (GTK_ENTRY (GET_WIDGET 
("event_entry"))),
                                                    tags,
                                                    delete_imported,
@@ -142,7 +133,7 @@ destroy_dialog (gpointer user_data)
                }
 
                _g_object_list_unref (file_list);
-               g_free (custom_format);
+               g_free (subfolder_template);
                _g_object_unref (destination);
                g_object_unref (importer_settings);
        }


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