[gthumb] script: added %T to insert a timestamp in the command



commit 1b58d6bf021b8e389ec927d097893dda00492d7b
Author: Paolo Bacchilega <paobac src gnome org>
Date:   Fri Feb 21 21:00:55 2020 +0100

    script: added %T to insert a timestamp in the command

 extensions/list_tools/data/ui/script-editor.ui | 62 ++++++++++++++++++++------
 extensions/list_tools/gth-script.c             | 19 +++++++-
 2 files changed, 66 insertions(+), 15 deletions(-)
---
diff --git a/extensions/list_tools/data/ui/script-editor.ui b/extensions/list_tools/data/ui/script-editor.ui
index 0f4b262e..f6a0bb29 100644
--- a/extensions/list_tools/data/ui/script-editor.ui
+++ b/extensions/list_tools/data/ui/script-editor.ui
@@ -1,5 +1,5 @@
 <?xml version="1.0" encoding="UTF-8"?>
-<!-- Generated with glade 3.20.0 -->
+<!-- Generated with glade 3.22.1 -->
 <interface>
   <requires lib="gtk+" version="3.10"/>
   <object class="GtkBox" id="script_editor">
@@ -157,7 +157,7 @@
                   <object class="GtkTable" id="table2">
                     <property name="visible">True</property>
                     <property name="can_focus">False</property>
-                    <property name="n_rows">10</property>
+                    <property name="n_rows">11</property>
                     <property name="n_columns">2</property>
                     <property name="column_spacing">12</property>
                     <property name="row_spacing">6</property>
@@ -340,8 +340,8 @@
                         </attributes>
                       </object>
                       <packing>
-                        <property name="top_attach">7</property>
-                        <property name="bottom_attach">8</property>
+                        <property name="top_attach">8</property>
+                        <property name="bottom_attach">9</property>
                         <property name="y_options">GTK_FILL</property>
                       </packing>
                     </child>
@@ -358,8 +358,8 @@
                       <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>
+                        <property name="top_attach">8</property>
+                        <property name="bottom_attach">9</property>
                         <property name="y_options">GTK_FILL</property>
                       </packing>
                     </child>
@@ -374,8 +374,8 @@
                         </attributes>
                       </object>
                       <packing>
-                        <property name="top_attach">8</property>
-                        <property name="bottom_attach">9</property>
+                        <property name="top_attach">9</property>
+                        <property name="bottom_attach">10</property>
                         <property name="y_options">GTK_FILL</property>
                       </packing>
                     </child>
@@ -392,8 +392,8 @@
                       <packing>
                         <property name="left_attach">1</property>
                         <property name="right_attach">2</property>
-                        <property name="top_attach">8</property>
-                        <property name="bottom_attach">9</property>
+                        <property name="top_attach">9</property>
+                        <property name="bottom_attach">10</property>
                         <property name="y_options">GTK_FILL</property>
                       </packing>
                     </child>
@@ -476,8 +476,8 @@
                         </attributes>
                       </object>
                       <packing>
-                        <property name="top_attach">9</property>
-                        <property name="bottom_attach">10</property>
+                        <property name="top_attach">10</property>
+                        <property name="bottom_attach">11</property>
                         <property name="y_options">GTK_FILL</property>
                       </packing>
                     </child>
@@ -494,8 +494,42 @@
                       <packing>
                         <property name="left_attach">1</property>
                         <property name="right_attach">2</property>
-                        <property name="top_attach">9</property>
-                        <property name="bottom_attach">10</property>
+                        <property name="top_attach">10</property>
+                        <property name="bottom_attach">11</property>
+                        <property name="y_options">GTK_FILL</property>
+                      </packing>
+                    </child>
+                    <child>
+                      <object class="GtkLabel" id="label25">
+                        <property name="visible">True</property>
+                        <property name="can_focus">False</property>
+                        <property name="label">%T</property>
+                        <property name="xalign">0</property>
+                        <attributes>
+                          <attribute name="size" value="8000"/>
+                        </attributes>
+                      </object>
+                      <packing>
+                        <property name="top_attach">7</property>
+                        <property name="bottom_attach">8</property>
+                        <property name="y_options">GTK_FILL</property>
+                      </packing>
+                    </child>
+                    <child>
+                      <object class="GtkLabel" id="label24">
+                        <property name="visible">True</property>
+                        <property name="can_focus">False</property>
+                        <property name="label" translatable="yes">The current date and time</property>
+                        <property name="xalign">0</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>
                         <property name="y_options">GTK_FILL</property>
                       </packing>
                     </child>
diff --git a/extensions/list_tools/gth-script.c b/extensions/list_tools/gth-script.c
index 023e2adf..2a20c360 100644
--- a/extensions/list_tools/gth-script.c
+++ b/extensions/list_tools/gth-script.c
@@ -708,6 +708,21 @@ create_attribute_list (GList    *file_list,
 }
 
 
+static char *
+get_timestamp (void)
+{
+       GDateTime *now;
+       char      *str;
+
+       now = g_date_time_new_now_local ();
+       str = g_date_time_format (now, "%Y-%m-%d %H.%M.%S");
+
+       g_date_time_unref (now);
+
+       return str;
+}
+
+
 static gboolean
 command_line_eval_cb (const GMatchInfo *info,
                      GString          *res,
@@ -730,6 +745,8 @@ command_line_eval_cb (const GMatchInfo *info,
                r = create_file_list (replace_data->file_list, get_ext_func, replace_data->quote_values);
        else if (strcmp (match, "%P") == 0)
                r = create_file_list (replace_data->file_list, get_parent_func, replace_data->quote_values);
+       else if (strcmp (match, "%T") == 0)
+               r = get_timestamp ();
        else if (strncmp (match, "%attr", 5) == 0) {
                r = create_attribute_list (replace_data->file_list, match, replace_data->quote_values);
                if (r == NULL)
@@ -1010,7 +1027,7 @@ gth_script_get_command_line (GthScript  *script,
 
        /* replace the parameters in the command line */
 
-       re = g_regex_new ("%U|%F|%B|%N|%E|%P|%ask({[^}]+}({[^}]+})?)?|%attr{[^}]+}", 0, 0, NULL);
+       re = g_regex_new ("%U|%F|%B|%N|%E|%P|%T|%ask({[^}]+}({[^}]+})?)?|%attr{[^}]+}", 0, 0, NULL);
 
        replace_data->quote_values = FALSE;
        replace_data->last_asked_value = replace_data->asked_values;


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]