[gthumb] image print: use the template editor



commit f4cb5d951bcfdd1d9c20e29bf24b8a29cebb06ff
Author: Paolo Bacchilega <paobac src gnome org>
Date:   Fri May 21 08:03:55 2021 +0200

    image print: use the template editor

 extensions/image_print/data/ui/print-layout.ui | 809 +++++++++++++------------
 extensions/image_print/gth-image-print-job.c   | 236 +++++---
 2 files changed, 573 insertions(+), 472 deletions(-)
---
diff --git a/extensions/image_print/data/ui/print-layout.ui b/extensions/image_print/data/ui/print-layout.ui
index 76d0b602..d0e5cb2d 100644
--- a/extensions/image_print/data/ui/print-layout.ui
+++ b/extensions/image_print/data/ui/print-layout.ui
@@ -1,6 +1,7 @@
 <?xml version="1.0" encoding="UTF-8"?>
+<!-- Generated with glade 3.38.2 -->
 <interface>
-  <requires lib="gtk+" version="2.16"/>
+  <requires lib="gtk+" version="3.16"/>
   <object class="GtkListStore" id="align_liststore">
     <columns>
       <!-- column-name Name -->
@@ -23,18 +24,18 @@
     <property name="lower">1</property>
     <property name="upper">100</property>
     <property name="value">1</property>
-    <property name="step_increment">1</property>
-    <property name="page_increment">10</property>
+    <property name="step-increment">1</property>
+    <property name="page-increment">10</property>
   </object>
   <object class="GtkAdjustment" id="height_adjustment">
     <property name="upper">100</property>
-    <property name="step_increment">1</property>
-    <property name="page_increment">10</property>
+    <property name="step-increment">1</property>
+    <property name="page-increment">10</property>
   </object>
   <object class="GtkAdjustment" id="left_adjustment">
     <property name="upper">100</property>
-    <property name="step_increment">1</property>
-    <property name="page_increment">10</property>
+    <property name="step-increment">1</property>
+    <property name="page-increment">10</property>
   </object>
   <object class="GtkListStore" id="rotation_liststore">
     <columns>
@@ -62,305 +63,440 @@
       </row>
     </data>
   </object>
+  <object class="GtkAdjustment" id="rows_adjustment">
+    <property name="lower">1</property>
+    <property name="upper">100</property>
+    <property name="value">1</property>
+    <property name="step-increment">1</property>
+    <property name="page-increment">10</property>
+  </object>
+  <object class="GtkAdjustment" id="scale_adjustment">
+    <property name="lower">0.01</property>
+    <property name="upper">1</property>
+    <property name="value">1</property>
+    <property name="step-increment">0.10</property>
+    <property name="page-increment">0.10</property>
+  </object>
+  <object class="GtkListStore" id="size_liststore">
+    <columns>
+      <!-- column-name name -->
+      <column type="gchararray"/>
+      <!-- column-name value -->
+      <column type="gint"/>
+    </columns>
+    <data>
+      <row>
+        <col id="0">1</col>
+        <col id="1">1</col>
+      </row>
+      <row>
+        <col id="0">2</col>
+        <col id="1">2</col>
+      </row>
+      <row>
+        <col id="0">4</col>
+        <col id="1">3</col>
+      </row>
+      <row>
+        <col id="0">8</col>
+        <col id="1">4</col>
+      </row>
+      <row>
+        <col id="0">16</col>
+        <col id="1">5</col>
+      </row>
+      <row>
+        <col id="0">32</col>
+        <col id="1">6</col>
+      </row>
+    </data>
+  </object>
+  <object class="GtkAdjustment" id="top_adjustment">
+    <property name="upper">100</property>
+    <property name="step-increment">1</property>
+    <property name="page-increment">10</property>
+  </object>
+  <object class="GtkListStore" id="unit_liststore">
+    <columns>
+      <!-- column-name Name -->
+      <column type="gchararray"/>
+    </columns>
+    <data>
+      <row>
+        <col id="0" translatable="yes">pixels</col>
+      </row>
+      <row>
+        <col id="0" translatable="yes">millimeters</col>
+      </row>
+      <row>
+        <col id="0" translatable="yes">inches</col>
+      </row>
+    </data>
+  </object>
+  <object class="GtkAdjustment" id="width_adjustment">
+    <property name="upper">100</property>
+    <property name="step-increment">1</property>
+    <property name="page-increment">10</property>
+  </object>
   <object class="GtkHBox" id="print_layout">
     <property name="visible">True</property>
-    <property name="can_focus">False</property>
-    <property name="border_width">12</property>
+    <property name="can-focus">False</property>
+    <property name="border-width">12</property>
     <property name="spacing">24</property>
     <child>
       <object class="GtkVBox" id="vbox11">
         <property name="visible">True</property>
-        <property name="can_focus">False</property>
+        <property name="can-focus">False</property>
         <property name="spacing">12</property>
         <child>
           <object class="GtkTable" id="table3">
             <property name="visible">True</property>
-            <property name="can_focus">False</property>
-            <property name="n_rows">3</property>
-            <property name="n_columns">2</property>
-            <property name="column_spacing">6</property>
-            <property name="row_spacing">6</property>
+            <property name="can-focus">False</property>
+            <property name="n-rows">3</property>
+            <property name="n-columns">2</property>
+            <property name="column-spacing">6</property>
+            <property name="row-spacing">6</property>
+            <child>
+              <placeholder/>
+            </child>
             <child>
               <object class="GtkLabel" id="label8">
                 <property name="visible">True</property>
-                <property name="can_focus">False</property>
-                <property name="xalign">0</property>
+                <property name="can-focus">False</property>
                 <property name="label" translatable="yes">_Header:</property>
-                <property name="use_underline">True</property>
-                <property name="mnemonic_widget">header_entry</property>
+                <property name="use-underline">True</property>
+                <property name="xalign">0</property>
               </object>
               <packing>
-                <property name="x_options">GTK_FILL</property>
-                <property name="y_options">GTK_FILL</property>
+                <property name="x-options">GTK_FILL</property>
+                <property name="y-options">GTK_FILL</property>
               </packing>
             </child>
             <child>
               <object class="GtkLabel" id="label12">
                 <property name="visible">True</property>
-                <property name="can_focus">False</property>
-                <property name="xalign">0</property>
+                <property name="can-focus">False</property>
                 <property name="label" translatable="yes">_Footer:</property>
-                <property name="use_underline">True</property>
-                <property name="mnemonic_widget">footer_entry</property>
-              </object>
-              <packing>
-                <property name="top_attach">1</property>
-                <property name="bottom_attach">2</property>
-                <property name="x_options">GTK_FILL</property>
-                <property name="y_options">GTK_FILL</property>
-              </packing>
-            </child>
-            <child>
-              <object class="GtkEntry" id="header_entry">
-                <property name="visible">True</property>
-                <property name="can_focus">True</property>
-                <property name="invisible_char">●</property>
-                <property name="secondary_icon_stock">gtk-help</property>
-                <property name="secondary_icon_tooltip_text">Help</property>
-              </object>
-              <packing>
-                <property name="left_attach">1</property>
-                <property name="right_attach">2</property>
-                <property name="y_options">GTK_FILL</property>
-              </packing>
-            </child>
-            <child>
-              <object class="GtkEntry" id="footer_entry">
-                <property name="visible">True</property>
-                <property name="can_focus">True</property>
-                <property name="invisible_char">●</property>
-                <property name="secondary_icon_stock">gtk-help</property>
-                <property name="secondary_icon_tooltip_text">Help</property>
+                <property name="use-underline">True</property>
+                <property name="xalign">0</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>
-                <property name="y_options">GTK_FILL</property>
+                <property name="top-attach">1</property>
+                <property name="bottom-attach">2</property>
+                <property name="x-options">GTK_FILL</property>
+                <property name="y-options">GTK_FILL</property>
               </packing>
             </child>
             <child>
               <object class="GtkTable" id="page_footer_help_table">
