[gthumb: 18/22] use a general preferences dialog for the import options.
- From: Paolo Bacchilega <paobac src gnome org>
- To: svn-commits-list gnome org
- Cc:
- Subject: [gthumb: 18/22] use a general preferences dialog for the import options.
- Date: Sat, 30 Jan 2010 23:20:46 +0000 (UTC)
commit fb016bb5b6b377d060b2785efca2d34ecc53539c
Author: Paolo Bacchilega <paobac src gnome org>
Date: Sat Jan 30 00:12:14 2010 +0100
use a general preferences dialog for the import options.
data/gthumb.schemas.in | 93 ++++
data/ui/import-preferences.ui | 240 +++++++++
.../data/gthumb_photo_importer.schemas.in | 95 +----
.../photo_importer/data/ui/photo-importer.ui | 303 +-----------
extensions/photo_importer/dlg-photo-importer.c | 313 +----------
extensions/photo_importer/gth-import-task.c | 83 ---
extensions/photo_importer/preferences.h | 25 +-
extensions/picasaweb/Makefile.am | 2 +-
.../picasaweb/data/ui/import-from-picasaweb.ui | 290 +----------
extensions/picasaweb/dlg-import-from-picasaweb.c | 16 +
gthumb/Makefile.am | 2 +
gthumb/gth-import-preferences-dialog.c | 551 ++++++++++++++++++++
gthumb/gth-import-preferences-dialog.h | 68 +++
gthumb/gth-preferences.h | 96 ++--
gthumb/typedefs.h | 15 +
15 files changed, 1072 insertions(+), 1120 deletions(-)
---
diff --git a/data/gthumb.schemas.in b/data/gthumb.schemas.in
index b691c05..4338f54 100644
--- a/data/gthumb.schemas.in
+++ b/data/gthumb.schemas.in
@@ -505,6 +505,99 @@
</locale>
</schema>
+ <!-- Importer -->
+
+ <schema>
+ <key>/schemas/apps/gthumb/importer/destination</key>
+ <applyto>/apps/gthumb/importer/destination</applyto>
+ <owner>gthumb</owner>
+ <type>string</type>
+ <default></default>
+ <locale name="C">
+ <short></short>
+ <long>
+ </long>
+ </locale>
+ </schema>
+
+ <schema>
+ <key>/schemas/apps/gthumb/importer/subfolder_type</key>
+ <applyto>/apps/gthumb/importer/subfolder_type</applyto>
+ <owner>gthumb</owner>
+ <type>string</type>
+ <default>none</default>
+ <locale name="C">
+ <short></short>
+ <long>Possible values are: none, file_date, current_date
+ </long>
+ </locale>
+ </schema>
+
+ <schema>
+ <key>/schemas/apps/gthumb/importer/subfolder_format</key>
+ <applyto>/apps/gthumb/importer/subfolder_format</applyto>
+ <owner>gthumb</owner>
+ <type>string</type>
+ <default>yyyymmdd</default>
+ <locale name="C">
+ <short></short>
+ <long>Possible values are: yyyymmdd, yyyymm, yyyy
+ </long>
+ </locale>
+ </schema>
+
+ <schema>
+ <key>/schemas/apps/gthumb/importer/subfolder_single</key>
+ <applyto>/apps/gthumb/importer/subfolder_single</applyto>
+ <owner>gthumb</owner>
+ <type>bool</type>
+ <default>FALSE</default>
+ <locale name="C">
+ <short></short>
+ <long>
+ </long>
+ </locale>
+ </schema>
+
+ <schema>
+ <key>/schemas/apps/gthumb/importer/subfolder_custom_format</key>
+ <applyto>/apps/gthumb/importer/subfolder_custom_format</applyto>
+ <owner>gthumb</owner>
+ <type>string</type>
+ <default></default>
+ <locale name="C">
+ <short></short>
+ <long>
+ </long>
+ </locale>
+ </schema>
+
+ <schema>
+ <key>/schemas/apps/gthumb/importer/overwrite_files</key>
+ <applyto>/apps/gthumb/importer/overwrite_files</applyto>
+ <owner>gthumb</owner>
+ <type>bool</type>
+ <default>FALSE</default>
+ <locale name="C">
+ <short></short>
+ <long>
+ </long>
+ </locale>
+ </schema>
+
+ <schema>
+ <key>/schemas/apps/gthumb/importer/adjust_orientation</key>
+ <applyto>/apps/gthumb/importer/adjust_orientation</applyto>
+ <owner>gthumb</owner>
+ <type>bool</type>
+ <default>FALSE</default>
+ <locale name="C">
+ <short></short>
+ <long>
+ </long>
+ </locale>
+ </schema>
+
<!-- Messages -->
<schema>
diff --git a/data/ui/import-preferences.ui b/data/ui/import-preferences.ui
new file mode 100644
index 0000000..6836ed1
--- /dev/null
+++ b/data/ui/import-preferences.ui
@@ -0,0 +1,240 @@
+<?xml version="1.0"?>
+<interface>
+ <requires lib="gtk+" version="2.16"/>
+ <!-- interface-naming-policy project-wide -->
+ <object class="GtkVBox" id="import_preferences">
+ <property name="visible">True</property>
+ <property name="border_width">5</property>
+ <property name="orientation">vertical</property>
+ <property name="spacing">12</property>
+ <child>
+ <object class="GtkFrame" id="frame1">
+ <property name="visible">True</property>
+ <property name="label_xalign">0</property>
+ <property name="shadow_type">none</property>
+ <child>
+ <object class="GtkAlignment" id="alignment2">
+ <property name="visible">True</property>
+ <property name="top_padding">6</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="GtkHBox" id="hbox2">
+ <property name="visible">True</property>
+ <property name="spacing">6</property>
+ <child>
+ <object class="GtkFileChooserButton" id="destination_filechooserbutton">
+ <property name="visible">True</property>
+ <property name="create_folders">False</property>
+ <property name="local_only">False</property>
+ <property name="action">select-folder</property>
+ </object>
+ <packing>
+ <property name="position">0</property>
+ </packing>
+ </child>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="position">0</property>
+ </packing>
+ </child>
+ </object>
+ </child>
+ </object>
+ </child>
+ <child type="label">
+ <object class="GtkLabel" id="label1">
+ <property name="visible">True</property>
+ <property name="label" translatable="yes">Destination</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">0</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkVBox" id="vbox6">
+ <property name="visible">True</property>
+ <property name="orientation">vertical</property>
+ <child>
+ <object class="GtkCheckButton" id="autosubfolder_checkbutton">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="receives_default">False</property>
+ <property name="draw_indicator">True</property>
+ <child>
+ <object class="GtkLabel" id="label2">
+ <property name="visible">True</property>
+ <property name="label" translatable="yes">_Automatic subfolder</property>
+ <property name="use_underline">True</property>
+ <attributes>
+ <attribute name="weight" value="bold"/>
+ </attributes>
+ </object>
+ </child>
+ </object>
+ <packing>
+ <property name="position">0</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkAlignment" id="alignment1">
+ <property name="visible">True</property>
+ <property name="top_padding">6</property>
+ <property name="left_padding">14</property>
+ <child>
+ <object class="GtkHBox" id="subfolder_type_box">
+ <property name="visible">True</property>
+ <property name="spacing">6</property>
+ <child>
+ <placeholder/>
+ </child>
+ <child>
+ <object class="GtkNotebook" id="subfolder_options_notebook">
+ <property name="visible">True</property>
+ <property name="show_tabs">False</property>
+ <property name="show_border">False</property>
+ <child>
+ <object class="GtkCheckButton" id="single_subfolder_checkbutton">
+ <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>
+ </child>
+ <child type="tab">
+ <placeholder/>
+ </child>
+ <child>
+ <object class="GtkEntry" id="custom_format_entry">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="invisible_char">●</property>
+ </object>
+ <packing>
+ <property name="position">1</property>
+ </packing>
+ </child>
+ <child type="tab">
+ <placeholder/>
+ </child>
+ <child>
+ <placeholder/>
+ </child>
+ <child type="tab">
+ <placeholder/>
+ </child>
+ </object>
+ <packing>
+ <property name="pack_type">end</property>
+ <property name="position">1</property>
+ </packing>
+ </child>
+ </object>
+ </child>
+ </object>
+ <packing>
+ <property name="position">1</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkAlignment" id="alignment3">
+ <property name="visible">True</property>
+ <property name="top_padding">6</property>
+ <property name="left_padding">14</property>
+ <child>
+ <object class="GtkLabel" id="example_label">
+ <property name="visible">True</property>
+ <property name="xalign">0</property>
+ <property name="label">example: file:///home/paolo/images/2009/08/12</property>
+ <attributes>
+ <attribute name="size" value="8500"/>
+ </attributes>
+ </object>
+ </child>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="position">2</property>
+ </packing>
+ </child>
+ </object>
+ <packing>
+ <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="position">2</property>
+ </packing>
+ </child>
+ </object>
+</interface>
diff --git a/extensions/photo_importer/data/gthumb_photo_importer.schemas.in b/extensions/photo_importer/data/gthumb_photo_importer.schemas.in
index ea9852b..17bb3f4 100644
--- a/extensions/photo_importer/data/gthumb_photo_importer.schemas.in
+++ b/extensions/photo_importer/data/gthumb_photo_importer.schemas.in
@@ -2,99 +2,8 @@
<schemalist>
<schema>
- <key>/schemas/apps/gthumb/ext/photo_importer/destination</key>
- <applyto>/apps/gthumb/ext/photo_importer/destination</applyto>
- <owner>gthumb</owner>
- <type>string</type>
- <default></default>
- <locale name="C">
- <short></short>
- <long>
- </long>
- </locale>
- </schema>
-
- <schema>
- <key>/schemas/apps/gthumb/ext/photo_importer/subfolder_type</key>
- <applyto>/apps/gthumb/ext/photo_importer/subfolder_type</applyto>
- <owner>gthumb</owner>
- <type>string</type>
- <default>none</default>
- <locale name="C">
- <short></short>
- <long>Possible values are: none, file_date, current_date
- </long>
- </locale>
- </schema>
-
- <schema>
- <key>/schemas/apps/gthumb/ext/photo_importer/subfolder_format</key>
- <applyto>/apps/gthumb/ext/photo_importer/subfolder_format</applyto>
- <owner>gthumb</owner>
- <type>string</type>
- <default>yyyymmdd</default>
- <locale name="C">
- <short></short>
- <long>Possible values are: yyyymmdd, yyyymm, yyyy
- </long>
- </locale>
- </schema>
-
- <schema>
- <key>/schemas/apps/gthumb/ext/photo_importer/subfolder_single</key>
- <applyto>/apps/gthumb/ext/photo_importer/subfolder_single</applyto>
- <owner>gthumb</owner>
- <type>bool</type>
- <default>FALSE</default>
- <locale name="C">
- <short></short>
- <long>
- </long>
- </locale>
- </schema>
-
- <schema>
- <key>/schemas/apps/gthumb/ext/photo_importer/subfolder_custom_format</key>
- <applyto>/apps/gthumb/ext/photo_importer/subfolder_custom_format</applyto>
- <owner>gthumb</owner>
- <type>string</type>
- <default></default>
- <locale name="C">
- <short></short>
- <long>
- </long>
- </locale>
- </schema>
-
- <schema>
- <key>/schemas/apps/gthumb/ext/photo_importer/delete_from_camera</key>
- <applyto>/apps/gthumb/ext/photo_importer/delete_from_camera</applyto>
- <owner>gthumb</owner>
- <type>bool</type>
- <default>FALSE</default>
- <locale name="C">
- <short></short>
- <long>
- </long>
- </locale>
- </schema>
-
- <schema>
- <key>/schemas/apps/gthumb/ext/photo_importer/overwrite_files</key>
- <applyto>/apps/gthumb/ext/photo_importer/overwrite_files</applyto>
- <owner>gthumb</owner>
- <type>bool</type>
- <default>FALSE</default>
- <locale name="C">
- <short></short>
- <long>
- </long>
- </locale>
- </schema>
-
- <schema>
- <key>/schemas/apps/gthumb/ext/photo_importer/adjust_orientation</key>
- <applyto>/apps/gthumb/ext/photo_importer/adjust_orientation</applyto>
+ <key>/schemas/apps/gthumb/ext/photo_importer/delete_from_device</key>
+ <applyto>/apps/gthumb/ext/photo_importer/delete_from_device</applyto>
<owner>gthumb</owner>
<type>bool</type>
<default>FALSE</default>
diff --git a/extensions/photo_importer/data/ui/photo-importer.ui b/extensions/photo_importer/data/ui/photo-importer.ui
index c77115a..bceb217 100644
--- a/extensions/photo_importer/data/ui/photo-importer.ui
+++ b/extensions/photo_importer/data/ui/photo-importer.ui
@@ -4,7 +4,7 @@
<!-- interface-naming-policy project-wide -->
<object class="GtkDialog" id="photo_importer_dialog">
<property name="border_width">5</property>
- <property name="title" translatable="yes">Import</property>
+ <property name="title" translatable="yes">Import from Removable Device</property>
<property name="type_hint">normal</property>
<property name="has_separator">False</property>
<child internal-child="vbox">
@@ -304,305 +304,4 @@
<property name="visible">True</property>
<property name="stock">gtk-ok</property>
</object>
- <object class="GtkDialog" id="preferences_dialog">
- <property name="border_width">5</property>
- <property name="title" translatable="yes">Preferences</property>
- <property name="resizable">False</property>
- <property name="modal">True</property>
- <property name="type_hint">dialog</property>
- <property name="transient_for">photo_importer_dialog</property>
- <property name="has_separator">False</property>
- <child internal-child="vbox">
- <object class="GtkVBox" id="dialog-vbox2">
- <property name="visible">True</property>
- <property name="orientation">vertical</property>
- <property name="spacing">2</property>
- <child>
- <object class="GtkVBox" id="vbox2">
- <property name="visible">True</property>
- <property name="border_width">5</property>
- <property name="orientation">vertical</property>
- <property name="spacing">12</property>
- <child>
- <object class="GtkFrame" id="frame1">
- <property name="visible">True</property>
- <property name="label_xalign">0</property>
- <property name="shadow_type">none</property>
- <child>
- <object class="GtkAlignment" id="alignment2">
- <property name="visible">True</property>
- <property name="top_padding">6</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="GtkHBox" id="hbox2">
- <property name="visible">True</property>
- <property name="spacing">6</property>
- <child>
- <object class="GtkFileChooserButton" id="destination_filechooserbutton">
- <property name="visible">True</property>
- <property name="action">select-folder</property>
- <property name="local_only">False</property>
- </object>
- <packing>
- <property name="position">0</property>
- </packing>
- </child>
- </object>
- <packing>
- <property name="expand">False</property>
- <property name="position">0</property>
- </packing>
- </child>
- </object>
- </child>
- </object>
- </child>
- <child type="label">
- <object class="GtkLabel" id="label1">
- <property name="visible">True</property>
- <property name="label" translatable="yes">Destination</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">0</property>
- </packing>
- </child>
- <child>
- <object class="GtkVBox" id="vbox6">
- <property name="visible">True</property>
- <property name="orientation">vertical</property>
- <child>
- <object class="GtkCheckButton" id="autosubfolder_checkbutton">
- <property name="visible">True</property>
- <property name="can_focus">True</property>
- <property name="receives_default">False</property>
- <property name="draw_indicator">True</property>
- <child>
- <object class="GtkLabel" id="label2">
- <property name="visible">True</property>
- <property name="label" translatable="yes">_Automatic subfolder</property>
- <property name="use_underline">True</property>
- <attributes>
- <attribute name="weight" value="bold"/>
- </attributes>
- </object>
- </child>
- </object>
- <packing>
- <property name="position">0</property>
- </packing>
- </child>
- <child>
- <object class="GtkAlignment" id="alignment1">
- <property name="visible">True</property>
- <property name="top_padding">6</property>
- <property name="left_padding">14</property>
- <child>
- <object class="GtkHBox" id="subfolder_type_box">
- <property name="visible">True</property>
- <property name="spacing">6</property>
- <child>
- <placeholder/>
- </child>
- <child>
- <object class="GtkNotebook" id="subfolder_options_notebook">
- <property name="visible">True</property>
- <property name="can_focus">True</property>
- <property name="show_tabs">False</property>
- <property name="show_border">False</property>
- <child>
- <object class="GtkCheckButton" id="single_subfolder_checkbutton">
- <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>
- </child>
- <child type="tab">
- <placeholder/>
- </child>
- <child>
- <object class="GtkEntry" id="custom_format_entry">
- <property name="visible">True</property>
- <property name="can_focus">True</property>
- <property name="invisible_char">●</property>
- </object>
- <packing>
- <property name="position">1</property>
- </packing>
- </child>
- <child type="tab">
- <placeholder/>
- </child>
- <child>
- <placeholder/>
- </child>
- <child type="tab">
- <placeholder/>
- </child>
- </object>
- <packing>
- <property name="pack_type">end</property>
- <property name="position">1</property>
- </packing>
- </child>
- </object>
- </child>
- </object>
- <packing>
- <property name="position">1</property>
- </packing>
- </child>
- <child>
- <object class="GtkAlignment" id="alignment3">
- <property name="visible">True</property>
- <property name="top_padding">6</property>
- <property name="left_padding">14</property>
- <child>
- <object class="GtkLabel" id="example_label">
- <property name="visible">True</property>
- <property name="xalign">0</property>
- <property name="label">example: file:///home/paolo/images/2009/08/12</property>
- <attributes>
- <attribute name="size" value="8500"/>
- </attributes>
- </object>
- </child>
- </object>
- <packing>
- <property name="expand">False</property>
- <property name="position">2</property>
- </packing>
- </child>
- </object>
- <packing>
- <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="position">2</property>
- </packing>
- </child>
- </object>
- <packing>
- <property name="expand">False</property>
- <property name="position">1</property>
- </packing>
- </child>
- <child internal-child="action_area">
- <object class="GtkHButtonBox" id="dialog-action_area2">
- <property name="visible">True</property>
- <property name="layout_style">end</property>
- <child>
- <object class="GtkButton" id="p_close_button">
- <property name="label">gtk-close</property>
- <property name="visible">True</property>
- <property name="can_focus">True</property>
- <property name="receives_default">True</property>
- <property name="use_stock">True</property>
- </object>
- <packing>
- <property name="expand">False</property>
- <property name="fill">False</property>
- <property name="position">0</property>
- </packing>
- </child>
- <child>
- <object class="GtkButton" id="help_button">
- <property name="label">gtk-help</property>
- <property name="visible">True</property>
- <property name="can_focus">True</property>
- <property name="receives_default">True</property>
- <property name="use_stock">True</property>
- </object>
- <packing>
- <property name="expand">False</property>
- <property name="fill">False</property>
- <property name="position">1</property>
- <property name="secondary">True</property>
- </packing>
- </child>
- </object>
- <packing>
- <property name="expand">False</property>
- <property name="pack_type">end</property>
- <property name="position">0</property>
- </packing>
- </child>
- </object>
- </child>
- <action-widgets>
- <action-widget response="0">p_close_button</action-widget>
- <action-widget response="0">help_button</action-widget>
- </action-widgets>
- </object>
</interface>
diff --git a/extensions/photo_importer/dlg-photo-importer.c b/extensions/photo_importer/dlg-photo-importer.c
index 4cd7414..c0fc43e 100644
--- a/extensions/photo_importer/dlg-photo-importer.c
+++ b/extensions/photo_importer/dlg-photo-importer.c
@@ -42,13 +42,12 @@ enum {
typedef struct {
GthBrowser *browser;
GtkWidget *dialog;
+ GtkWidget *preferences_dialog;
GtkBuilder *builder;
GFile *source;
GFile *last_source;
GtkListStore *source_store;
GtkWidget *source_list;
- GtkWidget *subfolder_type_list;
- GtkWidget *subfolder_format_list;
GtkWidget *file_list;
GCancellable *cancellable;
GList *files;
@@ -64,66 +63,36 @@ typedef struct {
} DialogData;
-static GthSubfolderType
-get_subfolder_type (DialogData *data)
-{
- if (! gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (GET_WIDGET ("autosubfolder_checkbutton"))))
- return GTH_SUBFOLDER_TYPE_NONE;
- else
- return gtk_combo_box_get_active (GTK_COMBO_BOX (data->subfolder_type_list)) + 1;
-}
-
-
static void
destroy_dialog (gpointer user_data)
{
- DialogData *data = user_data;
- GFile *destination;
- gboolean single_subfolder;
- GthSubfolderType subfolder_type;
- GthSubfolderFormat subfolder_format;
- const char *custom_format;
- gboolean delete_imported;
- gboolean overwrite_files;
- gboolean adjust_orientation;
+ DialogData *data = user_data;
+ gboolean delete_imported;
g_signal_handler_disconnect (gth_main_get_default_monitor (), data->monitor_event);
- destination = gtk_file_chooser_get_current_folder_file (GTK_FILE_CHOOSER (GET_WIDGET ("destination_filechooserbutton")));
- if (destination != NULL) {
- char *uri;
-
- uri = g_file_get_uri (destination);
- eel_gconf_set_string (PREF_PHOTO_IMPORT_DESTINATION, uri);
-
- g_free (uri);
- }
-
- single_subfolder = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (GET_WIDGET ("single_subfolder_checkbutton")));
- eel_gconf_set_boolean (PREF_PHOTO_IMPORT_SUBFOLDER_SINGLE, single_subfolder);
-
- subfolder_type = get_subfolder_type (data);
- eel_gconf_set_enum (PREF_PHOTO_IMPORT_SUBFOLDER_TYPE, GTH_TYPE_SUBFOLDER_TYPE, subfolder_type);
-
- subfolder_format = gtk_combo_box_get_active (GTK_COMBO_BOX (data->subfolder_format_list));
- eel_gconf_set_enum (PREF_PHOTO_IMPORT_SUBFOLDER_FORMAT, GTH_TYPE_SUBFOLDER_FORMAT, subfolder_format);
-
- custom_format = gtk_entry_get_text (GTK_ENTRY (GET_WIDGET ("custom_format_entry")));
- eel_gconf_set_string (PREF_PHOTO_IMPORT_SUBFOLDER_CUSTOM_FORMAT, custom_format);
-
delete_imported = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (GET_WIDGET ("delete_checkbutton")));
eel_gconf_set_boolean (PREF_PHOTO_IMPORT_DELETE, delete_imported);
- overwrite_files = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (GET_WIDGET ("overwrite_checkbutton")));
- eel_gconf_set_boolean (PREF_PHOTO_IMPORT_OVERWRITE, overwrite_files);
-
- 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) {
- GtkWidget *file_view;
- GList *items;
- GList *file_list;
+ GFile *destination;
+ gboolean single_subfolder;
+ GthSubfolderType subfolder_type;
+ GthSubfolderFormat subfolder_format;
+ char *custom_format;
+ gboolean overwrite_files;
+ gboolean adjust_orientation;
+ GtkWidget *file_view;
+ GList *items;
+ GList *file_list;
+
+ destination = gth_import_preferences_get_destination ();
+ single_subfolder = 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);
+ subfolder_format = eel_gconf_get_enum (PREF_IMPORT_SUBFOLDER_FORMAT, GTH_TYPE_SUBFOLDER_FORMAT, GTH_SUBFOLDER_FORMAT_YYYYMMDD);
+ custom_format = eel_gconf_get_string (PREF_IMPORT_SUBFOLDER_CUSTOM_FORMAT, "");
+ overwrite_files = eel_gconf_get_boolean (PREF_IMPORT_OVERWRITE, FALSE);
+ adjust_orientation = eel_gconf_get_boolean (PREF_IMPORT_ADJUST_ORIENTATION, FALSE);
file_view = gth_file_list_get_view (GTH_FILE_LIST (data->file_list));
items = gth_file_selection_get_selected (GTH_FILE_SELECTION (file_view));
@@ -157,10 +126,10 @@ destroy_dialog (gpointer user_data)
_g_object_list_unref (file_list);
_gtk_tree_path_list_free (items);
+ g_free (custom_format);
+ _g_object_unref (destination);
}
- _g_object_unref (destination);
-
gtk_widget_destroy (data->dialog);
gth_browser_set_dialog (data->browser, "photo_importer", NULL);
@@ -493,145 +462,13 @@ filter_combobox_changed_cb (GtkComboBox *widget,
}
-static GthFileData *
-create_example_file_data (void)
-{
- GFile *file;
- GFileInfo *info;
- GthFileData *file_data;
- GthMetadata *metadata;
-
- file = g_file_new_for_uri ("file://home/user/document.txt");
- info = g_file_info_new ();
- file_data = gth_file_data_new (file, info);
-
- metadata = g_object_new (GTH_TYPE_METADATA,
- "raw", "2005:03:09 13:23:51",
- "formatted", "2005:03:09 13:23:51",
- NULL);
- g_file_info_set_attribute_object (info, "Embedded::Photo::DateTimeOriginal", G_OBJECT (metadata));
-
- g_object_unref (metadata);
- g_object_unref (info);
- g_object_unref (file);
-
- return file_data;
-}
-
-
-static void
-update_destination (DialogData *data)
-{
- GFile *destination;
- GthSubfolderType subfolder_type;
- GthSubfolderFormat subfolder_format;
- gboolean single_subfolder;
- const char *custom_format;
- GthFileData *example_data;
- GFile *destination_example;
- char *uri;
- char *example;
-
- destination = gtk_file_chooser_get_current_folder_file (GTK_FILE_CHOOSER (GET_WIDGET ("destination_filechooserbutton")));
- if (destination == NULL)
- return;
-
- subfolder_type = get_subfolder_type (data);
- subfolder_format = gtk_combo_box_get_active (GTK_COMBO_BOX (data->subfolder_format_list));
- single_subfolder = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (GET_WIDGET ("single_subfolder_checkbutton")));
- custom_format = gtk_entry_get_text (GTK_ENTRY (GET_WIDGET ("custom_format_entry")));
-
- example_data = create_example_file_data ();
- destination_example = gth_import_task_get_file_destination (example_data,
- destination,
- subfolder_type,
- subfolder_format,
- single_subfolder,
- custom_format,
- gtk_entry_get_text (GTK_ENTRY (GET_WIDGET ("event_entry"))));
-
- uri = g_file_get_parse_name (destination_example);
- example = g_strdup_printf (_("example: %s"), uri);
- gtk_label_set_text (GTK_LABEL (GET_WIDGET ("example_label")), example);
-
- gtk_widget_set_sensitive (GET_WIDGET ("single_subfolder_checkbutton"), subfolder_type != GTH_SUBFOLDER_TYPE_NONE);
- gtk_widget_set_sensitive (data->subfolder_type_list, subfolder_type != GTH_SUBFOLDER_TYPE_NONE);
- gtk_widget_set_sensitive (data->subfolder_format_list, subfolder_type != GTH_SUBFOLDER_TYPE_NONE);
- gtk_widget_set_sensitive (GET_WIDGET ("subfolder_options_notebook"), subfolder_type != GTH_SUBFOLDER_TYPE_NONE);
-
- gtk_notebook_set_current_page (GTK_NOTEBOOK (GET_WIDGET ("subfolder_options_notebook")), (subfolder_format == GTH_SUBFOLDER_FORMAT_CUSTOM) ? 1 : 0);
-
- g_free (example);
- g_free (uri);
- g_object_unref (destination_example);
- g_object_unref (example_data);
- g_object_unref (destination);
-}
-
-
-static gboolean
-preferences_dialog_map_event_cb (GtkWidget *widget,
- GdkEvent *event,
- gpointer user_data)
-{
- update_destination ((DialogData *) user_data);
- return FALSE;
-}
-
-
-static void
-subfolder_type_list_changed_cb (GtkWidget *widget,
- DialogData *data)
-{
- update_destination (data);
-}
-
-
-static void
-subfolder_format_list_changed_cb (GtkWidget *widget,
- DialogData *data)
-{
- update_destination (data);
-}
-
-
-static void
-destination_selection_changed_cb (GtkWidget *widget,
- DialogData *data)
-{
- update_destination (data);
-}
-
-
-static void
-subfolder_hierarchy_checkbutton_toggled_cb (GtkWidget *widget,
- DialogData *data)
-{
- update_destination (data);
-}
-
-
static void
preferences_button_clicked_cb (GtkWidget *widget,
DialogData *data)
{
- gtk_window_present (GTK_WINDOW (GET_WIDGET ("preferences_dialog")));
-}
-
-
-static void
-autosubfolder_checkbutton_toggled_cb (GtkToggleButton *togglebutton,
- DialogData *data)
-{
- update_destination (data);
-}
-
-
-static void
-custom_format_entry_changed_cb (GtkEditable *editable,
- DialogData *data)
-{
- update_destination (data);
+ gth_import_preferences_dialog_set_event (GTH_IMPORT_PREFERENCES_DIALOG (data->preferences_dialog),
+ gtk_entry_get_text (GTK_ENTRY (GET_WIDGET ("event_entry"))));
+ gtk_window_present (GTK_WINDOW (data->preferences_dialog));
}
@@ -646,8 +483,6 @@ dlg_photo_importer (GthBrowser *browser,
char *general_filter;
int i, active_filter;
int i_general;
- GthSubfolderType subfolder_type;
- char *custom_format;
if (gth_browser_get_dialog (browser, "photo_importer") != NULL) {
gtk_window_present (GTK_WINDOW (gth_browser_get_dialog (browser, "photo_importer")));
@@ -691,15 +526,6 @@ dlg_photo_importer (GthBrowser *browser,
"text", SOURCE_LIST_COLUMN_NAME,
NULL);
- data->subfolder_type_list = _gtk_combo_box_new_with_texts (_("File date"),
- _("Current date"),
- NULL);
- gtk_combo_box_set_active (GTK_COMBO_BOX (data->subfolder_type_list), 0);
- gtk_widget_show (data->subfolder_type_list);
- gtk_box_pack_start (GTK_BOX (GET_WIDGET ("subfolder_type_box")), data->subfolder_type_list, TRUE, TRUE, 0);
-
- /*gtk_label_set_mnemonic_widget (GTK_LABEL (GET_WIDGET ("subfolder_label")), data->subfolder_type_list);*/
-
data->file_list = gth_file_list_new (GTH_FILE_LIST_TYPE_NORMAL);
sort_type = gth_main_get_sort_type ("file::mtime");
gth_file_list_set_sort_func (GTH_FILE_LIST (data->file_list), sort_type->cmp_func, FALSE);
@@ -712,17 +538,6 @@ dlg_photo_importer (GthBrowser *browser,
/*gtk_label_set_mnemonic_widget (GTK_LABEL (GET_WIDGET ("files_label")), data->file_list);*/
- data->subfolder_format_list = _gtk_combo_box_new_with_texts (_("year-month-day"),
- _("year-month"),
- _("year"),
- _("custom format"),
- NULL);
- gtk_combo_box_set_active (GTK_COMBO_BOX (data->subfolder_format_list), 0);
- gtk_widget_show (data->subfolder_format_list);
- gtk_box_pack_start (GTK_BOX (GET_WIDGET ("subfolder_type_box")), data->subfolder_format_list, TRUE, TRUE, 0);
-
- /**/
-
tests = gth_main_get_registered_objects_id (GTH_TYPE_TEST);
general_filter = "file::type::is_media"; /* default value */
active_filter = 0;
@@ -757,51 +572,15 @@ dlg_photo_importer (GthBrowser *browser,
_g_string_list_free (tests);
- {
- char *last_destination;
- GFile *folder;
-
- last_destination = eel_gconf_get_string (PREF_PHOTO_IMPORT_DESTINATION, NULL);
- if ((last_destination == NULL) || (*last_destination == 0)) {
- char *default_path;
-
- default_path = xdg_user_dir_lookup ("PICTURES");
- folder = g_file_new_for_path (default_path);
-
- g_free (default_path);
- }
- else
- folder = g_file_new_for_uri (last_destination);
-
- gtk_file_chooser_set_current_folder_file (GTK_FILE_CHOOSER (GET_WIDGET ("destination_filechooserbutton")),
- folder,
- NULL);
-
- g_object_unref (folder);
- g_free (last_destination);
- }
-
data->tags_entry = gth_tags_entry_new ();
gtk_widget_show (data->tags_entry);
gtk_box_pack_start (GTK_BOX (GET_WIDGET ("tags_entry_box")), data->tags_entry, TRUE, TRUE, 0);
gtk_label_set_mnemonic_widget (GTK_LABEL (GET_WIDGET ("tags_label")), data->tags_entry);
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 ("overwrite_checkbutton")), eel_gconf_get_boolean (PREF_PHOTO_IMPORT_OVERWRITE, FALSE));
- gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (GET_WIDGET ("adjust_orientation_checkbutton")), eel_gconf_get_boolean (PREF_PHOTO_IMPORT_ADJUST_ORIENTATION, FALSE));
- gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (GET_WIDGET ("single_subfolder_checkbutton")), eel_gconf_get_boolean (PREF_PHOTO_IMPORT_SUBFOLDER_SINGLE, FALSE));
- subfolder_type = eel_gconf_get_enum (PREF_PHOTO_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);
- gtk_combo_box_set_active (GTK_COMBO_BOX (data->subfolder_type_list), (subfolder_type == 0) ? 0 : subfolder_type - 1);
- gtk_combo_box_set_active (GTK_COMBO_BOX (data->subfolder_format_list), eel_gconf_get_enum (PREF_PHOTO_IMPORT_SUBFOLDER_FORMAT, GTH_TYPE_SUBFOLDER_FORMAT, GTH_SUBFOLDER_FORMAT_YYYYMMDD));
-
- custom_format = eel_gconf_get_string (PREF_PHOTO_IMPORT_SUBFOLDER_CUSTOM_FORMAT, "");
- if (custom_format != NULL) {
- gtk_entry_set_text (GTK_ENTRY (GET_WIDGET ("custom_format_entry")), custom_format);
- g_free (custom_format);
- }
- update_destination (data);
+ data->preferences_dialog = gth_import_preferences_dialog_new ();
+ gtk_window_set_transient_for (GTK_WINDOW (data->preferences_dialog), GTK_WINDOW (data->dialog));
/* Set the signals handlers. */
@@ -833,46 +612,10 @@ dlg_photo_importer (GthBrowser *browser,
"selection_changed",
G_CALLBACK (file_view_selection_changed_cb),
data);
- g_signal_connect (data->subfolder_type_list,
- "changed",
- G_CALLBACK (subfolder_type_list_changed_cb),
- data);
- g_signal_connect (data->subfolder_format_list,
- "changed",
- G_CALLBACK (subfolder_format_list_changed_cb),
- data);
- g_signal_connect (GET_WIDGET ("destination_filechooserbutton"),
- "selection_changed",
- G_CALLBACK (destination_selection_changed_cb),
- data);
- g_signal_connect (GET_WIDGET ("single_subfolder_checkbutton"),
- "toggled",
- G_CALLBACK (subfolder_hierarchy_checkbutton_toggled_cb),
- data);
g_signal_connect (GET_WIDGET ("preferences_button"),
"clicked",
G_CALLBACK (preferences_button_clicked_cb),
data);
- g_signal_connect (GET_WIDGET ("preferences_dialog"),
- "map-event",
- G_CALLBACK (preferences_dialog_map_event_cb),
- data);
- g_signal_connect (GET_WIDGET ("preferences_dialog"),
- "delete-event",
- G_CALLBACK (gtk_widget_hide_on_delete),
- NULL);
- g_signal_connect_swapped (GET_WIDGET ("p_close_button"),
- "clicked",
- G_CALLBACK (gtk_widget_hide_on_delete),
- GET_WIDGET ("preferences_dialog"));
- g_signal_connect (GET_WIDGET ("autosubfolder_checkbutton"),
- "toggled",
- G_CALLBACK (autosubfolder_checkbutton_toggled_cb),
- data);
- g_signal_connect (GET_WIDGET ("custom_format_entry"),
- "changed",
- G_CALLBACK (custom_format_entry_changed_cb),
- data);
data->monitor_event = g_signal_connect (gth_main_get_default_monitor (),
"entry_points_changed",
G_CALLBACK (entry_points_changed_cb),
diff --git a/extensions/photo_importer/gth-import-task.c b/extensions/photo_importer/gth-import-task.c
index 1316cca..89409b7 100644
--- a/extensions/photo_importer/gth-import-task.c
+++ b/extensions/photo_importer/gth-import-task.c
@@ -529,86 +529,3 @@ gth_import_task_new (GthBrowser *browser,
return (GthTask *) self;
}
-
-
-GFile *
-gth_import_task_get_file_destination (GthFileData *file_data,
- GFile *destination,
- GthSubfolderType subfolder_type,
- GthSubfolderFormat subfolder_format,
- gboolean single_subfolder,
- const char *custom_format,
- const char *event_name)
-{
- GTimeVal timeval;
- char *child;
- GFile *file_destination;
-
- if (subfolder_type == GTH_SUBFOLDER_TYPE_FILE_DATE) {
- GthMetadata *metadata;
-
- metadata = (GthMetadata *) g_file_info_get_attribute_object (file_data->info, "Embedded::Photo::DateTimeOriginal");
- if (metadata != NULL)
- _g_time_val_from_exif_date (gth_metadata_get_raw (metadata), &timeval);
- else
- subfolder_type = GTH_SUBFOLDER_TYPE_CURRENT_DATE;
- }
-
- if (subfolder_type == GTH_SUBFOLDER_TYPE_CURRENT_DATE)
- g_get_current_time (&timeval);
-
- switch (subfolder_type) {
- case GTH_SUBFOLDER_TYPE_FILE_DATE:
- case GTH_SUBFOLDER_TYPE_CURRENT_DATE:
- if (subfolder_format != GTH_SUBFOLDER_FORMAT_CUSTOM) {
- GDate *date;
- char **parts;
-
- date = g_date_new ();
- g_date_set_time_val (date, &timeval);
-
- parts = g_new0 (char *, 4);
- parts[0] = g_strdup_printf ("%04d", g_date_get_year (date));
- if (subfolder_format != GTH_SUBFOLDER_FORMAT_YYYY) {
- parts[1] = g_strdup_printf ("%02d", g_date_get_month (date));
- if (subfolder_format != GTH_SUBFOLDER_FORMAT_YYYYMM)
- parts[2] = g_strdup_printf ("%02d", g_date_get_day (date));
- }
-
- if (single_subfolder)
- child = g_strjoinv ("-", parts);
- else
- child = g_strjoinv ("/", parts);
-
- g_strfreev (parts);
- g_date_free (date);
- }
- else {
- char *format = NULL;
-
- if (event_name != NULL) {
- GRegex *re;
-
- re = g_regex_new ("%E", 0, 0, NULL);
- format = g_regex_replace_literal (re, custom_format, -1, 0, event_name, 0, NULL);
-
- g_regex_unref (re);
- }
- if (format == NULL)
- format = g_strdup (custom_format);
- child = _g_time_val_strftime (&timeval, format);
-
- g_free (format);
- }
- break;
-
- case GTH_SUBFOLDER_TYPE_NONE:
- child = NULL;
- break;
- }
- file_destination = _g_file_append_path (destination, child);
-
- g_free (child);
-
- return file_destination;
-}
diff --git a/extensions/photo_importer/preferences.h b/extensions/photo_importer/preferences.h
index 3ff58d8..1df543b 100644
--- a/extensions/photo_importer/preferences.h
+++ b/extensions/photo_importer/preferences.h
@@ -27,30 +27,7 @@
G_BEGIN_DECLS
-typedef enum {
- GTH_SUBFOLDER_TYPE_NONE = 0,
- GTH_SUBFOLDER_TYPE_FILE_DATE,
- GTH_SUBFOLDER_TYPE_CURRENT_DATE,
-} GthSubfolderType;
-
-
-typedef enum {
- GTH_SUBFOLDER_FORMAT_YYYYMMDD,
- GTH_SUBFOLDER_FORMAT_YYYYMM,
- GTH_SUBFOLDER_FORMAT_YYYY,
- GTH_SUBFOLDER_FORMAT_CUSTOM
-} GthSubfolderFormat;
-
-
-#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_FORMAT "/apps/gthumb/ext/photo_importer/subfolder_format"
-#define PREF_PHOTO_IMPORT_SUBFOLDER_SINGLE "/apps/gthumb/ext/photo_importer/subfolder_single"
-#define PREF_PHOTO_IMPORT_SUBFOLDER_CUSTOM_FORMAT "/apps/gthumb/ext/photo_importer/subfolder_custom_format"
-#define PREF_PHOTO_IMPORT_DELETE "/apps/gthumb/ext/photo_importer/delete_from_camera"
-#define PREF_PHOTO_IMPORT_OVERWRITE "/apps/gthumb/ext/photo_importer/overwrite_files"
-#define PREF_PHOTO_IMPORT_ADJUST_ORIENTATION "/apps/gthumb/ext/photo_importer/adjust_orientation"
-
+#define PREF_PHOTO_IMPORT_DELETE "/apps/gthumb/ext/photo_importer/delete_from_device"
G_END_DECLS
diff --git a/extensions/picasaweb/Makefile.am b/extensions/picasaweb/Makefile.am
index 2261800..5e68a11 100644
--- a/extensions/picasaweb/Makefile.am
+++ b/extensions/picasaweb/Makefile.am
@@ -38,7 +38,7 @@ libpicasaweb_la_SOURCES = \
libpicasaweb_la_CFLAGS = $(GTHUMB_CFLAGS) $(LIBSOUP_CFLAGS) $(GNOME_KEYRING_CFLAGS) -I$(top_srcdir) -I$(top_builddir)/gthumb
libpicasaweb_la_LDFLAGS = $(EXTENSION_LIBTOOL_FLAGS)
-libpicasaweb_la_LIBADD = $(GTHUMB_LIBS)
+libpicasaweb_la_LIBADD = $(GTHUMB_LIBS)
libpicasaweb_la_DEPENDENCIES = $(top_builddir)/gthumb/gthumb$(EXEEXT)
extensioninidir = $(extensiondir)
diff --git a/extensions/picasaweb/data/ui/import-from-picasaweb.ui b/extensions/picasaweb/data/ui/import-from-picasaweb.ui
index 937002e..5f6529e 100644
--- a/extensions/picasaweb/data/ui/import-from-picasaweb.ui
+++ b/extensions/picasaweb/data/ui/import-from-picasaweb.ui
@@ -14,7 +14,7 @@
</object>
<object class="GtkDialog" id="import_dialog">
<property name="border_width">5</property>
- <property name="title" translatable="yes">Import</property>
+ <property name="title" translatable="yes">Import from Picasa Web Album</property>
<property name="type_hint">dialog</property>
<property name="has_separator">False</property>
<child internal-child="vbox">
@@ -250,294 +250,6 @@
<property name="visible">True</property>
<property name="stock">gtk-goto-bottom</property>
</object>
- <object class="GtkDialog" id="preferences_dialog">
- <property name="border_width">5</property>
- <property name="title" translatable="yes">Preferences</property>
- <property name="resizable">False</property>
- <property name="modal">True</property>
- <property name="type_hint">dialog</property>
- <property name="transient_for">import_dialog</property>
- <property name="has_separator">False</property>
- <child internal-child="vbox">
- <object class="GtkVBox" id="dialog-vbox4">
- <property name="visible">True</property>
- <property name="orientation">vertical</property>
- <property name="spacing">2</property>
- <child>
- <object class="GtkVBox" id="vbox2">
- <property name="visible">True</property>
- <property name="border_width">5</property>
- <property name="orientation">vertical</property>
- <property name="spacing">12</property>
- <child>
- <object class="GtkFrame" id="frame1">
- <property name="visible">True</property>
- <property name="label_xalign">0</property>
- <property name="shadow_type">none</property>
- <child>
- <object class="GtkAlignment" id="alignment2">
- <property name="visible">True</property>
- <property name="top_padding">6</property>
- <property name="left_padding">12</property>
- <child>
- <object class="GtkVBox" id="vbox3">
- <property name="visible">True</property>
- <property name="orientation">vertical</property>
- <property name="spacing">6</property>
- <child>
- <object class="GtkHBox" id="hbox2">
- <property name="visible">True</property>
- <property name="spacing">6</property>
- <child>
- <object class="GtkFileChooserButton" id="destination_filechooserbutton">
- <property name="visible">True</property>
- <property name="create_folders">False</property>
- <property name="local_only">False</property>
- <property name="action">select-folder</property>
- </object>
- <packing>
- <property name="position">0</property>
- </packing>
- </child>
- </object>
- <packing>
- <property name="expand">False</property>
- <property name="position">0</property>
- </packing>
- </child>
- </object>
- </child>
- </object>
- </child>
- <child type="label">
- <object class="GtkLabel" id="label2">
- <property name="visible">True</property>
- <property name="label" translatable="yes">Destination</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">0</property>
- </packing>
- </child>
- <child>
- <object class="GtkVBox" id="vbox6">
- <property name="visible">True</property>
- <property name="orientation">vertical</property>
- <child>
- <object class="GtkCheckButton" id="autosubfolder_checkbutton">
- <property name="visible">True</property>
- <property name="can_focus">True</property>
- <property name="receives_default">False</property>
- <property name="draw_indicator">True</property>
- <child>
- <object class="GtkLabel" id="label4">
- <property name="visible">True</property>
- <property name="label" translatable="yes">_Automatic subfolder</property>
- <property name="use_underline">True</property>
- <attributes>
- <attribute name="weight" value="bold"/>
- </attributes>
- </object>
- </child>
- </object>
- <packing>
- <property name="position">0</property>
- </packing>
- </child>
- <child>
- <object class="GtkAlignment" id="alignment1">
- <property name="visible">True</property>
- <property name="top_padding">6</property>
- <property name="left_padding">14</property>
- <child>
- <object class="GtkHBox" id="subfolder_type_box">
- <property name="visible">True</property>
- <property name="spacing">6</property>
- <child>
- <placeholder/>
- </child>
- <child>
- <object class="GtkNotebook" id="subfolder_options_notebook">
- <property name="visible">True</property>
- <property name="show_tabs">False</property>
- <property name="show_border">False</property>
- <child>
- <object class="GtkCheckButton" id="single_subfolder_checkbutton">
- <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>
- </child>
- <child type="tab">
- <placeholder/>
- </child>
- <child>
- <object class="GtkEntry" id="custom_format_entry">
- <property name="visible">True</property>
- <property name="can_focus">True</property>
- <property name="invisible_char">●</property>
- </object>
- <packing>
- <property name="position">1</property>
- </packing>
- </child>
- <child type="tab">
- <placeholder/>
- </child>
- <child>
- <placeholder/>
- </child>
- <child type="tab">
- <placeholder/>
- </child>
- </object>
- <packing>
- <property name="pack_type">end</property>
- <property name="position">1</property>
- </packing>
- </child>
- </object>
- </child>
- </object>
- <packing>
- <property name="position">1</property>
- </packing>
- </child>
- <child>
- <object class="GtkAlignment" id="alignment3">
- <property name="visible">True</property>
- <property name="top_padding">6</property>
- <property name="left_padding">14</property>
- <child>
- <object class="GtkLabel" id="example_label">
- <property name="visible">True</property>
- <property name="xalign">0</property>
- <property name="label">example: file:///home/paolo/images/2009/08/12</property>
- <attributes>
- <attribute name="size" value="8500"/>
- </attributes>
- </object>
- </child>
- </object>
- <packing>
- <property name="expand">False</property>
- <property name="position">2</property>
- </packing>
- </child>
- </object>
- <packing>
- <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>
- </object>
- </child>
- </object>
- </child>
- <child type="label">
- <object class="GtkLabel" id="label5">
- <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="position">2</property>
- </packing>
- </child>
- </object>
- <packing>
- <property name="expand">False</property>
- <property name="position">1</property>
- </packing>
- </child>
- <child internal-child="action_area">
- <object class="GtkHButtonBox" id="dialog-action_area4">
- <property name="visible">True</property>
- <property name="layout_style">end</property>
- <child>
- <object class="GtkButton" id="p_close_button">
- <property name="label">gtk-close</property>
- <property name="visible">True</property>
- <property name="can_focus">True</property>
- <property name="receives_default">True</property>
- <property name="use_stock">True</property>
- </object>
- <packing>
- <property name="expand">False</property>
- <property name="fill">False</property>
- <property name="position">0</property>
- </packing>
- </child>
- <child>
- <object class="GtkButton" id="help_button">
- <property name="label">gtk-help</property>
- <property name="visible">True</property>
- <property name="can_focus">True</property>
- <property name="receives_default">True</property>
- <property name="use_stock">True</property>
- </object>
- <packing>
- <property name="expand">False</property>
- <property name="fill">False</property>
- <property name="position">1</property>
- <property name="secondary">True</property>
- </packing>
- </child>
- </object>
- <packing>
- <property name="expand">False</property>
- <property name="pack_type">end</property>
- <property name="position">0</property>
- </packing>
- </child>
- </object>
- </child>
- <action-widgets>
- <action-widget response="0">p_close_button</action-widget>
- <action-widget response="0">help_button</action-widget>
- </action-widgets>
- </object>
<object class="GtkListStore" id="album_liststore">
<columns>
<!-- column-name data -->
diff --git a/extensions/picasaweb/dlg-import-from-picasaweb.c b/extensions/picasaweb/dlg-import-from-picasaweb.c
index 9382394..7831c05 100644
--- a/extensions/picasaweb/dlg-import-from-picasaweb.c
+++ b/extensions/picasaweb/dlg-import-from-picasaweb.c
@@ -61,6 +61,7 @@ typedef struct {
GthFileData *location;
GtkBuilder *builder;
GtkWidget *dialog;
+ GtkWidget *preferences_dialog;
GtkWidget *progress_dialog;
GtkWidget *file_list;
GList *accounts;
@@ -860,6 +861,14 @@ file_list_selection_changed_cb (GtkIconView *iconview,
}
+static void
+preferences_button_clicked_cb (GtkWidget *widget,
+ DialogData *data)
+{
+ gtk_window_present (GTK_WINDOW (data->preferences_dialog));
+}
+
+
void
dlg_import_from_picasaweb (GthBrowser *browser)
{
@@ -915,6 +924,9 @@ dlg_import_from_picasaweb (GthBrowser *browser)
gtk_widget_set_sensitive (GET_WIDGET ("download_button"), FALSE);
+ data->preferences_dialog = gth_import_preferences_dialog_new ();
+ gtk_window_set_transient_for (GTK_WINDOW (data->preferences_dialog), GTK_WINDOW (data->dialog));
+
/* Set the signals handlers. */
g_signal_connect (G_OBJECT (data->dialog),
@@ -941,6 +953,10 @@ dlg_import_from_picasaweb (GthBrowser *browser)
"selection_changed",
G_CALLBACK (file_list_selection_changed_cb),
data);
+ g_signal_connect (GET_WIDGET ("preferences_button"),
+ "clicked",
+ G_CALLBACK (preferences_button_clicked_cb),
+ data);
data->accounts = picasa_web_accounts_load_from_file (&data->email);
auto_select_account (data);
diff --git a/gthumb/Makefile.am b/gthumb/Makefile.am
index a30d276..b7575c5 100644
--- a/gthumb/Makefile.am
+++ b/gthumb/Makefile.am
@@ -72,6 +72,7 @@ PUBLIC_HEADER_FILES = \
gth-image-selector.h \
gth-image-viewer.h \
gth-image-viewer-tool.h \
+ gth-import-preferences-dialog.h \
gth-location-chooser.h \
gth-main.h \
gth-metadata.h \
@@ -182,6 +183,7 @@ gthumb_SOURCES = \
gth-image-selector.c \
gth-image-viewer.c \
gth-image-viewer-tool.c \
+ gth-import-preferences-dialog.c \
gth-location-chooser.c \
gth-main.c \
gth-main-default-hooks.c \
diff --git a/gthumb/gth-import-preferences-dialog.c b/gthumb/gth-import-preferences-dialog.c
new file mode 100644
index 0000000..cda4346
--- /dev/null
+++ b/gthumb/gth-import-preferences-dialog.c
@@ -0,0 +1,551 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
+
+/*
+ * GThumb
+ *
+ * Copyright (C) 2010 Free Software Foundation, Inc.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Street #330, Boston, MA 02111-1307, USA.
+ */
+
+#include <config.h>
+#include <glib/gi18n.h>
+#include "gth-import-preferences-dialog.h"
+#include "gth-enum-types.h"
+#include "gth-file-data.h"
+#include "gth-metadata.h"
+#include "gth-preferences.h"
+#include "gtk-utils.h"
+#include "gconf-utils.h"
+#include "glib-utils.h"
+#include "typedefs.h"
+
+
+#define GET_WIDGET(x) (_gtk_builder_get_widget (self->priv->builder, (x)))
+
+
+static gpointer parent_class = NULL;
+
+
+struct _GthImportPreferencesDialogPrivate {
+ GtkBuilder *builder;
+ GtkWidget *subfolder_type_list;
+ GtkWidget *subfolder_format_list;
+ char *event;
+};
+
+
+static void
+gth_import_preferences_dialog_finalize (GObject *object)
+{
+ GthImportPreferencesDialog *self;
+
+ self = GTH_IMPORT_PREFERENCES_DIALOG (object);
+
+ _g_object_unref (self->priv->builder);
+ g_free (self->priv->event);
+
+ G_OBJECT_CLASS (parent_class)->finalize (object);
+}
+
+
+static void
+gth_import_preferences_dialog_class_init (GthImportPreferencesDialogClass *klass)
+{
+ GObjectClass *object_class;
+
+ parent_class = g_type_class_peek_parent (klass);
+ g_type_class_add_private (klass, sizeof (GthImportPreferencesDialogPrivate));
+
+ object_class = (GObjectClass*) klass;
+ object_class->finalize = gth_import_preferences_dialog_finalize;
+}
+
+
+static GthSubfolderType
+get_subfolder_type (GthImportPreferencesDialog *self)
+{
+ if (! gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (GET_WIDGET ("autosubfolder_checkbutton"))))
+ return GTH_SUBFOLDER_TYPE_NONE;
+ else
+ return gtk_combo_box_get_active (GTK_COMBO_BOX (self->priv->subfolder_type_list)) + 1;
+}
+
+
+static void
+save_options (GthImportPreferencesDialog *self)
+{
+ GFile *destination;
+ gboolean single_subfolder;
+ 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) {
+ char *uri;
+
+ uri = g_file_get_uri (destination);
+ eel_gconf_set_string (PREF_IMPORT_DESTINATION, uri);
+
+ g_free (uri);
+ }
+
+ single_subfolder = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (GET_WIDGET ("single_subfolder_checkbutton")));
+ eel_gconf_set_boolean (PREF_IMPORT_SUBFOLDER_SINGLE, single_subfolder);
+
+ subfolder_type = get_subfolder_type (self);
+ eel_gconf_set_enum (PREF_IMPORT_SUBFOLDER_TYPE, GTH_TYPE_SUBFOLDER_TYPE, subfolder_type);
+
+ subfolder_format = gtk_combo_box_get_active (GTK_COMBO_BOX (self->priv->subfolder_format_list));
+ eel_gconf_set_enum (PREF_IMPORT_SUBFOLDER_FORMAT, GTH_TYPE_SUBFOLDER_FORMAT, subfolder_format);
+
+ 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);
+}
+
+
+static void
+save_and_hide (GthImportPreferencesDialog *self)
+{
+ save_options (self);
+ gtk_widget_hide (GTK_WIDGET (self));
+}
+
+
+static gboolean
+preferences_dialog_delete_event_cb (GtkWidget *widget,
+ GdkEvent *event,
+ gpointer user_data)
+{
+ save_and_hide ((GthImportPreferencesDialog *) user_data);
+ return TRUE;
+}
+
+
+static GthFileData *
+create_example_file_data (void)
+{
+ GFile *file;
+ GFileInfo *info;
+ GthFileData *file_data;
+ GthMetadata *metadata;
+
+ file = g_file_new_for_uri ("file://home/user/document.txt");
+ info = g_file_info_new ();
+ file_data = gth_file_data_new (file, info);
+
+ metadata = g_object_new (GTH_TYPE_METADATA,
+ "raw", "2005:03:09 13:23:51",
+ "formatted", "2005:03:09 13:23:51",
+ NULL);
+ g_file_info_set_attribute_object (info, "Embedded::Photo::DateTimeOriginal", G_OBJECT (metadata));
+
+ g_object_unref (metadata);
+ g_object_unref (info);
+ g_object_unref (file);
+
+ return file_data;
+}
+
+
+static void
+update_destination (GthImportPreferencesDialog *self)
+{
+ GFile *destination;
+ GthSubfolderType subfolder_type;
+ GthSubfolderFormat subfolder_format;
+ gboolean single_subfolder;
+ const char *custom_format;
+ GthFileData *example_data;
+ GFile *destination_example;
+ char *uri;
+ char *example;
+
+ destination = gtk_file_chooser_get_current_folder_file (GTK_FILE_CHOOSER (GET_WIDGET ("destination_filechooserbutton")));
+ if (destination == NULL)
+ return;
+
+ subfolder_type = get_subfolder_type (self);
+ subfolder_format = gtk_combo_box_get_active (GTK_COMBO_BOX (self->priv->subfolder_format_list));
+ single_subfolder = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (GET_WIDGET ("single_subfolder_checkbutton")));
+ custom_format = gtk_entry_get_text (GTK_ENTRY (GET_WIDGET ("custom_format_entry")));
+
+ example_data = create_example_file_data ();
+ destination_example = gth_import_utils_get_file_destination (example_data,
+ destination,
+ subfolder_type,
+ subfolder_format,
+ single_subfolder,
+ custom_format,
+ self->priv->event);
+
+ uri = g_file_get_parse_name (destination_example);
+ example = g_strdup_printf (_("example: %s"), uri);
+ gtk_label_set_text (GTK_LABEL (GET_WIDGET ("example_label")), example);
+
+ gtk_widget_set_sensitive (GET_WIDGET ("single_subfolder_checkbutton"), subfolder_type != GTH_SUBFOLDER_TYPE_NONE);
+ gtk_widget_set_sensitive (self->priv->subfolder_type_list, subfolder_type != GTH_SUBFOLDER_TYPE_NONE);
+ gtk_widget_set_sensitive (self->priv->subfolder_format_list, subfolder_type != GTH_SUBFOLDER_TYPE_NONE);
+ gtk_widget_set_sensitive (GET_WIDGET ("subfolder_options_notebook"), subfolder_type != GTH_SUBFOLDER_TYPE_NONE);
+
+ gtk_notebook_set_current_page (GTK_NOTEBOOK (GET_WIDGET ("subfolder_options_notebook")), (subfolder_format == GTH_SUBFOLDER_FORMAT_CUSTOM) ? 1 : 0);
+
+ g_free (example);
+ g_free (uri);
+ g_object_unref (destination_example);
+ g_object_unref (example_data);
+ g_object_unref (destination);
+}
+
+
+static gboolean
+preferences_dialog_map_event_cb (GtkWidget *widget,
+ GdkEvent *event,
+ gpointer user_data)
+{
+ update_destination ((GthImportPreferencesDialog *) user_data);
+ return FALSE;
+}
+
+
+static void
+subfolder_type_list_changed_cb (GtkWidget *widget,
+ gpointer user_data)
+{
+ update_destination ((GthImportPreferencesDialog *) user_data);
+}
+
+
+static void
+subfolder_format_list_changed_cb (GtkWidget *widget,
+ gpointer user_data)
+{
+ update_destination ((GthImportPreferencesDialog *) user_data);
+}
+
+
+static void
+destination_selection_changed_cb (GtkWidget *widget,
+ gpointer *user_data)
+{
+ update_destination ((GthImportPreferencesDialog *) user_data);
+}
+
+
+static void
+subfolder_hierarchy_checkbutton_toggled_cb (GtkWidget *widget,
+ gpointer *user_data)
+{
+ update_destination ((GthImportPreferencesDialog *) user_data);
+}
+
+
+static void
+autosubfolder_checkbutton_toggled_cb (GtkToggleButton *togglebutton,
+ gpointer *user_data)
+{
+ update_destination ((GthImportPreferencesDialog *) user_data);
+}
+
+
+static void
+custom_format_entry_changed_cb (GtkEditable *editable,
+ gpointer *user_data)
+{
+ update_destination ((GthImportPreferencesDialog *) user_data);
+}
+
+
+static void
+dialog_response_cb (GtkDialog *dialog,
+ int response_id,
+ gpointer user_data)
+{
+ GthImportPreferencesDialog *self = user_data;
+
+ if ((response_id == GTK_RESPONSE_DELETE_EVENT) || (response_id == GTK_RESPONSE_CLOSE))
+ save_and_hide (self);
+}
+
+
+static void
+gth_import_preferences_dialog_init (GthImportPreferencesDialog *self)
+{
+ GtkWidget *content;
+ GFile *destination;
+ GthSubfolderType subfolder_type;
+ char *custom_format;
+
+ self->priv = G_TYPE_INSTANCE_GET_PRIVATE (self, GTH_TYPE_IMPORT_PREFERENCES_DIALOG, GthImportPreferencesDialogPrivate);
+ self->priv->builder = _gtk_builder_new_from_file ("import-preferences.ui", NULL);
+
+ gtk_window_set_title (GTK_WINDOW (self), _("Preferences"));
+ gtk_window_set_resizable (GTK_WINDOW (self), FALSE);
+ gtk_dialog_set_has_separator (GTK_DIALOG (self), FALSE);
+ gtk_box_set_spacing (GTK_BOX (gtk_dialog_get_content_area (GTK_DIALOG (self))), 5);
+ gtk_container_set_border_width (GTK_CONTAINER (self), 5);
+
+ content = _gtk_builder_get_widget (self->priv->builder, "import_preferences");
+ gtk_container_set_border_width (GTK_CONTAINER (content), 5);
+ gtk_box_pack_start (GTK_BOX (gtk_dialog_get_content_area (GTK_DIALOG (self))), content, TRUE, TRUE, 0);
+
+ /* subfolder type */
+
+ self->priv->subfolder_type_list = _gtk_combo_box_new_with_texts (_("File date"),
+ _("Current date"),
+ NULL);
+ gtk_combo_box_set_active (GTK_COMBO_BOX (self->priv->subfolder_type_list), 0);
+ gtk_widget_show (self->priv->subfolder_type_list);
+ gtk_box_pack_start (GTK_BOX (GET_WIDGET ("subfolder_type_box")), self->priv->subfolder_type_list, TRUE, TRUE, 0);
+ /*gtk_label_set_mnemonic_widget (GTK_LABEL (GET_WIDGET ("subfolder_label")), self->priv->subfolder_type_list);*/
+
+ /* subfolder format */
+
+ self->priv->subfolder_format_list = _gtk_combo_box_new_with_texts (_("year-month-day"),
+ _("year-month"),
+ _("year"),
+ _("custom format"),
+ NULL);
+ gtk_combo_box_set_active (GTK_COMBO_BOX (self->priv->subfolder_format_list), 0);
+ gtk_widget_show (self->priv->subfolder_format_list);
+ gtk_box_pack_start (GTK_BOX (GET_WIDGET ("subfolder_type_box")), self->priv->subfolder_format_list, TRUE, TRUE, 0);
+
+ gtk_dialog_add_button (GTK_DIALOG (self),
+ GTK_STOCK_CLOSE,
+ GTK_RESPONSE_CLOSE);
+
+ /* set widget data */
+
+ destination = gth_import_preferences_get_destination ();
+ 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);
+ gtk_combo_box_set_active (GTK_COMBO_BOX (self->priv->subfolder_type_list), (subfolder_type == 0) ? 0 : subfolder_type - 1);
+ gtk_combo_box_set_active (GTK_COMBO_BOX (self->priv->subfolder_format_list), eel_gconf_get_enum (PREF_IMPORT_SUBFOLDER_FORMAT, GTH_TYPE_SUBFOLDER_FORMAT, GTH_SUBFOLDER_FORMAT_YYYYMMDD));
+
+ custom_format = eel_gconf_get_string (PREF_IMPORT_SUBFOLDER_CUSTOM_FORMAT, "");
+ if (custom_format != NULL) {
+ gtk_entry_set_text (GTK_ENTRY (GET_WIDGET ("custom_format_entry")), custom_format);
+ g_free (custom_format);
+ }
+
+ update_destination (self);
+
+ g_signal_connect (self->priv->subfolder_type_list,
+ "changed",
+ G_CALLBACK (subfolder_type_list_changed_cb),
+ self);
+ g_signal_connect (self->priv->subfolder_format_list,
+ "changed",
+ G_CALLBACK (subfolder_format_list_changed_cb),
+ self);
+ g_signal_connect (GET_WIDGET ("destination_filechooserbutton"),
+ "selection_changed",
+ G_CALLBACK (destination_selection_changed_cb),
+ self);
+ g_signal_connect (GET_WIDGET ("single_subfolder_checkbutton"),
+ "toggled",
+ G_CALLBACK (subfolder_hierarchy_checkbutton_toggled_cb),
+ self);
+ g_signal_connect (self,
+ "map-event",
+ G_CALLBACK (preferences_dialog_map_event_cb),
+ self);
+ g_signal_connect (self,
+ "delete-event",
+ G_CALLBACK (preferences_dialog_delete_event_cb),
+ self);
+ g_signal_connect (GET_WIDGET ("autosubfolder_checkbutton"),
+ "toggled",
+ G_CALLBACK (autosubfolder_checkbutton_toggled_cb),
+ self);
+ g_signal_connect (GET_WIDGET ("custom_format_entry"),
+ "changed",
+ G_CALLBACK (custom_format_entry_changed_cb),
+ self);
+ g_signal_connect (self,
+ "response",
+ G_CALLBACK (dialog_response_cb),
+ self);
+
+ g_object_unref (destination);
+}
+
+
+GType
+gth_import_preferences_dialog_get_type (void)
+{
+ static GType type = 0;
+
+ if (type == 0) {
+ static const GTypeInfo g_define_type_info = {
+ sizeof (GthImportPreferencesDialogClass),
+ (GBaseInitFunc) NULL,
+ (GBaseFinalizeFunc) NULL,
+ (GClassInitFunc) gth_import_preferences_dialog_class_init,
+ (GClassFinalizeFunc) NULL,
+ NULL,
+ sizeof (GthImportPreferencesDialog),
+ 0,
+ (GInstanceInitFunc) gth_import_preferences_dialog_init,
+ NULL
+ };
+ type = g_type_register_static (GTK_TYPE_DIALOG,
+ "GthImportPreferencesDialog",
+ &g_define_type_info,
+ 0);
+ }
+
+ return type;
+}
+
+
+GtkWidget *
+gth_import_preferences_dialog_new (void)
+{
+ return (GtkWidget *) g_object_new (GTH_TYPE_IMPORT_PREFERENCES_DIALOG, NULL);
+}
+
+
+void
+gth_import_preferences_dialog_set_event (GthImportPreferencesDialog *self,
+ const char *event)
+{
+ g_free (self->priv->event);
+ self->priv->event = g_strdup (event);
+}
+
+
+GFile *
+gth_import_preferences_get_destination (void)
+{
+ char *last_destination;
+ GFile *folder;
+
+ last_destination = eel_gconf_get_string (PREF_IMPORT_DESTINATION, NULL);
+ if ((last_destination == NULL) || (*last_destination == 0)) {
+ char *default_path;
+
+ default_path = xdg_user_dir_lookup ("PICTURES");
+ folder = g_file_new_for_path (default_path);
+
+ g_free (default_path);
+ }
+ else
+ folder = g_file_new_for_uri (last_destination);
+
+ g_free (last_destination);
+
+ return folder;
+}
+
+
+GFile *
+gth_import_utils_get_file_destination (GthFileData *file_data,
+ GFile *destination,
+ GthSubfolderType subfolder_type,
+ GthSubfolderFormat subfolder_format,
+ gboolean single_subfolder,
+ const char *custom_format,
+ const char *event_name)
+{
+ GTimeVal timeval;
+ char *child;
+ GFile *file_destination;
+
+ if (subfolder_type == GTH_SUBFOLDER_TYPE_FILE_DATE) {
+ GthMetadata *metadata;
+
+ metadata = (GthMetadata *) g_file_info_get_attribute_object (file_data->info, "Embedded::Photo::DateTimeOriginal");
+ if (metadata != NULL)
+ _g_time_val_from_exif_date (gth_metadata_get_raw (metadata), &timeval);
+ else
+ subfolder_type = GTH_SUBFOLDER_TYPE_CURRENT_DATE;
+ }
+
+ if (subfolder_type == GTH_SUBFOLDER_TYPE_CURRENT_DATE)
+ g_get_current_time (&timeval);
+
+ switch (subfolder_type) {
+ case GTH_SUBFOLDER_TYPE_FILE_DATE:
+ case GTH_SUBFOLDER_TYPE_CURRENT_DATE:
+ if (subfolder_format != GTH_SUBFOLDER_FORMAT_CUSTOM) {
+ GDate *date;
+ char **parts;
+
+ date = g_date_new ();
+ g_date_set_time_val (date, &timeval);
+
+ parts = g_new0 (char *, 4);
+ parts[0] = g_strdup_printf ("%04d", g_date_get_year (date));
+ if (subfolder_format != GTH_SUBFOLDER_FORMAT_YYYY) {
+ parts[1] = g_strdup_printf ("%02d", g_date_get_month (date));
+ if (subfolder_format != GTH_SUBFOLDER_FORMAT_YYYYMM)
+ parts[2] = g_strdup_printf ("%02d", g_date_get_day (date));
+ }
+
+ if (single_subfolder)
+ child = g_strjoinv ("-", parts);
+ else
+ child = g_strjoinv ("/", parts);
+
+ g_strfreev (parts);
+ g_date_free (date);
+ }
+ else {
+ char *format = NULL;
+
+ if (event_name != NULL) {
+ GRegex *re;
+
+ re = g_regex_new ("%E", 0, 0, NULL);
+ format = g_regex_replace_literal (re, custom_format, -1, 0, event_name, 0, NULL);
+
+ g_regex_unref (re);
+ }
+ if (format == NULL)
+ format = g_strdup (custom_format);
+ child = _g_time_val_strftime (&timeval, format);
+
+ g_free (format);
+ }
+ break;
+
+ case GTH_SUBFOLDER_TYPE_NONE:
+ child = NULL;
+ break;
+ }
+ file_destination = _g_file_append_path (destination, child);
+
+ g_free (child);
+
+ return file_destination;
+}
diff --git a/gthumb/gth-import-preferences-dialog.h b/gthumb/gth-import-preferences-dialog.h
new file mode 100644
index 0000000..27c94fb
--- /dev/null
+++ b/gthumb/gth-import-preferences-dialog.h
@@ -0,0 +1,68 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
+
+/*
+ * GThumb
+ *
+ * Copyright (C) 2010 Free Software Foundation, Inc.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Street #330, Boston, MA 02111-1307, USA.
+ */
+
+#ifndef GTH_IMPORT_PREFERENCES_DIALOG_H
+#define GTH_IMPORT_PREFERENCES_DIALOG_H
+
+#include <gtk/gtk.h>
+#include "gth-file-data.h"
+#include "typedefs.h"
+
+G_BEGIN_DECLS
+
+#define GTH_TYPE_IMPORT_PREFERENCES_DIALOG (gth_import_preferences_dialog_get_type ())
+#define GTH_IMPORT_PREFERENCES_DIALOG(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GTH_TYPE_IMPORT_PREFERENCES_DIALOG, GthImportPreferencesDialog))
+#define GTH_IMPORT_PREFERENCES_DIALOG_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GTH_TYPE_IMPORT_PREFERENCES_DIALOG, GthImportPreferencesDialogClass))
+#define GTH_IS_IMPORT_PREFERENCES_DIALOG(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GTH_TYPE_IMPORT_PREFERENCES_DIALOG))
+#define GTH_IS_IMPORT_PREFERENCES_DIALOG_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GTH_TYPE_IMPORT_PREFERENCES_DIALOG))
+#define GTH_IMPORT_PREFERENCES_DIALOG_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GTH_TYPE_IMPORT_PREFERENCES_DIALOG, GthImportPreferencesDialogClass))
+
+typedef struct _GthImportPreferencesDialog GthImportPreferencesDialog;
+typedef struct _GthImportPreferencesDialogClass GthImportPreferencesDialogClass;
+typedef struct _GthImportPreferencesDialogPrivate GthImportPreferencesDialogPrivate;
+
+struct _GthImportPreferencesDialog {
+ GtkDialog parent_instance;
+ GthImportPreferencesDialogPrivate *priv;
+};
+
+struct _GthImportPreferencesDialogClass {
+ GtkDialogClass parent_class;
+};
+
+GType gth_import_preferences_dialog_get_type (void);
+GtkWidget * gth_import_preferences_dialog_new (void);
+void gth_import_preferences_dialog_set_event (GthImportPreferencesDialog *self,
+ const char *event);
+GFile * gth_import_preferences_get_destination (void);
+GFile * gth_import_utils_get_file_destination (GthFileData *file_data,
+ GFile *destination,
+ GthSubfolderType subfolder_type,
+ GthSubfolderFormat subfolder_format,
+ gboolean single_subfolder,
+ const char *custom_format,
+ const char *event_name);
+
+
+G_END_DECLS
+
+#endif /* GTH_IMPORT_PREFERENCES_DIALOG_H */
diff --git a/gthumb/gth-preferences.h b/gthumb/gth-preferences.h
index 1beb287..f3321b9 100644
--- a/gthumb/gth-preferences.h
+++ b/gthumb/gth-preferences.h
@@ -29,55 +29,65 @@
G_BEGIN_DECLS
-#define PREF_DESKTOP_ICON_THEME "/desktop/gnome/file_views/icon_theme"
-
-#define PREF_GO_TO_LAST_LOCATION "/apps/gthumb/general/go_to_last_location"
-#define PREF_USE_STARTUP_LOCATION "/apps/gthumb/general/use_startup_location"
-#define PREF_STARTUP_LOCATION "/apps/gthumb/general/startup_location"
-#define PREF_MAX_HISTORY_LENGTH "/apps/gthumb/general/max_history_length"
-#define PREF_EDITORS "/apps/gthumb/general/editors"
-#define PREF_MIGRATE_DIRECTORIES "/apps/gthumb/general/migrate_directories"
-#define PREF_MIGRATE_COMMENT_SYSTEM "/apps/gthumb/general/migrate_comment_system"
-#define PREF_ACTIVE_EXTENSIONS "/apps/gthumb/general/active_extensions"
-
-#define PREF_GENERAL_FILTER "/apps/gthumb/browser/general_filter"
-#define PREF_SHOW_HIDDEN_FILES "/apps/gthumb/browser/show_hidden_files"
-#define PREF_SHOW_THUMBNAILS "/apps/gthumb/browser/show_thumbnails"
-#define PREF_FAST_FILE_TYPE "/apps/gthumb/browser/fast_file_type"
-#define PREF_SAVE_THUMBNAILS "/apps/gthumb/browser/save_thumbnails"
-#define PREF_THUMBNAIL_SIZE "/apps/gthumb/browser/thumbnail_size"
-#define PREF_THUMBNAIL_LIMIT "/apps/gthumb/browser/thumbnail_limit"
-#define PREF_THUMBNAIL_CAPTION "/apps/gthumb/browser/thumbnail_caption"
-#define PREF_CLICK_POLICY "/apps/gthumb/browser/click_policy"
-#define PREF_SORT_TYPE "/apps/gthumb/browser/sort_type"
-#define PREF_SORT_INVERSE "/apps/gthumb/browser/sort_inverse"
-#define PREF_VIEW_AS "/apps/gthumb/browser/view_as"
-
-#define PREF_ZOOM_QUALITY "/apps/gthumb/viewer/zoom_quality"
-#define PREF_ZOOM_CHANGE "/apps/gthumb/viewer/zoom_change"
-#define PREF_TRANSP_TYPE "/apps/gthumb/viewer/transparency_type"
-#define PREF_RESET_SCROLLBARS "/apps/gthumb/viewer/reset_scrollbars"
-#define PREF_CHECK_TYPE "/apps/gthumb/viewer/check_type"
-#define PREF_CHECK_SIZE "/apps/gthumb/viewer/check_size"
-#define PREF_BLACK_BACKGROUND "/apps/gthumb/viewer/black_background"
-
-#define PREF_UI_TOOLBAR_STYLE "/apps/gthumb/ui/toolbar_style"
-#define PREF_UI_WINDOW_WIDTH "/apps/gthumb/ui/window_width"
-#define PREF_UI_WINDOW_HEIGHT "/apps/gthumb/ui/window_height"
-#define PREF_UI_TOOLBAR_VISIBLE "/apps/gthumb/ui/toolbar_visible"
-#define PREF_UI_STATUSBAR_VISIBLE "/apps/gthumb/ui/statusbar_visible"
-#define PREF_UI_FILTERBAR_VISIBLE "/apps/gthumb/ui/filterbar_visible"
-#define PREF_UI_SIDEBAR_VISIBLE "/apps/gthumb/ui/sidebar_visible"
-#define PREF_UI_BROWSER_SIDEBAR_WIDTH "/apps/gthumb/ui/browser_sidebar_width"
-#define PREF_UI_VIEWER_SIDEBAR_WIDTH "/apps/gthumb/ui/viewer_sidebar_width"
-#define PREF_UI_PROPERTIES_HEIGHT "/apps/gthumb/ui/properties_height"
-#define PREF_UI_COMMENT_HEIGHT "/apps/gthumb/ui/comment_height"
-
-#define PREF_ADD_TO_CATALOG_LAST_CATALOG "/apps/gthumb/dialogs/add_to_catalog/last_catalog"
-#define PREF_ADD_TO_CATALOG_VIEW "/apps/gthumb/dialogs/add_to_catalog/view"
-
-#define PREF_MSG_CANNOT_MOVE_TO_TRASH "/apps/gthumb/dialogs/messages/cannot_move_to_trash"
-#define PREF_MSG_SAVE_MODIFIED_IMAGE "/apps/gthumb/dialogs/messages/save_modified_image"
+#define PREF_DESKTOP_ICON_THEME "/desktop/gnome/file_views/icon_theme"
+
+#define PREF_GO_TO_LAST_LOCATION "/apps/gthumb/general/go_to_last_location"
+#define PREF_USE_STARTUP_LOCATION "/apps/gthumb/general/use_startup_location"
+#define PREF_STARTUP_LOCATION "/apps/gthumb/general/startup_location"
+#define PREF_MAX_HISTORY_LENGTH "/apps/gthumb/general/max_history_length"
+#define PREF_EDITORS "/apps/gthumb/general/editors"
+#define PREF_MIGRATE_DIRECTORIES "/apps/gthumb/general/migrate_directories"
+#define PREF_MIGRATE_COMMENT_SYSTEM "/apps/gthumb/general/migrate_comment_system"
+#define PREF_ACTIVE_EXTENSIONS "/apps/gthumb/general/active_extensions"
+
+#define PREF_GENERAL_FILTER "/apps/gthumb/browser/general_filter"
+#define PREF_SHOW_HIDDEN_FILES "/apps/gthumb/browser/show_hidden_files"
+#define PREF_SHOW_THUMBNAILS "/apps/gthumb/browser/show_thumbnails"
+#define PREF_FAST_FILE_TYPE "/apps/gthumb/browser/fast_file_type"
+#define PREF_SAVE_THUMBNAILS "/apps/gthumb/browser/save_thumbnails"
+#define PREF_THUMBNAIL_SIZE "/apps/gthumb/browser/thumbnail_size"
+#define PREF_THUMBNAIL_LIMIT "/apps/gthumb/browser/thumbnail_limit"
+#define PREF_THUMBNAIL_CAPTION "/apps/gthumb/browser/thumbnail_caption"
+#define PREF_CLICK_POLICY "/apps/gthumb/browser/click_policy"
+#define PREF_SORT_TYPE "/apps/gthumb/browser/sort_type"
+#define PREF_SORT_INVERSE "/apps/gthumb/browser/sort_inverse"
+#define PREF_VIEW_AS "/apps/gthumb/browser/view_as"
+
+#define PREF_ZOOM_QUALITY "/apps/gthumb/viewer/zoom_quality"
+#define PREF_ZOOM_CHANGE "/apps/gthumb/viewer/zoom_change"
+#define PREF_TRANSP_TYPE "/apps/gthumb/viewer/transparency_type"
+#define PREF_RESET_SCROLLBARS "/apps/gthumb/viewer/reset_scrollbars"
+#define PREF_CHECK_TYPE "/apps/gthumb/viewer/check_type"
+#define PREF_CHECK_SIZE "/apps/gthumb/viewer/check_size"
+#define PREF_BLACK_BACKGROUND "/apps/gthumb/viewer/black_background"
+
+#define PREF_UI_TOOLBAR_STYLE "/apps/gthumb/ui/toolbar_style"
+#define PREF_UI_WINDOW_WIDTH "/apps/gthumb/ui/window_width"
+#define PREF_UI_WINDOW_HEIGHT "/apps/gthumb/ui/window_height"
+#define PREF_UI_TOOLBAR_VISIBLE "/apps/gthumb/ui/toolbar_visible"
+#define PREF_UI_STATUSBAR_VISIBLE "/apps/gthumb/ui/statusbar_visible"
+#define PREF_UI_FILTERBAR_VISIBLE "/apps/gthumb/ui/filterbar_visible"
+#define PREF_UI_SIDEBAR_VISIBLE "/apps/gthumb/ui/sidebar_visible"
+#define PREF_UI_BROWSER_SIDEBAR_WIDTH "/apps/gthumb/ui/browser_sidebar_width"
+#define PREF_UI_VIEWER_SIDEBAR_WIDTH "/apps/gthumb/ui/viewer_sidebar_width"
+#define PREF_UI_PROPERTIES_HEIGHT "/apps/gthumb/ui/properties_height"
+#define PREF_UI_COMMENT_HEIGHT "/apps/gthumb/ui/comment_height"
+
+#define PREF_IMPORT_DESTINATION "/apps/gthumb/importer/destination"
+#define PREF_IMPORT_SUBFOLDER_TYPE "/apps/gthumb/importer/subfolder_type"
+#define PREF_IMPORT_SUBFOLDER_FORMAT "/apps/gthumb/importer/subfolder_format"
+#define PREF_IMPORT_SUBFOLDER_SINGLE "/apps/gthumb/importer/subfolder_single"
+#define PREF_IMPORT_SUBFOLDER_CUSTOM_FORMAT "/apps/gthumb/importer/subfolder_custom_format"
+#define PREF_IMPORT_OVERWRITE "/apps/gthumb/importer/overwrite_files"
+#define PREF_IMPORT_ADJUST_ORIENTATION "/apps/gthumb/importer/adjust_orientation"
+
+#define PREF_ADD_TO_CATALOG_LAST_CATALOG "/apps/gthumb/dialogs/add_to_catalog/last_catalog"
+#define PREF_ADD_TO_CATALOG_VIEW "/apps/gthumb/dialogs/add_to_catalog/view"
+
+#define PREF_MSG_CANNOT_MOVE_TO_TRASH "/apps/gthumb/dialogs/messages/cannot_move_to_trash"
+#define PREF_MSG_SAVE_MODIFIED_IMAGE "/apps/gthumb/dialogs/messages/save_modified_image"
+
+/* default values */
#define DEFAULT_GENERAL_FILTER "file::type::is_media"
#define DEFAULT_THUMBNAIL_CAPTION "standard::display-name,gth::file::display-size"
diff --git a/gthumb/typedefs.h b/gthumb/typedefs.h
index 973e51f..14b466a 100644
--- a/gthumb/typedefs.h
+++ b/gthumb/typedefs.h
@@ -108,6 +108,21 @@ typedef enum {
} GthOverwriteMode;
+typedef enum {
+ GTH_SUBFOLDER_TYPE_NONE = 0,
+ GTH_SUBFOLDER_TYPE_FILE_DATE,
+ GTH_SUBFOLDER_TYPE_CURRENT_DATE,
+} GthSubfolderType;
+
+
+typedef enum {
+ GTH_SUBFOLDER_FORMAT_YYYYMMDD,
+ GTH_SUBFOLDER_FORMAT_YYYYMM,
+ GTH_SUBFOLDER_FORMAT_YYYY,
+ GTH_SUBFOLDER_FORMAT_CUSTOM
+} GthSubfolderFormat;
+
+
typedef void (*DataFunc) (gpointer user_data);
typedef void (*ReadyFunc) (GError *error,
gpointer user_data);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]