[gthumb] Changes to the renamed dialog



commit 1adb8e9fd68a385d02ead43c7e3582149087b59b
Author: Paolo Bacchilega <paobac src gnome org>
Date:   Fri Jan 15 23:37:25 2010 +0100

    Changes to the renamed dialog
    
    *) read all the files metadata for the rename dialog
    *) use %A instead of %attr for the generic attribute
    *) other minor changes

 extensions/rename_series/actions.c                |   26 +++++++-
 extensions/rename_series/data/ui/rename-series.ui |   54 ++++++++--------
 extensions/rename_series/dlg-rename-series.c      |   74 +++++++-------------
 3 files changed, 77 insertions(+), 77 deletions(-)
---
diff --git a/extensions/rename_series/actions.c b/extensions/rename_series/actions.c
index bc5b8e3..6cc9cab 100644
--- a/extensions/rename_series/actions.c
+++ b/extensions/rename_series/actions.c
@@ -27,17 +27,39 @@
 #include "dlg-rename-series.h"
 
 
+static void
+file_list_ready_cb (GList    *file_list,
+		    GError   *error,
+		    gpointer  user_data)
+{
+	GthBrowser *browser = user_data;
+
+	if (error != NULL) {
+		_gtk_error_dialog_from_gerror_show (GTK_WINDOW (browser), _("Cannot read file information"), &error);
+		return;
+	}
+
+	dlg_rename_series (browser, file_list);
+
+	g_object_unref (browser);
+}
+
+
 void
 gth_browser_activate_action_edit_rename (GtkAction  *action,
 					 GthBrowser *browser)
 {
 	GList *items;
+	GList *file_data_list;
 	GList *file_list;
 
 	items = gth_file_selection_get_selected (GTH_FILE_SELECTION (gth_browser_get_file_list_view (browser)));
-	file_list = gth_file_list_get_files (GTH_FILE_LIST (gth_browser_get_file_list (browser)), items);
-	dlg_rename_series (browser, file_list);
+	file_data_list = gth_file_list_get_files (GTH_FILE_LIST (gth_browser_get_file_list (browser)), items);
+	file_list = gth_file_data_list_to_file_list (file_data_list);
+	g_object_ref (browser);
+	_g_query_all_metadata_async (file_list, FALSE, TRUE, "*", NULL, file_list_ready_cb, browser);
 
 	_g_object_list_unref (file_list);
+	_g_object_list_unref (file_data_list);
 	_gtk_tree_path_list_free (items);
 }
diff --git a/extensions/rename_series/data/ui/rename-series.ui b/extensions/rename_series/data/ui/rename-series.ui
index 283e7b2..e4ca46f 100644
--- a/extensions/rename_series/data/ui/rename-series.ui
+++ b/extensions/rename_series/data/ui/rename-series.ui
@@ -250,24 +250,24 @@
                           </packing>
                         </child>
                         <child>
-                          <object class="GtkLabel" id="label16">
+                          <object class="GtkLabel" id="label18">
                             <property name="visible">True</property>
                             <property name="xalign">0</property>
-                            <property name="label" translatable="yes" comments="Translate only 'attribute name'">%attr{ attribute name }</property>
+                            <property name="label" translatable="yes">%N</property>
                             <attributes>
                               <attribute name="size" value="8000"/>
                             </attributes>
                           </object>
                           <packing>
-                            <property name="top_attach">5</property>
-                            <property name="bottom_attach">6</property>
+                            <property name="top_attach">4</property>
+                            <property name="bottom_attach">5</property>
                           </packing>
                         </child>
                         <child>
-                          <object class="GtkLabel" id="label17">
+                          <object class="GtkLabel" id="label19">
                             <property name="visible">True</property>
                             <property name="xalign">0</property>
-                            <property name="label" translatable="yes">A file attribute</property>
+                            <property name="label" translatable="yes">The original enumerator</property>
                             <attributes>
                               <attribute name="size" value="8000"/>
                             </attributes>
@@ -275,29 +275,30 @@
                           <packing>
                             <property name="left_attach">1</property>
                             <property name="right_attach">2</property>
-                            <property name="top_attach">5</property>
-                            <property name="bottom_attach">6</property>
+                            <property name="top_attach">4</property>
+                            <property name="bottom_attach">5</property>
                           </packing>
                         </child>
                         <child>
-                          <object class="GtkLabel" id="label18">
+                          <object class="GtkLabel" id="label4">
                             <property name="visible">True</property>
                             <property name="xalign">0</property>
-                            <property name="label" translatable="yes">%N</property>
+                            <property name="label" translatable="yes" comments="translate only the text in the curly brackets">%M{ format }</property>
                             <attributes>
                               <attribute name="size" value="8000"/>
                             </attributes>
                           </object>
                           <packing>
-                            <property name="top_attach">4</property>
-                            <property name="bottom_attach">5</property>
+                            <property name="top_attach">5</property>
+                            <property name="bottom_attach">6</property>
                           </packing>
                         </child>
                         <child>
-                          <object class="GtkLabel" id="label19">
+                          <object class="GtkLabel" id="label8">
                             <property name="visible">True</property>
                             <property name="xalign">0</property>
-                            <property name="label" translatable="yes">The original enumerator</property>
+                            <property name="label" translatable="yes">The modification date</property>
+                            <property name="wrap">True</property>
                             <attributes>
                               <attribute name="size" value="8000"/>
                             </attributes>
@@ -305,15 +306,15 @@
                           <packing>
                             <property name="left_attach">1</property>
                             <property name="right_attach">2</property>
-                            <property name="top_attach">4</property>
-                            <property name="bottom_attach">5</property>
+                            <property name="top_attach">5</property>
+                            <property name="bottom_attach">6</property>
                           </packing>
                         </child>
                         <child>
