[gthumb] use the adjust orientation option only when importing from a device



commit a8c66b9688e66cab107dd58a173e3a19393dda49
Author: Paolo Bacchilega <paobac src gnome org>
Date:   Fri Aug 6 18:01:10 2010 +0200

    use the adjust orientation option only when importing from a device

 data/ui/preferences.ui                             |    6 +-
 extensions/importer/data/ui/import-preferences.ui  |   64 +-------------------
 .../importer/gth-import-preferences-dialog.c       |   12 ----
 extensions/importer/preferences.h                  |    2 -
 extensions/photo_importer/callbacks.c              |   64 ++++++++++++++++++++
 extensions/photo_importer/callbacks.h              |    9 ++-
 .../data/gthumb_photo_importer.schemas.in          |   13 ++++
 extensions/photo_importer/data/ui/Makefile.am      |    2 +-
 .../data/ui/photo-importer-options.ui              |   64 ++++++++++++++++++++
 extensions/photo_importer/main.c                   |    1 +
 extensions/photo_importer/preferences.h            |    3 +-
 11 files changed, 156 insertions(+), 84 deletions(-)
---
diff --git a/data/ui/preferences.ui b/data/ui/preferences.ui
index 595b297..32c7690 100644
--- a/data/ui/preferences.ui
+++ b/data/ui/preferences.ui
@@ -18,7 +18,7 @@
             <property name="can_focus">True</property>
             <property name="border_width">5</property>
             <child>
-              <object class="GtkVBox" id="vbox11">
+              <object class="GtkVBox" id="general_vbox">
                 <property name="visible">True</property>
                 <property name="border_width">12</property>
                 <property name="orientation">vertical</property>
@@ -222,8 +222,8 @@
                                 <child>
                                   <object class="GtkFileChooserButton" id="startup_dir_filechooserbutton">
                                     <property name="visible">True</property>
-                                    <property name="local_only">False</property>
                                     <property name="action">select-folder</property>
+                                    <property name="local_only">False</property>
                                     <property name="title" translatable="yes">Choose startup folder</property>
                                   </object>
                                   <packing>
@@ -382,7 +382,7 @@
               </packing>
             </child>
             <child>
-              <object class="GtkVBox" id="vbox12">
+              <object class="GtkVBox" id="browser_vbox">
                 <property name="visible">True</property>
                 <property name="border_width">12</property>
                 <property name="orientation">vertical</property>
diff --git a/extensions/importer/data/ui/import-preferences.ui b/extensions/importer/data/ui/import-preferences.ui
index 2ea138d..126445d 100644
--- a/extensions/importer/data/ui/import-preferences.ui
+++ b/extensions/importer/data/ui/import-preferences.ui
@@ -29,9 +29,9 @@
                     <child>
                       <object class="GtkFileChooserButton" id="destination_filechooserbutton">
                         <property name="visible">True</property>
+                        <property name="create_folders">False</property>
                         <property name="action">select-folder</property>
                         <property name="local_only">False</property>
-                        <property name="create_folders">False</property>
                       </object>
                       <packing>
                         <property name="position">0</property>
@@ -107,6 +107,7 @@
                     <child>
                       <object class="GtkHBox" id="subfolder_type_box">
                         <property name="visible">True</property>
+                        <property name="spacing">6</property>
                         <child>
                           <placeholder/>
                         </child>
@@ -479,66 +480,5 @@
         <property name="position">1</property>
       </packing>
     </child>
-    <child>
-      <object class="GtkFrame" id="frame2">
-        <property name="visible">True</property>
-        <property name="label_xalign">0</property>
-        <property name="shadow_type">none</property>
-        <child>
-          <object class="GtkAlignment" id="alignment4">
-            <property name="visible">True</property>
-            <property name="top_padding">6</property>
-            <property name="left_padding">12</property>
-            <child>
-              <object class="GtkVBox" id="vbox5">
-                <property name="visible">True</property>
-                <property name="orientation">vertical</property>
-                <property name="spacing">6</property>
-                <child>
-                  <object class="GtkCheckButton" id="overwrite_checkbutton">
-                    <property name="label" translatable="yes">_Overwrite existing 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="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>
-            </child>
-          </object>
-        </child>
-        <child type="label">
-          <object class="GtkLabel" id="label3">
-            <property name="visible">True</property>
-            <property name="label" translatable="yes">Files</property>
-            <property name="use_markup">True</property>
-            <attributes>
-              <attribute name="weight" value="bold"/>
-            </attributes>
-          </object>
-        </child>
-      </object>
-      <packing>
-        <property name="expand">False</property>
-        <property name="position">2</property>
-      </packing>
-    </child>
   </object>
 </interface>
