[evince/gnome-40] properties: Show None when missing creation/modification date



commit 681ad3f94c480733263ddc0cbaa4be61d07bbcea
Author: Volte--Vieira Philippe <philippeisvv hotmail fr>
Date:   Fri Jun 25 19:47:29 2021 +0000

    properties: Show None when missing creation/modification date
    
    According to the PDF spec, the creation date and modification date are
    optional (for pdf documents). We can safely assume that a file will not
    to be modified exactly at 31 Dec 1969 23:59:59 UTC, so each creation and
    modification date equal to -1 is considered as NULL for the pointers to
    the other attributes (None is displayed).
    
    The if statements could be used in the future when using GDateDime instead
    of GTime (a pointer could help, or optional type), and it works for
    any type of document, not only PDF.
    
    Closes: #1549
    
    Signed-off-by: Philippe Volte--Vieira <philippeisvv hotmail fr>

 properties/ev-properties-view.c | 20 ++++++++++++++------
 1 file changed, 14 insertions(+), 6 deletions(-)
---
diff --git a/properties/ev-properties-view.c b/properties/ev-properties-view.c
index 1c97b135..3e34e23b 100644
--- a/properties/ev-properties-view.c
+++ b/properties/ev-properties-view.c
@@ -392,14 +392,22 @@ ev_properties_view_set_info (EvPropertiesView *properties, const EvDocumentInfo
                set_property (properties, GTK_GRID (grid), CREATOR_PROPERTY, info->creator, &row);
        }
        if (info->fields_mask & EV_DOCUMENT_INFO_CREATION_DATE) {
-               text = ev_document_misc_format_date (info->creation_date);
-               set_property (properties, GTK_GRID (grid), CREATION_DATE_PROPERTY, text, &row);
-               g_free (text);
+               if (info->creation_date == -1) {
+                       set_property (properties, GTK_GRID (grid), CREATION_DATE_PROPERTY, NULL, &row);
+               } else {
+                       text = ev_document_misc_format_date (info->creation_date);
+                       set_property (properties, GTK_GRID (grid), CREATION_DATE_PROPERTY, text, &row);
+                       g_free (text);
+               }
        }
        if (info->fields_mask & EV_DOCUMENT_INFO_MOD_DATE) {
-               text = ev_document_misc_format_date (info->modified_date);
-               set_property (properties, GTK_GRID (grid), MOD_DATE_PROPERTY, text, &row);
-               g_free (text);
+               if (info->modified_date == -1) {
+                       set_property (properties, GTK_GRID (grid), MOD_DATE_PROPERTY, NULL, &row);
+               } else {
+                       text = ev_document_misc_format_date (info->modified_date);
+                       set_property (properties, GTK_GRID (grid), MOD_DATE_PROPERTY, text, &row);
+                       g_free (text);
+               }
        }
        if (info->fields_mask & EV_DOCUMENT_INFO_FORMAT) {
                set_property (properties, GTK_GRID (grid), FORMAT_PROPERTY, info->format, &row);


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