-                <property name="can_focus">False</property>
-                <property name="n_rows">6</property>
-                <property name="n_columns">2</property>
-                <property name="column_spacing">12</property>
-                <property name="row_spacing">6</property>
+                <property name="can-focus">False</property>
+                <property name="n-rows">6</property>
+                <property name="n-columns">2</property>
+                <property name="column-spacing">12</property>
+                <property name="row-spacing">6</property>
                 <child>
                   <object class="GtkLabel" id="label6">
                     <property name="visible">True</property>
-                    <property name="can_focus">False</property>
+                    <property name="can-focus">False</property>
+                    <property name="label">%p</property>
                     <property name="xalign">0</property>
                     <property name="yalign">0.49000000953674316</property>
-                    <property name="label">%p</property>
                     <attributes>
                       <attribute name="size" value="8000"/>
                     </attributes>
                   </object>
                   <packing>
-                    <property name="top_attach">1</property>
-                    <property name="bottom_attach">2</property>
-                    <property name="y_options">GTK_FILL</property>
+                    <property name="top-attach">1</property>
+                    <property name="bottom-attach">2</property>
+                    <property name="y-options">GTK_FILL</property>
                   </packing>
                 </child>
                 <child>
                   <object class="GtkLabel" id="label13">
                     <property name="visible">True</property>
-                    <property name="can_focus">False</property>
-                    <property name="xalign">0</property>
+                    <property name="can-focus">False</property>
                     <property name="label">%P</property>
+                    <property name="xalign">0</property>
                     <attributes>
                       <attribute name="size" value="8000"/>
                     </attributes>
                   </object>
                   <packing>
-                    <property name="top_attach">2</property>
-                    <property name="bottom_attach">3</property>
-                    <property name="y_options">GTK_FILL</property>
+                    <property name="top-attach">2</property>
+                    <property name="bottom-attach">3</property>
+                    <property name="y-options">GTK_FILL</property>
                   </packing>
                 </child>
                 <child>
                   <object class="GtkLabel" id="label14">
                     <property name="visible">True</property>
-                    <property name="can_focus">False</property>
-                    <property name="xalign">0</property>
+                    <property name="can-focus">False</property>
                     <property name="label" translatable="yes">The current page number</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">1</property>
-                    <property name="bottom_attach">2</property>
-                    <property name="y_options">GTK_FILL</property>
+                    <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="y-options">GTK_FILL</property>
                   </packing>
                 </child>
                 <child>
                   <object class="GtkLabel" id="label15">
                     <property name="visible">True</property>
-                    <property name="can_focus">False</property>
-                    <property name="xalign">0</property>
+                    <property name="can-focus">False</property>
                     <property name="label" translatable="yes">The total number of pages</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">2</property>
-                    <property name="bottom_attach">3</property>
-                    <property name="y_options">GTK_FILL</property>
+                    <property name="left-attach">1</property>
+                    <property name="right-attach">2</property>
+                    <property name="top-attach">2</property>
+                    <property name="bottom-attach">3</property>
+                    <property name="y-options">GTK_FILL</property>
                   </packing>
                 </child>
                 <child>
                   <object class="GtkLabel" id="label16">
                     <property name="visible">True</property>
-                    <property name="can_focus">False</property>
-                    <property name="xalign">0</property>
+                    <property name="can-focus">False</property>
                     <property name="label" translatable="yes">Special code</property>
+                    <property name="xalign">0</property>
                     <attributes>
                       <attribute name="weight" value="bold"/>
                       <attribute name="size" value="8000"/>
                     </attributes>
                   </object>
                   <packing>
-                    <property name="y_options">GTK_FILL</property>
+                    <property name="y-options">GTK_FILL</property>
                   </packing>
                 </child>
                 <child>
                   <object class="GtkLabel" id="label17">
                     <property name="visible">True</property>
-                    <property name="can_focus">False</property>
-                    <property name="xalign">0</property>
+                    <property name="can-focus">False</property>
                     <property name="label" translatable="yes">Description</property>
+                    <property name="xalign">0</property>
                     <attributes>
                       <attribute name="weight" value="bold"/>
                       <attribute name="size" value="8000"/>
                     </attributes>
                   </object>
                   <packing>
-                    <property name="left_attach">1</property>
-                    <property name="right_attach">2</property>
-                    <property name="y_options">GTK_FILL</property>
+                    <property name="left-attach">1</property>
+                    <property name="right-attach">2</property>
+                    <property name="y-options">GTK_FILL</property>
                   </packing>
                 </child>
                 <child>
                   <object class="GtkLabel" id="label18">
                     <property name="visible">True</property>
-                    <property name="can_focus">False</property>
-                    <property name="xalign">0</property>
+                    <property name="can-focus">False</property>
                     <property name="label" translatable="yes" comments="translate only the text in the curly 
brackets">%D{ format }</property>
+                    <property name="xalign">0</property>
                     <attributes>
                       <attribute name="size" value="8000"/>
                     </attributes>
                   </object>
                   <packing>
-                    <property name="top_attach">3</property>
-                    <property name="bottom_attach">4</property>
-                    <property name="y_options">GTK_FILL</property>
+                    <property name="top-attach">3</property>
+                    <property name="bottom-attach">4</property>
+                    <property name="y-options">GTK_FILL</property>
                   </packing>
                 </child>
                 <child>
                   <object class="GtkLabel" id="label20">
                     <property name="visible">True</property>
-                    <property name="can_focus">False</property>
-                    <property name="xalign">0</property>
+                    <property name="can-focus">False</property>
                     <property name="label" translatable="yes">The current date</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">3</property>
-                    <property name="bottom_attach">4</property>
-                    <property name="y_options">GTK_FILL</property>
+                    <property name="left-attach">1</property>
+                    <property name="right-attach">2</property>
+                    <property name="top-attach">3</property>
+                    <property name="bottom-attach">4</property>
+                    <property name="y-options">GTK_FILL</property>
                   </packing>
                 </child>
                 <child>
                   <object class="GtkLabel" id="label21">
                     <property name="visible">True</property>
-                    <property name="can_focus">False</property>
-                    <property name="xalign">0</property>
+                    <property name="can-focus">False</property>
                     <property name="label">%F</property>
+                    <property name="xalign">0</property>
                     <attributes>
                       <attribute name="size" value="8000"/>
                     </attributes>
                   </object>
                   <packing>
-                    <property name="top_attach">4</property>
-                    <property name="bottom_attach">5</property>
-                    <property name="y_options">GTK_FILL</property>
+                    <property name="top-attach">4</property>
+                    <property name="bottom-attach">5</property>
+                    <property name="y-options">GTK_FILL</property>
                   </packing>
                 </child>
                 <child>
                   <object class="GtkLabel" id="label22">
                     <property name="visible">True</property>
-                    <property name="can_focus">False</property>
-                    <property name="xalign">0</property>
+                    <property name="can-focus">False</property>
                     <property name="label">%E</property>
+                    <property name="xalign">0</property>
                     <attributes>
                       <attribute name="size" value="8000"/>
                     </attributes>
                   </object>
                   <packing>