diff --git a/extensions/importer/gth-import-preferences-dialog.c b/extensions/importer/gth-import-preferences-dialog.c
index 81a60aa..8739be6 100644
--- a/extensions/importer/gth-import-preferences-dialog.c
+++ b/extensions/importer/gth-import-preferences-dialog.c
@@ -108,8 +108,6 @@ save_options (GthImportPreferencesDialog *self)
 	GthSubfolderType    subfolder_type;
 	GthSubfolderFormat  subfolder_format;
 	const char         *custom_format;
-	gboolean            overwrite_files;
-	gboolean            adjust_orientation;
 
 	destination = gtk_file_chooser_get_current_folder_file (GTK_FILE_CHOOSER (GET_WIDGET ("destination_filechooserbutton")));
 	if (destination != NULL) {
@@ -133,12 +131,6 @@ save_options (GthImportPreferencesDialog *self)
 	custom_format = gtk_entry_get_text (GTK_ENTRY (GET_WIDGET ("custom_format_entry")));
 	eel_gconf_set_string (PREF_IMPORT_SUBFOLDER_CUSTOM_FORMAT, custom_format);
 
-	overwrite_files = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (GET_WIDGET ("overwrite_checkbutton")));
-	eel_gconf_set_boolean (PREF_IMPORT_OVERWRITE, overwrite_files);
-
-	adjust_orientation = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (GET_WIDGET ("adjust_orientation_checkbutton")));
-	eel_gconf_set_boolean (PREF_IMPORT_ADJUST_ORIENTATION, adjust_orientation);
-
 	_g_object_unref (destination);
 }
 
@@ -362,8 +354,6 @@ gth_import_preferences_dialog_init (GthImportPreferencesDialog *self)
 	gtk_file_chooser_set_current_folder_file (GTK_FILE_CHOOSER (GET_WIDGET ("destination_filechooserbutton")),
 						  destination,
 						  NULL);
-	gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (GET_WIDGET ("overwrite_checkbutton")), eel_gconf_get_boolean (PREF_IMPORT_OVERWRITE, FALSE));
-	gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (GET_WIDGET ("adjust_orientation_checkbutton")), eel_gconf_get_boolean (PREF_IMPORT_ADJUST_ORIENTATION, FALSE));
 	gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (GET_WIDGET ("single_subfolder_checkbutton")), eel_gconf_get_boolean (PREF_IMPORT_SUBFOLDER_SINGLE, FALSE));
 	subfolder_type = eel_gconf_get_enum (PREF_IMPORT_SUBFOLDER_TYPE, GTH_TYPE_SUBFOLDER_TYPE, GTH_SUBFOLDER_TYPE_FILE_DATE);
 	gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (GET_WIDGET ("autosubfolder_checkbutton")), subfolder_type != GTH_SUBFOLDER_TYPE_NONE);
@@ -376,8 +366,6 @@ gth_import_preferences_dialog_init (GthImportPreferencesDialog *self)
 		g_free (custom_format);
 	}
 
-	gtk_widget_set_sensitive (GET_WIDGET ("adjust_orientation_checkbutton"), gth_main_extension_is_active ("image_rotation") && gth_main_extension_is_active ("exiv2_tools"));
-
 	update_destination (self);
 
 	g_signal_connect (self->priv->subfolder_type_list,
diff --git a/extensions/importer/preferences.h b/extensions/importer/preferences.h
index 6ada88b..1016260 100644
--- a/extensions/importer/preferences.h
+++ b/extensions/importer/preferences.h
@@ -32,8 +32,6 @@ G_BEGIN_DECLS
 #define PREF_IMPORT_SUBFOLDER_FORMAT        "/apps/gthumb/ext/importer/subfolder_format"
 #define PREF_IMPORT_SUBFOLDER_SINGLE        "/apps/gthumb/ext/importer/subfolder_single"
 #define PREF_IMPORT_SUBFOLDER_CUSTOM_FORMAT "/apps/gthumb/ext/importer/subfolder_custom_format"
-#define PREF_IMPORT_OVERWRITE               "/apps/gthumb/ext/importer/overwrite_files"
-#define PREF_IMPORT_ADJUST_ORIENTATION      "/apps/gthumb/ext/importer/adjust_orientation"
 #define PREF_IMPORT_WARN_DELETE_UNSUPPORTED "/apps/gthumb/ext/importer/warn_delete_unsupported"
 
 G_END_DECLS
diff --git a/extensions/photo_importer/callbacks.c b/extensions/photo_importer/callbacks.c
index 0e573d1..50aae04 100644
--- a/extensions/photo_importer/callbacks.c
+++ b/extensions/photo_importer/callbacks.c
@@ -27,6 +27,7 @@
 #include <gthumb.h>
 #include "actions.h"
 #include "dlg-photo-importer.h"
+#include "preferences.h"
 
 
 #define BROWSER_DATA_KEY "photo-importer-browser-data"
@@ -139,3 +140,66 @@ pi__import_photos_cb (GthBrowser *browser,
 			 data,
 			 import_data_unref);
 }
