[gthumb/ext] [photo_importer] added option to rotate images physically
- From: Paolo Bacchilega <paobac src gnome org>
- To: svn-commits-list gnome org
- Cc:
- Subject: [gthumb/ext] [photo_importer] added option to rotate images physically
- Date: Tue, 18 Aug 2009 19:11:26 +0000 (UTC)
commit e49455569b640d87d7f0d3f5b3e3a9664f6ff3ac
Author: Paolo Bacchilega <paobac src gnome org>
Date: Tue Aug 18 21:08:49 2009 +0200
[photo_importer] added option to rotate images physically
.../data/gthumb_photo_importer.schemas.in | 13 ++
.../photo_importer/data/ui/photo-importer.ui | 40 +++++--
extensions/photo_importer/dlg-photo-importer.c | 19 +++-
extensions/photo_importer/gth-import-task.c | 119 ++++++++++++++------
extensions/photo_importer/gth-import-task.h | 23 ++--
.../photo_importer/photo_importer.extension.in.in | 1 +
extensions/photo_importer/preferences.h | 9 +-
7 files changed, 162 insertions(+), 62 deletions(-)
---
diff --git a/extensions/photo_importer/data/gthumb_photo_importer.schemas.in b/extensions/photo_importer/data/gthumb_photo_importer.schemas.in
index 7ba451e..4e6be34 100644
--- a/extensions/photo_importer/data/gthumb_photo_importer.schemas.in
+++ b/extensions/photo_importer/data/gthumb_photo_importer.schemas.in
@@ -53,5 +53,18 @@
</locale>
</schema>
+ <schema>
+ <key>/schemas/apps/gthumb/ext/photo_importer/adjust_orientation</key>
+ <applyto>/apps/gthumb/ext/photo_importer/adjust_orientation</applyto>
+ <owner>gthumb</owner>
+ <type>bool</type>
+ <default>TRUE</default>
+ <locale name="C">
+ <short></short>
+ <long>
+ </long>
+ </locale>
+ </schema>
+
</schemalist>
</gconfschemafile>
diff --git a/extensions/photo_importer/data/ui/photo-importer.ui b/extensions/photo_importer/data/ui/photo-importer.ui
index d4c8254..a12c02d 100644
--- a/extensions/photo_importer/data/ui/photo-importer.ui
+++ b/extensions/photo_importer/data/ui/photo-importer.ui
@@ -312,16 +312,39 @@
<property name="orientation">vertical</property>
<property name="spacing">12</property>
<child>
- <object class="GtkCheckButton" id="delete_checkbutton">
- <property name="label" translatable="yes">_Delete imported files</property>
+ <object class="GtkVBox" id="vbox5">
<property name="visible">True</property>
- <property name="can_focus">True</property>
- <property name="receives_default">False</property>
- <property name="use_underline">True</property>
- <property name="draw_indicator">True</property>
+ <property name="orientation">vertical</property>
+ <property name="spacing">6</property>
+ <child>
+ <object class="GtkCheckButton" id="delete_checkbutton">
+ <property name="label" translatable="yes">_Delete imported files</property>
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="receives_default">False</property>
+ <property name="use_underline">True</property>
+ <property name="draw_indicator">True</property>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="position">0</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkCheckButton" id="adjust_orientation_checkbutton">
+ <property name="label" translatable="yes">_Rotate images physically</property>
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="receives_default">False</property>
+ <property name="use_underline">True</property>
+ <property name="draw_indicator">True</property>
+ </object>
+ <packing>
+ <property name="position">1</property>
+ </packing>
+ </child>
</object>
<packing>
- <property name="expand">False</property>
<property name="position">0</property>
</packing>
</child>
@@ -374,10 +397,11 @@
</child>
<child>
<object class="GtkCheckButton" id="single_subfolder_checkbutton">
- <property name="label" translatable="yes">as single subfolder</property>
+ <property name="label" translatable="yes">as _single subfolder</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">False</property>
+ <property name="use_underline">True</property>
<property name="draw_indicator">True</property>
</object>
<packing>
diff --git a/extensions/photo_importer/dlg-photo-importer.c b/extensions/photo_importer/dlg-photo-importer.c
index 58d17d7..3f71c54 100644
--- a/extensions/photo_importer/dlg-photo-importer.c
+++ b/extensions/photo_importer/dlg-photo-importer.c
@@ -70,6 +70,7 @@ destroy_dialog (gpointer user_data)
gboolean single_subfolder;
GthSubfolderType subfolder_type;
gboolean delete_imported;
+ gboolean adjust_orientation;
g_signal_handler_disconnect (gth_main_get_default_monitor (), data->monitor_event);
@@ -92,22 +93,29 @@ destroy_dialog (gpointer user_data)
delete_imported = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (GET_WIDGET ("delete_checkbutton")));
eel_gconf_set_boolean (PREF_PHOTO_IMPORT_DELETE, delete_imported);
+ adjust_orientation = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (GET_WIDGET ("adjust_orientation_checkbutton")));
+ eel_gconf_set_boolean (PREF_PHOTO_IMPORT_ADJUST_ORIENTATION, adjust_orientation);
+
if (data->import) {
- GthFileStore *file_store;
- GList *files;
- GthTask *task;
+ GthFileStore *file_store;
+ GList *files;
+ char **tags;
+ GthTask *task;
file_store = (GthFileStore *) gth_file_view_get_model (GTH_FILE_VIEW (gth_file_list_get_view (GTH_FILE_LIST (data->file_list))));
files = gth_file_store_get_checked (file_store);
+ tags = g_strsplit (gtk_entry_get_text (GTK_ENTRY (GET_WIDGET ("tags_entry"))), " ", -1);
task = gth_import_task_new (data->browser,
files,
destination,
subfolder_type,
single_subfolder,
- gtk_entry_get_text (GTK_ENTRY (GET_WIDGET ("tags_entry"))),
- delete_imported);
+ tags,
+ delete_imported,
+ adjust_orientation);
gth_browser_exec_task (data->browser, task, FALSE);
+ g_strfreev (tags);
g_object_unref (task);
_g_object_list_unref (files);
}
@@ -699,6 +707,7 @@ dlg_photo_importer (GthBrowser *browser,
}
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (GET_WIDGET ("delete_checkbutton")), eel_gconf_get_boolean (PREF_PHOTO_IMPORT_DELETE, FALSE));
+ gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (GET_WIDGET ("adjust_orientation_checkbutton")), eel_gconf_get_boolean (PREF_PHOTO_IMPORT_ADJUST_ORIENTATION, TRUE));
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (GET_WIDGET ("single_subfolder_checkbutton")), eel_gconf_get_boolean (PREF_PHOTO_IMPORT_SUBFOLDER_SINGLE, FALSE));
gtk_combo_box_set_active (GTK_COMBO_BOX (data->subfolder_type_list), eel_gconf_get_enum (PREF_PHOTO_IMPORT_SUBFOLDER_TYPE, GTH_TYPE_SUBFOLDER_TYPE, GTH_SUBFOLDER_TYPE_FILE_DATE));
update_destination (data);
diff --git a/extensions/photo_importer/gth-import-task.c b/extensions/photo_importer/gth-import-task.c
index 67659ad..70af240 100644
--- a/extensions/photo_importer/gth-import-task.c
+++ b/extensions/photo_importer/gth-import-task.c
@@ -21,23 +21,25 @@
*/
#include <config.h>
+#include <extensions/image_rotation/rotation-utils.h>
#include "gth-import-task.h"
-
struct _GthImportTaskPrivate {
- GthBrowser *browser;
- GList *files;
- GFile *destination;
- GthSubfolderType subfolder_type;
- gboolean single_subfolder;
- char *tags;
- gboolean delete_imported;
- GCancellable *cancellable;
-
- gsize tot_size;
- gsize copied_size;
- gsize current_file_size;
- GList *current;
+ GthBrowser *browser;
+ GList *files;
+ GFile *destination;
+ GthSubfolderType subfolder_type;
+ gboolean single_subfolder;
+ char **tags;
+ gboolean delete_imported;
+ gboolean adjust_orientation;
+ GCancellable *cancellable;
+
+ gsize tot_size;
+ gsize copied_size;
+ gsize current_file_size;
+ GList *current;
+ GthFileData *destination_file;
};
@@ -53,7 +55,8 @@ gth_import_task_finalize (GObject *object)
_g_object_list_unref (self->priv->files);
g_object_unref (self->priv->destination);
- g_free (self->priv->tags);
+ _g_object_unref (self->priv->destination_file);
+ g_strfreev (self->priv->tags);
g_object_unref (self->priv->cancellable);
g_object_unref (self->priv->browser);
@@ -65,26 +68,69 @@ static void import_current_file (GthImportTask *self);
static void
+import_next_file (GthImportTask *self)
+{
+ self->priv->copied_size += self->priv->current_file_size;
+ self->priv->current = self->priv->current->next;
+ import_current_file (self);
+}
+
+
+static void
+transformation_ready_cb (GError *error,
+ gpointer user_data)
+{
+ GthImportTask *self = user_data;
+
+ /*
+ * FIXME: add tags
+ */
+
+ import_next_file (self);
+}
+
+
+static void
copy_ready_cb (GError *error,
gpointer user_data)
{
GthImportTask *self = user_data;
- GthFileData *file_data;
+ gboolean appling_tranformation = FALSE;
if (error != NULL) {
gth_task_completed (GTH_TASK (self), error);
return;
}
- /*
- * adjust orientation
- * add tags
- */
+ if (self->priv->adjust_orientation) {
+ GthMetadata *metadata;
- file_data = self->priv->current->data;
- self->priv->copied_size += self->priv->current_file_size;
- self->priv->current = self->priv->current->next;
- import_current_file (self);
+ metadata = (GthMetadata *) g_file_info_get_attribute_object (self->priv->destination_file->info, "Exif::Image::Orientation");
+ if (metadata != NULL) {
+ const char *value;
+
+ value = gth_metadata_get_raw (metadata);
+ if (value != NULL) {
+ int transform;
+
+ sscanf (value, "%d", &transform);
+ if (transform != 1) {
+ apply_transformation_async (self->priv->destination_file,
+ (GthTransform) transform,
+ JPEG_MCU_ACTION_ABORT,
+ self->priv->cancellable,
+ transformation_ready_cb,
+ self);
+ appling_tranformation = TRUE;
+ }
+ }
+
+ g_object_unref (metadata);
+ }
+ }
+
+ if (! appling_tranformation)
+ import_next_file (self);
}
@@ -146,10 +192,13 @@ file_info_ready_cb (GList *files,
}
}
+ _g_object_unref (self->priv->destination_file);
+
destination_file = _g_file_get_destination (file_data->file, NULL, destination);
+ self->priv->destination_file = gth_file_data_new (destination_file, file_data->info);
_g_copy_file_async (file_data,
destination_file,
- FALSE /*self->priv->delete_imported*/,
+ FALSE /* FIXME: self->priv->delete_imported */,
G_FILE_COPY_ALL_METADATA | G_FILE_COPY_TARGET_DEFAULT_PERMS,
G_PRIORITY_DEFAULT,
self->priv->cancellable,
@@ -178,7 +227,7 @@ import_current_file (GthImportTask *self)
file_data = self->priv->current->data;
list = g_list_prepend (NULL, file_data);
_g_query_metadata_async (list,
- "Exif::Image::DateTime",
+ "Exif::Image::DateTime,Exif::Image::Orientation",
self->priv->cancellable,
file_info_ready_cb,
self);
@@ -266,13 +315,14 @@ gth_import_task_get_type (void)
GthTask *
-gth_import_task_new (GthBrowser *browser,
- GList *files,
- GFile *destination,
- GthSubfolderType subfolder_type,
- gboolean single_subfolder,
- const char *tags,
- gboolean delete_imported)
+gth_import_task_new (GthBrowser *browser,
+ GList *files,
+ GFile *destination,
+ GthSubfolderType subfolder_type,
+ gboolean single_subfolder,
+ char **tags,
+ gboolean delete_imported,
+ gboolean adjust_orientation)
{
GthImportTask *self;
@@ -282,8 +332,9 @@ gth_import_task_new (GthBrowser *browser,
self->priv->destination = g_file_dup (destination);
self->priv->subfolder_type = subfolder_type;
self->priv->single_subfolder = single_subfolder;
- self->priv->tags = g_strdup (tags);
+ self->priv->tags = g_strdupv (tags);
self->priv->delete_imported = delete_imported;
+ self->priv->adjust_orientation = adjust_orientation;
return (GthTask *) self;
}
diff --git a/extensions/photo_importer/gth-import-task.h b/extensions/photo_importer/gth-import-task.h
index 4318cb8..779564c 100644
--- a/extensions/photo_importer/gth-import-task.h
+++ b/extensions/photo_importer/gth-import-task.h
@@ -50,17 +50,18 @@ struct _GthImportTaskClass {
};
GType gth_import_task_get_type (void);
-GthTask * gth_import_task_new (GthBrowser *browser,
- GList *files, /* GthFileData list */
- GFile *destination,
- GthSubfolderType subfolder_type,
- gboolean single_subfolder,
- const char *tags,
- gboolean delete_imported);
-GFile * gth_import_task_get_file_destination (GthFileData *file_data,
- GFile *destination,
- GthSubfolderType subfolder_type,
- gboolean single_subfolder);
+GthTask * gth_import_task_new (GthBrowser *browser,
+ GList *files, /* GthFileData list */
+ GFile *destination,
+ GthSubfolderType subfolder_type,
+ gboolean single_subfolder,
+ char **tags,
+ gboolean delete_imported,
+ gboolean adjust_orientation);
+GFile * gth_import_task_get_file_destination (GthFileData *file_data,
+ GFile *destination,
+ GthSubfolderType subfolder_type,
+ gboolean single_subfolder);
G_END_DECLS
diff --git a/extensions/photo_importer/photo_importer.extension.in.in b/extensions/photo_importer/photo_importer.extension.in.in
index 3d51e65..6b00bd9 100644
--- a/extensions/photo_importer/photo_importer.extension.in.in
+++ b/extensions/photo_importer/photo_importer.extension.in.in
@@ -8,3 +8,4 @@ Version=1.0
[Loader]
Type=module
File=%LIBRARY%
+Requires=image_rotation
diff --git a/extensions/photo_importer/preferences.h b/extensions/photo_importer/preferences.h
index 13ada60..dd210e4 100644
--- a/extensions/photo_importer/preferences.h
+++ b/extensions/photo_importer/preferences.h
@@ -33,10 +33,11 @@ typedef enum {
GTH_SUBFOLDER_TYPE_CURRENT_DATE
} GthSubfolderType;
-#define PREF_PHOTO_IMPORT_DESTINATION "/apps/gthumb/ext/photo_importer/destination"
-#define PREF_PHOTO_IMPORT_SUBFOLDER_TYPE "/apps/gthumb/ext/photo_importer/subfolder_type"
-#define PREF_PHOTO_IMPORT_SUBFOLDER_SINGLE "/apps/gthumb/ext/photo_importer/subfolder_single"
-#define PREF_PHOTO_IMPORT_DELETE "/apps/gthumb/ext/photo_importer/delete_from_camera"
+#define PREF_PHOTO_IMPORT_DESTINATION "/apps/gthumb/ext/photo_importer/destination"
+#define PREF_PHOTO_IMPORT_SUBFOLDER_TYPE "/apps/gthumb/ext/photo_importer/subfolder_type"
+#define PREF_PHOTO_IMPORT_SUBFOLDER_SINGLE "/apps/gthumb/ext/photo_importer/subfolder_single"
+#define PREF_PHOTO_IMPORT_DELETE "/apps/gthumb/ext/photo_importer/delete_from_camera"
+#define PREF_PHOTO_IMPORT_ADJUST_ORIENTATION "/apps/gthumb/ext/photo_importer/adjust_orientation"
G_END_DECLS
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]