[gnome-control-center/wip/datetime-panel: 13/15] datetime: add a function to retrieve current timezone from dbus
- From: Thomas Wood <thos src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-control-center/wip/datetime-panel: 13/15] datetime: add a function to retrieve current timezone from dbus
- Date: Mon, 28 Jun 2010 17:10:12 +0000 (UTC)
commit 8174f22fe744e33817aa20546cf7c04b8b582ae3
Author: Thomas Wood <thomas wood intel com>
Date: Mon Jun 28 17:48:47 2010 +0100
datetime: add a function to retrieve current timezone from dbus
Add get_system_timezone_async function to request the current timezone from
the SettingsDaemon.DateTimeMechanism dbus object.
panels/datetime/set-timezone.c | 82 ++++++++++++++++++++++++++++++++++++++++
panels/datetime/set-timezone.h | 17 ++++++++
2 files changed, 99 insertions(+), 0 deletions(-)
---
diff --git a/panels/datetime/set-timezone.c b/panels/datetime/set-timezone.c
index 91c80dd..d0ca80b 100644
--- a/panels/datetime/set-timezone.c
+++ b/panels/datetime/set-timezone.c
@@ -289,3 +289,85 @@ set_system_timezone_async (const gchar *filename,
set_time_async (data);
free_data (data);
}
+
+/* get timezone */
+
+typedef struct
+{
+ GetTimezoneFunc callback;
+ GDestroyNotify notify;
+
+ gpointer data;
+
+} GetTimezoneData;
+
+static void
+get_timezone_destroy_notify (GetTimezoneData *data)
+{
+ if (data->notify && data->data)
+ data->notify (data);
+
+ g_free (data);
+}
+
+static void
+get_timezone_notify (DBusGProxy *proxy,
+ DBusGProxyCall *call,
+ void *user_data)
+{
+ GError *error = NULL;
+ gboolean retval;
+ gchar *string = NULL;
+ GetTimezoneData *data = user_data;
+
+ retval = dbus_g_proxy_end_call (proxy, call, &error,
+ G_TYPE_STRING, &string,
+ G_TYPE_INVALID);
+
+ if (data->callback) {
+ if (!retval) {
+ data->callback (data->data, NULL, error);
+ g_error_free (error);
+ }
+ else {
+ data->callback (data->data, string, NULL);
+ g_free (string);
+ }
+ }
+}
+
+void
+get_system_timezone_async (GetTimezoneFunc callback,
+ gpointer user_data,
+ GDestroyNotify notify)
+{
+ DBusGConnection *bus;
+ DBusGProxy *proxy;
+ GetTimezoneData *data;
+
+ bus = get_system_bus ();
+ if (bus == NULL)
+ return;
+
+ data = g_new0 (GetTimezoneData, 1);
+ data->data = user_data;
+ data->notify = notify;
+ data->callback = callback;
+
+ proxy = dbus_g_proxy_new_for_name (bus,
+ "org.gnome.SettingsDaemon.DateTimeMechanism",
+ "/",
+ "org.gnome.SettingsDaemon.DateTimeMechanism");
+
+ dbus_g_proxy_begin_call (proxy,
+ "GetTimezone",
+ get_timezone_notify,
+ data,
+ (GDestroyNotify) get_timezone_destroy_notify,
+ /* parameters: */
+ G_TYPE_INVALID,
+ /* return values: */
+ G_TYPE_STRING,
+ G_TYPE_INVALID);
+
+}
diff --git a/panels/datetime/set-timezone.h b/panels/datetime/set-timezone.h
index 5280b07..bea433e 100644
--- a/panels/datetime/set-timezone.h
+++ b/panels/datetime/set-timezone.h
@@ -20,9 +20,18 @@
#ifndef __SET_SYSTEM_TIMEZONE_H__
+#include <config.h>
+
#include <glib.h>
#include <time.h>
+typedef void (*GetTimezoneFunc) (gpointer data,
+ const gchar *timezone,
+ GError *error);
+void get_system_timezone_async (GetTimezoneFunc callback,
+ gpointer data,
+ GDestroyNotify notify);
+
gint can_set_system_timezone (void);
gint can_set_system_time (void);
@@ -37,4 +46,12 @@ void set_system_timezone_async (const gchar *filename,
gpointer data,
GDestroyNotify notify);
+
+
+#ifdef HAVE_SOLARIS
+#define SYSTEM_ZONEINFODIR "/usr/share/lib/zoneinfo/tab"
+#else
+#define SYSTEM_ZONEINFODIR "/usr/share/zoneinfo"
+#endif
+
#endif
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]