[gimp] app: parse the release date for the last release.



commit d5febf6e62e7bf86a2fb917cb4348afc5b03afd4
Author: Jehan <jehan girinstud io>
Date:   Thu Jan 2 23:09:23 2020 +0100

    app: parse the release date for the last release.
    
    I was mistakenly using the date of the last check, not the release date.

 app/config/gimpcoreconfig.c | 14 ++++++++++++++
 app/config/gimpcoreconfig.h |  1 +
 app/config/gimprc-blurbs.h  |  3 +++
 app/dialogs/about-dialog.c  |  2 +-
 app/gimp-update.c           | 36 +++++++++++++++++++++++++++---------
 5 files changed, 46 insertions(+), 10 deletions(-)
---
diff --git a/app/config/gimpcoreconfig.c b/app/config/gimpcoreconfig.c
index 3e4ad36724..17544fc323 100644
--- a/app/config/gimpcoreconfig.c
+++ b/app/config/gimpcoreconfig.c
@@ -130,6 +130,7 @@ enum
   PROP_DEBUG_POLICY,
   PROP_CHECK_UPDATES,
   PROP_CHECK_UPDATE_TIMESTAMP,
+  PROP_LAST_RELEASE_TIMESTAMP,
   PROP_LAST_KNOWN_RELEASE,
 
   /* ignored, only for backward compatibility: */
@@ -693,6 +694,13 @@ gimp_core_config_class_init (GimpCoreConfigClass *klass)
                           0, G_MAXINT64, 0,
                           GIMP_PARAM_STATIC_STRINGS);
 
