aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorCharles Kerr <charles.kerr@canonical.com>2012-11-04 17:51:51 -0600
committerCharles Kerr <charles.kerr@canonical.com>2012-11-04 17:51:51 -0600
commite0956b83d773f47e92108c2ad21031e6f0efc757 (patch)
treed8e9320dd0271902dcd6c16c9973724c2fa717f9 /src
parent60825ab6ff90e0755dce38d533aecb677995ff24 (diff)
downloadayatana-indicator-datetime-e0956b83d773f47e92108c2ad21031e6f0efc757.tar.gz
ayatana-indicator-datetime-e0956b83d773f47e92108c2ad21031e6f0efc757.tar.bz2
ayatana-indicator-datetime-e0956b83d773f47e92108c2ad21031e6f0efc757.zip
extract method geo_set_timezone() from geo_address_cb() and geo_client_invalid() s.t. modifying the geo_location variable always happens in just one place.
Diffstat (limited to 'src')
-rw-r--r--src/datetime-service.c36
1 files changed, 13 insertions, 23 deletions
diff --git a/src/datetime-service.c b/src/datetime-service.c
index e63fed6..f8d673f 100644
--- a/src/datetime-service.c
+++ b/src/datetime-service.c
@@ -1185,6 +1185,17 @@ system_proxy_cb (GObject * object, GAsyncResult * res, gpointer user_data)
g_signal_connect(proxy, "g-signal", G_CALLBACK(session_active_change_cb), user_data);
}
+static void
+geo_set_timezone (const gchar * timezone)
+{
+ if (geo_timezone != timezone) {
+ g_clear_pointer (&geo_timezone, g_free);
+ geo_timezone = g_strdup (timezone);
+ g_debug("Geoclue timezone is: %s", timezone ? timezone : "(Null)");
+ update_location_menu_items();
+ }
+}
+
/* Callback from getting the address */
static void
geo_address_cb (GeoclueAddress * address, int timestamp, GHashTable * addy_data, GeoclueAccuracy * accuracy, GError * error, gpointer user_data)
@@ -1195,21 +1206,7 @@ geo_address_cb (GeoclueAddress * address, int timestamp, GHashTable * addy_data,
return;
}
- g_debug("Geoclue timezone is: %s", (gchar *)g_hash_table_lookup(addy_data, "timezone"));
-
- if (geo_timezone != NULL) {
- g_free(geo_timezone);
- geo_timezone = NULL;
- }
-
- gpointer tz_hash = g_hash_table_lookup(addy_data, "timezone");
- if (tz_hash != NULL) {
- geo_timezone = g_strdup((gchar *)tz_hash);
- }
-
- update_location_menu_items();
-
- return;
+ geo_set_timezone (g_hash_table_lookup (addy_data, "timezone"));
}
/* Clean up the reference we kept to the address and make sure to
@@ -1300,14 +1297,7 @@ geo_client_invalid (GeoclueMasterClient * client, gpointer user_data)
GeoclueMaster * master = geoclue_master_get_default();
geoclue_master_create_client_async(master, geo_create_client, NULL);
- if (geo_timezone != NULL) {
- g_free(geo_timezone);
- geo_timezone = NULL;
- }
-
- update_location_menu_items();
-
- return;
+ geo_set_timezone (NULL);
}
/* Callback from creating the client */