-                    <property name="top_attach">5</property>
-                    <property name="bottom_attach">6</property>
-                    <property name="y_options">GTK_FILL</property>
+                    <property name="top-attach">5</property>
+                    <property name="bottom-attach">6</property>
+                    <property name="y-options">GTK_FILL</property>
                   </packing>
                 </child>
                 <child>
                   <object class="GtkLabel" id="label23">
                     <property name="visible">True</property>
-                    <property name="can_focus">False</property>
-                    <property name="xalign">0</property>
+                    <property name="can-focus">False</property>
                     <property name="label" translatable="yes">The total number of files</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">4</property>
-                    <property name="bottom_attach">5</property>
-                    <property name="y_options">GTK_FILL</property>
+                    <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="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="xalign">0</property>
+                    <property name="can-focus">False</property>
                     <property name="label" translatable="yes">The event description</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">5</property>
-                    <property name="bottom_attach">6</property>
-                    <property name="y_options">GTK_FILL</property>
+                    <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="y-options">GTK_FILL</property>
                   </packing>
                 </child>
               </object>
               <packing>
-                <property name="left_attach">1</property>
-                <property name="right_attach">2</property>
-                <property name="top_attach">2</property>
-                <property name="bottom_attach">3</property>
-                <property name="y_options">GTK_FILL</property>
+                <property name="left-attach">1</property>
+                <property name="right-attach">2</property>
+                <property name="top-attach">2</property>
+                <property name="bottom-attach">3</property>
+                <property name="y-options">GTK_FILL</property>
               </packing>
             </child>
             <child>
-              <placeholder/>
+              <object class="GtkBox">
+                <property name="visible">True</property>
+                <property name="can-focus">False</property>
+                <child>
+                  <object class="GtkEntry" id="header_entry">
+                    <property name="visible">True</property>
+                    <property name="can-focus">True</property>
+                    <property name="invisible-char">●</property>
+                    <property name="secondary-icon-tooltip-markup" translatable="yes">Help</property>
+                  </object>
+                  <packing>
+                    <property name="expand">True</property>
+                    <property name="fill">True</property>
+                    <property name="position">0</property>
+                  </packing>
+                </child>
+                <child>
+                  <object class="GtkButton" id="edit_header_button">
+                    <property name="visible">True</property>
+                    <property name="can-focus">True</property>
+                    <property name="receives-default">True</property>
+                    <child>
+                      <object class="GtkImage">
+                        <property name="visible">True</property>
+                        <property name="can-focus">False</property>
+                        <property name="icon-name">document-edit-symbolic</property>
+                      </object>
+                    </child>
+                  </object>
+                  <packing>
+                    <property name="expand">False</property>
+                    <property name="fill">True</property>
+                    <property name="position">1</property>
+                  </packing>
+                </child>
+                <style>
+                  <class name="linked"/>
+                </style>
+              </object>
+              <packing>
+                <property name="left-attach">1</property>
+                <property name="right-attach">2</property>
+              </packing>
+            </child>
+            <child>
+              <object class="GtkBox">
+                <property name="visible">True</property>
+                <property name="can-focus">False</property>
+                <child>
+                  <object class="GtkEntry" id="footer_entry">
+                    <property name="visible">True</property>
+                    <property name="can-focus">True</property>
+                    <property name="invisible-char">●</property>
+                    <property name="secondary-icon-tooltip-markup" translatable="yes">Help</property>
+                  </object>
+                  <packing>
+                    <property name="expand">True</property>
+                    <property name="fill">True</property>
+                    <property name="position">0</property>
+                  </packing>
+                </child>
+                <child>
+                  <object class="GtkButton" id="edit_footer_button">
+                    <property name="visible">True</property>
+                    <property name="can-focus">True</property>
+                    <property name="receives-default">True</property>
+                    <child>
+                      <object class="GtkImage">
+                        <property name="visible">True</property>
+                        <property name="can-focus">False</property>
+                        <property name="icon-name">document-edit-symbolic</property>
+                      </object>
+                    </child>
+                  </object>
+                  <packing>
+                    <property name="expand">False</property>
+                    <property name="fill">True</property>
+                    <property name="position">1</property>
+                  </packing>
+                </child>
+                <style>
+                  <class name="linked"/>
+                </style>
+              </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>
           </object>
           <packing>
@@ -372,20 +508,20 @@
         <child>
           <object class="GtkVBox" id="vbox2">
             <property name="visible">True</property>
-            <property name="can_focus">False</property>
+            <property name="can-focus">False</property>
             <property name="spacing">6</property>
             <child>
               <object class="GtkHBox" id="hbox9">
                 <property name="visible">True</property>
-                <property name="can_focus">False</property>
+                <property name="can-focus">False</property>
                 <property name="spacing">6</property>
                 <child>
                   <object class="GtkLabel" id="label2">
                     <property name="visible">True</property>
-                    <property name="can_focus">False</property>
-                    <property name="xalign">0</property>
+                    <property name="can-focus">False</property>
                     <property name="label" translatable="yes">Layout</property>
-                    <property name="use_underline">True</property>
+                    <property name="use-underline">True</property>
+                    <property name="xalign">0</property>
                     <attributes>
                       <attribute name="weight" value="bold"/>
                     </attributes>
@@ -406,81 +542,81 @@
             <child>
               <object class="GtkAlignment" id="alignment6">
                 <property name="visible">True</property>
-                <property name="can_focus">False</property>
-                <property name="left_padding">12</property>
+                <property name="can-focus">False</property>
+                <property name="left-padding">12</property>
                 <child>
                   <object class="GtkVBox" id="vbox5">
                     <property name="visible">True</property>
-                    <property name="can_focus">False</property>
+                    <property name="can-focus">False</property>
                     <property name="spacing">6</property>
                     <child>
                       <object class="GtkTable" id="table2">
                         <property name="visible">True</property>
-                        <property name="can_focus">False</property>
-                        <property name="n_rows">2</property>
-                        <property name="n_columns">2</property>
-                        <property name="column_spacing">6</property>
-                        <property name="row_spacing">6</property>
+                        <property name="can-focus">False</property>
+                        <property name="n-rows">2</property>
+                        <property name="n-columns">2</property>
+                        <property name="column-spacing">6</property>
+                        <property name="row-spacing">6</property>
                         <child>
                           <object class="GtkSpinButton" id="columns_spinbutton">
                             <property name="visible">True</property>
-                            <property name="can_focus">True</property>
-                            <property name="invisible_char">●</property>
-                            <property name="width_chars">6</property>
+                            <property name="can-focus">True</property>
+                            <property name="invisible-char">●</property>
+                            <property name="width-chars">6</property>
                             <property name="adjustment">columns_adjustment</property>
-                            <property name="climb_rate">1</property>
+                            <property name="climb-rate">1</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>
-                            <property name="x_options">GTK_FILL</property>
-                            <property name="y_options">GTK_FILL</property>
+                            <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="x-options">GTK_FILL</property>
+                            <property name="y-options">GTK_FILL</property>
                           </packing>
                         </child>
                         <child>
                           <object class="GtkSpinButton" id="rows_spinbutton">
                             <property name="visible">True</property>
-                            <property name="can_focus">True</property>
-                            <property name="invisible_char">●</property>
-                            <property name="width_chars">6</property>
+                            <property name="can-focus">True</property>
+                            <property name="invisible-char">●</property>
+                            <property name="width-chars">6</property>
                             <property name="adjustment">rows_adjustment</property>
