[gthumb] [photo_importer] show the destination in the main dialog as well
- From: Paolo Bacchilega <paobac src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gthumb] [photo_importer] show the destination in the main dialog as well
- Date: Wed, 4 Aug 2010 22:03:55 +0000 (UTC)
commit 5e0941472c3551331e452a91f82d04d0202fa4dd
Author: Paolo Bacchilega <paobac src gnome org>
Date: Wed Aug 4 20:54:42 2010 +0200
[photo_importer] show the destination in the main dialog as well
.../importer/gth-import-preferences-dialog.c | 98 ++++++++++++++------
.../importer/gth-import-preferences-dialog.h | 6 +
.../photo_importer/data/ui/photo-importer.ui | 71 +++++++++++++--
extensions/photo_importer/dlg-photo-importer.c | 47 ++++++++++
4 files changed, 187 insertions(+), 35 deletions(-)
---
diff --git a/extensions/importer/gth-import-preferences-dialog.c b/extensions/importer/gth-import-preferences-dialog.c
index b2b85ab..27b50ab 100644
--- a/extensions/importer/gth-import-preferences-dialog.c
+++ b/extensions/importer/gth-import-preferences-dialog.c
@@ -31,7 +31,15 @@
#define GET_WIDGET(x) (_gtk_builder_get_widget (self->priv->builder, (x)))
+/* Signals */
+enum {
+ DESTINATION_CHANGED,
+ LAST_SIGNAL
+};
+
+
static gpointer parent_class = NULL;
+static guint signals[LAST_SIGNAL] = { 0 };
struct _GthImportPreferencesDialogPrivate {
@@ -67,6 +75,18 @@ gth_import_preferences_dialog_class_init (GthImportPreferencesDialogClass *klass
object_class = (GObjectClass*) klass;
object_class->finalize = gth_import_preferences_dialog_finalize;
+
+ /* signals */
+
+ signals[DESTINATION_CHANGED] =
+ g_signal_new ("destination-changed",
+ G_TYPE_FROM_CLASS (klass),
+ G_SIGNAL_RUN_LAST,
+ G_STRUCT_OFFSET (GthImportPreferencesDialogClass, destination_changed),
+ NULL, NULL,
+ g_cclosure_marshal_VOID__VOID,
+ G_TYPE_NONE,
+ 0);
}
@@ -170,54 +190,34 @@ create_example_file_data (void)
static void
update_destination (GthImportPreferencesDialog *self)
{
- GFile *destination;
- GthSubfolderType subfolder_type;
- GthSubfolderFormat subfolder_format;
- gboolean single_subfolder;
- const char *custom_format;
- GthFileData *example_data;
- GTimeVal timeval;
GFile *destination_example;
char *uri;
char *example;
+ GthSubfolderType subfolder_type;
+ GthSubfolderFormat subfolder_format;
- destination = gtk_file_chooser_get_file (GTK_FILE_CHOOSER (GET_WIDGET ("destination_filechooserbutton")));
- if (destination == NULL)
+ destination_example = gth_import_preferences_dialog_get_destination_example (self);
+ if (destination_example == 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 ();
- g_get_current_time (&timeval);
-
- destination_example = gth_import_utils_get_file_destination (example_data,
- destination,
- subfolder_type,
- subfolder_format,
- single_subfolder,
- custom_format,
- self->priv->event,
- timeval);
-
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);
+ subfolder_type = get_subfolder_type (self);
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);
+ subfolder_format = gtk_combo_box_get_active (GTK_COMBO_BOX (self->priv->subfolder_format_list));
gtk_notebook_set_current_page (GTK_NOTEBOOK (GET_WIDGET ("subfolder_options_notebook")), (subfolder_format == GTH_SUBFOLDER_FORMAT_CUSTOM) ? 1 : 0);
+ g_signal_emit (self, signals[DESTINATION_CHANGED], 0);
+
g_free (example);
g_free (uri);
g_object_unref (destination_example);
- g_object_unref (example_data);
- g_object_unref (destination);
}
@@ -466,4 +466,46 @@ gth_import_preferences_dialog_set_event (GthImportPreferencesDialog *self,
{
g_free (self->priv->event);
self->priv->event = g_strdup (event);
+
+ g_signal_emit (self, signals[DESTINATION_CHANGED], 0);
+}
+
+
+GFile *
+gth_import_preferences_dialog_get_destination_example (GthImportPreferencesDialog *self)
+{
+ GFile *destination;
+ GthSubfolderType subfolder_type;
+ GthSubfolderFormat subfolder_format;
+ gboolean single_subfolder;
+ const char *custom_format;
+ GthFileData *example_data;
+ GTimeVal timeval;
+ GFile *destination_example;
+
+ destination = gtk_file_chooser_get_file (GTK_FILE_CHOOSER (GET_WIDGET ("destination_filechooserbutton")));
+ if (destination == NULL)
+ return NULL;
+
+ 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 ();
+ g_get_current_time (&timeval);
+
+ destination_example = gth_import_utils_get_file_destination (example_data,
+ destination,
+ subfolder_type,
+ subfolder_format,
+ single_subfolder,
+ custom_format,
+ self->priv->event,
+ timeval);
+
+ g_object_unref (example_data);
+ g_object_unref (destination);
+
+ return destination_example;
}
diff --git a/extensions/importer/gth-import-preferences-dialog.h b/extensions/importer/gth-import-preferences-dialog.h
index e0bb499..2d254b3 100644
--- a/extensions/importer/gth-import-preferences-dialog.h
+++ b/extensions/importer/gth-import-preferences-dialog.h
@@ -47,12 +47,18 @@ struct _GthImportPreferencesDialog {
struct _GthImportPreferencesDialogClass {
GtkDialogClass parent_class;
+
+ /*< signals >*/
+
+ void (*destination_changed) (GthImportPreferencesDialog *self);
};
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_dialog_get_destination_example
+ (GthImportPreferencesDialog *self);
G_END_DECLS
diff --git a/extensions/photo_importer/data/ui/photo-importer.ui b/extensions/photo_importer/data/ui/photo-importer.ui
index d6b6394..d57eb9d 100644
--- a/extensions/photo_importer/data/ui/photo-importer.ui
+++ b/extensions/photo_importer/data/ui/photo-importer.ui
@@ -1,4 +1,4 @@
-<?xml version="1.0" encoding="UTF-8"?>
+<?xml version="1.0"?>
<interface>
<requires lib="gtk+" version="2.16"/>
<!-- interface-naming-policy project-wide -->
@@ -10,11 +10,13 @@
<child internal-child="vbox">
<object class="GtkVBox" id="dialog-vbox1">
<property name="visible">True</property>
+ <property name="orientation">vertical</property>
<property name="spacing">2</property>
<child>
<object class="GtkVBox" id="vbox1">
<property name="visible">True</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">
@@ -108,6 +110,7 @@
<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="filelist_box">
@@ -129,7 +132,7 @@
<child>
<object class="GtkTable" id="tags_box">
<property name="visible">True</property>
- <property name="n_rows">2</property>
+ <property name="n_rows">3</property>
<property name="n_columns">2</property>
<property name="column_spacing">6</property>
<property name="row_spacing">5</property>
@@ -144,8 +147,8 @@
<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>
+ <property name="top_attach">2</property>
+ <property name="bottom_attach">3</property>
</packing>
</child>
<child>
@@ -163,8 +166,8 @@
</child>
</object>
<packing>
- <property name="top_attach">1</property>
- <property name="bottom_attach">2</property>
+ <property name="top_attach">2</property>
+ <property name="bottom_attach">3</property>
<property name="x_options">GTK_FILL</property>
</packing>
</child>
@@ -177,6 +180,8 @@
<property name="mnemonic_widget">event_entry</property>
</object>
<packing>
+ <property name="top_attach">1</property>
+ <property name="bottom_attach">2</property>
<property name="x_options">GTK_FILL</property>
</packing>
</child>
@@ -184,7 +189,59 @@
<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>
+ <property name="right_attach">2</property>
+ <property name="top_attach">1</property>
+ <property name="bottom_attach">2</property>
+ </packing>
+ </child>
+ <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_button</property>
+ </object>
+ <packing>
+ <property name="x_options">GTK_FILL</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkButton" id="destination_button">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="receives_default">True</property>
+ <property name="tooltip_text" translatable="yes">Click to change the destination or set an automatic subfolder</property>
+ <child>
+ <object class="GtkHBox" id="hbox2">
+ <property name="visible">True</property>
+ <property name="spacing">6</property>
+ <child>
+ <object class="GtkImage" id="destination_icon">
+ <property name="visible">True</property>
+ <property name="icon_name">folder</property>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="position">0</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkLabel" id="destination_label">
+ <property name="visible">True</property>
+ <property name="xalign">0</property>
+ <property name="ellipsize">start</property>
+ </object>
+ <packing>
+ <property name="position">1</property>
+ </packing>
+ </child>
+ </object>
+ </child>
</object>
<packing>
<property name="left_attach">1</property>
diff --git a/extensions/photo_importer/dlg-photo-importer.c b/extensions/photo_importer/dlg-photo-importer.c
index ee847bb..1b3a93d 100644
--- a/extensions/photo_importer/dlg-photo-importer.c
+++ b/extensions/photo_importer/dlg-photo-importer.c
@@ -270,6 +270,29 @@ file_view_selection_changed_cb (GtkIconView *iconview,
static void
+preferences_dialog_destination_changed_cb (GthImportPreferencesDialog *dialog,
+ DialogData *data)
+{
+ GFile *destination_example;
+
+ destination_example = gth_import_preferences_dialog_get_destination_example (dialog);
+ if (destination_example != NULL) {
+ char *name;
+
+ name = g_file_get_parse_name (destination_example);
+ gtk_image_set_from_icon_name(GTK_IMAGE (GET_WIDGET("destination_icon")), "folder", GTK_ICON_SIZE_MENU);
+ gtk_label_set_text (GTK_LABEL (GET_WIDGET ("destination_label")), name);
+
+ g_free (name);
+ }
+ else {
+ gtk_image_set_from_icon_name(GTK_IMAGE (GET_WIDGET("destination_icon")), "dialog-error", GTK_ICON_SIZE_MENU);
+ gtk_label_set_text (GTK_LABEL (GET_WIDGET ("destination_label")), _("Invalid Destination"));
+ }
+}
+
+
+static void
list_ready_cb (GList *files,
GError *error,
gpointer user_data)
@@ -474,6 +497,15 @@ preferences_button_clicked_cb (GtkWidget *widget,
}
+static void
+event_entry_changed_cb (GtkEditable *editable,
+ DialogData *data)
+{
+ gth_import_preferences_dialog_set_event (GTH_IMPORT_PREFERENCES_DIALOG (data->preferences_dialog),
+ gtk_entry_get_text (GTK_ENTRY (GET_WIDGET ("event_entry"))));
+}
+
+
void
dlg_photo_importer (GthBrowser *browser,
GFile *source)
@@ -615,6 +647,10 @@ dlg_photo_importer (GthBrowser *browser,
"selection_changed",
G_CALLBACK (file_view_selection_changed_cb),
data);
+ g_signal_connect (data->preferences_dialog,
+ "destination_changed",
+ G_CALLBACK (preferences_dialog_destination_changed_cb),
+ data);
g_signal_connect (GET_WIDGET ("preferences_button"),
"clicked",
G_CALLBACK (preferences_button_clicked_cb),
@@ -623,6 +659,14 @@ dlg_photo_importer (GthBrowser *browser,
"entry-points-changed",
G_CALLBACK (entry_points_changed_cb),
data);
+ g_signal_connect_after (GET_WIDGET ("event_entry"),
+ "changed",
+ G_CALLBACK (event_entry_changed_cb),
+ data);
+ g_signal_connect (GET_WIDGET ("destination_button"),
+ "clicked",
+ G_CALLBACK (preferences_button_clicked_cb),
+ data);
/* Run dialog. */
@@ -630,5 +674,8 @@ dlg_photo_importer (GthBrowser *browser,
gtk_window_set_modal (GTK_WINDOW (data->dialog), FALSE);
gtk_widget_show (data->dialog);
+ 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);
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]