[gimp/gimp-2-10] app: parse the release date for the last release.



commit 621e941bf2ef4faf708ace5156479cba52c695ca
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.
    
    (cherry picked from commit d5febf6e62e7bf86a2fb917cb4348afc5b03afd4)

 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 276197cab8..2c4c968579 100644
--- a/app/config/gimpcoreconfig.c
+++ b/app/config/gimpcoreconfig.c
@@ -129,6 +129,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: */
@@ -692,6 +693,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",
@@ -1076,6 +1084,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;
@@ -1294,6 +1305,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 4f22f79b2a..50e35c164e 100644
--- a/app/config/gimpcoreconfig.h
+++ b/app/config/gimpcoreconfig.h
@@ -106,6 +106,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 4d95f0dabb..075a721321 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 4bac38b49a..3692e3c337 100644
--- a/app/dialogs/about-dialog.c
+++ b/app/dialogs/about-dialog.c
@@ -286,7 +286,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]