From 27bd0190002c6facbd662c19ffb4be5b1d995441 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Thu, 7 Oct 2010 14:11:36 -0600 Subject: Create a way for to see if the timezones are the same. --- src/datetime-service.c | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) diff --git a/src/datetime-service.c b/src/datetime-service.c index 7f37ac2..e821dfc 100644 --- a/src/datetime-service.c +++ b/src/datetime-service.c @@ -56,6 +56,39 @@ static GeoclueMasterClient * geo_master = NULL; static GeoclueAddress * geo_address = NULL; static gchar * geo_timezone = NULL; +/* Check to see if our timezones are the same */ +static void +check_timezone_sync (void) { + gboolean in_sync = FALSE; + + if (geo_timezone == NULL) { + in_sync = TRUE; + } + + if (current_timezone == NULL) { + in_sync = TRUE; + } + + if (!in_sync && g_strcmp0(geo_timezone, current_timezone) == 0) { + in_sync = TRUE; + } + + if (in_sync) { + g_debug("Timezones in sync"); + dbusmenu_menuitem_property_set_bool(tzchange, DBUSMENU_MENUITEM_PROP_VISIBLE, FALSE); + } else { + g_debug("Timezones are different"); + gchar * label = g_strdup_printf(_("Change timezone to: %s"), geo_timezone); + + dbusmenu_menuitem_property_set(tzchange, DBUSMENU_MENUITEM_PROP_LABEL, label); + dbusmenu_menuitem_property_set_bool(tzchange, DBUSMENU_MENUITEM_PROP_VISIBLE, TRUE); + + g_free(label); + } + + return; +} + /* Update the current timezone */ static void update_current_timezone (void) { @@ -85,6 +118,8 @@ update_current_timezone (void) { g_debug("System timezone is: %s", current_timezone); + check_timezone_sync(); + return; } @@ -302,6 +337,8 @@ geo_address_cb (GeoclueAddress * address, int timestamp, GHashTable * addy_data, geo_timezone = g_strdup((gchar *)tz_hash); } + check_timezone_sync(); + return; } -- cgit v1.2.3