Show page no. in OSD
authorColin Clark <colin.clark@cclark.uk>
Wed, 14 Aug 2019 14:19:56 +0000 (15:19 +0100)
committerColin Clark <colin.clark@cclark.uk>
Wed, 14 Aug 2019 14:19:56 +0000 (15:19 +0100)
If the file is a multi-page file, e.g. .tiff, show page number and page
total as "[n/m]" using tag: file.page_no

doc/docbook/GuideSidebarsInfo.xml
src/exif-common.c
src/osd.c

index 6e110fd..f9c6fc4 100644 (file)
             <entry>file.link</entry>\r
             <entry>if the file is a symbolic link, shows the path of the source file</entry>\r
           </row>\r
+          <row>\r
+            <entry>file.page_no</entry>\r
+            <entry>if the file is a multi-page file, e.g. .tiff, the current page number and page total is displayed (e.g. [2/10])</entry>\r
+          </row>\r
           <row>\r
             <entry>lua.&lt;lua script&gt;</entry>\r
             <entry>\r
index ce90d73..8cc7c2d 100644 (file)
@@ -944,6 +944,7 @@ ExifFormattedText ExifFormattedList[] = {
        {"file.group",                          N_("File group"),       NULL},
        {"file.link",                           N_("File link"),        NULL},
        {"file.class",                          N_("File class"),       NULL},
+       {"file.page_no",                        N_("Page no."),         NULL},
        { NULL, NULL, NULL }
 };
 
@@ -1192,6 +1193,8 @@ static gchar *mode_number(mode_t m)
 
 gchar *metadata_file_info(FileData *fd, const gchar *key, MetadataFormat format)
 {
+       gchar *page_n_of_m;
+
        if (strcmp(key, "file.size") == 0)
                {
                return g_strdup_printf("%ld", (long)fd->size);
@@ -1224,6 +1227,18 @@ gchar *metadata_file_info(FileData *fd, const gchar *key, MetadataFormat format)
                {
                return g_strdup(fd->sym_link);
                }
+       if (strcmp(key, "file.page_no") == 0)
+               {
+               if (fd->page_total > 1)
+                       {
+                       page_n_of_m = g_strdup_printf("[%d/%d]", fd->page_num + 1, fd->page_total);
+                       return page_n_of_m;
+                       }
+               else
+                       {
+                       return NULL;
+                       }
+               }
        return g_strdup("");
 }
 
index 1f8ccd3..a32c837 100644 (file)
--- a/src/osd.c
+++ b/src/osd.c
@@ -52,6 +52,7 @@ static const gchar *predefined_tags[][2] = {
        {"%file.group%",                                        N_("File group")},
        {"%file.link%",                                         N_("File link")},
        {"%file.class%",                                        N_("File class")},
+       {"%file.page_no%",                                      N_("File page no.")},
        {"%formatted.DateTime%",                        N_("Image date")},
        {"%formatted.DateTimeDigitized%",       N_("Date digitized")},
        {"%formatted.ShutterSpeed%",            N_("ShutterSpeed")},