[gthumb/ext] [photo importer] completed dialog layout; load and save preferences.
- From: Paolo Bacchilega <paobac src gnome org>
- To: svn-commits-list gnome org
- Cc:
- Subject: [gthumb/ext] [photo importer] completed dialog layout; load and save preferences.
- Date: Wed, 12 Aug 2009 18:40:30 +0000 (UTC)
commit 04a68e9a89247b43593e949473db7cc42fc1e2db
Author: Paolo Bacchilega <paobac src gnome org>
Date: Wed Aug 12 20:33:51 2009 +0200
[photo importer] completed dialog layout; load and save preferences.
extensions/photo_importer/Makefile.am | 42 ++-
extensions/photo_importer/data/Makefile.am | 16 +
.../data/gthumb_photo_importer.schemas.in | 57 ++++
.../photo_importer/data/ui/photo-importer.ui | 354 ++++++++++++--------
extensions/photo_importer/dlg-photo-importer.c | 196 +++++++++++-
extensions/photo_importer/preferences.h | 43 +++
gthumb/Makefile.am | 2 +-
gthumb/glib-utils.c | 3 +
gthumb/gth-file-list.c | 35 +--
gthumb/gth-file-store.c | 73 ++++-
gthumb/gth-file-store.h | 5 +
11 files changed, 644 insertions(+), 182 deletions(-)
---
diff --git a/extensions/photo_importer/Makefile.am b/extensions/photo_importer/Makefile.am
index b1f8077..54a5c93 100644
--- a/extensions/photo_importer/Makefile.am
+++ b/extensions/photo_importer/Makefile.am
@@ -3,17 +3,47 @@ SUBDIRS = data
extensiondir = $(libdir)/gthumb-2.0/extensions
extension_LTLIBRARIES = libphoto_importer.la
+ENUM_TYPES = \
+ enum-types.h \
+ enum-types.c
+
+HEADER_FILES = \
+ actions.h \
+ callbacks.h \
+ dlg-photo-importer.h \
+ gth-import-task.h \
+ preferences.h
+
+enum-types.h: $(HEADER_FILES) $(GLIB_MKENUMS)
+ $(GLIB_MKENUMS) \
+ --fhead "#ifndef ENUM_TYPES_H\n#define ENUM_TYPES_H\n\n#include <glib-object.h>\n\nG_BEGIN_DECLS\n" \
+ --fprod "/* enumerations from \"@filename \" */\n" \
+ --vhead "GType @enum_name _get_type (void);\n#define GTH_TYPE_ ENUMSHORT@ (@enum_name _get_type())\n" \
+ --ftail "G_END_DECLS\n\n#endif /* ENUM_TYPES_H */" \
+ $^> xgen-$(@F) \
+ && (cmp -s xgen-$(@F) enum-types.h || cp xgen-$(@F) enum-types.h ) \
+ && rm -f xgen-$(@F)
+
+enum-types.c: $(HEADER_FILES) enum-types.h
+ $(GLIB_MKENUMS) \
+ --fhead "#include <glib-object.h>\n" \
+ --fprod "\n/* enumerations from \"@filename \" */\n#include \"@filename \"" \
+ --vhead "GType\n enum_name@_get_type (void)\n{\n static GType etype = 0;\n if (etype == 0) {\n static const G Type@Value values[] = {" \
+ --vprod " { @VALUENAME@, \"@VALUENAME \", \"@valuenick \" }," \
+ --vtail " { 0, NULL, NULL }\n };\n etype = g_ type@_register_static (\"@EnumName \", values);\n }\n return etype;\n}\n" \
+ $^> xgen-$(@F) \
+ && (cmp -s xgen-$(@F) enum-types.c || cp xgen-$(@F) enum-types.c ) \
+ && rm -f xgen-$(@F)
+
libphoto_importer_la_SOURCES = \
+ $(ENUM_TYPES) \
+ $(HEADER_FILES) \
actions.c \
- actions.h \
callbacks.c \
- callbacks.h \
dlg-photo-importer.c \
- dlg-photo-importer.h \
gth-import-task.c \
- gth-import-task.h \
main.c
-
+
libphoto_importer_la_CFLAGS = $(GTHUMB_CFLAGS) $(DISABLE_DEPRECATED) $(WARNINGS) -I$(top_srcdir) -I$(top_builddir)/gthumb
libphoto_importer_la_LDFLAGS = $(EXTENSION_LIBTOOL_FLAGS)
libphoto_importer_la_LIBADD = $(GTHUMB_LIBS)
@@ -31,6 +61,6 @@ extensionini_DATA = $(extensionini_in_files:.extension.in.in=.extension)
EXTRA_DIST = $(extensionini_in_files)
-DISTCLEANFILES = $(extensionini_DATA)
+DISTCLEANFILES = $(extensionini_DATA)
-include $(top_srcdir)/git.mk
diff --git a/extensions/photo_importer/data/Makefile.am b/extensions/photo_importer/data/Makefile.am
index 4d5385d..a696480 100644
--- a/extensions/photo_importer/data/Makefile.am
+++ b/extensions/photo_importer/data/Makefile.am
@@ -1,2 +1,18 @@
SUBDIRS = ui
+
+schemadir = @GCONF_SCHEMA_FILE_DIR@
+schema_in_files = gthumb_photo_importer.schemas.in
+schema_DATA = $(schema_in_files:.schemas.in=.schemas)
+
+ INTLTOOL_SCHEMAS_RULE@
+
+if GCONF_SCHEMAS_INSTALL
+install-data-local:
+ GCONF_CONFIG_SOURCE=$(GCONF_SCHEMA_CONFIG_SOURCE) $(GCONFTOOL) --makefile-install-rule $(top_builddir)/data/$(schema_DATA)
+endif
+
+EXTRA_DIST = $(schema_in_files)
+
+DISTCLEANFILES = $(schema_DATA)
+
-include $(top_srcdir)/git.mk
diff --git a/extensions/photo_importer/data/gthumb_photo_importer.schemas.in b/extensions/photo_importer/data/gthumb_photo_importer.schemas.in
new file mode 100644
index 0000000..7ba451e
--- /dev/null
+++ b/extensions/photo_importer/data/gthumb_photo_importer.schemas.in
@@ -0,0 +1,57 @@
+<gconfschemafile>
+ <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_day, file_month, today, now, custom
+ </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></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>
+
+ </schemalist>
+</gconfschemafile>
diff --git a/extensions/photo_importer/data/ui/photo-importer.ui b/extensions/photo_importer/data/ui/photo-importer.ui
index 2a9f8a1..40a6d09 100644
--- a/extensions/photo_importer/data/ui/photo-importer.ui
+++ b/extensions/photo_importer/data/ui/photo-importer.ui
@@ -17,160 +17,105 @@
<property name="visible">True</property>
<property name="border_width">5</property>
<property name="orientation">vertical</property>
- <property name="spacing">12</property>
+ <property name="spacing">6</property>
<child>
<object class="GtkHBox" id="hbox3">
<property name="visible">True</property>
<property name="spacing">12</property>
<child>
- <object class="GtkVBox" id="vbox2">
+ <object class="GtkTable" id="table1">
<property name="visible">True</property>
- <property name="orientation">vertical</property>
+ <property name="n_columns">2</property>
+ <property name="column_spacing">6</property>
+ <property name="row_spacing">6</property>
<child>
- <object class="GtkTable" id="table1">
+ <object class="GtkLabel" id="source_label">
+ <property name="visible">True</property>
+ <property name="xalign">0</property>
+ <property name="label" translatable="yes">_Source:</property>
+ <property name="use_underline">True</property>
+ </object>
+ <packing>
+ <property name="x_options">GTK_FILL</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkHBox" id="source_box">
<property name="visible">True</property>
- <property name="n_rows">4</property>
- <property name="n_columns">2</property>
- <property name="column_spacing">6</property>
- <property name="row_spacing">6</property>
- <child>
- <object class="GtkLabel" id="label1">
- <property name="visible">True</property>
- <property name="xalign">0</property>
- <property name="label" translatable="yes">_Destination:</property>
- <property name="use_underline">True</property>
- <property name="mnemonic_widget">destination_filechooserbutton</property>
- </object>
- <packing>
- <property name="top_attach">1</property>
- <property name="bottom_attach">2</property>
- <property name="x_options">GTK_FILL</property>
- </packing>
- </child>
- <child>
- <object class="GtkLabel" id="subfolder_label">
- <property name="visible">True</property>
- <property name="xalign">0</property>
- <property name="label" translatable="yes">S_ubFolder:</property>
- <property name="use_underline">True</property>
- </object>
- <packing>
- <property name="top_attach">2</property>
- <property name="bottom_attach">3</property>
- <property name="x_options">GTK_FILL</property>
- </packing>
- </child>
- <child>
- <object class="GtkLabel" id="label3">
- <property name="visible">True</property>
- <property name="xalign">0</property>
- <property name="label" translatable="yes">_Tags:</property>
- <property name="use_underline">True</property>
- <property name="mnemonic_widget">tags_entry</property>
- </object>
- <packing>
- <property name="top_attach">3</property>
- <property name="bottom_attach">4</property>
- <property name="x_options">GTK_FILL</property>
- </packing>
- </child>
- <child>
- <object class="GtkFileChooserButton" id="destination_filechooserbutton">
- <property name="visible">True</property>
- <property name="action">select-folder</property>
- </object>
- <packing>
- <property name="left_attach">1</property>
- <property name="right_attach">2</property>
- <property name="top_attach">1</property>
- <property name="bottom_attach">2</property>
- </packing>
- </child>
- <child>
- <object class="GtkEntry" id="tags_entry">
- <property name="visible">True</property>
- <property name="can_focus">True</property>
- <property name="invisible_char">●</property>
- </object>
- <packing>
- <property name="left_attach">1</property>
- <property name="right_attach">2</property>
- <property name="top_attach">3</property>
- <property name="bottom_attach">4</property>
- </packing>
- </child>
- <child>
- <object class="GtkHBox" id="subfolder_box">
- <property name="visible">True</property>
- <property name="spacing">6</property>
- <child>
- <object class="GtkHBox" id="subfolder_type_box">
- <property name="visible">True</property>
- <child>
- <placeholder/>
- </child>
- </object>
- <packing>
- <property name="position">0</property>
- </packing>
- </child>
- <child>
- <object class="GtkEntry" id="subfolder_entry">
- <property name="visible">True</property>
- <property name="can_focus">True</property>
- <property name="invisible_char">●</property>
- </object>
- <packing>
- <property name="expand">False</property>
- <property name="position">1</property>
- </packing>
- </child>
- </object>
- <packing>
- <property name="left_attach">1</property>
- <property name="right_attach">2</property>
- <property name="top_attach">2</property>
- <property name="bottom_attach">3</property>
- </packing>
- </child>
<child>
- <object class="GtkLabel" id="source_label">
- <property name="visible">True</property>
- <property name="xalign">0</property>
- <property name="label" translatable="yes">_Source:</property>
- <property name="use_underline">True</property>
- </object>
- <packing>
- <property name="x_options">GTK_FILL</property>
- </packing>
+ <placeholder/>
</child>
+ </object>
+ <packing>
+ <property name="left_attach">1</property>
+ <property name="right_attach">2</property>
+ </packing>
+ </child>
+ </object>
+ <packing>
+ <property name="position">0</property>
+ </packing>
+ </child>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="position">0</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkHBox" id="hbox4">
+ <property name="visible">True</property>
+ <property name="spacing">6</property>
+ <child>
+ <object class="GtkLabel" id="status_label">
+ <property name="visible">True</property>
+ <property name="xalign">0</property>
+ <property name="use_underline">True</property>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="position">0</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkHBox" id="hbox1">
+ <property name="visible">True</property>
+ <property name="spacing">6</property>
+ <child>
+ <object class="GtkLabel" id="filter_label">
+ <property name="visible">True</property>
+ <property name="xalign">0</property>
+ <property name="label" translatable="yes">S_how:</property>
+ <property name="use_underline">True</property>
+ </object>
+ <packing>
+ <property name="position">0</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkHBox" id="filter_box">
+ <property name="visible">True</property>
+ <property name="spacing">6</property>
<child>
- <object class="GtkHBox" id="source_box">
- <property name="visible">True</property>
- <child>
- <placeholder/>
- </child>
- </object>
- <packing>
- <property name="left_attach">1</property>
- <property name="right_attach">2</property>
- </packing>
+ <placeholder/>
</child>
</object>
<packing>
<property name="expand">False</property>
- <property name="position">0</property>
+ <property name="position">1</property>
</packing>
</child>
</object>
<packing>
- <property name="position">0</property>
+ <property name="expand">False</property>
+ <property name="pack_type">end</property>
+ <property name="position">1</property>
</packing>
</child>
</object>
<packing>
<property name="expand">False</property>
- <property name="position">0</property>
+ <property name="position">1</property>
</packing>
</child>
<child>
@@ -207,7 +152,8 @@
</object>
<packing>
<property name="expand">False</property>
- <property name="position">0</property>
+ <property name="pack_type">end</property>
+ <property name="position">1</property>
</packing>
</child>
<child>
@@ -220,42 +166,156 @@
</object>
<packing>
<property name="expand">False</property>
- <property name="position">1</property>
+ <property name="pack_type">end</property>
+ <property name="position">0</property>
</packing>
</child>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="position">1</property>
+ </packing>
+ </child>
+ </object>
+ <packing>
+ <property name="position">2</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkTable" id="table3">
+ <property name="visible">True</property>
+ <property name="n_columns">2</property>
+ <property name="column_spacing">6</property>
+ <property name="row_spacing">5</property>
+ <child>
+ <object class="GtkLabel" id="label5">
+ <property name="visible">True</property>
+ <property name="xalign">0</property>
+ <property name="label" translatable="yes">_Tags:</property>
+ <property name="use_underline">True</property>
+ <property name="mnemonic_widget">tags_entry</property>
+ </object>
+ <packing>
+ <property name="x_options">GTK_FILL</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkEntry" id="tags_entry">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="invisible_char">●</property>
+ </object>
+ <packing>
+ <property name="left_attach">1</property>
+ <property name="right_attach">2</property>
+ </packing>
+ </child>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="position">3</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkExpander" id="expander1">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <child>
+ <object class="GtkAlignment" id="alignment1">
+ <property name="visible">True</property>
+ <property name="top_padding">6</property>
+ <property name="left_padding">12</property>
<child>
- <object class="GtkHBox" id="filter_box">
+ <object class="GtkVBox" id="vbox4">
<property name="visible">True</property>
+ <property name="orientation">vertical</property>
<property name="spacing">6</property>
<child>
- <object class="GtkLabel" id="filter_label">
+ <object class="GtkHBox" id="hbox2">
<property name="visible">True</property>
- <property name="label" translatable="yes">S_how:</property>
- <property name="use_underline">True</property>
+ <property name="spacing">6</property>
+ <child>
+ <object class="GtkFileChooserButton" id="destination_filechooserbutton">
+ <property name="visible">True</property>
+ <property name="local_only">False</property>
+ <property name="action">select-folder</property>
+ </object>
+ <packing>
+ <property name="position">0</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkLabel" id="label2">
+ <property name="visible">True</property>
+ <property name="xalign">0</property>
+ <property name="label" translatable="yes">+</property>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="position">1</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkHBox" id="subfolder_type_box">
+ <property name="visible">True</property>
+ <property name="spacing">6</property>
+ <child>
+ <placeholder/>
+ </child>
+ <child>
+ <object class="GtkCheckButton" id="single_subfolder_checkbutton">
+ <property name="label" translatable="yes">single folder</property>
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="receives_default">False</property>
+ <property name="draw_indicator">True</property>
+ </object>
+ <packing>
+ <property name="pack_type">end</property>
+ <property name="position">1</property>
+ </packing>
+ </child>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="position">2</property>
+ </packing>
+ </child>
</object>
<packing>
+ <property name="expand">False</property>
<property name="position">0</property>
</packing>
</child>
<child>
- <placeholder/>
+ <object class="GtkLabel" id="example_label">
+ <property name="visible">True</property>
+ <property name="xalign">0</property>
+ <property name="label" translatable="yes">example: file:///home/paolo/images/2009/08/12</property>
+ <attributes>
+ <attribute name="size" value="8500"/>
+ </attributes>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="position">1</property>
+ </packing>
</child>
</object>
- <packing>
- <property name="expand">False</property>
- <property name="pack_type">end</property>
- <property name="position">2</property>
- </packing>
</child>
</object>
- <packing>
- <property name="expand">False</property>
- <property name="position">1</property>
- </packing>
+ </child>
+ <child type="label">
+ <object class="GtkLabel" id="label4">
+ <property name="visible">True</property>
+ <property name="label" translatable="yes">_Destination</property>
+ <property name="use_underline">True</property>
+ </object>
</child>
</object>
<packing>
- <property name="position">1</property>
+ <property name="expand">False</property>
+ <property name="position">4</property>
</packing>
</child>
</object>
diff --git a/extensions/photo_importer/dlg-photo-importer.c b/extensions/photo_importer/dlg-photo-importer.c
index 5eb65dc..eab5a3a 100644
--- a/extensions/photo_importer/dlg-photo-importer.c
+++ b/extensions/photo_importer/dlg-photo-importer.c
@@ -24,7 +24,9 @@
#include <gtk/gtk.h>
#include <gthumb.h>
#include "dlg-photo-importer.h"
+#include "enum-types.h"
#include "gth-import-task.h"
+#include "preferences.h"
enum {
@@ -64,9 +66,22 @@ static void
destroy_dialog (gpointer user_data)
{
DialogData *data = user_data;
+ GFile *destination;
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);
+ }
+ eel_gconf_set_boolean (PREF_PHOTO_IMPORT_SUBFOLDER_SINGLE, gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (GET_WIDGET ("single_subfolder_checkbutton"))));
+ eel_gconf_set_enum (PREF_PHOTO_IMPORT_SUBFOLDER_TYPE, GTH_TYPE_SUBFOLDER_TYPE, gtk_combo_box_get_active (GTK_COMBO_BOX (data->subfolder_type_list)));
+
if (data->import) {
/*
GthTask *task;
@@ -157,6 +172,45 @@ update_sensitivity (DialogData *data)
static void
+update_status (DialogData *data)
+{
+ GthFileStore *file_store;
+ int n_checked;
+ goffset size;
+ GList *checked;
+ GList *scan;
+ char *ssize;
+ char *status;
+
+ file_store = (GthFileStore *) gth_file_view_get_model (GTH_FILE_VIEW (gth_file_list_get_view (GTH_FILE_LIST (data->file_list))));
+
+ n_checked = 0;
+ size = 0;
+ checked = gth_file_store_get_checked (file_store);
+ for (scan = checked; scan; scan = scan->next) {
+ GthFileData *file_data = scan->data;
+
+ size += g_file_info_get_size (file_data->info);
+ n_checked += 1;
+ }
+ ssize = g_format_size_for_display (size);
+ status = g_strdup_printf (_("Files: %d (%s)"), n_checked, ssize);
+ gtk_label_set_text (GTK_LABEL (GET_WIDGET ("status_label")), status);
+
+ g_free (status);
+ g_free (ssize);
+}
+
+
+static void
+file_store_changed_cb (GthFileStore *file_store,
+ DialogData *data)
+{
+ update_status (data);
+}
+
+
+static void
list_ready_cb (GList *files,
GError *error,
gpointer user_data)
@@ -392,6 +446,91 @@ select_none_button_clicked_cb (GtkButton *button,
}
+static void
+update_destination (DialogData *data)
+{
+ GFile *destination;
+ GTimeVal timeval;
+ GthSubfolderType subfolder_type;
+ GDate *date;
+ char **parts = NULL;
+ char *child;
+ 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 = gtk_combo_box_get_active (GTK_COMBO_BOX (data->subfolder_type_list));
+ if (subfolder_type == GTH_SUBFOLDER_TYPE_CURRENT_DATE)
+ g_get_current_time (&timeval);
+ else
+ _g_time_val_from_exif_date ("2005:04:03 11:34:18", &timeval);
+
+ date = g_date_new ();
+ g_date_set_time_val (date, &timeval);
+
+ switch (subfolder_type) {
+ case GTH_SUBFOLDER_TYPE_NONE:
+ break;
+ case GTH_SUBFOLDER_TYPE_FILE_DATE:
+ case GTH_SUBFOLDER_TYPE_CURRENT_DATE:
+ parts = g_new0 (char *, 4);
+ parts[0] = g_strdup_printf ("%04d", g_date_get_year (date));
+ parts[1] = g_strdup_printf ("%02d", g_date_get_month (date));
+ parts[2] = g_strdup_printf ("%02d", g_date_get_day (date));
+ break;
+ }
+
+ if (parts == NULL)
+ child = NULL;
+ else if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (GET_WIDGET ("single_subfolder_checkbutton"))))
+ child = g_strjoinv ("-", parts);
+ else
+ child = g_strjoinv ("/", parts);
+
+ destination_example = _g_file_append_path (destination, child);
+ uri = g_file_get_uri (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);
+
+ g_free (example);
+ g_free (uri);
+ g_object_unref (destination_example);
+ g_strfreev (parts);
+ g_date_free (date);
+ g_object_unref (destination);
+}
+
+
+static void
+subfolder_type_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);
+}
+
+
void
dlg_photo_importer (GthBrowser *browser,
GFile *source)
@@ -447,17 +586,14 @@ dlg_photo_importer (GthBrowser *browser,
NULL);
data->subfolder_type_list = _gtk_combo_box_new_with_texts (_("No subfolder"),
- _("Day photo taken"),
- _("Month photo taken"),
+ _("File date"),
_("Current date"),
- _("Current date and time"),
- _("Custom"),
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);
+ /*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_SELECTOR);
sort_type = gth_main_get_sort_type ("file::mtime");
@@ -469,6 +605,8 @@ dlg_photo_importer (GthBrowser *browser,
gtk_widget_show (data->file_list);
gtk_box_pack_start (GTK_BOX (GET_WIDGET ("filelist_box")), data->file_list, TRUE, TRUE, 0);
+ /*gtk_label_set_mnemonic_widget (GTK_LABEL (GET_WIDGET ("files_label")), data->file_list);*/
+
/**/
tests = gth_main_get_all_tests ();
@@ -505,6 +643,34 @@ 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);
+ }
+
+ gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (GET_WIDGET ("single_subfolder_checkbutton")), eel_gconf_get_boolean (PREF_PHOTO_IMPORT_SUBFOLDER_SINGLE, FALSE));
+ gtk_combo_box_set_active (GTK_COMBO_BOX (data->subfolder_type_list), eel_gconf_get_enum (PREF_PHOTO_IMPORT_SUBFOLDER_TYPE, GTH_TYPE_SUBFOLDER_TYPE, GTH_SUBFOLDER_TYPE_FILE_DATE));
+ update_destination (data);
+
/* Set the signals handlers. */
g_signal_connect (G_OBJECT (data->dialog),
@@ -535,6 +701,26 @@ dlg_photo_importer (GthBrowser *browser,
"clicked",
G_CALLBACK (select_none_button_clicked_cb),
data);
+ g_signal_connect (gth_file_view_get_model (GTH_FILE_VIEW (gth_file_list_get_view (GTH_FILE_LIST (data->file_list)))),
+ "visibility_changed",
+ G_CALLBACK (file_store_changed_cb),
+ data);
+ g_signal_connect (gth_file_view_get_model (GTH_FILE_VIEW (gth_file_list_get_view (GTH_FILE_LIST (data->file_list)))),
+ "check_changed",
+ G_CALLBACK (file_store_changed_cb),
+ data);
+ g_signal_connect (data->subfolder_type_list,
+ "changed",
+ G_CALLBACK (subfolder_type_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);
data->monitor_event = g_signal_connect (gth_main_get_default_monitor (),
"entry_points_changed",
diff --git a/extensions/photo_importer/preferences.h b/extensions/photo_importer/preferences.h
new file mode 100644
index 0000000..13ada60
--- /dev/null
+++ b/extensions/photo_importer/preferences.h
@@ -0,0 +1,43 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
+
+/*
+ * GThumb
+ *
+ * Copyright (C) 2009 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 PREFERENCES_H
+#define PREFERENCES_H
+
+#include <gthumb.h>
+
+G_BEGIN_DECLS
+
+typedef enum {
+ GTH_SUBFOLDER_TYPE_NONE = 0,
+ GTH_SUBFOLDER_TYPE_FILE_DATE,
+ GTH_SUBFOLDER_TYPE_CURRENT_DATE
+} GthSubfolderType;
+
+#define PREF_PHOTO_IMPORT_DESTINATION "/apps/gthumb/ext/photo_importer/destination"
+#define PREF_PHOTO_IMPORT_SUBFOLDER_TYPE "/apps/gthumb/ext/photo_importer/subfolder_type"
+#define PREF_PHOTO_IMPORT_SUBFOLDER_SINGLE "/apps/gthumb/ext/photo_importer/subfolder_single"
+#define PREF_PHOTO_IMPORT_DELETE "/apps/gthumb/ext/photo_importer/delete_from_camera"
+
+G_END_DECLS
+
+#endif /* PREFERENCES_H */
diff --git a/gthumb/Makefile.am b/gthumb/Makefile.am
index 25da4c6..2c9d93d 100644
--- a/gthumb/Makefile.am
+++ b/gthumb/Makefile.am
@@ -248,7 +248,7 @@ gthumb_CFLAGS = \
gth-enum-types.h: $(PUBLIC_HEADER_FILES) $(GLIB_MKENUMS)
$(GLIB_MKENUMS) \
- --fhead "#ifndef GTH_ENUM__TYPES_H\n#define GTH_ENUM_TYPES_H\n\n#include <glib-object.h>\n\nG_BEGIN_DECLS\n" \
+ --fhead "#ifndef GTH_ENUM_TYPES_H\n#define GTH_ENUM_TYPES_H\n\n#include <glib-object.h>\n\nG_BEGIN_DECLS\n" \
--fprod "/* enumerations from \"@filename \" */\n" \
--vhead "GType @enum_name _get_type (void);\n#define GTH_TYPE_ ENUMSHORT@ (@enum_name _get_type())\n" \
--ftail "G_END_DECLS\n\n#endif /* GTH_ENUM_TYPES_H */" \
diff --git a/gthumb/glib-utils.c b/gthumb/glib-utils.c
index 5dee212..fcdd88e 100644
--- a/gthumb/glib-utils.c
+++ b/gthumb/glib-utils.c
@@ -1940,6 +1940,9 @@ _g_file_append_path (GFile *file,
char *new_uri;
GFile *new_file;
+ if (path == NULL)
+ return g_file_dup (file);
+
uri = g_file_get_uri (file);
escaped = g_uri_escape_string (path, G_URI_RESERVED_CHARS_ALLOWED_IN_PATH, FALSE);
new_uri = _g_build_uri (uri, escaped, NULL);
diff --git a/gthumb/gth-file-list.c b/gthumb/gth-file-list.c
index 9cbe90e..46ccc70 100644
--- a/gthumb/gth-file-list.c
+++ b/gthumb/gth-file-list.c
@@ -576,30 +576,23 @@ gth_file_list_construct (GthFileList *file_list,
NULL);
gtk_cell_layout_pack_start (GTK_CELL_LAYOUT (file_list->priv->view), renderer, FALSE);
+ gtk_cell_layout_set_attributes (GTK_CELL_LAYOUT (file_list->priv->view),
+ renderer,
+ "thumbnail", GTH_FILE_STORE_THUMBNAIL_COLUMN,
+ "is_icon", GTH_FILE_STORE_IS_ICON_COLUMN,
+ "file", GTH_FILE_STORE_FILE_DATA_COLUMN,
+ NULL);
if (file_list->priv->type == GTH_FILE_LIST_TYPE_BROWSER)
- gtk_cell_layout_set_attributes (GTK_CELL_LAYOUT (file_list->priv->view),
- renderer,
- "thumbnail", GTH_FILE_STORE_THUMBNAIL_COLUMN,
- "is_icon", GTH_FILE_STORE_IS_ICON_COLUMN,
- "file", GTH_FILE_STORE_FILE_DATA_COLUMN,
- "selected", GTH_FILE_STORE_CHECKED_COLUMN,
- NULL);
+ gtk_cell_layout_add_attribute (GTK_CELL_LAYOUT (file_list->priv->view),
+ renderer,
+ "selected",
+ GTH_FILE_STORE_CHECKED_COLUMN);
else if (file_list->priv->type == GTH_FILE_LIST_TYPE_SELECTOR)
- gtk_cell_layout_set_attributes (GTK_CELL_LAYOUT (file_list->priv->view),
- renderer,
- "thumbnail", GTH_FILE_STORE_THUMBNAIL_COLUMN,
- "is_icon", GTH_FILE_STORE_IS_ICON_COLUMN,
- "file", GTH_FILE_STORE_FILE_DATA_COLUMN,
- "checked", GTH_FILE_STORE_CHECKED_COLUMN,
- NULL);
- else
- gtk_cell_layout_set_attributes (GTK_CELL_LAYOUT (file_list->priv->view),
- renderer,
- "thumbnail", GTH_FILE_STORE_THUMBNAIL_COLUMN,
- "is_icon", GTH_FILE_STORE_IS_ICON_COLUMN,
- "file", GTH_FILE_STORE_FILE_DATA_COLUMN,
- NULL);
+ gtk_cell_layout_add_attribute (GTK_CELL_LAYOUT (file_list->priv->view),
+ renderer,
+ "checked",
+ GTH_FILE_STORE_CHECKED_COLUMN);
/* text */
diff --git a/gthumb/gth-file-store.c b/gthumb/gth-file-store.c
index cc8e8e7..2f7421a 100644
--- a/gthumb/gth-file-store.c
+++ b/gthumb/gth-file-store.c
@@ -31,7 +31,15 @@
#define REALLOC_STEP 32
+enum {
+ CHECK_CHANGED,
+ VISIBILITY_CHANGED,
+ LAST_SIGNAL
+};
+
+
static GType column_type[GTH_FILE_STORE_N_COLUMNS] = { G_TYPE_INVALID, };
+static guint gth_file_store_signals[LAST_SIGNAL] = { 0 };
typedef struct {
@@ -65,6 +73,7 @@ struct _GthFileStorePrivate
GthFileDataCompFunc cmp_func;
gboolean inverse_sort;
gboolean update_filter;
+ gboolean check_changed;
};
@@ -210,6 +219,25 @@ gth_file_store_class_init (GthFileStoreClass *class)
object_class = (GObjectClass*) class;
object_class->finalize = gth_file_store_finalize;
+
+ gth_file_store_signals[CHECK_CHANGED] =
+ g_signal_new ("check_changed",
+ G_TYPE_FROM_CLASS (class),
+ G_SIGNAL_RUN_LAST,
+ G_STRUCT_OFFSET (GthFileStoreClass, check_changed),
+ NULL, NULL,
+ g_cclosure_marshal_VOID__VOID,
+ G_TYPE_NONE,
+ 0);
+ gth_file_store_signals[VISIBILITY_CHANGED] =
+ g_signal_new ("visibility_changed",
+ G_TYPE_FROM_CLASS (class),
+ G_SIGNAL_RUN_LAST,
+ G_STRUCT_OFFSET (GthFileStoreClass, visibility_changed),
+ NULL, NULL,
+ g_cclosure_marshal_VOID__VOID,
+ G_TYPE_NONE,
+ 0);
}
@@ -1013,6 +1041,9 @@ g_print (" INSERT: %d\n", i);
row_inserted = TRUE;
}
+ g_signal_emit (file_store, gth_file_store_signals[VISIBILITY_CHANGED], 0);
+ g_signal_emit (file_store, gth_file_store_signals[CHECK_CHANGED], 0);
+
g_free (new_rows);
g_free (old_rows);
}
@@ -1114,6 +1145,40 @@ gth_file_store_n_visibles (GthFileStore *file_store)
}
+GList *
+gth_file_store_get_checked (GthFileStore *file_store)
+{
+ GList *list = NULL;
+ int i;
+
+ for (i = 0; i < file_store->priv->num_rows; i++) {
+ GthFileRow *row = file_store->priv->rows[i];
+
+ if ((row != NULL) && row->checked)
+ list = g_list_prepend (list, g_object_ref (file_store->priv->rows[i]->file_data));
+ }
+
+ return g_list_reverse (list);
+}
+
+
+int
+gth_file_store_get_n_checked (GthFileStore *file_store)
+{
+ int n = 0;
+ int i;
+
+ for (i = 0; i < file_store->priv->num_rows; i++) {
+ GthFileRow *row = file_store->priv->rows[i];
+
+ if ((row != NULL) && row->checked)
+ n++;
+ }
+
+ return n;
+}
+
+
GthFileData *
gth_file_store_get_file (GthFileStore *file_store,
GtkTreeIter *iter)
@@ -1378,13 +1443,12 @@ gth_file_store_queue_set_valist (GthFileStore *file_store,
file_data = va_arg (var_args, GthFileData *);
g_return_if_fail (GTH_IS_FILE_DATA (file_data));
_gth_file_row_set_file (row, file_data);
- file_store->priv->update_filter = TRUE;
row->changed = TRUE;
+ file_store->priv->update_filter = TRUE;
break;
case GTH_FILE_STORE_THUMBNAIL_COLUMN:
thumbnail = va_arg (var_args, GdkPixbuf *);
g_return_if_fail (GDK_IS_PIXBUF (thumbnail));
-
_gth_file_row_set_thumbnail (row, thumbnail);
row->changed = TRUE;
break;
@@ -1400,6 +1464,7 @@ gth_file_store_queue_set_valist (GthFileStore *file_store,
case GTH_FILE_STORE_CHECKED_COLUMN:
row->checked = va_arg (var_args, gboolean);
row->changed = TRUE;
+ file_store->priv->check_changed = TRUE;
break;
default:
g_warning ("%s: Invalid column number %d added to iter (remember to end your list of columns with a -1)", G_STRLOC, column);
@@ -1463,6 +1528,10 @@ gth_file_store_exec_set (GthFileStore *file_store)
_gth_file_store_update_visibility (file_store, NULL);
file_store->priv->update_filter = FALSE;
}
+ else if (file_store->priv->check_changed) {
+ g_signal_emit (file_store, gth_file_store_signals[CHECK_CHANGED], 0);
+ file_store->priv->check_changed = FALSE;
+ }
}
diff --git a/gthumb/gth-file-store.h b/gthumb/gth-file-store.h
index ef49dda..0e7c8f9 100644
--- a/gthumb/gth-file-store.h
+++ b/gthumb/gth-file-store.h
@@ -59,6 +59,9 @@ struct _GthFileStore
struct _GthFileStoreClass
{
GObjectClass __parent_class;
+
+ void (*visibility_changed) (GthFileStore *self);
+ void (*check_changed) (GthFileStore *self);
};
GType gth_file_store_get_type (void) G_GNUC_CONST;
@@ -72,6 +75,8 @@ GList * gth_file_store_get_all (GthFileStore *file_sto
int gth_file_store_n_files (GthFileStore *file_store);
GList * gth_file_store_get_visibles (GthFileStore *file_store);
int gth_file_store_n_visibles (GthFileStore *file_store);
+GList * gth_file_store_get_checked (GthFileStore *file_store);
+int gth_file_store_get_n_checked (GthFileStore *file_store);
GthFileData * gth_file_store_get_file (GthFileStore *file_store,
GtkTreeIter *iter);
gboolean gth_file_store_find (GthFileStore *file_store,
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]