-                            <property name="climb_rate">1</property>
+                            <property name="climb-rate">1</property>
                           </object>
                           <packing>
-                            <property name="left_attach">1</property>
-                            <property name="right_attach">2</property>
-                            <property name="x_options">GTK_FILL</property>
-                            <property name="y_options">GTK_FILL</property>
+                            <property name="left-attach">1</property>
+                            <property name="right-attach">2</property>
+                            <property name="x-options">GTK_FILL</property>
+                            <property name="y-options">GTK_FILL</property>
                           </packing>
                         </child>
                         <child>
                           <object class="GtkLabel" id="label11">
                             <property name="visible">True</property>
-                            <property name="can_focus">False</property>
-                            <property name="xalign">0</property>
+                            <property name="can-focus">False</property>
                             <property name="label" translatable="yes">Columns:</property>
-                            <property name="use_underline">True</property>
+                            <property name="use-underline">True</property>
+                            <property name="xalign">0</property>
                           </object>
                           <packing>
-                            <property name="top_attach">1</property>
-                            <property name="bottom_attach">2</property>
-                            <property name="x_options">GTK_FILL</property>
-                            <property name="y_options">GTK_FILL</property>
+                            <property name="top-attach">1</property>
+                            <property name="bottom-attach">2</property>
+                            <property name="x-options">GTK_FILL</property>
+                            <property name="y-options">GTK_FILL</property>
                           </packing>
                         </child>
                         <child>
                           <object class="GtkLabel" id="label9">
                             <property name="visible">True</property>
-                            <property name="can_focus">False</property>
-                            <property name="xalign">0</property>
+                            <property name="can-focus">False</property>
                             <property name="label" translatable="yes">_Rows:</property>
-                            <property name="use_underline">True</property>
+                            <property name="use-underline">True</property>
+                            <property name="xalign">0</property>
                           </object>
                           <packing>
-                            <property name="x_options">GTK_FILL</property>
-                            <property name="y_options">GTK_FILL</property>
+                            <property name="x-options">GTK_FILL</property>
+                            <property name="y-options">GTK_FILL</property>
                           </packing>
                         </child>
                       </object>
@@ -509,14 +645,14 @@
         <child>
           <object class="GtkVBox" id="vbox3">
             <property name="visible">True</property>
-            <property name="can_focus">False</property>
+            <property name="can-focus">False</property>
             <property name="spacing">6</property>
             <child>
               <object class="GtkLabel" id="label5">
                 <property name="visible">True</property>
-                <property name="can_focus">False</property>
-                <property name="xalign">0</property>
+                <property name="can-focus">False</property>
                 <property name="label" translatable="yes">Caption</property>
+                <property name="xalign">0</property>
                 <attributes>
                   <attribute name="weight" value="bold"/>
                 </attributes>
@@ -530,20 +666,20 @@
             <child>
               <object class="GtkAlignment" id="alignment5">
                 <property name="visible">True</property>
-                <property name="can_focus">False</property>
-                <property name="left_padding">12</property>
+                <property name="can-focus">False</property>
+                <property name="left-padding">12</property>
                 <child>
                   <object class="GtkVBox" id="vbox4">
                     <property name="visible">True</property>
-                    <property name="can_focus">False</property>
+                    <property name="can-focus">False</property>
                     <property name="spacing">6</property>
                     <child>
                       <object class="GtkScrolledWindow" id="caption_scrolledwindow">
-                        <property name="width_request">300</property>
-                        <property name="height_request">150</property>
+                        <property name="width-request">300</property>
+                        <property name="height-request">150</property>
                         <property name="visible">True</property>
-                        <property name="can_focus">True</property>
-                        <property name="shadow_type">in</property>
+                        <property name="can-focus">True</property>
+                        <property name="shadow-type">in</property>
                         <child>
                           <placeholder/>
                         </child>
@@ -573,20 +709,20 @@
         <child>
           <object class="GtkVBox" id="vbox6">
             <property name="visible">True</property>
-            <property name="can_focus">False</property>
+            <property name="can-focus">False</property>
             <property name="spacing">6</property>
             <child>
               <object class="GtkHBox" id="hbox4">
                 <property name="visible">True</property>
-                <property name="can_focus">False</property>
+                <property name="can-focus">False</property>
                 <property name="spacing">6</property>
                 <child>
                   <object class="GtkLabel" id="label10">
                     <property name="visible">True</property>
-                    <property name="can_focus">False</property>
-                    <property name="xalign">0</property>
+                    <property name="can-focus">False</property>
                     <property name="label" translatable="yes">Image</property>
-                    <property name="use_underline">True</property>
+                    <property name="use-underline">True</property>
+                    <property name="xalign">0</property>
                     <attributes>
                       <attribute name="weight" value="bold"/>
                     </attributes>
@@ -607,47 +743,47 @@
             <child>
               <object class="GtkAlignment" id="alignment2">
                 <property name="visible">True</property>
-                <property name="can_focus">False</property>
-                <property name="left_padding">12</property>
+                <property name="can-focus">False</property>
+                <property name="left-padding">12</property>
                 <child>
                   <object class="GtkVBox" id="vbox1">
                     <property name="visible">True</property>
-                    <property name="can_focus">False</property>
+                    <property name="can-focus">False</property>
                     <property name="spacing">6</property>
                     <child>
                       <object class="GtkTable" id="table1">
                         <property name="visible">True</property>
-                        <property name="can_focus">False</property>
-                        <property name="n_rows">4</property>
-                        <property name="n_columns">2</property>
-                        <property name="column_spacing">6</property>
-                        <property name="row_spacing">6</property>
+                        <property name="can-focus">False</property>
+                        <property name="n-rows">4</property>
+                        <property name="n-columns">2</property>
+                        <property name="column-spacing">6</property>
+                        <property name="row-spacing">6</property>
                         <child>
                           <object class="GtkLabel" id="label3">
                             <property name="visible">True</property>
-                            <property name="can_focus">False</property>
-                            <property name="xalign">0</property>
+                            <property name="can-focus">False</property>
                             <property name="label" translatable="yes">Position:</property>
+                            <property name="xalign">0</property>
                           </object>
                           <packing>
-                            <property name="x_options">GTK_FILL</property>
-                            <property name="y_options">GTK_FILL</property>
+                            <property name="x-options">GTK_FILL</property>
+                            <property name="y-options">GTK_FILL</property>
                           </packing>
                         </child>
                         <child>
                           <object class="GtkHBox" id="hbox6">
                             <property name="visible">True</property>
-                            <property name="can_focus">False</property>
+                            <property name="can-focus">False</property>
                             <property name="spacing">6</property>
                             <child>
                               <object class="GtkSpinButton" id="img_left_spinbutton">
                                 <property name="visible">True</property>
-                                <property name="can_focus">True</property>
-                                <property name="tooltip_text" translatable="yes">Left</property>
-                                <property name="invisible_char">●</property>
-                                <property name="width_chars">6</property>
+                                <property name="can-focus">True</property>
+                                <property name="tooltip-text" translatable="yes">Left</property>
+                                <property name="invisible-char">●</property>
+                                <property name="width-chars">6</property>
                                 <property name="adjustment">left_adjustment</property>
-                                <property name="climb_rate">1</property>
+                                <property name="climb-rate">1</property>
                               </object>
                               <packing>
                                 <property name="expand">False</property>
@@ -658,12 +794,12 @@
                             <child>
                               <object class="GtkSpinButton" id="img_top_spinbutton">
                                 <property name="visible">True</property>
