[gthumb] Save and restore the settings in the change date dialog
- From: Paolo Bacchilega <paobac src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gthumb] Save and restore the settings in the change date dialog
- Date: Sun, 3 Jul 2011 17:20:15 +0000 (UTC)
commit 9c61f6bbfafb10973cd69f921457e8fa66b0aae7
Author: Paolo Bacchilega <paobac src gnome org>
Date: Sun Jul 3 19:17:25 2011 +0200
Save and restore the settings in the change date dialog
[bug #451803, new feature]
extensions/change_date/Makefile.am | 3 +-
extensions/change_date/data/Makefile.am | 15 ++++
.../change_date/data/gthumb_change_date.schemas.in | 77 +++++++++++++++++++
extensions/change_date/dlg-change-date.c | 81 ++++++++++++++++++-
extensions/change_date/preferences.h | 42 ++++++++++
5 files changed, 212 insertions(+), 6 deletions(-)
---
diff --git a/extensions/change_date/Makefile.am b/extensions/change_date/Makefile.am
index 5b9336b..4459b19 100644
--- a/extensions/change_date/Makefile.am
+++ b/extensions/change_date/Makefile.am
@@ -12,7 +12,8 @@ libchange_date_la_SOURCES = \
dlg-change-date.h \
gth-change-date-task.c \
gth-change-date-task.h \
- main.c
+ main.c \
+ preferences.h
libchange_date_la_CFLAGS = $(GTHUMB_CFLAGS) -I$(top_srcdir) -I$(top_builddir)/gthumb
libchange_date_la_LDFLAGS = $(EXTENSION_LIBTOOL_FLAGS)
diff --git a/extensions/change_date/data/Makefile.am b/extensions/change_date/data/Makefile.am
index c1713cf..1d8bbef 100644
--- a/extensions/change_date/data/Makefile.am
+++ b/extensions/change_date/data/Makefile.am
@@ -1,3 +1,18 @@
SUBDIRS = ui
+schemadir = @GCONF_SCHEMA_FILE_DIR@
+schema_in_files = gthumb_change_date.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)/extensions/change_date/data/$(schema_DATA)
+endif
+
+EXTRA_DIST = $(schema_in_files)
+
+CLEANFILES = $(schema_DATA)
+
-include $(top_srcdir)/git.mk
diff --git a/extensions/change_date/data/gthumb_change_date.schemas.in b/extensions/change_date/data/gthumb_change_date.schemas.in
new file mode 100644
index 0000000..82a59a3
--- /dev/null
+++ b/extensions/change_date/data/gthumb_change_date.schemas.in
@@ -0,0 +1,77 @@
+<gconfschemafile>
+ <schemalist>
+
+ <schema>
+ <key>/schemas/apps/gthumb/ext/resize_images/width</key>
+ <applyto>/apps/gthumb/ext/resize_images/width</applyto>
+ <owner>gthumb</owner>
+ <type>int</type>
+ <default>640</default>
+ <locale name="C">
+ <short></short>
+ <long></long>
+ </locale>
+ </schema>
+
+ <schema>
+ <key>/schemas/apps/gthumb/ext/resize_images/height</key>
+ <applyto>/apps/gthumb/ext/resize_images/height</applyto>
+ <owner>gthumb</owner>
+ <type>int</type>
+ <default>480</default>
+ <locale name="C">
+ <short></short>
+ <long></long>
+ </locale>
+ </schema>
+
+ <schema>
+ <key>/schemas/apps/gthumb/ext/resize_images/unit</key>
+ <applyto>/apps/gthumb/ext/resize_images/unit</applyto>
+ <owner>gthumb</owner>
+ <type>string</type>
+ <default>%</default>
+ <locale name="C">
+ <short>Possible values: pixels, percentage</short>
+ <long></long>
+ </locale>
+ </schema>
+
+ <schema>
+ <key>/schemas/apps/gthumb/ext/resize_images/keep_aspect_ratio</key>
+ <applyto>/apps/gthumb/ext/resize_images/keep_aspect_ratio</applyto>
+ <owner>gthumb</owner>
+ <type>bool</type>
+ <default>true</default>
+ <locale name="C">
+ <short></short>
+ <long></long>
+ </locale>
+ </schema>
+
+ <schema>
+ <key>/schemas/apps/gthumb/ext/resize_images/allow_swap_width_height</key>
+ <applyto>/apps/gthumb/ext/resize_images/allow_swap_width_height</applyto>
+ <owner>gthumb</owner>
+ <type>bool</type>
+ <default>true</default>
+ <locale name="C">
+ <short></short>
+ <long></long>
+ </locale>
+ </schema>
+
+ <schema>
+ <key>/schemas/apps/gthumb/ext/resize_images/mime_type</key>
+ <applyto>/apps/gthumb/ext/resize_images/mime_type</applyto>
+ <owner>gthumb</owner>
+ <type>string</type>
+ <default></default>
+ <locale name="C">
+ <short></short>
+ <long></long>
+ </locale>
+ </schema>
+
+ </schemalist>
+</gconfschemafile>
diff --git a/extensions/change_date/dlg-change-date.c b/extensions/change_date/dlg-change-date.c
index de6e2f7..fa35227 100644
--- a/extensions/change_date/dlg-change-date.c
+++ b/extensions/change_date/dlg-change-date.c
@@ -23,6 +23,7 @@
#include <gtk/gtk.h>
#include <gthumb.h>
#include "gth-change-date-task.h"
+#include "preferences.h"
#define GET_WIDGET(x) (_gtk_builder_get_widget (data->builder, (x)))
@@ -92,6 +93,28 @@ ok_button_clicked (GtkWidget *button,
time_adjustment = -time_adjustment;
}
+ /* save the preferences */
+
+ eel_gconf_set_boolean (PREF_CHANGE_DATE_SET_LAST_MODIFIED_DATE, (change_fields & GTH_CHANGE_LAST_MODIFIED_DATE) == GTH_CHANGE_LAST_MODIFIED_DATE);
+ eel_gconf_set_boolean (PREF_CHANGE_DATE_SET_COMMENT_DATE, (change_fields & GTH_CHANGE_COMMENT_DATE) == GTH_CHANGE_COMMENT_DATE);
+ eel_gconf_set_boolean (PREF_CHANGE_DATE_SET_EXIF_DATETIMEORIGINAL_TAG, (change_fields & GTH_CHANGE_EXIF_DATETIMEORIGINAL_TAG) == GTH_CHANGE_EXIF_DATETIMEORIGINAL_TAG);
+
+ eel_gconf_set_boolean (PREF_CHANGE_DATE_TO_FOLLOWING_DATE, change_type == GTH_CHANGE_TO_FOLLOWING_DATE);
+ if (change_type == GTH_CHANGE_TO_FOLLOWING_DATE) {
+ char *s;
+ s = gth_datetime_to_exif_date (date_time);
+ eel_gconf_set_string (PREF_CHANGE_DATE_DATE, s);
+ g_free (s);
+ }
+ eel_gconf_set_boolean (PREF_CHANGE_DATE_TO_FILE_MODIFIED_DATE, change_type == GTH_CHANGE_TO_FILE_MODIFIED_DATE);
+ eel_gconf_set_boolean (PREF_CHANGE_DATE_TO_FILE_CREATION_DATE, change_type == GTH_CHANGE_TO_FILE_CREATION_DATE);
+ eel_gconf_set_boolean (PREF_CHANGE_DATE_TO_PHOTO_ORIGINAL_DATE, change_type == GTH_CHANGE_TO_PHOTO_ORIGINAL_DATE);
+ eel_gconf_set_boolean (PREF_CHANGE_DATE_ADJUST_TIME, change_type == GTH_CHANGE_ADJUST_TIME);
+ if (change_type == GTH_CHANGE_ADJUST_TIME)
+ eel_gconf_set_integer (PREF_CHANGE_DATE_TIME_ADJUSTMENT, time_adjustment);
+
+ /* exec the task */
+
task = gth_change_date_task_new (gth_browser_get_location (data->browser),
data->file_list,
change_fields,
@@ -160,17 +183,65 @@ dlg_change_date (GthBrowser *browser,
data->dialog = GET_WIDGET ("change_date_dialog");
data->date_selector = gth_time_selector_new ();
gth_time_selector_show_time (GTH_TIME_SELECTOR (data->date_selector), TRUE, TRUE);
+ gtk_widget_show (data->date_selector);
+ gtk_box_pack_start (GTK_BOX (GET_WIDGET ("date_selector_box")), data->date_selector, TRUE, TRUE, 0);
+
+ /* Set widgets data. */
+
+ gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (GET_WIDGET ("change_last_modified_checkbutton")), eel_gconf_get_boolean (PREF_CHANGE_DATE_SET_LAST_MODIFIED_DATE, FALSE));
+ gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (GET_WIDGET ("change_comment_checkbutton")), eel_gconf_get_boolean (PREF_CHANGE_DATE_SET_COMMENT_DATE, FALSE));
+ gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (GET_WIDGET ("change_datetimeoriginal_checkbutton")), eel_gconf_get_boolean (PREF_CHANGE_DATE_SET_EXIF_DATETIMEORIGINAL_TAG, FALSE));
+
+ gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (GET_WIDGET ("to_following_date_radiobutton")), eel_gconf_get_boolean (PREF_CHANGE_DATE_TO_FOLLOWING_DATE, TRUE));
datetime = gth_datetime_new ();
g_get_current_time (&timeval);
- gth_datetime_from_timeval (datetime, &timeval);
+ if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (GET_WIDGET ("to_following_date_radiobutton")))) {
+ char *s;
+ s = eel_gconf_get_string (PREF_CHANGE_DATE_DATE, "");
+ if (strcmp (s, "") != 0)
+ gth_datetime_from_exif_date (datetime, s);
+ else
+ gth_datetime_from_timeval (datetime, &timeval);
+ g_free (s);
+ }
+ else
+ gth_datetime_from_timeval (datetime, &timeval);
gth_time_selector_set_value (GTH_TIME_SELECTOR (data->date_selector), datetime);
- gtk_widget_show (data->date_selector);
- gtk_box_pack_start (GTK_BOX (GET_WIDGET ("date_selector_box")), data->date_selector, TRUE, TRUE, 0);
-
gth_datetime_free (datetime);
- /* Set widgets data. */
+ gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (GET_WIDGET ("to_last_modified_date_radiobutton")), eel_gconf_get_boolean (PREF_CHANGE_DATE_TO_FILE_MODIFIED_DATE, FALSE));
+ gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (GET_WIDGET ("to_creation_date_radiobutton")), eel_gconf_get_boolean (PREF_CHANGE_DATE_TO_FILE_CREATION_DATE, FALSE));
+ gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (GET_WIDGET ("to_photo_original_date_radiobutton")), eel_gconf_get_boolean (PREF_CHANGE_DATE_TO_PHOTO_ORIGINAL_DATE, FALSE));
+ gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (GET_WIDGET ("adjust_time_radiobutton")), eel_gconf_get_boolean (PREF_CHANGE_DATE_ADJUST_TIME, FALSE));
+ if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (GET_WIDGET ("adjust_time_radiobutton")))) {
+ int adjustement;
+ int sign;
+ int hours;
+ int minutes;
+ int seconds;
+
+ adjustement = eel_gconf_get_integer (PREF_CHANGE_DATE_TIME_ADJUSTMENT, 0);
+ if (adjustement < 0) {
+ sign = -1;
+ adjustement = - adjustement;
+ }
+ else
+ sign = 1;
+
+ hours = adjustement / 3600;
+ adjustement = adjustement % 3600;
+
+ minutes = adjustement / 60;
+ adjustement = adjustement % 60;
+
+ seconds = adjustement;
+
+ gtk_spin_button_set_value (GTK_SPIN_BUTTON (GET_WIDGET ("adjust_time_h_spinbutton")), hours);
+ gtk_spin_button_set_value (GTK_SPIN_BUTTON (GET_WIDGET ("adjust_time_m_spinbutton")), minutes);
+ gtk_spin_button_set_value (GTK_SPIN_BUTTON (GET_WIDGET ("adjust_time_s_spinbutton")), seconds);
+ gtk_combo_box_set_active (GTK_COMBO_BOX (GET_WIDGET ("adjust_sign_combobox")), (sign >= 0) ? 0 : 1);
+ }
update_sensitivity (data);
diff --git a/extensions/change_date/preferences.h b/extensions/change_date/preferences.h
new file mode 100644
index 0000000..644df01
--- /dev/null
+++ b/extensions/change_date/preferences.h
@@ -0,0 +1,42 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
+
+/*
+ * GThumb
+ *
+ * Copyright (C) 2011 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, see <http://www.gnu.org/licenses/>.
+ */
+
+#ifndef PREFERENCES_H
+#define PREFERENCES_H
+
+#include <gthumb.h>
+
+G_BEGIN_DECLS
+
+#define PREF_CHANGE_DATE_SET_LAST_MODIFIED_DATE "/apps/gthumb/ext/change_date/set_last_modified_date"
+#define PREF_CHANGE_DATE_SET_COMMENT_DATE "/apps/gthumb/ext/change_date/set_comment_date"
+#define PREF_CHANGE_DATE_SET_EXIF_DATETIMEORIGINAL_TAG "/apps/gthumb/ext/change_date/set_exif_datetimeoriginal_tag"
+#define PREF_CHANGE_DATE_TO_FOLLOWING_DATE "/apps/gthumb/ext/change_date/to_following_date"
+#define PREF_CHANGE_DATE_DATE "/apps/gthumb/ext/change_date/date"
+#define PREF_CHANGE_DATE_TO_FILE_MODIFIED_DATE "/apps/gthumb/ext/change_date/to_file_modified_date"
+#define PREF_CHANGE_DATE_TO_FILE_CREATION_DATE "/apps/gthumb/ext/change_date/to_file_creation_date"
+#define PREF_CHANGE_DATE_TO_PHOTO_ORIGINAL_DATE "/apps/gthumb/ext/change_date/to_photo_original_date"
+#define PREF_CHANGE_DATE_ADJUST_TIME "/apps/gthumb/ext/change_date/adjust_time"
+#define PREF_CHANGE_DATE_TIME_ADJUSTMENT "/apps/gthumb/ext/change_date/time_adjustment"
+
+G_END_DECLS
+
+#endif /* PREFERENCES_H */
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]