From f57128cae925df888e1e0cafb9ba988c665ecff8 Mon Sep 17 00:00:00 2001 From: Michael Terry Date: Tue, 28 Jun 2011 15:32:04 +0100 Subject: update to handle latest gnome-settings-daemon dbus API for setting timezones; be more fool-proof when looking up current timezone in indicator --- src/utils.c | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) (limited to 'src/utils.c') diff --git a/src/utils.c b/src/utils.c index ab93ecf..73c8ab2 100644 --- a/src/utils.c +++ b/src/utils.c @@ -117,6 +117,30 @@ get_current_zone_name (const gchar * location) return rv; } +gchar * +read_timezone () +{ + GError * error = NULL; + gchar * tempzone = NULL; + if (!g_file_get_contents(TIMEZONE_FILE, &tempzone, NULL, &error)) { + g_warning("Unable to read timezone file '" TIMEZONE_FILE "': %s", error->message); + g_error_free(error); + return NULL; + } + + /* This shouldn't happen, so let's make it a big boom! */ + g_return_val_if_fail(tempzone != NULL, NULL); + + /* Note: this really makes sense as strstrip works in place + so we end up with something a little odd without the dup + so we have the dup to make sure everything is as expected + for everyone else. */ + gchar * rv = g_strdup(g_strstrip(tempzone)); + g_free(tempzone); + + return rv; +} + /* Translate msg according to the locale specified by LC_TIME */ static char * T_(const char *msg) -- cgit v1.2.3