-                                <property name="can_focus">True</property>
-                                <property name="tooltip_text" translatable="yes">Top</property>
-                                <property name="invisible_char">●</property>
-                                <property name="width_chars">6</property>
+                                <property name="can-focus">True</property>
+                                <property name="tooltip-text" translatable="yes">Top</property>
+                                <property name="invisible-char">●</property>
+                                <property name="width-chars">6</property>
                                 <property name="adjustment">top_adjustment</property>
-                                <property name="climb_rate">1</property>
+                                <property name="climb-rate">1</property>
                               </object>
                               <packing>
                                 <property name="expand">False</property>
@@ -674,7 +810,7 @@
                             <child>
                               <object class="GtkComboBox" id="position_combobox">
                                 <property name="visible">True</property>
-                                <property name="can_focus">False</property>
+                                <property name="can-focus">False</property>
                                 <property name="model">align_liststore</property>
                                 <property name="active">0</property>
                                 <child>
@@ -692,39 +828,39 @@
                             </child>
                           </object>
                           <packing>
-                            <property name="left_attach">1</property>
-                            <property name="right_attach">2</property>
-                            <property name="y_options">GTK_FILL</property>
+                            <property name="left-attach">1</property>
+                            <property name="right-attach">2</property>
+                            <property name="y-options">GTK_FILL</property>
                           </packing>
                         </child>
                         <child>
                           <object class="GtkLabel" id="label4">
                             <property name="visible">True</property>
-                            <property name="can_focus">False</property>
-                            <property name="xalign">0</property>
+                            <property name="can-focus">False</property>
                             <property name="label" translatable="yes">Size:</property>
+                            <property name="xalign">0</property>
                           </object>
                           <packing>
-                            <property name="top_attach">1</property>
-                            <property name="bottom_attach">2</property>
-                            <property name="x_options">GTK_FILL</property>
-                            <property name="y_options">GTK_FILL</property>
+                            <property name="top-attach">1</property>
+                            <property name="bottom-attach">2</property>
+                            <property name="x-options">GTK_FILL</property>
+                            <property name="y-options">GTK_FILL</property>
                           </packing>
                         </child>
                         <child>
                           <object class="GtkHBox" id="hbox11">
                             <property name="visible">True</property>
-                            <property name="can_focus">False</property>
+                            <property name="can-focus">False</property>
                             <property name="spacing">6</property>
                             <child>
                               <object class="GtkSpinButton" id="img_width_spinbutton">
                                 <property name="visible">True</property>
-                                <property name="can_focus">True</property>
-                                <property name="tooltip_text" translatable="yes">Width</property>
-                                <property name="invisible_char">●</property>
-                                <property name="width_chars">6</property>
+                                <property name="can-focus">True</property>
+                                <property name="tooltip-text" translatable="yes">Width</property>
+                                <property name="invisible-char">●</property>
+                                <property name="width-chars">6</property>
                                 <property name="adjustment">width_adjustment</property>
-                                <property name="climb_rate">1</property>
+                                <property name="climb-rate">1</property>
                               </object>
                               <packing>
                                 <property name="expand">False</property>
@@ -735,12 +871,12 @@
                             <child>
                               <object class="GtkSpinButton" id="img_height_spinbutton">
                                 <property name="visible">True</property>
-                                <property name="can_focus">True</property>
-                                <property name="tooltip_text" translatable="yes">Height</property>
-                                <property name="invisible_char">●</property>
-                                <property name="width_chars">6</property>
+                                <property name="can-focus">True</property>
+                                <property name="tooltip-text" translatable="yes">Height</property>
+                                <property name="invisible-char">●</property>
+                                <property name="width-chars">6</property>
                                 <property name="adjustment">height_adjustment</property>
-                                <property name="climb_rate">1</property>
+                                <property name="climb-rate">1</property>
                               </object>
                               <packing>
                                 <property name="expand">False</property>
@@ -751,10 +887,10 @@
                             <child>
                               <object class="GtkHScale" id="image_scale">
                                 <property name="visible">True</property>
-                                <property name="can_focus">True</property>
+                                <property name="can-focus">True</property>
                                 <property name="adjustment">scale_adjustment</property>
                                 <property name="digits">2</property>
-                                <property name="value_pos">right</property>
+                                <property name="value-pos">right</property>
                               </object>
                               <packing>
                                 <property name="expand">True</property>
@@ -764,21 +900,21 @@
                             </child>
                           </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>
-                            <property name="y_options">GTK_FILL</property>
+                            <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="y-options">GTK_FILL</property>
                           </packing>
                         </child>
                         <child>
                           <object class="GtkHBox" id="hbox7">
                             <property name="visible">True</property>
-                            <property name="can_focus">False</property>
+                            <property name="can-focus">False</property>
                             <child>
                               <object class="GtkComboBox" id="rotation_combobox">
                                 <property name="visible">True</property>
-                                <property name="can_focus">False</property>
+                                <property name="can-focus">False</property>
                                 <property name="model">rotation_liststore</property>
                                 <property name="active">0</property>
                                 <child>
@@ -796,41 +932,41 @@
                             </child>
                           </object>
                           <packing>
-                            <property name="left_attach">1</property>
-                            <property name="right_attach">2</property>
-                            <property name="top_attach">2</property>
-                            <property name="bottom_attach">3</property>
-                            <property name="y_options">GTK_FILL</property>
+                            <property name="left-attach">1</property>
+                            <property name="right-attach">2</property>
+                            <property name="top-attach">2</property>
+                            <property name="bottom-attach">3</property>
+                            <property name="y-options">GTK_FILL</property>
                           </packing>
                         </child>
                         <child>
                           <object class="GtkLabel" id="label19">
                             <property name="visible">True</property>
-                            <property name="can_focus">False</property>
-                            <property name="xalign">0</property>
+                            <property name="can-focus">False</property>
                             <property name="label" translatable="yes">Rotation:</property>
-                            <property name="use_underline">True</property>
+                            <property name="use-underline">True</property>
+                            <property name="xalign">0</property>
                           </object>
                           <packing>
-                            <property name="top_attach">2</property>
-                            <property name="bottom_attach">3</property>
-                            <property name="x_options">GTK_FILL</property>
-                            <property name="y_options">GTK_FILL</property>
+                            <property name="top-attach">2</property>
+                            <property name="bottom-attach">3</property>
+                            <property name="x-options">GTK_FILL</property>
+                            <property name="y-options">GTK_FILL</property>
                           </packing>
                         </child>
                         <child>
                           <object class="GtkAlignment" id="alignment3">
                             <property name="visible">True</property>
-                            <property name="can_focus">False</property>
-                            <property name="top_padding">12</property>
+                            <property name="can-focus">False</property>
+                            <property name="top-padding">12</property>
                             <child>
                               <object class="GtkHBox" id="hbox5">
                                 <property name="visible">True</property>
-                                <property name="can_focus">False</property>
+                                <property name="can-focus">False</property>
                                 <child>
                                   <object class="GtkComboBox" id="unit_combobox">
                                     <property name="visible">True</property>
-                                    <property name="can_focus">False</property>
+                                    <property name="can-focus">False</property>
                                     <property name="model">unit_liststore</property>
                                     <property name="active">0</property>
                                     <child>
@@ -850,32 +986,32 @@
                             </child>
                           </object>
                           <packing>