+
+
+/* -- pi__dlg_preferences_construct_cb -- */
+
+
+#define PREFERENCES_DATA_KEY "photo-import-preference-data"
+
+
+typedef struct {
+	GtkBuilder *builder;
+} PreferencesData;
+
+
+static void
+preferences_data_free (PreferencesData *data)
+{
+	g_object_unref (data->builder);
+	g_free (data);
+}
+
+
+static void
+adjust_orientation_checkbutton_toggled_cb (GtkToggleButton *button,
+					   PreferencesData *data)
+{
+	eel_gconf_set_boolean (PREF_PHOTO_IMPORT_ADJUST_ORIENTATION, gtk_toggle_button_get_active (button));
+}
+
+
+void
+pi__dlg_preferences_construct_cb (GtkWidget  *dialog,
+				  GthBrowser *browser,
+				  GtkBuilder *dialog_builder)
+{
+	PreferencesData *data;
+	GtkWidget       *general_vbox;
+	GtkWidget       *importer_options;
+	GtkWidget       *widget;
+
+	data = g_new0 (PreferencesData, 1);
+	data->builder = _gtk_builder_new_from_file("photo-importer-options.ui", "photo_importer");
+
+	general_vbox = _gtk_builder_get_widget (dialog_builder, "general_vbox");
+	importer_options = _gtk_builder_get_widget (data->builder, "importer_options");
+	gtk_box_pack_start (GTK_BOX (general_vbox),
+			    importer_options,
+			    FALSE,
+			    FALSE,
+			    0);
+	/* move the options before the 'other' options */
+	gtk_box_reorder_child (GTK_BOX (general_vbox),
+			       importer_options,
+			       _gtk_container_get_n_children (GTK_CONTAINER (general_vbox)) - 2);
+
+	widget = _gtk_builder_get_widget (data->builder, "adjust_orientation_checkbutton");
+	gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (widget), eel_gconf_get_boolean (PREF_PHOTO_IMPORT_ADJUST_ORIENTATION, FALSE));
+	g_signal_connect (widget,
+			  "toggled",
+			  G_CALLBACK (adjust_orientation_checkbutton_toggled_cb),
+			  data);
+
+	g_object_set_data_full (G_OBJECT (dialog), PREFERENCES_DATA_KEY, data, (GDestroyNotify) preferences_data_free);
+}
diff --git a/extensions/photo_importer/callbacks.h b/extensions/photo_importer/callbacks.h
index a1bb41a..d501eeb 100644
--- a/extensions/photo_importer/callbacks.h
+++ b/extensions/photo_importer/callbacks.h
@@ -25,8 +25,11 @@
 
 #include <gthumb.h>
 
-void pi__gth_browser_construct_cb (GthBrowser *browser);
-void pi__import_photos_cb         (GthBrowser *browser,
-				   GFile      *source);
+void pi__gth_browser_construct_cb      (GthBrowser *browser);
+void pi__import_photos_cb              (GthBrowser *browser,
+				        GFile      *source);
+void pi__dlg_preferences_construct_cb  (GtkWidget  *dialog,
+					GthBrowser *browser,
+					GtkBuilder *dialog_builder);
 
 #endif /* CALLBACKS_H */
