From a2c380c8f271486eb6dfeb82a46ca7a95aca85c5 Mon Sep 17 00:00:00 2001 From: Charles Kerr Date: Mon, 6 May 2013 17:51:48 -0500 Subject: in timezone-file, check to see if the new timezone differs from the old one before emitting a property-change notification --- src/timezone-file.c | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) (limited to 'src') diff --git a/src/timezone-file.c b/src/timezone-file.c index c7c2cf6..3a83c5a 100644 --- a/src/timezone-file.c +++ b/src/timezone-file.c @@ -62,15 +62,22 @@ reload (IndicatorDatetimeTimezoneFile * self) if (!g_file_get_contents (p->filename, &new_timezone, NULL, &err)) { - g_warning ("Unable to read timezone file '%s': %s", p->filename, err->message); + g_warning ("%s Unable to read timezone file '%s': %s", G_STRLOC, p->filename, err->message); g_error_free (err); } else { g_strstrip (new_timezone); - g_free (p->timezone); - p->timezone = new_timezone; - indicator_datetime_timezone_notify_timezone (INDICATOR_DATETIME_TIMEZONE(self)); + + if (g_strcmp0 (p->timezone, new_timezone)) + { + g_free (p->timezone); + p->timezone = g_strdup (new_timezone); + g_debug ("%s new timezone set: '%s'", G_STRLOC, p->timezone); + indicator_datetime_timezone_notify_timezone (INDICATOR_DATETIME_TIMEZONE(self)); + } + + g_free (new_timezone); } } @@ -91,13 +98,13 @@ set_filename (IndicatorDatetimeTimezoneFile * self, const char * filename) p->monitor = g_file_monitor_file (p->file, G_FILE_MONITOR_NONE, NULL, &err); if (err != NULL) { - g_warning ("Unable to monitor timezone file '%s': %s", TIMEZONE_FILE, err->message); + g_warning ("%s Unable to monitor timezone file '%s': %s", G_STRLOC, TIMEZONE_FILE, err->message); g_error_free (err); } else { g_signal_connect_swapped (p->monitor, "changed", G_CALLBACK(reload), self); - g_debug ("Monitoring timezone file '%s'", p->filename); + g_debug ("%s Monitoring timezone file '%s'", G_STRLOC, p->filename); } reload (self); -- cgit v1.2.3