[gthumb] Added ability to import photos from a folder
- From: Paolo Bacchilega <paobac src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gthumb] Added ability to import photos from a folder
- Date: Wed, 27 Jul 2011 12:00:59 +0000 (UTC)
commit dfd5b1a691b7566ebdffa9497f12f0e47191bc8a
Author: Paolo Bacchilega <paobac src gnome org>
Date: Tue Jul 26 18:04:41 2011 +0200
Added ability to import photos from a folder
This is equivalent to importing from a removable device, with the
difference that the user can select a folder instead of a device.
[new feature, bug #452764 (partial)]
extensions/photo_importer/actions.c | 61 +++++++-
extensions/photo_importer/actions.h | 3 +-
extensions/photo_importer/callbacks.c | 10 +-
.../photo_importer/data/ui/photo-importer.ui | 176 ++++++++++++--------
extensions/photo_importer/dlg-photo-importer.c | 163 +++++++++++++-----
extensions/photo_importer/dlg-photo-importer.h | 6 +-
6 files changed, 301 insertions(+), 118 deletions(-)
---
diff --git a/extensions/photo_importer/actions.c b/extensions/photo_importer/actions.c
index e2da957..cb02754 100644
--- a/extensions/photo_importer/actions.c
+++ b/extensions/photo_importer/actions.c
@@ -27,8 +27,63 @@
void
-gth_browser_activate_action_import_files (GtkAction *action,
- GthBrowser *browser)
+gth_browser_activate_action_import_from_device (GtkAction *action,
+ GthBrowser *browser)
{
- dlg_photo_importer (browser, NULL);
+ dlg_photo_importer_from_device (browser, NULL);
+}
+
+
+static void
+folder_chooser_response_cb (GtkDialog *dialog,
+ int response_id,
+ gpointer user_data)
+{
+ GthBrowser *browser = user_data;
+ GFile *folder;
+
+ if (response_id != GTK_RESPONSE_OK) {
+ gtk_widget_destroy (GTK_WIDGET (dialog));
+ return;
+ }
+
+ folder = gtk_file_chooser_get_file (GTK_FILE_CHOOSER (dialog));
+ if (folder != NULL) {
+ dlg_photo_importer_from_folder (browser, folder);
+ g_object_unref (folder);
+ }
+
+ gtk_widget_destroy (GTK_WIDGET (dialog));
+}
+
+
+void
+gth_browser_activate_action_import_from_folder (GtkAction *action,
+ GthBrowser *browser)
+{
+ GtkWidget *chooser;
+ GFile *folder;
+
+ chooser = gtk_file_chooser_dialog_new (_("Choose a folder"),
+ GTK_WINDOW (browser),
+ GTK_FILE_CHOOSER_ACTION_SELECT_FOLDER,
+ GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
+ _("Import"), GTK_RESPONSE_OK,
+ NULL);
+ gtk_file_chooser_set_local_only (GTK_FILE_CHOOSER (chooser), FALSE);
+
+ folder = NULL;
+ if (GTH_IS_FILE_SOURCE_VFS (gth_browser_get_location_source (browser)))
+ folder = _g_object_ref (gth_browser_get_location (browser));
+ if (folder == NULL)
+ folder = g_file_new_for_uri (get_home_uri ());
+ gtk_file_chooser_set_file (GTK_FILE_CHOOSER (chooser), folder, NULL);
+
+ g_signal_connect (chooser,
+ "response",
+ G_CALLBACK (folder_chooser_response_cb),
+ browser);
+ gtk_widget_show (chooser);
+
+ _g_object_unref (folder);
}
diff --git a/extensions/photo_importer/actions.h b/extensions/photo_importer/actions.h
index 51e74b9..644d72d 100644
--- a/extensions/photo_importer/actions.h
+++ b/extensions/photo_importer/actions.h
@@ -26,6 +26,7 @@
#define DEFINE_ACTION(x) void x (GtkAction *action, gpointer data);
-DEFINE_ACTION(gth_browser_activate_action_import_files)
+DEFINE_ACTION(gth_browser_activate_action_import_from_device)
+DEFINE_ACTION(gth_browser_activate_action_import_from_folder)
#endif /* ACTIONS_H */
diff --git a/extensions/photo_importer/callbacks.c b/extensions/photo_importer/callbacks.c
index b39d7dd..3735f66 100644
--- a/extensions/photo_importer/callbacks.c
+++ b/extensions/photo_importer/callbacks.c
@@ -39,6 +39,7 @@ static const char *ui_info =
" <menu name='Import' action='ImportMenu'>"
" <placeholder name='Misc_Actions'>"
" <menuitem action='File_ImportFromDevice'/>"
+" <menuitem action='File_ImportFromFolder'/>"
" </placeholder>"
" </menu>"
" </menu>"
@@ -50,7 +51,11 @@ static GtkActionEntry action_entries[] = {
{ "File_ImportFromDevice", "camera-photo",
N_("_Removable Device..."), NULL,
N_("Import photos and other files from a removable device"),
- G_CALLBACK (gth_browser_activate_action_import_files) },
+ G_CALLBACK (gth_browser_activate_action_import_from_device) },
+ { "File_ImportFromFolder", "folder",
+ N_("F_older..."), NULL,
+ N_("Import photos and other files from a folder"),
+ G_CALLBACK (gth_browser_activate_action_import_from_folder) }
};
@@ -120,7 +125,8 @@ import_photos_idle_cb (gpointer user_data)
{
ImportData *data = user_data;
- dlg_photo_importer (data->browser, data->source);
+ dlg_photo_importer_from_device (data->browser, data->source);
+
return FALSE;
}
diff --git a/extensions/photo_importer/data/ui/photo-importer.ui b/extensions/photo_importer/data/ui/photo-importer.ui
index 7cea563..17e378e 100644
--- a/extensions/photo_importer/data/ui/photo-importer.ui
+++ b/extensions/photo_importer/data/ui/photo-importer.ui
@@ -1,67 +1,143 @@
-<?xml version="1.0"?>
+<?xml version="1.0" encoding="UTF-8"?>
<interface>
- <requires lib="gtk+" version="2.16"/>
- <!-- interface-naming-policy project-wide -->
+ <requires lib="gtk+" version="2.24"/>
+ <object class="GtkImage" id="image1">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="stock">gtk-ok</property>
+ </object>
<object class="GtkDialog" id="photo_importer_dialog">
+ <property name="can_focus">False</property>
<property name="border_width">5</property>
- <property name="title" translatable="yes">Import from Removable Device</property>
<property name="type_hint">normal</property>
<child internal-child="vbox">
- <object class="GtkVBox" id="dialog-vbox1">
+ <object class="GtkBox" id="dialog-vbox1">
<property name="visible">True</property>
+ <property name="can_focus">False</property>
<property name="orientation">vertical</property>
<property name="spacing">2</property>
+ <child internal-child="action_area">
+ <object class="GtkButtonBox" id="dialog-action_area1">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="layout_style">end</property>
+ <child>
+ <object class="GtkButton" id="cancel_button">
+ <property name="label">gtk-cancel</property>
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="receives_default">True</property>
+ <property name="use_action_appearance">False</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="ok_button">
+ <property name="label" translatable="yes">_Import</property>
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="receives_default">True</property>
+ <property name="use_action_appearance">False</property>
+ <property name="image">image1</property>
+ <property name="use_underline">True</property>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">False</property>
+ <property name="position">1</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_action_appearance">False</property>
+ <property name="use_stock">True</property>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">False</property>
+ <property name="position">2</property>
+ <property name="secondary">True</property>
+ </packing>
+ </child>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">True</property>
+ <property name="pack_type">end</property>
+ <property name="position">0</property>
+ </packing>
+ </child>
<child>
<object class="GtkVBox" id="vbox1">
<property name="visible">True</property>
+ <property name="can_focus">False</property>
<property name="border_width">5</property>
- <property name="orientation">vertical</property>
<property name="spacing">6</property>
<child>
<object class="GtkHBox" id="source_selector_box">
<property name="visible">True</property>
+ <property name="can_focus">False</property>
<property name="spacing">6</property>
<child>
<object class="GtkLabel" id="source_label">
<property name="visible">True</property>
+ <property name="can_focus">False</property>
<property name="xalign">0</property>
<property name="label" translatable="yes">_Source:</property>
<property name="use_underline">True</property>
</object>
<packing>
<property name="expand">False</property>
+ <property name="fill">True</property>
<property name="position">0</property>
</packing>
</child>
<child>
<object class="GtkHBox" id="source_box">
<property name="visible">True</property>
+ <property name="can_focus">False</property>
<child>
<placeholder/>
</child>
</object>
<packing>
+ <property name="expand">True</property>
+ <property name="fill">True</property>
<property name="position">1</property>
</packing>
</child>
<child>
<object class="GtkHBox" id="hbox1">
<property name="visible">True</property>
+ <property name="can_focus">False</property>
<property name="spacing">6</property>
<child>
<object class="GtkLabel" id="filter_label">
<property name="visible">True</property>
+ <property name="can_focus">False</property>
<property name="xalign">0</property>
<property name="label" translatable="yes">S_how:</property>
<property name="use_underline">True</property>
</object>
<packing>
+ <property name="expand">True</property>
+ <property name="fill">True</property>
<property name="position">0</property>
</packing>
</child>
<child>
<object class="GtkHBox" id="filter_box">
<property name="visible">True</property>
+ <property name="can_focus">False</property>
<property name="spacing">6</property>
<child>
<placeholder/>
@@ -69,12 +145,14 @@
</object>
<packing>
<property name="expand">False</property>
+ <property name="fill">True</property>
<property name="position">1</property>
</packing>
</child>
</object>
<packing>
<property name="expand">False</property>
+ <property name="fill">True</property>
<property name="pack_type">end</property>
<property name="position">2</property>
</packing>
@@ -82,55 +160,66 @@
</object>
<packing>
<property name="expand">False</property>
+ <property name="fill">True</property>
<property name="position">0</property>
</packing>
</child>
<child>
<object class="GtkHBox" id="hbox4">
<property name="visible">True</property>
+ <property name="can_focus">False</property>
<property name="spacing">6</property>
<child>
<object class="GtkLabel" id="status_label">
<property name="visible">True</property>
+ <property name="can_focus">False</property>
<property name="xalign">0</property>
<property name="use_underline">True</property>
</object>
<packing>
<property name="expand">False</property>
+ <property name="fill">True</property>
<property name="position">0</property>
</packing>
</child>
</object>
<packing>
<property name="expand">False</property>
+ <property name="fill">True</property>
<property name="position">1</property>
</packing>
</child>
<child>
<object class="GtkVBox" id="vbox3">
<property name="visible">True</property>
- <property name="orientation">vertical</property>
+ <property name="can_focus">False</property>
<property name="spacing">6</property>
<child>
<object class="GtkHBox" id="filelist_box">
<property name="visible">True</property>
+ <property name="can_focus">False</property>
<property name="spacing">6</property>
<child>
<placeholder/>
</child>
</object>
<packing>
+ <property name="expand">True</property>
+ <property name="fill">True</property>
<property name="position">0</property>
</packing>
</child>
</object>
<packing>
+ <property name="expand">True</property>
+ <property name="fill">True</property>
<property name="position">2</property>
</packing>
</child>
<child>
<object class="GtkTable" id="tags_box">
<property name="visible">True</property>
+ <property name="can_focus">False</property>
<property name="n_rows">3</property>
<property name="n_columns">2</property>
<property name="column_spacing">6</property>
@@ -138,6 +227,7 @@
<child>
<object class="GtkHBox" id="tags_entry_box">
<property name="visible">True</property>
+ <property name="can_focus">False</property>
<property name="spacing">6</property>
<child>
<placeholder/>
@@ -153,10 +243,12 @@
<child>
<object class="GtkAlignment" id="alignment5">
<property name="visible">True</property>
+ <property name="can_focus">False</property>
<property name="top_padding">3</property>
<child>
<object class="GtkLabel" id="tags_label">
<property name="visible">True</property>
+ <property name="can_focus">False</property>
<property name="xalign">0</property>
<property name="yalign">0</property>
<property name="label" translatable="yes">_Tags:</property>
@@ -173,6 +265,7 @@
<child>
<object class="GtkLabel" id="event_label">
<property name="visible">True</property>
+ <property name="can_focus">False</property>
<property name="xalign">0</property>
<property name="label" translatable="yes">_Event:</property>
<property name="use_underline">True</property>
@@ -188,7 +281,7 @@
<object class="GtkEntry" id="event_entry">
<property name="visible">True</property>
<property name="can_focus">True</property>
- <property name="invisible_char">●</property>
+ <property name="invisible_char">â</property>
</object>
<packing>
<property name="left_attach">1</property>
@@ -200,6 +293,7 @@
<child>
<object class="GtkLabel" id="label1">
<property name="visible">True</property>
+ <property name="can_focus">False</property>
<property name="xalign">0</property>
<property name="label" translatable="yes">_Destination:</property>
<property name="use_underline">True</property>
@@ -211,6 +305,7 @@
<child>
<object class="GtkHBox" id="destination_button_box">
<property name="visible">True</property>
+ <property name="can_focus">False</property>
<child>
<placeholder/>
</child>
@@ -223,6 +318,7 @@
</object>
<packing>
<property name="expand">False</property>
+ <property name="fill">True</property>
<property name="position">3</property>
</packing>
</child>
@@ -232,74 +328,24 @@
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">False</property>
+ <property name="use_action_appearance">False</property>
<property name="use_underline">True</property>
+ <property name="xalign">0</property>
<property name="draw_indicator">True</property>
</object>
<packing>
<property name="expand">False</property>
+ <property name="fill">True</property>
<property name="position">4</property>
</packing>
</child>
</object>
<packing>
+ <property name="expand">True</property>
+ <property name="fill">True</property>
<property name="position">1</property>
</packing>
</child>
- <child internal-child="action_area">
- <object class="GtkHButtonBox" id="dialog-action_area1">
- <property name="visible">True</property>
- <property name="layout_style">end</property>
- <child>
- <object class="GtkButton" id="cancel_button">
- <property name="label">gtk-cancel</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="ok_button">
- <property name="label" translatable="yes">_Import</property>
- <property name="visible">True</property>
- <property name="can_focus">True</property>
- <property name="receives_default">True</property>
- <property name="image">image1</property>
- <property name="use_underline">True</property>
- </object>
- <packing>
- <property name="expand">False</property>
- <property name="fill">False</property>
- <property name="position">1</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">2</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>
@@ -308,8 +354,4 @@
<action-widget response="0">help_button</action-widget>
</action-widgets>
</object>
- <object class="GtkImage" id="image1">
- <property name="visible">True</property>
- <property name="stock">gtk-ok</property>
- </object>
</interface>
diff --git a/extensions/photo_importer/dlg-photo-importer.c b/extensions/photo_importer/dlg-photo-importer.c
index 5fc8f08..16f3a09 100644
--- a/extensions/photo_importer/dlg-photo-importer.c
+++ b/extensions/photo_importer/dlg-photo-importer.c
@@ -27,6 +27,12 @@
#include "preferences.h"
+typedef enum {
+ DLG_IMPORTER_SOURCE_TYPE_DEVICE,
+ DLG_IMPORTER_SOURCE_TYPE_FOLDER
+} DlgImporterSourceType;
+
+
enum {
SOURCE_LIST_COLUMN_MOUNT,
SOURCE_LIST_COLUMN_ICON,
@@ -39,13 +45,15 @@ enum {
typedef struct {
GthBrowser *browser;
+ DlgImporterSourceType selector_type;
GtkWidget *dialog;
GtkWidget *preferences_dialog;
GtkBuilder *builder;
GFile *source;
GFile *last_source;
- GtkListStore *source_store;
- GtkWidget *source_list;
+ GtkListStore *device_list_store;
+ GtkWidget *device_chooser;
+ GtkWidget *folder_chooser;
GtkWidget *file_list;
GCancellable *cancellable;
GList *files;
@@ -243,10 +251,14 @@ update_sensitivity (DialogData *data)
{
gboolean can_import;
- can_import = data->source != NULL;
+ if (data->selector_type == DLG_IMPORTER_SOURCE_TYPE_DEVICE)
+ can_import = data->source != NULL;
+ else
+ can_import = TRUE;
gtk_widget_set_sensitive (GET_WIDGET ("ok_button"), can_import);
gtk_widget_set_sensitive (GET_WIDGET ("source_selector_box"), can_import);
gtk_widget_set_sensitive (GET_WIDGET ("tags_box"), can_import);
+ gtk_widget_set_sensitive (GET_WIDGET ("delete_checkbutton"), can_import);
}
@@ -375,20 +387,20 @@ load_file_list (DialogData *data)
static void
-source_list_changed_cb (GtkWidget *widget,
- DialogData *data)
+device_chooser_changed_cb (GtkWidget *widget,
+ DialogData *data)
{
GtkTreeIter iter;
GMount *mount;
- if (! gtk_combo_box_get_active_iter (GTK_COMBO_BOX (data->source_list), &iter)) {
+ if (! gtk_combo_box_get_active_iter (GTK_COMBO_BOX (data->device_chooser), &iter)) {
_g_clear_object (&data->source);
_g_clear_object (&data->last_source);
gth_file_list_clear (GTH_FILE_LIST (data->file_list), _("(Empty)"));
return;
}
- gtk_tree_model_get (GTK_TREE_MODEL (data->source_store), &iter,
+ gtk_tree_model_get (GTK_TREE_MODEL (data->device_list_store), &iter,
SOURCE_LIST_COLUMN_MOUNT, &mount,
-1);
@@ -399,6 +411,7 @@ source_list_changed_cb (GtkWidget *widget,
return;
}
+ _g_object_unref (data->source);
data->source = g_mount_get_root (mount);
load_file_list (data);
@@ -407,13 +420,32 @@ source_list_changed_cb (GtkWidget *widget,
static void
-update_source_list (DialogData *data)
+folder_chooser_file_set_cb (GtkFileChooserButton *widget,
+ gpointer user_data)
+{
+ DialogData *data = user_data;
+ GFile *folder;
+
+ folder = gtk_file_chooser_get_file (GTK_FILE_CHOOSER (widget));
+ if (folder == NULL)
+ return;
+
+ _g_object_unref (data->source);
+ data->source = g_object_ref (folder);;
+ load_file_list (data);
+
+ g_object_unref (folder);
+}
+
+
+static void
+update_device_source_list (DialogData *data)
{
gboolean source_available = FALSE;
GList *mounts;
GList *scan;
- gtk_list_store_clear (data->source_store);
+ gtk_list_store_clear (data->device_list_store);
mounts = g_volume_monitor_get_mounts (g_volume_monitor_get ());
for (scan = mounts; scan; scan = scan->next) {
@@ -427,7 +459,7 @@ update_source_list (DialogData *data)
if (g_mount_is_shadowed (mount))
continue;
- gtk_list_store_append (data->source_store, &iter);
+ gtk_list_store_append (data->device_list_store, &iter);
root = g_mount_get_root (mount);
if (data->source == NULL)
@@ -450,7 +482,7 @@ update_source_list (DialogData *data)
g_free (drive_name);
}
- gtk_list_store_set (data->source_store, &iter,
+ gtk_list_store_set (data->device_list_store, &iter,
SOURCE_LIST_COLUMN_MOUNT, mount,
SOURCE_LIST_COLUMN_ICON, icon,
SOURCE_LIST_COLUMN_NAME, name,
@@ -458,7 +490,7 @@ update_source_list (DialogData *data)
if (g_file_equal (data->source, root)) {
source_available = TRUE;
- gtk_combo_box_set_active_iter (GTK_COMBO_BOX (data->source_list), &iter);
+ gtk_combo_box_set_active_iter (GTK_COMBO_BOX (data->device_chooser), &iter);
}
g_free (name);
@@ -480,7 +512,7 @@ static void
entry_points_changed_cb (GthMonitor *monitor,
DialogData *data)
{
- update_source_list (data);
+ update_device_source_list (data);
}
@@ -510,9 +542,10 @@ event_entry_changed_cb (GtkEditable *editable,
}
-void
-dlg_photo_importer (GthBrowser *browser,
- GFile *source)
+static void
+dlg_photo_importer (GthBrowser *browser,
+ GFile *source,
+ DlgImporterSourceType selector_type)
{
DialogData *data;
GtkCellRenderer *renderer;
@@ -530,6 +563,7 @@ dlg_photo_importer (GthBrowser *browser,
data = g_new0 (DialogData, 1);
data->browser = browser;
data->builder = _gtk_builder_new_from_file ("photo-importer.ui", "photo_importer");
+ data->selector_type = selector_type;
data->source = _g_object_ref (source);
data->cancellable = g_cancellable_new ();
data->vfs_source = g_object_new (GTH_TYPE_FILE_SOURCE_VFS, NULL);
@@ -542,28 +576,48 @@ dlg_photo_importer (GthBrowser *browser,
gth_browser_set_dialog (browser, "photo_importer", data->dialog);
g_object_set_data (G_OBJECT (data->dialog), "dialog_data", data);
- data->source_store = gtk_list_store_new (SOURCE_LIST_COLUMNS, G_TYPE_OBJECT, G_TYPE_ICON, G_TYPE_STRING);
- data->source_list = gtk_combo_box_new_with_model (GTK_TREE_MODEL (data->source_store));
- gtk_widget_show (data->source_list);
- gtk_box_pack_start (GTK_BOX (GET_WIDGET ("source_box")), data->source_list, TRUE, TRUE, 0);
-
- gtk_label_set_mnemonic_widget (GTK_LABEL (GET_WIDGET ("source_label")), data->source_list);
-
- g_object_unref (data->source_store);
+ if (data->selector_type == DLG_IMPORTER_SOURCE_TYPE_DEVICE) {
+ gtk_window_set_title (GTK_WINDOW (data->dialog), _("Import from Removable Device"));
+
+ data->device_list_store = gtk_list_store_new (SOURCE_LIST_COLUMNS, G_TYPE_OBJECT, G_TYPE_ICON, G_TYPE_STRING);
+ data->device_chooser = gtk_combo_box_new_with_model (GTK_TREE_MODEL (data->device_list_store));
+ gtk_widget_show (data->device_chooser);
+ gtk_box_pack_start (GTK_BOX (GET_WIDGET ("source_box")), data->device_chooser, TRUE, TRUE, 0);
+ gtk_label_set_mnemonic_widget (GTK_LABEL (GET_WIDGET ("source_label")), data->device_chooser);
+
+ renderer = gtk_cell_renderer_pixbuf_new ();
+ gtk_cell_layout_pack_start (GTK_CELL_LAYOUT (data->device_chooser), renderer, FALSE);
+ gtk_cell_layout_set_attributes (GTK_CELL_LAYOUT (data->device_chooser),
+ renderer,
+ "gicon", SOURCE_LIST_COLUMN_ICON,
+ NULL);
+
+ renderer = gtk_cell_renderer_text_new ();
+ gtk_cell_layout_pack_start (GTK_CELL_LAYOUT (data->device_chooser), renderer, TRUE);
+ gtk_cell_layout_set_attributes (GTK_CELL_LAYOUT (data->device_chooser),
+ renderer,
+ "text", SOURCE_LIST_COLUMN_NAME,
+ NULL);
+
+ g_object_unref (data->device_list_store);
+ }
+ else {
+ if (data->source == NULL) {
+ if (GTH_IS_FILE_SOURCE_VFS (gth_browser_get_location_source (browser)))
+ data->source = _g_object_ref (gth_browser_get_location (browser));
+ if (data->source == NULL)
+ data->source = g_file_new_for_uri (get_home_uri ());
+ }
- renderer = gtk_cell_renderer_pixbuf_new ();
- gtk_cell_layout_pack_start (GTK_CELL_LAYOUT (data->source_list), renderer, FALSE);
- gtk_cell_layout_set_attributes (GTK_CELL_LAYOUT (data->source_list),
- renderer,
- "gicon", SOURCE_LIST_COLUMN_ICON,
- NULL);
+ gtk_window_set_title (GTK_WINDOW (data->dialog), _("Import from Folder"));
- renderer = gtk_cell_renderer_text_new ();
- gtk_cell_layout_pack_start (GTK_CELL_LAYOUT (data->source_list), renderer, TRUE);
- gtk_cell_layout_set_attributes (GTK_CELL_LAYOUT (data->source_list),
- renderer,
- "text", SOURCE_LIST_COLUMN_NAME,
- NULL);
+ data->folder_chooser = gtk_file_chooser_button_new (_("Choose a folder"), GTK_FILE_CHOOSER_ACTION_SELECT_FOLDER);
+ gtk_label_set_mnemonic_widget (GTK_LABEL (GET_WIDGET ("source_label")), data->folder_chooser);
+ gtk_file_chooser_set_file (GTK_FILE_CHOOSER (data->folder_chooser), data->source, NULL);
+ gtk_file_chooser_set_local_only (GTK_FILE_CHOOSER (data->folder_chooser), FALSE);
+ gtk_widget_show (data->folder_chooser);
+ gtk_box_pack_start (GTK_BOX (GET_WIDGET ("source_box")), data->folder_chooser, TRUE, TRUE, 0);
+ }
data->file_list = gth_file_list_new (gth_icon_view_new (), GTH_FILE_LIST_TYPE_NORMAL, FALSE);
sort_type = gth_main_get_sort_type ("file::mtime");
@@ -576,8 +630,6 @@ 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_registered_objects_id (GTH_TYPE_TEST);
general_filter = "file::type::is_media"; /* default value */
active_filter = 0;
@@ -648,10 +700,16 @@ dlg_photo_importer (GthBrowser *browser,
"clicked",
G_CALLBACK (help_clicked_cb),
data);
- g_signal_connect (data->source_list,
- "changed",
- G_CALLBACK (source_list_changed_cb),
- data);
+ if (data->selector_type == DLG_IMPORTER_SOURCE_TYPE_DEVICE)
+ g_signal_connect (data->device_chooser,
+ "changed",
+ G_CALLBACK (device_chooser_changed_cb),
+ data);
+ else
+ g_signal_connect (data->folder_chooser,
+ "selection-changed",
+ G_CALLBACK (folder_chooser_file_set_cb),
+ data);
g_signal_connect (data->filter_combobox,
"changed",
G_CALLBACK (filter_combobox_changed_cb),
@@ -682,5 +740,24 @@ dlg_photo_importer (GthBrowser *browser,
gth_import_preferences_dialog_set_event (GTH_IMPORT_PREFERENCES_DIALOG (data->preferences_dialog),
gtk_entry_get_text (GTK_ENTRY (GET_WIDGET ("event_entry"))));
- update_source_list (data);
+ if (data->selector_type == DLG_IMPORTER_SOURCE_TYPE_DEVICE)
+ update_device_source_list (data);
+ else
+ load_file_list (data);
+}
+
+
+void
+dlg_photo_importer_from_device (GthBrowser *browser,
+ GFile *source)
+{
+ dlg_photo_importer (browser, source, DLG_IMPORTER_SOURCE_TYPE_DEVICE);
+}
+
+
+void
+dlg_photo_importer_from_folder (GthBrowser *browser,
+ GFile *source)
+{
+ dlg_photo_importer (browser, source, DLG_IMPORTER_SOURCE_TYPE_FOLDER);
}
diff --git a/extensions/photo_importer/dlg-photo-importer.h b/extensions/photo_importer/dlg-photo-importer.h
index 91e1655..383ed69 100644
--- a/extensions/photo_importer/dlg-photo-importer.h
+++ b/extensions/photo_importer/dlg-photo-importer.h
@@ -24,7 +24,9 @@
#include <gthumb.h>
-void dlg_photo_importer (GthBrowser *browser,
- GFile *source);
+void dlg_photo_importer_from_device (GthBrowser *browser,
+ GFile *source);
+void dlg_photo_importer_from_folder (GthBrowser *browser,
+ GFile *source);
#endif /* DLG_PHOTO_IMPORTER_H */
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]