diff --git a/extensions/photo_importer/data/gthumb_photo_importer.schemas.in b/extensions/photo_importer/data/gthumb_photo_importer.schemas.in
index 17bb3f4..c53d9d8 100644
--- a/extensions/photo_importer/data/gthumb_photo_importer.schemas.in
+++ b/extensions/photo_importer/data/gthumb_photo_importer.schemas.in
@@ -14,5 +14,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>FALSE</default>
+	<locale name="C">
+	  <short></short>
+	  <long>
+	  </long>
+	</locale>
+      </schema>
+
     </schemalist>
 </gconfschemafile>
diff --git a/extensions/photo_importer/data/ui/Makefile.am b/extensions/photo_importer/data/ui/Makefile.am
index ba1ed63..328ca20 100644
--- a/extensions/photo_importer/data/ui/Makefile.am
+++ b/extensions/photo_importer/data/ui/Makefile.am
@@ -1,5 +1,5 @@
 uidir = $(pkgdatadir)/ui
-ui_DATA = photo-importer.ui
+ui_DATA = photo-importer.ui photo-importer-options.ui
 EXTRA_DIST = $(ui_DATA)
 
 -include $(top_srcdir)/git.mk
diff --git a/extensions/photo_importer/data/ui/photo-importer-options.ui b/extensions/photo_importer/data/ui/photo-importer-options.ui
new file mode 100644
index 0000000..1bfbf4c
--- /dev/null
+++ b/extensions/photo_importer/data/ui/photo-importer-options.ui
@@ -0,0 +1,64 @@
+<?xml version="1.0"?>
+<interface>
+  <requires lib="gtk+" version="2.16"/>
+  <!-- interface-naming-policy project-wide -->
+  <object class="GtkVBox" id="importer_options">
+    <property name="visible">True</property>
+    <property name="orientation">vertical</property>
+    <property name="spacing">6</property>
+    <child>
+      <object class="GtkHBox" id="hbox4">
+        <property name="visible">True</property>
+        <property name="spacing">5</property>
+        <child>
+          <object class="GtkLabel" id="label2">
+            <property name="visible">True</property>
+            <property name="label" translatable="yes">After importing from a device:</property>
+            <property name="justify">center</property>
+            <attributes>
+              <attribute name="weight" value="bold"/>
+            </attributes>
+          </object>
+          <packing>
+            <property name="expand">False</property>
+            <property name="fill">False</property>
+            <property name="position">0</property>
+          </packing>
+        </child>
+      </object>
+      <packing>
+        <property name="expand">False</property>
+        <property name="position">0</property>
+      </packing>
+    </child>
+    <child>
+      <object class="GtkAlignment" id="alignment1">
+        <property name="visible">True</property>
+        <property name="left_padding">12</property>
+        <child>
+          <object class="GtkVBox" id="vbox4">
+            <property name="visible">True</property>
+            <property name="orientation">vertical</property>
+            <property name="spacing">6</property>
+            <child>
+              <object class="GtkCheckButton" id="adjust_orientation_checkbutton">
+                <property name="label" translatable="yes">_Rotate the 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">0</property>
+              </packing>
+            </child>
+          </object>
+        </child>
+      </object>
+      <packing>
+        <property name="position">1</property>
+      </packing>
+    </child>
+  </object>
+</interface>
diff --git a/extensions/photo_importer/main.c b/extensions/photo_importer/main.c
index f9dcada..bfd7291 100644
--- a/extensions/photo_importer/main.c
+++ b/extensions/photo_importer/main.c
@@ -32,6 +32,7 @@ gthumb_extension_activate (void)
 {
 	gth_hook_add_callback ("import-photos", 10, G_CALLBACK (pi__import_photos_cb), NULL);
 	gth_hook_add_callback ("gth-browser-construct", 10, G_CALLBACK (pi__gth_browser_construct_cb), NULL);
+	gth_hook_add_callback ("dlg-preferences-construct", 10, G_CALLBACK (pi__dlg_preferences_construct_cb), NULL);
 }
 
 
diff --git a/extensions/photo_importer/preferences.h b/extensions/photo_importer/preferences.h
index 2476394..8a5afcb 100644
--- a/extensions/photo_importer/preferences.h
+++ b/extensions/photo_importer/preferences.h
@@ -27,7 +27,8 @@
 
 G_BEGIN_DECLS
 
-#define PREF_PHOTO_IMPORT_DELETE "/apps/gthumb/ext/photo_importer/delete_from_device"
+#define PREF_PHOTO_IMPORT_DELETE               "/apps/gthumb/ext/photo_importer/delete_from_device"
+#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]