-                            <property name="left_attach">1</property>
-                            <property name="right_attach">2</property>
-                            <property name="top_attach">3</property>
-                            <property name="bottom_attach">4</property>
-                            <property name="y_options">GTK_FILL</property>
+                            <property name="left-attach">1</property>
+                            <property name="right-attach">2</property>
+                            <property name="top-attach">3</property>
+                            <property name="bottom-attach">4</property>
+                            <property name="y-options">GTK_FILL</property>
                           </packing>
                         </child>
                         <child>
                           <object class="GtkAlignment" id="alignment4">
                             <property name="visible">True</property>
-                            <property name="can_focus">False</property>
-                            <property name="top_padding">12</property>
+                            <property name="can-focus">False</property>
+                            <property name="top-padding">12</property>
                             <child>
                               <object class="GtkLabel" id="label1">
                                 <property name="visible">True</property>
-                                <property name="can_focus">False</property>
-                                <property name="xalign">0</property>
+                                <property name="can-focus">False</property>
                                 <property name="label" translatable="yes">Unit:</property>
+                                <property name="xalign">0</property>
                               </object>
                             </child>
                           </object>
                           <packing>
-                            <property name="top_attach">3</property>
-                            <property name="bottom_attach">4</property>
-                            <property name="x_options">GTK_FILL</property>
-                            <property name="y_options">GTK_FILL</property>
+                            <property name="top-attach">3</property>
+                            <property name="bottom-attach">4</property>
+                            <property name="x-options">GTK_FILL</property>
+                            <property name="y-options">GTK_FILL</property>
                           </packing>
                         </child>
                       </object>
@@ -911,17 +1047,17 @@
     <child>
       <object class="GtkVBox" id="vbox24">
         <property name="visible">True</property>
-        <property name="can_focus">False</property>
+        <property name="can-focus">False</property>
         <property name="spacing">6</property>
         <child>
           <object class="GtkVBox" id="vbox7">
             <property name="visible">True</property>
-            <property name="can_focus">False</property>
+            <property name="can-focus">False</property>
             <child>
               <object class="GtkLabel" id="label7">
-                <property name="can_focus">False</property>
-                <property name="xalign">0</property>
+                <property name="can-focus">False</property>
                 <property name="label" translatable="yes">Preview</property>
+                <property name="xalign">0</property>
                 <attributes>
                   <attribute name="weight" value="bold"/>
                 </attributes>
@@ -935,20 +1071,20 @@
             <child>
               <object class="GtkAlignment" id="alignment1">
                 <property name="visible">True</property>
-                <property name="can_focus">False</property>
+                <property name="can-focus">False</property>
                 <child>
                   <object class="GtkVBox" id="vbox25">
                     <property name="visible">True</property>
-                    <property name="can_focus">False</property>
+                    <property name="can-focus">False</property>
                     <child>
                       <object class="GtkHBox" id="hbox30">
                         <property name="visible">True</property>
-                        <property name="can_focus">False</property>
+                        <property name="can-focus">False</property>
                         <property name="spacing">6</property>
                         <child>
                           <object class="GtkLabel" id="page_label">
                             <property name="visible">True</property>
-                            <property name="can_focus">False</property>
+                            <property name="can-focus">False</property>
                             <property name="xalign">0</property>
                           </object>
                           <packing>
@@ -959,17 +1095,16 @@
                         </child>
                         <child>
                           <object class="GtkButton" id="next_page_button">
-                            <property name="use_action_appearance">False</property>
+                            <property name="use-action-appearance">False</property>
                             <property name="visible">True</property>
                             <property name="sensitive">False</property>
-                            <property name="can_focus">True</property>
-                            <property name="receives_default">True</property>
-                            <property name="use_action_appearance">False</property>
+                            <property name="can-focus">True</property>
+                            <property name="receives-default">True</property>
                             <property name="relief">none</property>
                             <child>
                               <object class="GtkImage" id="image4">
                                 <property name="visible">True</property>
-                                <property name="can_focus">False</property>
+                                <property name="can-focus">False</property>
                                 <property name="stock">gtk-go-forward</property>
                               </object>
                             </child>
@@ -977,23 +1112,22 @@
                           <packing>
                             <property name="expand">False</property>
                             <property name="fill">False</property>
-                            <property name="pack_type">end</property>
+                            <property name="pack-type">end</property>
                             <property name="position">1</property>
                           </packing>
                         </child>
                         <child>
                           <object class="GtkButton" id="prev_page_button">
-                            <property name="use_action_appearance">False</property>
+                            <property name="use-action-appearance">False</property>
                             <property name="visible">True</property>
                             <property name="sensitive">False</property>
-                            <property name="can_focus">True</property>
-                            <property name="receives_default">True</property>
-                            <property name="use_action_appearance">False</property>
+                            <property name="can-focus">True</property>
+                            <property name="receives-default">True</property>
                             <property name="relief">none</property>
                             <child>
                               <object class="GtkImage" id="image5">
                                 <property name="visible">True</property>
-                                <property name="can_focus">False</property>
+                                <property name="can-focus">False</property>
                                 <property name="stock">gtk-go-back</property>
                               </object>
                             </child>
@@ -1001,7 +1135,7 @@
                           <packing>
                             <property name="expand">False</property>
                             <property name="fill">False</property>
-                            <property name="pack_type">end</property>
+                            <property name="pack-type">end</property>
                             <property name="position">2</property>
                           </packing>
                         </child>
@@ -1015,11 +1149,11 @@
                     <child>
                       <object class="GtkHBox" id="hbox2">
                         <property name="visible">True</property>
-                        <property name="can_focus">False</property>
+                        <property name="can-focus">False</property>
                         <child>
                           <object class="GtkDrawingArea" id="preview_drawingarea">
                             <property name="visible">True</property>
-                            <property name="can_focus">False</property>
+                            <property name="can-focus">False</property>
                             <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | 
GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK | GDK_ENTER_NOTIFY_MASK | GDK_LEAVE_NOTIFY_MASK | 
GDK_STRUCTURE_MASK</property>
                           </object>
                           <packing>
@@ -1059,79 +1193,4 @@
       </packing>
     </child>
   </object>
-  <object class="GtkAdjustment" id="rows_adjustment">
-    <property name="lower">1</property>
-    <property name="upper">100</property>
-    <property name="value">1</property>
-    <property name="step_increment">1</property>
-    <property name="page_increment">10</property>
-  </object>
-  <object class="GtkAdjustment" id="scale_adjustment">
-    <property name="lower">0.01</property>
-    <property name="upper">1</property>
-    <property name="value">1</property>
-    <property name="step_increment">0.10000000000000001</property>
-    <property name="page_increment">0.10000000000000001</property>
-  </object>
-  <object class="GtkListStore" id="size_liststore">
-    <columns>
-      <!-- column-name name -->
-      <column type="gchararray"/>
-      <!-- column-name value -->
-      <column type="gint"/>
-    </columns>
-    <data>
-      <row>
-        <col id="0">1</col>
-        <col id="1">1</col>
-      </row>
-      <row>
-        <col id="0">2</col>
-        <col id="1">2</col>
-      </row>
-      <row>
-        <col id="0">4</col>
-        <col id="1">3</col>
-      </row>
-      <row>
-        <col id="0">8</col>
-        <col id="1">4</col>
-      </row>
-      <row>
-        <col id="0">16</col>
-        <col id="1">5</col>
-      </row>
-      <row>
-        <col id="0">32</col>
-        <col id="1">6</col>
-      </row>
-    </data>
-  </object>
-  <object class="GtkAdjustment" id="top_adjustment">
-    <property name="upper">100</property>
-    <property name="step_increment">1</property>
-    <property name="page_increment">10</property>
-  </object>
-  <object class="GtkListStore" id="unit_liststore">
-    <columns>
-      <!-- column-name Name -->
-      <column type="gchararray"/>
-    </columns>
-    <data>
-      <row>
-        <col id="0" translatable="yes">pixels</col>
-      </row>
-      <row>
-        <col id="0" translatable="yes">millimeters</col>
-      </row>
-      <row>
-        <col id="0" translatable="yes">inches</col>
-      </row>
-    </data>
-  </object>
-  <object class="GtkAdjustment" id="width_adjustment">
-    <property name="upper">100</property>
-    <property name="step_increment">1</property>
-    <property name="page_increment">10</property>
-  </object>
 </interface>
