aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--configure.ac2
-rw-r--r--src/datetime-prefs.c40
-rw-r--r--src/datetime-service.c21
3 files changed, 42 insertions, 21 deletions
diff --git a/configure.ac b/configure.ac
index ac19fb7..4bd3f6c 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1,5 +1,5 @@
AC_INIT([indicator-datetime],
- [0.3.92],
+ [0.3.93],
[http://bugs.launchpad.net/indicator-datetime],
[indicator-datetime],
[http://launchpad.net/indicator-datetime])
diff --git a/src/datetime-prefs.c b/src/datetime-prefs.c
index bfe75c0..0e2e99c 100644
--- a/src/datetime-prefs.c
+++ b/src/datetime-prefs.c
@@ -70,6 +70,8 @@ struct _IndicatorDatetimePanelPrivate
gboolean changing_time;
GtkWidget * loc_dlg;
CcTimezoneCompletion * completion;
+ GCancellable * tz_query_cancel;
+ GCancellable * ntp_query_cancel;
};
struct _IndicatorDatetimePanelClass
@@ -214,6 +216,8 @@ ntp_query_answered (GObject *object, GAsyncResult *res, IndicatorDatetimePanel *
GError * error = NULL;
GVariant * answers = g_dbus_proxy_call_finish (G_DBUS_PROXY (object), res, &error);
+ g_clear_object (&self->priv->ntp_query_cancel);
+
if (error != NULL) {
g_warning("Could not query DBus proxy for SettingsDaemon: %s", error->message);
g_error_free(error);
@@ -265,6 +269,8 @@ tz_query_answered (GObject *object, GAsyncResult *res, IndicatorDatetimePanel *
GError * error = NULL;
GVariant * answers = g_dbus_proxy_call_finish (G_DBUS_PROXY (object), res, &error);
+ g_clear_object (&self->priv->tz_query_cancel);
+
if (error != NULL) {
g_warning("Could not query DBus proxy for SettingsDaemon: %s", error->message);
g_error_free(error);
@@ -286,6 +292,7 @@ static void
proxy_ready (GObject *object, GAsyncResult *res, IndicatorDatetimePanel * self)
{
GError * error = NULL;
+ IndicatorDatetimePanelPrivate * priv = self->priv;
self->priv->proxy = g_dbus_proxy_new_for_bus_finish (res, &error);
@@ -296,10 +303,16 @@ proxy_ready (GObject *object, GAsyncResult *res, IndicatorDatetimePanel * self)
}
/* And now, do initial proxy configuration */
- g_dbus_proxy_call (self->priv->proxy, "GetUsingNtp", NULL, G_DBUS_CALL_FLAGS_NONE, -1,
- NULL, (GAsyncReadyCallback)ntp_query_answered, self);
- g_dbus_proxy_call (self->priv->proxy, "GetTimezone", NULL, G_DBUS_CALL_FLAGS_NONE, -1,
- NULL, (GAsyncReadyCallback)tz_query_answered, self);
+ if (priv->ntp_query_cancel == NULL) {
+ priv->ntp_query_cancel = g_cancellable_new();
+ g_dbus_proxy_call (priv->proxy, "GetUsingNtp", NULL, G_DBUS_CALL_FLAGS_NONE, -1,
+ priv->ntp_query_cancel, (GAsyncReadyCallback)ntp_query_answered, self);
+ }
+ if (priv->tz_query_cancel == NULL); {
+ priv->tz_query_cancel = g_cancellable_new();
+ g_dbus_proxy_call (priv->proxy, "GetTimezone", NULL, G_DBUS_CALL_FLAGS_NONE, -1,
+ priv->tz_query_cancel, (GAsyncReadyCallback)tz_query_answered, self);
+ }
}
static void
@@ -564,21 +577,14 @@ setup_time_spinners (IndicatorDatetimePanel * self, GtkWidget * time, GtkWidget
}
static void
-hide_locations (IndicatorDatetimePanel * self)
-{
- if (self->priv->loc_dlg != NULL)
- gtk_widget_destroy (self->priv->loc_dlg);
-}
-
-static void
show_locations (IndicatorDatetimePanel * self)
{
if (self->priv->loc_dlg == NULL) {
self->priv->loc_dlg = datetime_setup_locations_dialog (self->priv->tzmap);
GtkWidget * dlg = gtk_widget_get_toplevel (GTK_WIDGET (self));
+ gtk_window_set_type_hint (GTK_WINDOW(self->priv->loc_dlg), GDK_WINDOW_TYPE_HINT_DIALOG);
gtk_window_set_transient_for (GTK_WINDOW (self->priv->loc_dlg), GTK_WINDOW (dlg));
g_signal_connect (self->priv->loc_dlg, "destroy", G_CALLBACK (gtk_widget_destroyed), &self->priv->loc_dlg);
- g_signal_connect_swapped (dlg, "focus-in-event", G_CALLBACK (hide_locations), self);
gtk_widget_show_all (self->priv->loc_dlg);
}
else {
@@ -784,6 +790,16 @@ indicator_datetime_panel_dispose (GObject * object)
g_clear_object (&priv->builder);
g_clear_object (&priv->proxy);
+ if (priv->tz_query_cancel != NULL) {
+ g_cancellable_cancel (priv->tz_query_cancel);
+ g_clear_object (&priv->tz_query_cancel);
+ }
+
+ if (priv->ntp_query_cancel != NULL) {
+ g_cancellable_cancel (priv->ntp_query_cancel);
+ g_clear_object (&priv->ntp_query_cancel);
+ }
+
if (priv->loc_dlg) {
gtk_widget_destroy (priv->loc_dlg);
priv->loc_dlg = NULL;
diff --git a/src/datetime-service.c b/src/datetime-service.c
index a10cbb5..8ecef1c 100644
--- a/src/datetime-service.c
+++ b/src/datetime-service.c
@@ -108,7 +108,7 @@ struct comp_instance {
};
/**
- * A temp struct used by update_location_menu_items() for pruning duplicates.
+ * A temp struct used by update_location_menu_items() for pruning duplicates and sorting.
*/
struct TimeLocation
{
@@ -124,14 +124,16 @@ time_location_free (struct TimeLocation * loc)
g_free (loc);
}
static struct TimeLocation*
-time_location_new (const char * zone, const char * name)
+time_location_new (const char * zone, const char * name, time_t now)
{
struct TimeLocation * loc = g_new (struct TimeLocation, 1);
GTimeZone * tz = g_time_zone_new (zone);
- loc->offset = g_time_zone_get_offset (tz, 0);
+ gint interval = g_time_zone_find_interval (tz, G_TIME_TYPE_UNIVERSAL, now);
+ loc->offset = g_time_zone_get_offset (tz, interval);
loc->zone = g_strdup (zone);
loc->name = g_strdup (name);
g_time_zone_unref (tz);
+ g_debug ("%s zone '%s' name '%s' offset is %d", G_STRLOC, zone, name, (int)loc->offset);
return loc;
}
static int
@@ -146,9 +148,9 @@ time_location_compare (const struct TimeLocation * a, const struct TimeLocation
return ret;
}
static GSList*
-locations_add (GSList * locations, const char * zone, const char * name)
+locations_add (GSList * locations, const char * zone, const char * name, time_t now)
{
- struct TimeLocation * loc = time_location_new (zone, name);
+ struct TimeLocation * loc = time_location_new (zone, name, now);
if (g_slist_find_custom (locations, loc, (GCompareFunc)time_location_compare) == NULL) {
g_debug ("%s Adding zone '%s', name '%s'", G_STRLOC, zone, name);
@@ -182,18 +184,19 @@ update_location_menu_items (void)
***/
GSList * locations = NULL;
+ const time_t now = time(NULL);
/* maybe add geo_timezone */
if (geo_timezone != NULL) {
gchar * name = get_current_zone_name (geo_timezone);
- locations = locations_add (locations, geo_timezone, name);
+ locations = locations_add (locations, geo_timezone, name, now);
g_free (name);
}
/* maybe add current_timezone */
if (current_timezone != NULL) {
gchar * name = get_current_zone_name (current_timezone);
- locations = locations_add (locations, current_timezone, name);
+ locations = locations_add (locations, current_timezone, name, now);
g_free (name);
}
@@ -207,7 +210,7 @@ update_location_menu_items (void)
gchar * zone;
gchar * name;
split_settings_location (user_locations[i], &zone, &name);
- locations = locations_add (locations, zone, name);
+ locations = locations_add (locations, zone, name, now);
g_free (name);
g_free (zone);
}
@@ -1479,6 +1482,8 @@ main (int argc, char ** argv)
g_object_unref(G_OBJECT(server));
g_object_unref(G_OBJECT(root));
+ icaltimezone_free_builtin_timezones();
+
geo_address_clean();
geo_client_clean();