+  GIMP_CONFIG_PROP_INT64 (object_class, PROP_LAST_RELEASE_TIMESTAMP,
+                          "last-release-timestamp",
+                          "timestamp of the last release",
+                          LAST_RELEASE_TIMESTAMP_BLURB,
+                          0, G_MAXINT64, 0,
+                          GIMP_PARAM_STATIC_STRINGS);
+
   GIMP_CONFIG_PROP_STRING (object_class, PROP_LAST_KNOWN_RELEASE,
                            "last-known-release",
                            "last known release of GIMP",
@@ -1084,6 +1092,9 @@ gimp_core_config_set_property (GObject      *object,
     case PROP_CHECK_UPDATE_TIMESTAMP:
       core_config->check_update_timestamp = g_value_get_int64 (value);
       break;
+    case PROP_LAST_RELEASE_TIMESTAMP:
+      core_config->last_release_timestamp = g_value_get_int64 (value);
+      break;
     case PROP_LAST_KNOWN_RELEASE:
       core_config->last_known_release = g_value_dup_string (value);
       break;
@@ -1305,6 +1316,9 @@ gimp_core_config_get_property (GObject    *object,
     case PROP_CHECK_UPDATE_TIMESTAMP:
       g_value_set_int64 (value, core_config->check_update_timestamp);
       break;
+    case PROP_LAST_RELEASE_TIMESTAMP:
+      g_value_set_int64 (value, core_config->last_release_timestamp);
+      break;
     case PROP_LAST_KNOWN_RELEASE:
       g_value_set_string (value, core_config->last_known_release);
       break;
diff --git a/app/config/gimpcoreconfig.h b/app/config/gimpcoreconfig.h
index ea62eeeda6..1ed815fe1d 100644
--- a/app/config/gimpcoreconfig.h
+++ b/app/config/gimpcoreconfig.h
@@ -107,6 +107,7 @@ struct _GimpCoreConfig
   gboolean                check_updates;
   gint64                  check_update_timestamp;
   gchar                  *last_known_release;
+  gint64                  last_release_timestamp;
 };
 
 struct _GimpCoreConfigClass
diff --git a/app/config/gimprc-blurbs.h b/app/config/gimprc-blurbs.h
index 5644be6c77..b2f30bad50 100644
--- a/app/config/gimprc-blurbs.h
+++ b/app/config/gimprc-blurbs.h
@@ -267,6 +267,9 @@ _("The last known release version of GIMP as queried from official website.")
 #define LAST_OPENED_SIZE_BLURB \
 _("How many recently opened image filenames to keep on the File menu.")
 
+#define LAST_RELEASE_TIMESTAMP_BLURB \
+_("The timestamp for the last known release date.")
+
 #define MARCHING_ANTS_SPEED_BLURB \
 _("Speed of marching ants in the selection outline.  This value is in " \
   "milliseconds (less time indicates faster marching).")
diff --git a/app/dialogs/about-dialog.c b/app/dialogs/about-dialog.c
index a25311d731..39688e45ad 100644
--- a/app/dialogs/about-dialog.c
+++ b/app/dialogs/about-dialog.c
@@ -276,7 +276,7 @@ about_dialog_add_update (GimpAboutDialog *dialog,
   g_list_free (children);
 
   /* The preferred localized date representation without the time. */
-  datetime = g_date_time_new_from_unix_local (config->check_update_timestamp);
+  datetime = g_date_time_new_from_unix_local (config->last_release_timestamp);
   date = g_date_time_format (datetime, "%x");
   g_date_time_unref (datetime);
 
diff --git a/app/gimp-update.c b/app/gimp-update.c
index 5f5788aab3..870897b010 100644
--- a/app/gimp-update.c
+++ b/app/gimp-update.c
@@ -142,6 +142,7 @@ gimp_check_updates_callback (GObject      *source,
       json_path_compile (path, "$['STABLE']", &error);
       result = json_path_match (path, json_parser_get_root (parser));
       versions = json_array_get_object_element (json_node_get_array (result), 0);
+      json_node_unref (result);
       members = json_object_get_members (versions);
 
       for (iter = members; iter; iter = iter->next)
@@ -152,18 +153,35 @@ gimp_check_updates_callback (GObject      *source,
        */
       if (gimp_version_break (last_version, &major, &minor, &micro))
         {
-          g_object_set (config,
-                        "check-update-timestamp", g_get_real_time() / G_USEC_PER_SEC,
-                        "last-known-release",
-                        (major > GIMP_MAJOR_VERSION ||
-                         (major == GIMP_MAJOR_VERSION && minor > GIMP_MINOR_VERSION) ||
-                         (major == GIMP_MAJOR_VERSION && minor == GIMP_MINOR_VERSION && micro > 
GIMP_MICRO_VERSION)) ?
-                        last_version : NULL,
-                        NULL);
+          GDateTime *datetime;
+          gchar     *str;
+
+          str = g_strdup_printf ("$['STABLE']['%s']['date']", last_version);
+          json_path_compile (path, str, &error);
+          g_free (str);
+          result = json_path_match (path, json_parser_get_root (parser));
+          str = g_strdup_printf ("%s 00:00:00Z",
+                                 json_array_get_string_element (json_node_get_array (result),
+                                                                0));
+          json_node_unref (result);
+          datetime = g_date_time_new_from_iso8601 (str, NULL);
+          g_free (str);
+          if (datetime)
+            {
+              g_object_set (config,
+                            "check-update-timestamp", g_get_real_time() / G_USEC_PER_SEC,
+                            "last-release-timestamp", g_date_time_to_unix (datetime),
+                            "last-known-release",
+                            (major > GIMP_MAJOR_VERSION ||
+                             (major == GIMP_MAJOR_VERSION && minor > GIMP_MINOR_VERSION) ||
+                             (major == GIMP_MAJOR_VERSION && minor == GIMP_MINOR_VERSION && micro > 
GIMP_MICRO_VERSION)) ?
+                            last_version : NULL,
+                            NULL);
+              g_date_time_unref (datetime);
+            }
         }
 
       g_list_free (members);
-      json_node_unref (result);
       g_object_unref (path);
       g_object_unref (parser);
       g_object_unref (stream);


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