[gthumb] Bug 594788 - 2 date codes: %D and %M with default formats + ui help
- From: Paolo Bacchilega <paobac src gnome org>
- To: svn-commits-list gnome org
- Cc:
- Subject: [gthumb] Bug 594788 - 2 date codes: %D and %M with default formats + ui help
- Date: Fri, 15 Jan 2010 22:43:18 +0000 (UTC)
commit 626dbaaba4f397188b9567563cb45ceba83c1598
Author: Matthias Hawran <matthias hawran net>
Date: Thu Jan 14 11:05:58 2010 +0100
Bug 594788 - 2 date codes: %D and %M with default formats + ui help
extensions/rename_series/data/ui/rename-series.ui | 39 +++++++++++++++--
extensions/rename_series/dlg-rename-series.c | 47 +++++++++++++++++----
2 files changed, 74 insertions(+), 12 deletions(-)
---
diff --git a/extensions/rename_series/data/ui/rename-series.ui b/extensions/rename_series/data/ui/rename-series.ui
index b7f4d13..283e7b2 100644
--- a/extensions/rename_series/data/ui/rename-series.ui
+++ b/extensions/rename_series/data/ui/rename-series.ui
@@ -129,7 +129,7 @@
</child>
<child>
<object class="GtkTable" id="template_help_table">
- <property name="n_rows">7</property>
+ <property name="n_rows">8</property>
<property name="n_columns">2</property>
<property name="column_spacing">12</property>
<property name="row_spacing">6</property>
@@ -313,7 +313,7 @@
<object class="GtkLabel" id="label4">
<property name="visible">True</property>
<property name="xalign">0</property>
- <property name="label" translatable="yes">%date{ date format }</property>
+ <property name="label" translatable="yes">%M{ date format }</property>
<attributes>
<attribute name="size" value="8000"/>
</attributes>
@@ -327,7 +327,8 @@
<object class="GtkLabel" id="label8">
<property name="visible">True</property>
<property name="xalign">0</property>
- <property name="label" translatable="yes">A date format</property>
+ <property name="label" translatable="yes">A modification date format</property>
+ <property name="wrap">True</property>
<attributes>
<attribute name="size" value="8000"/>
</attributes>
@@ -339,6 +340,36 @@
<property name="bottom_attach">7</property>
</packing>
</child>
+ <child>
+ <object class="GtkLabel" id="label12">
+ <property name="visible">True</property>
+ <property name="xalign">0</property>
+ <property name="label" translatable="yes">%D{ date format }</property>
+ <attributes>
+ <attribute name="size" value="8000"/>
+ </attributes>
+ </object>
+ <packing>
+ <property name="top_attach">7</property>
+ <property name="bottom_attach">8</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkLabel" id="label13">
+ <property name="visible">True</property>
+ <property name="xalign">0</property>
+ <property name="label" translatable="yes">A digital date format</property>
+ <attributes>
+ <attribute name="size" value="8000"/>
+ </attributes>
+ </object>
+ <packing>
+ <property name="left_attach">1</property>
+ <property name="right_attach">2</property>
+ <property name="top_attach">7</property>
+ <property name="bottom_attach">8</property>
+ </packing>
+ </child>
</object>
<packing>
<property name="position">1</property>
@@ -525,8 +556,8 @@
<object class="GtkSizeGroup" id="sizegroup1">
<property name="mode">vertical</property>
<widgets>
- <widget name="label1"/>
<widget name="template_entry"/>
+ <widget name="label1"/>
</widgets>
</object>
<object class="GtkAdjustment" id="start_at_adjustment">
diff --git a/extensions/rename_series/dlg-rename-series.c b/extensions/rename_series/dlg-rename-series.c
index 01c6aac..110258f 100644
--- a/extensions/rename_series/dlg-rename-series.c
+++ b/extensions/rename_series/dlg-rename-series.c
@@ -221,25 +221,56 @@ template_eval_cb (const GMatchInfo *info,
g_free (format);
}
- else if (strncmp (match, "%date", 5) == 0) {
- GTimeVal timeval;
+ else if (strncmp (match, "%D",2) == 0) {
+ GTimeVal timeval;
GRegex *re;
char **a;
char *date = NULL;
- /* Get file time info */
- if(!gth_file_data_get_digitalization_time (template_data->file_data,&timeval))
- timeval = *gth_file_data_get_modification_time (template_data->file_data);
+ /* Get file digitalization time info */
+ if(gth_file_data_get_digitalization_time (template_data->file_data,&timeval)) {
+ /* Get input date format */
+ re = g_regex_new ("%D\\{([^}]+)\\}", 0, 0, NULL);
+ a = g_regex_split (re, match, 0);
+ if (g_strv_length (a) >= 2)
+ date = g_strstrip (a[1]);
+
+ /* Convert */
+ if ((date != NULL) && (*date != '\0')) {
+ r = _g_time_val_strftime (&timeval, date);
+ }
+ else {
+ /* default if no input format */
+ r = _g_time_val_strftime (&timeval, "%Y-%m-%d");
+ }
+
+ g_strfreev (a);
+ g_regex_unref (re);
+ }
+ }
+ else if (strncmp (match, "%M",2) == 0) {
+ GTimeVal timeval;
+ GRegex *re;
+ char **a;
+ char *date = NULL;
+
+ /* Get file modification time info */
+ timeval = *gth_file_data_get_modification_time (template_data->file_data);
/* Get input date format */
- re = g_regex_new ("%date\\{([^}]+)\\}", 0, 0, NULL);
+ re = g_regex_new ("%M\\{([^}]+)\\}", 0, 0, NULL);
a = g_regex_split (re, match, 0);
if (g_strv_length (a) >= 2)
date = g_strstrip (a[1]);
/* Convert */
- if ((date != NULL) && (*date != '\0'))
+ if ((date != NULL) && (*date != '\0')) {
r = _g_time_val_strftime (&timeval, date);
+ }
+ else {
+ /* default if no input format */
+ r = _g_time_val_strftime (&timeval, "%Y-%m-%d");
+ }
g_strfreev (a);
g_regex_unref (re);
@@ -297,7 +328,7 @@ dlg_rename_series_update_preview (DialogData *data)
template_data->error = &error;
template_data->n = gtk_spin_button_get_value_as_int (GTK_SPIN_BUTTON (GET_WIDGET ("start_at_spinbutton")));
template_data->template = gtk_entry_get_text (GTK_ENTRY (GET_WIDGET ("template_entry")));
- re = g_regex_new ("#+|%F|%E|%N|%attr\\{[^}]+\\}|%date\\{[^}]+\\}", 0, 0, NULL);
+ re = g_regex_new ("#+|%F|%E|%N|%attr\\{[^}]+\\}|%D(\\{[^}]+\\})?|%M(\\{[^}]+\\})?", 0, 0, NULL);
for (scan = data->new_file_list; scan; scan = scan->next) {
char *new_name;
char *new_name2;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]