-                          <object class="GtkLabel" id="label4">
+                          <object class="GtkLabel" id="label12">
                             <property name="visible">True</property>
                             <property name="xalign">0</property>
-                            <property name="label" translatable="yes">%M{ date format }</property>
+                            <property name="label" translatable="yes" comments="translate only the text in the curly brackets">%D{ format }</property>
                             <attributes>
                               <attribute name="size" value="8000"/>
                             </attributes>
@@ -324,11 +325,10 @@
                           </packing>
                         </child>
                         <child>
-                          <object class="GtkLabel" id="label8">
+                          <object class="GtkLabel" id="label13">
                             <property name="visible">True</property>
                             <property name="xalign">0</property>
-                            <property name="label" translatable="yes">A modification date format</property>
-                            <property name="wrap">True</property>
+                            <property name="label" translatable="yes">The digitalization date</property>
                             <attributes>
                               <attribute name="size" value="8000"/>
                             </attributes>
@@ -341,10 +341,10 @@
                           </packing>
                         </child>
                         <child>
-                          <object class="GtkLabel" id="label12">
+                          <object class="GtkLabel" id="label16">
                             <property name="visible">True</property>
                             <property name="xalign">0</property>
-                            <property name="label" translatable="yes">%D{ date format }</property>
+                            <property name="label" translatable="yes" comments="translate only the text in the curly brackets">%A{ identifier }</property>
                             <attributes>
                               <attribute name="size" value="8000"/>
                             </attributes>
@@ -355,10 +355,10 @@
                           </packing>
                         </child>
                         <child>
-                          <object class="GtkLabel" id="label13">
+                          <object class="GtkLabel" id="label17">
                             <property name="visible">True</property>
                             <property name="xalign">0</property>
-                            <property name="label" translatable="yes">A digital date format</property>
+                            <property name="label" translatable="yes">A file attribute</property>
                             <attributes>
                               <attribute name="size" value="8000"/>
                             </attributes>
@@ -556,13 +556,13 @@
   <object class="GtkSizeGroup" id="sizegroup1">
     <property name="mode">vertical</property>
     <widgets>
-      <widget name="template_entry"/>
       <widget name="label1"/>
+      <widget name="template_entry"/>
     </widgets>
   </object>
   <object class="GtkAdjustment" id="start_at_adjustment">
-    <property name="value">1</property>
     <property name="upper">1000000000</property>
+    <property name="value">1</property>
     <property name="step_increment">1</property>
     <property name="page_increment">10</property>
   </object>
diff --git a/extensions/rename_series/dlg-rename-series.c b/extensions/rename_series/dlg-rename-series.c
index 110258f..77c6260 100644
--- a/extensions/rename_series/dlg-rename-series.c
+++ b/extensions/rename_series/dlg-rename-series.c
@@ -161,7 +161,7 @@ get_attribute_value (GthFileData *file_data,
 	char      *attribute = NULL;
 	char      *value = NULL;
 
-	re = g_regex_new ("%attr\\{([^}]+)\\}", 0, 0, NULL);
+	re = g_regex_new ("%A\\{([^}]+)\\}", 0, 0, NULL);
 	a = g_regex_split (re, match, 0);
 	if (g_strv_length (a) >= 2)
 		attribute = g_strstrip (a[1]);
@@ -208,7 +208,7 @@ template_eval_cb (const GMatchInfo *info,
 	else if (strcmp (match, "%N") == 0) {
 		r = get_original_enum (template_data->file_data, match);
 	}
-	else if (strncmp (match, "%attr", 5) == 0) {
+	else if (strncmp (match, "%A", 2) == 0) {
 		r = get_attribute_value (template_data->file_data, match);
 		/*if (r == NULL)
 			*template_data->error = g_error_new_literal (GTH_TASK_ERROR, GTH_TASK_ERROR_FAILED, _("Malformed template"));*/
@@ -221,60 +221,38 @@ template_eval_cb (const GMatchInfo *info,
 
 		g_free (format);
 	}
-	else if (strncmp (match, "%D",2) == 0) {
-		GTimeVal   timeval;
-		GRegex    *re;
-		char     **a;
-		char      *date = NULL;
-
-		/* 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);
+	else if ((strncmp (match, "%D", 2) == 0) || (strncmp (match, "%M", 2) == 0)) {
+		gboolean value_available = FALSE;
+		GTimeVal timeval;
+
+		if (strncmp (match, "%D", 2) == 0) {
+			value_available = gth_file_data_get_digitalization_time (template_data->file_data, &timeval);
+		}
+		else if (strncmp (match, "%M", 2) == 0) {
+			timeval = *gth_file_data_get_modification_time (template_data->file_data);
+			value_available = TRUE;
+		}
+
+		if (value_available) {
+			GRegex  *re;
+			char   **a;
+			char    *date = NULL;
+
+			/* Get the date format */
+
+			re = g_regex_new ("%[A-Z]\\{([^}]+)\\}", 0, 0, NULL);
 			a = g_regex_split (re, match, 0);
 			if (g_strv_length (a) >= 2)
 				date = g_strstrip (a[1]);
+			if ((date == NULL) || (*date == '\0'))
+				date = "%Y-%m-%d";
 
-			/* 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");
-			}
+			r = _g_time_val_strftime (&timeval, date);
 
 			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 ("%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')) {
-			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);
-	}
 
 	if (r != NULL)
 		g_string_append (res, r);
@@ -328,7 +306,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\\{[^}]+\\}|%D(\\{[^}]+\\})?|%M(\\{[^}]+\\})?", 0, 0, NULL);
+	re = g_regex_new ("#+|%F|%E|%N|%D(\\{[^}]+\\})?|%M(\\{[^}]+\\})?|%A\\{[^}]+\\}", 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]