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 d5febf6e62)
This commit is contained in:
Jehan
2020-01-02 23:09:23 +01:00
parent 1e76a008c5
commit 621e941bf2
5 changed files with 46 additions and 10 deletions

View File

@ -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;

View File

@ -106,6 +106,7 @@ struct _GimpCoreConfig
gboolean check_updates;
gint64 check_update_timestamp;
gchar *last_known_release;
gint64 last_release_timestamp;
};
struct _GimpCoreConfigClass

View File

@ -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).")

View File

@ -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);

View File

@ -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);