diff --git a/extensions/image_print/gth-image-print-job.c b/extensions/image_print/gth-image-print-job.c
index 71f25028..bce58fa3 100644
--- a/extensions/image_print/gth-image-print-job.c
+++ b/extensions/image_print/gth-image-print-job.c
@@ -33,6 +33,15 @@
 #define GET_WIDGET(name) _gtk_builder_get_widget (self->priv->builder, (name))
 
 
+static GthTemplateCode Text_Special_Codes[] = {
+       { GTH_TEMPLATE_CODE_TYPE_SIMPLE, N_("Current page number"), 'p', 0 },
+       { GTH_TEMPLATE_CODE_TYPE_SIMPLE, N_("Total number of pages"), 'P', 0 },
+       { GTH_TEMPLATE_CODE_TYPE_DATE, N_("Current date"), 'D', 1 },
+       { GTH_TEMPLATE_CODE_TYPE_SIMPLE, N_("Total number of files"), 'F', 0 },
+       { GTH_TEMPLATE_CODE_TYPE_SIMPLE, N_("Event description"), 'E', 0 },
+};
+
+
 struct _GthImagePrintJobPrivate {
        GSettings          *settings;
        GtkPrintOperationAction  action;
@@ -216,55 +225,65 @@ gth_image_print_job_set_font_options (GthImagePrintJob *self,
 
 
 static gboolean
-template_eval_cb (const GMatchInfo *match_info,
-                 GString          *result,
-                 gpointer          user_data)
+template_eval_cb (TemplateFlags   flags,
+                 gunichar        parent_code,
+                 gunichar        code,
+                 char          **args,
+                 GString        *result,
+                 gpointer        user_data)
 {
        GthImagePrintJob *self = user_data;
-       char             *r = NULL;
-       char             *match;
+       gboolean          preview;
+       char             *text = NULL;
+       GDateTime        *timestamp;
 
-       match = g_match_info_fetch (match_info, 0);
-       if (strcmp (match, "%p") == 0) {
-               r = g_strdup_printf ("%d", self->priv->current_page + 1);
-       }
-       else if (strcmp (match, "%P") == 0) {
-               r = g_strdup_printf ("%d", self->priv->n_pages);
-       }
-       else if (strcmp (match, "%F") == 0) {
-               r = g_strdup_printf ("%d", self->priv->n_images);
+       preview = flags & TEMPLATE_FLAGS_PREVIEW;
+
+       if (parent_code == 'D') {
+               /* strftime code, return the code itself. */
+               _g_string_append_template_code (result, code, args);
+               return FALSE;
        }
-       else if (strncmp (match, "%D", 2) == 0) {
-               GTimeVal   timeval;
-               GRegex    *re;
-               char     **a;
-               char      *format = NULL;
 
-               g_get_current_time (&timeval);
+       if (preview && (code != 0))
+               g_string_append (result, "<span foreground=\"#4696f8\">");
+
+       switch (code) {
+       case 'p':
+               text = g_strdup_printf ("%d", self->priv->current_page + 1);
+               break;
 
-               /* Get the date format */
+       case 'P':
+               text = g_strdup_printf ("%d", self->priv->n_pages);
+               break;
 
-               re = g_regex_new ("%[A-Z]\\{([^}]+)\\}", 0, 0, NULL);
-               a = g_regex_split (re, match, 0);
-               if (g_strv_length (a) >= 2)
-                       format = g_strstrip (a[1]);
-               r = _g_time_val_strftime (&timeval, format);
+       case 'F':
+               text = g_strdup_printf ("%d", self->priv->n_images);
+               break;
 
-               g_strfreev (a);
-               g_regex_unref (re);
-       }
-       else if (strcmp (match, "%E") == 0) {
+       case 'D':
+               timestamp = g_date_time_new_now_local ();
+               text = g_date_time_format (timestamp,
+                                          (args[0] != NULL) ? args[0] : DEFAULT_STRFTIME_FORMAT);
+               g_date_time_unref (timestamp);
+               break;
+
+       case 'E':
                if (self->priv->event_name != NULL)
-                       r = g_strdup (self->priv->event_name);
-               else
-                       r = g_strdup ("");
+                       g_string_append (result, self->priv->event_name);
+               break;
+
+       default:
+               break;
        }
 
-       if (r != NULL)
-               g_string_append (result, r);
+       if (text != NULL) {
+               g_string_append (result, text);
+               g_free (text);
+       }
 
-       g_free (r);
-       g_free (match);
+       if (preview && (code != 0))
+               g_string_append (result, "</span>");
 
        return FALSE;
 }
@@ -274,20 +293,10 @@ static char *
 get_text_from_template (GthImagePrintJob *self,
                        const char       *text)
 {
-       GRegex *re;
-       char   *new_text;
-
-       if (text == NULL)
-               return NULL;
-
-       if (g_utf8_strchr (text,  -1, '%') == NULL)
-               return g_strdup (text);
-
-       re = g_regex_new ("%[DEFPp](\\{[^}]+\\})?", 0, 0, NULL);
-       new_text = g_regex_replace_eval (re, text, -1, 0, 0, template_eval_cb, self, NULL);
-       g_regex_unref (re);
-
-       return new_text;
+       return _g_template_eval (text,
+                                0,
+                                template_eval_cb,
+                                self);
 }
 
 
@@ -296,23 +305,23 @@ update_header_and_footer_texts (GthImagePrintJob *self)
 {
        g_free (self->priv->header);
        self->priv->header = NULL;
-       if ((self->priv->header_template != NULL) && (g_strcmp0 (self->priv->header_template, "") != 0))
+       if (! _g_str_empty (self->priv->header_template))
                self->priv->header = get_text_from_template (self, self->priv->header_template);
 
        g_free (self->priv->footer);
        self->priv->footer = NULL;
-       if ((self->priv->footer_template != NULL) && (g_strcmp0 (self->priv->footer_template, "") != 0))
+       if (! _g_str_empty (self->priv->footer_template))
                self->priv->footer = get_text_from_template (self, self->priv->footer_template);
 }
 
 
 static void
 gth_image_print_job_update_layout_info (GthImagePrintJob   *self,
-                                       gdouble             page_width,
-                                       gdouble             page_height,
-                                       GtkPageOrientation  orientation,
-                                       PangoLayout        *pango_layout,
-                                       gboolean            preview)
+                                       gdouble             page_width,
+                                       gdouble             page_height,
+                                       GtkPageOrientation  orientation,
+                                       PangoLayout        *pango_layout,
+                                       gboolean            preview)
 {
        gboolean height_changed = FALSE;
        int      height;
@@ -559,9 +568,9 @@ gth_image_print_job_update_page_layout (GthImagePrintJob   *self,
 
 static void
 gth_image_print_job_update_layout (GthImagePrintJob   *self,
-                                  gdouble             page_width,
-                                  gdouble             page_height,
-                                  GtkPageOrientation  orientation)
+                                  gdouble             page_width,
+                                  gdouble             page_height,
+                                  GtkPageOrientation  orientation)
 {
        PangoLayout *pango_layout;
 
@@ -972,8 +981,8 @@ preview_draw_cb (GtkWidget *widget,
 
        pango_layout = gtk_widget_create_pango_layout (GTK_WIDGET (self->priv->browser), NULL);
        gth_image_print_job_paint (self,
-                                  cr,
-                                  pango_layout,
+                                  cr,
+                                  pango_layout,
                                   gtk_page_setup_get_left_margin (self->priv->page_setup, GTK_UNIT_MM),
                                   gtk_page_setup_get_top_margin (self->priv->page_setup, GTK_UNIT_MM),
                                   self->priv->current_page,
@@ -1257,19 +1266,52 @@ footer_entry_changed_cb (GtkEditable *editable,
 
 
 static void
-header_or_footer_icon_press_cb (GtkEntry            *entry,
-                               GtkEntryIconPosition icon_pos,
-                               GdkEvent            *event,
-                               gpointer             user_data)
+edit_header_button_clicked_cb (GtkButton *button,
+                              gpointer   user_data)
 {
        GthImagePrintJob *self = user_data;
-       GtkWidget        *help_table;
+       GtkWidget        *dialog;
+
+       dialog = gth_template_editor_dialog_new (Text_Special_Codes,
+                                                G_N_ELEMENTS (Text_Special_Codes),
+                                                0,
+                                                _("Edit Template"),
+                                                NULL);
+       gth_template_editor_dialog_set_preview_cb (GTH_TEMPLATE_EDITOR_DIALOG (dialog),
+                                                  template_eval_cb,
+                                                  self);
+       gth_template_editor_dialog_set_template (GTH_TEMPLATE_EDITOR_DIALOG (dialog),
+                                                gtk_entry_get_text (GTK_ENTRY (GET_WIDGET 
("header_entry"))));
+       g_signal_connect (dialog,
+                         "response",
+                         G_CALLBACK (gth_template_editor_dialog_default_response),
+                         GET_WIDGET ("header_entry"));
+       gtk_widget_show (dialog);
+}
 
-       help_table = GET_WIDGET ("page_footer_help_table");
-       if (gtk_widget_get_visible (help_table))
-               gtk_widget_hide (help_table);
-       else
-               gtk_widget_show (help_table);
+
+static void
+edit_footer_button_clicked_cb (GtkButton *button,
+                              gpointer   user_data)
+{
+       GthImagePrintJob *self = user_data;
+       GtkWidget        *dialog;
+
+       dialog = gth_template_editor_dialog_new (Text_Special_Codes,
+                                                G_N_ELEMENTS (Text_Special_Codes),
+                                                0,
+                                                _("Edit Template"),
+                                                NULL);
+       gth_template_editor_dialog_set_preview_cb (GTH_TEMPLATE_EDITOR_DIALOG (dialog),
+                                                  template_eval_cb,
+                                                  self);
+       gth_template_editor_dialog_set_template (GTH_TEMPLATE_EDITOR_DIALOG (dialog),
+                                                gtk_entry_get_text (GTK_ENTRY (GET_WIDGET 
("footer_entry"))));
+       g_signal_connect (dialog,
+                         "response",
+                         G_CALLBACK (gth_template_editor_dialog_default_response),
+                         GET_WIDGET ("footer_entry"));
+       gtk_widget_show (dialog);
 }
 
 
@@ -1415,7 +1457,7 @@ image_scale_format_value_cb (GtkScale *scale,
 
 static GObject *
 operation_create_custom_widget_cb (GtkPrintOperation *operation,
-                                  gpointer           user_data)
+                                  gpointer           user_data)
 {
        GthImagePrintJob *self = user_data;
 
@@ -1436,7 +1478,7 @@ operation_create_custom_widget_cb (GtkPrintOperation *operation,
        g_signal_connect (GET_WIDGET ("preview_drawingarea"),
                          "draw",
                          G_CALLBACK (preview_draw_cb),
-                         self);
+                         self);
        g_signal_connect (GET_WIDGET ("preview_drawingarea"),
                          "motion-notify-event",
                          G_CALLBACK (preview_motion_notify_event_cb),
@@ -1451,12 +1493,12 @@ operation_create_custom_widget_cb (GtkPrintOperation *operation,
                          self);
        g_signal_connect (GET_WIDGET ("rows_spinbutton"),
                          "value-changed",
-                         G_CALLBACK (rows_spinbutton_changed_cb),
-                         self);
+                         G_CALLBACK (rows_spinbutton_changed_cb),
+                         self);
        g_signal_connect (GET_WIDGET ("columns_spinbutton"),
                          "value-changed",
-                         G_CALLBACK (columns_spinbutton_changed_cb),
-                         self);
+                         G_CALLBACK (columns_spinbutton_changed_cb),
+                         self);
        g_signal_connect (GET_WIDGET ("next_page_button"),
                          "clicked",
                          G_CALLBACK (next_page_button_clicked_cb),
@@ -1467,34 +1509,34 @@ operation_create_custom_widget_cb (GtkPrintOperation *operation,
                          self);
        g_signal_connect (self->priv->caption_chooser,
                          "changed",
-                         G_CALLBACK (caption_chooser_changed_cb),
-                         self);
+                         G_CALLBACK (caption_chooser_changed_cb),
+                         self);
        g_signal_connect (GET_WIDGET ("unit_combobox"),
                          "changed",
-                         G_CALLBACK (unit_combobox_changed_cb),
-                         self);
+                         G_CALLBACK (unit_combobox_changed_cb),
+                         self);
        g_signal_connect (GET_WIDGET ("header_entry"),
                          "changed",
-                         G_CALLBACK (header_entry_changed_cb),
-                         self);
+                         G_CALLBACK (header_entry_changed_cb),
+                         self);
        g_signal_connect (GET_WIDGET ("footer_entry"),
                          "changed",
-                         G_CALLBACK (footer_entry_changed_cb),
-                         self);
-       g_signal_connect (GET_WIDGET ("header_entry"),
-                         "icon-press",
-                         G_CALLBACK (header_or_footer_icon_press_cb),
-                         self);
-       g_signal_connect (GET_WIDGET ("footer_entry"),
-                         "icon-press",
-                         G_CALLBACK (header_or_footer_icon_press_cb),
-                         self);
+                         G_CALLBACK (footer_entry_changed_cb),
+                         self);
+       g_signal_connect (GET_WIDGET ("edit_header_button"),
+                         "clicked",
+                         G_CALLBACK (edit_header_button_clicked_cb),
+                         self);
+       g_signal_connect (GET_WIDGET ("edit_footer_button"),
+                         "clicked",
+                         G_CALLBACK (edit_footer_button_clicked_cb),
+                         self);
 
        self->priv->rotation_combobox_changed_event =
                        g_signal_connect (GET_WIDGET ("rotation_combobox"),
                                          "changed",
-                                         G_CALLBACK (rotation_combobox_changed_cb),
-                                         self);
+                                         G_CALLBACK (rotation_combobox_changed_cb),
+                                         self);
        self->priv->scale_adjustment_value_changed_event =
                        g_signal_connect (GET_WIDGET ("scale_adjustment"),
                                          "value-changed",


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