From 030ba7689c5dabac3a0d84bb55c8fcec7d87737b Mon Sep 17 00:00:00 2001 From: Michael Terry Date: Tue, 15 Feb 2011 14:51:00 -0500 Subject: fix typo that prevented old locations from being deleted --- src/datetime-service.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/datetime-service.c') diff --git a/src/datetime-service.c b/src/datetime-service.c index 10f53df..0117be1 100644 --- a/src/datetime-service.c +++ b/src/datetime-service.c @@ -367,10 +367,10 @@ update_timezone_menu_items(gpointer user_data) { /* Remove all of the previous locations */ if (dconflocations != NULL) { g_debug("Freeing old locations"); - while (appointments != NULL) { + while (dconflocations != NULL) { DbusmenuMenuitem * litem = DBUSMENU_MENUITEM(dconflocations->data); g_debug("Freeing old location: %p", litem); - // Remove all the existing menu items which are in appointments. + // Remove all the existing menu items which are in dconflocations. dconflocations = g_list_remove(dconflocations, litem); dbusmenu_menuitem_child_delete(root, DBUSMENU_MENUITEM(litem)); g_object_unref(G_OBJECT(litem)); -- cgit v1.2.3 From f704c6178715e68128e324490660aea5014eb2f7 Mon Sep 17 00:00:00 2001 From: Michael Terry Date: Tue, 15 Feb 2011 14:53:47 -0500 Subject: show current or geo location if we are going to use them --- src/datetime-service.c | 2 ++ 1 file changed, 2 insertions(+) (limited to 'src/datetime-service.c') diff --git a/src/datetime-service.c b/src/datetime-service.c index 0117be1..3c84551 100644 --- a/src/datetime-service.c +++ b/src/datetime-service.c @@ -148,6 +148,7 @@ check_timezone_sync (void) { dbusmenu_menuitem_property_set (current_location, TIMEZONE_MENUITEM_PROP_LABEL, label); // TODO work out the current time at that location dbusmenu_menuitem_property_set (current_location, TIMEZONE_MENUITEM_PROP_RIGHT, "+tzone"); + dbusmenu_menuitem_property_set_bool (current_location, DBUSMENU_MENUITEM_PROP_VISIBLE, TRUE); } else { g_debug("Label for current location is null, this shouldn't happen"); } @@ -156,6 +157,7 @@ check_timezone_sync (void) { dbusmenu_menuitem_property_set (geo_location, TIMEZONE_MENUITEM_PROP_LABEL, geo_timezone); // TODO work out the current time at that location dbusmenu_menuitem_property_set (geo_location, TIMEZONE_MENUITEM_PROP_RIGHT, "+tzone"); + dbusmenu_menuitem_property_set_bool (geo_location, DBUSMENU_MENUITEM_PROP_VISIBLE, TRUE); } } else { // TODO work out the geo location name in a nice way -- cgit v1.2.3 From 02f8926f9c00954625a57e8d5d650e2523b98154 Mon Sep 17 00:00:00 2001 From: Michael Terry Date: Tue, 15 Feb 2011 15:06:33 -0500 Subject: add preference zones in order, after current timezone --- src/datetime-service.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'src/datetime-service.c') diff --git a/src/datetime-service.c b/src/datetime-service.c index 3c84551..2db6421 100644 --- a/src/datetime-service.c +++ b/src/datetime-service.c @@ -364,7 +364,7 @@ update_timezone_menu_items(gpointer user_data) { } guint len = g_strv_length(locations); DbusmenuMenuitem *item; - gint i; + gint i, offset; /* Remove all of the previous locations */ if (dconflocations != NULL) { @@ -390,6 +390,7 @@ update_timezone_menu_items(gpointer user_data) { return FALSE; } + offset = dbusmenu_menuitem_get_position (current_location, root)+1; for (i = 0; i < len; i++) { // Iterate over configured places and add any which aren't already listed if (g_strcmp0(locations[i], current_timezone) != 0 && @@ -402,8 +403,7 @@ update_timezone_menu_items(gpointer user_data) { dbusmenu_menuitem_property_set_bool (item, TIMEZONE_MENUITEM_PROP_RADIO, FALSE); dbusmenu_menuitem_property_set_bool (item, DBUSMENU_MENUITEM_PROP_ENABLED, TRUE); dbusmenu_menuitem_property_set_bool (item, DBUSMENU_MENUITEM_PROP_VISIBLE, TRUE); - dbusmenu_menuitem_child_add_position (root, item, - dbusmenu_menuitem_get_position (locations_separator, root)+3); + dbusmenu_menuitem_child_add_position (root, item, offset++); //g_signal_connect(G_OBJECT(item), DBUSMENU_MENUITEM_SIGNAL_ITEM_ACTIVATED, G_CALLBACK(quick_set_tz), NULL); dconflocations = g_list_append(dconflocations, item); } -- cgit v1.2.3 From 67264a791f282ac18eba02af4df73f71c9736886 Mon Sep 17 00:00:00 2001 From: Michael Terry Date: Tue, 15 Feb 2011 15:10:49 -0500 Subject: start with current timezone selected --- src/datetime-service.c | 1 + 1 file changed, 1 insertion(+) (limited to 'src/datetime-service.c') diff --git a/src/datetime-service.c b/src/datetime-service.c index 2db6421..795403f 100644 --- a/src/datetime-service.c +++ b/src/datetime-service.c @@ -149,6 +149,7 @@ check_timezone_sync (void) { // TODO work out the current time at that location dbusmenu_menuitem_property_set (current_location, TIMEZONE_MENUITEM_PROP_RIGHT, "+tzone"); dbusmenu_menuitem_property_set_bool (current_location, DBUSMENU_MENUITEM_PROP_VISIBLE, TRUE); + dbusmenu_menuitem_property_set_bool(current_location, TIMEZONE_MENUITEM_PROP_RADIO, TRUE); } else { g_debug("Label for current location is null, this shouldn't happen"); } -- cgit v1.2.3 From 6bc13b2d4f6cab5a349a072d256dcb55418c6ef2 Mon Sep 17 00:00:00 2001 From: Michael Terry Date: Tue, 15 Feb 2011 15:32:56 -0500 Subject: re-enable setting the timezone when clicking --- src/datetime-service.c | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-) (limited to 'src/datetime-service.c') diff --git a/src/datetime-service.c b/src/datetime-service.c index 795403f..432657d 100644 --- a/src/datetime-service.c +++ b/src/datetime-service.c @@ -216,7 +216,7 @@ update_current_timezone (void) { return; } -/* See how our timezone setting went +/* See how our timezone setting went */ static void quick_set_tz_cb (OobsObject * obj, OobsResult result, gpointer user_data) { @@ -226,26 +226,27 @@ quick_set_tz_cb (OobsObject * obj, OobsResult result, gpointer user_data) g_warning("Unable to quick set timezone"); } return; -}*/ +} -/* Set the timezone to the Geoclue discovered one +/* Set the timezone to the Geoclue discovered one */ static void -quick_set_tz (DbusmenuMenuitem * menuitem, guint timestamp, const gchar *command) +quick_set_tz (DbusmenuMenuitem * menuitem, guint timestamp, gpointer user_data) { - g_debug("Quick setting timezone to: %s", geo_timezone); + const gchar * tz = dbusmenu_menuitem_property_get(menuitem, TIMEZONE_MENUITEM_PROP_LABEL); + g_debug("Quick setting timezone to: %s", tz); - g_return_if_fail(geo_timezone != NULL); + g_return_if_fail(tz != NULL); OobsObject * obj = oobs_time_config_get(); g_return_if_fail(obj != NULL); OobsTimeConfig * timeconfig = OOBS_TIME_CONFIG(obj); - oobs_time_config_set_timezone(timeconfig, geo_timezone); + oobs_time_config_set_timezone(timeconfig, tz); oobs_object_commit_async(obj, quick_set_tz_cb, NULL); return; -}*/ +} /* Updates the label in the date menuitem */ static gboolean @@ -405,7 +406,7 @@ update_timezone_menu_items(gpointer user_data) { dbusmenu_menuitem_property_set_bool (item, DBUSMENU_MENUITEM_PROP_ENABLED, TRUE); dbusmenu_menuitem_property_set_bool (item, DBUSMENU_MENUITEM_PROP_VISIBLE, TRUE); dbusmenu_menuitem_child_add_position (root, item, offset++); - //g_signal_connect(G_OBJECT(item), DBUSMENU_MENUITEM_SIGNAL_ITEM_ACTIVATED, G_CALLBACK(quick_set_tz), NULL); + g_signal_connect(G_OBJECT(item), DBUSMENU_MENUITEM_SIGNAL_ITEM_ACTIVATED, G_CALLBACK(quick_set_tz), NULL); dconflocations = g_list_append(dconflocations, item); } } @@ -694,7 +695,7 @@ build_menus (DbusmenuMenuitem * root) dbusmenu_menuitem_property_set (geo_location, TIMEZONE_MENUITEM_PROP_LABEL, "Updating location information..."); dbusmenu_menuitem_property_set_bool (geo_location, DBUSMENU_MENUITEM_PROP_ENABLED, FALSE); dbusmenu_menuitem_property_set_bool (geo_location, DBUSMENU_MENUITEM_PROP_VISIBLE, TRUE); - //g_signal_connect(G_OBJECT(geo_location), DBUSMENU_MENUITEM_SIGNAL_ITEM_ACTIVATED, G_CALLBACK(quick_set_tz), NULL); + g_signal_connect(G_OBJECT(geo_location), DBUSMENU_MENUITEM_SIGNAL_ITEM_ACTIVATED, G_CALLBACK(quick_set_tz), NULL); dbusmenu_menuitem_child_append(root, geo_location); current_location = dbusmenu_menuitem_new(); @@ -702,7 +703,7 @@ build_menus (DbusmenuMenuitem * root) dbusmenu_menuitem_property_set (current_location, TIMEZONE_MENUITEM_PROP_LABEL, "Current Timezone"); dbusmenu_menuitem_property_set_bool (current_location, DBUSMENU_MENUITEM_PROP_ENABLED, FALSE); dbusmenu_menuitem_property_set_bool (current_location, DBUSMENU_MENUITEM_PROP_VISIBLE, FALSE); - //g_signal_connect(G_OBJECT(current_location), DBUSMENU_MENUITEM_SIGNAL_ITEM_ACTIVATED, G_CALLBACK(quick_set_tz), NULL); + g_signal_connect(G_OBJECT(current_location), DBUSMENU_MENUITEM_SIGNAL_ITEM_ACTIVATED, G_CALLBACK(quick_set_tz), NULL); dbusmenu_menuitem_child_append(root, current_location); check_timezone_sync(); -- cgit v1.2.3 From 02fcae957feca3cefd3c950c265fab03c5b1177c Mon Sep 17 00:00:00 2001 From: Michael Terry Date: Tue, 15 Feb 2011 15:52:09 -0500 Subject: ignore timezone switches if nothing to do --- src/datetime-service.c | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'src/datetime-service.c') diff --git a/src/datetime-service.c b/src/datetime-service.c index 432657d..0894e83 100644 --- a/src/datetime-service.c +++ b/src/datetime-service.c @@ -233,10 +233,14 @@ static void quick_set_tz (DbusmenuMenuitem * menuitem, guint timestamp, gpointer user_data) { const gchar * tz = dbusmenu_menuitem_property_get(menuitem, TIMEZONE_MENUITEM_PROP_LABEL); + g_debug("Quick setting timezone to: %s", tz); g_return_if_fail(tz != NULL); + if (g_strcmp0(tz, current_timezone) == 0) + return; + OobsObject * obj = oobs_time_config_get(); g_return_if_fail(obj != NULL); -- cgit v1.2.3