aboutsummaryrefslogtreecommitdiffstats
path: root/calendar/cal-client/cal-client.c
diff options
context:
space:
mode:
authorDamon Chaplin <damon@ximian.com>2001-06-14 14:00:21 +0800
committerDamon Chaplin <damon@src.gnome.org>2001-06-14 14:00:21 +0800
commit4517358debc8bcd761a469e901bae160704deaf2 (patch)
tree0233963c7d4d6a0d256f9a638c1e556f3364ee59 /calendar/cal-client/cal-client.c
parent8089ac1639e1bf714bc8c467b0ad679b491e8088 (diff)
downloadgsoc2013-evolution-4517358debc8bcd761a469e901bae160704deaf2.tar.gz
gsoc2013-evolution-4517358debc8bcd761a469e901bae160704deaf2.tar.zst
gsoc2013-evolution-4517358debc8bcd761a469e901bae160704deaf2.zip
new dialog for setting the time zone.
2001-06-14 Damon Chaplin <damon@ximian.com> * gui/dialogs/e-timezone-dialog.[hc]: * gui/dialogs/e-timezone-dialog.glade: new dialog for setting the time zone. * gui/dialogs/Makefile.am: added timezone dialog files. * idl/evolution-calendar.idl: added CalTimezoneInfo struct and seq, and getBuiltinTimezoneInfo method. * pcs/cal.c (impl_Cal_get_builtin_timezone_info): implemented method. (cal_class_init): added method to epv. * cal-client/cal-client.c (struct CalClientPrivate): added timezone_info array to contain cached info on builtin timezone city names and coordinates. (cal_client_get_builtin_timezone_info): new function to get the info about builtin timezones. * cal-client/cal-client.h: added CalTimezoneInfo struct, to contain the city names and coords of the builtin timezones. svn path=/trunk/; revision=10223
Diffstat (limited to 'calendar/cal-client/cal-client.c')
-rw-r--r--calendar/cal-client/cal-client.c102
1 files changed, 102 insertions, 0 deletions
diff --git a/calendar/cal-client/cal-client.c b/calendar/cal-client/cal-client.c
index cd8c8713d6..d761370c74 100644
--- a/calendar/cal-client/cal-client.c
+++ b/calendar/cal-client/cal-client.c
@@ -50,6 +50,11 @@ struct _CalClientPrivate {
/* The calendar client interface object we are contacting */
GNOME_Evolution_Calendar_Cal cal;
+
+ /* An array of CalTimezone structs containing information on builtin
+ timezones. We cache this so we only request it once from the
+ server. */
+ GArray *timezone_info;
};
@@ -66,6 +71,8 @@ static void cal_client_class_init (CalClientClass *class);
static void cal_client_init (CalClient *client);
static void cal_client_destroy (GtkObject *object);
+static void cal_client_free_builtin_timezone_info (GArray *zones);
+
static guint cal_client_signals[LAST_SIGNAL];
static GtkObjectClass *parent_class;
@@ -155,6 +162,7 @@ cal_client_init (CalClient *client)
priv->load_state = CAL_CLIENT_LOAD_NOT_LOADED;
priv->uri = NULL;
priv->factory = CORBA_OBJECT_NIL;
+ priv->timezone_info = NULL;
}
/* Gets rid of the factory that a client knows about */
@@ -269,6 +277,11 @@ cal_client_destroy (GtkObject *object)
priv->uri = NULL;
}
+ if (priv->timezone_info) {
+ cal_client_free_builtin_timezone_info (priv->timezone_info);
+ priv->timezone_info = NULL;
+ }
+
g_free (priv);
client->priv = NULL;
@@ -1506,6 +1519,95 @@ cal_client_remove_object (CalClient *client, const char *uid)
return retval;
}
+/* Builds a list of CalComponentAlarms structures */
+static GArray *
+build_timezone_info_array (GNOME_Evolution_Calendar_CalTimezoneInfoSeq *seq)
+{
+ GArray *zones;
+ CalTimezoneInfo zone;
+ int i;
+
+ zones = g_array_new (FALSE, FALSE, sizeof (CalTimezoneInfo));
+
+ for (i = 0; i < seq->_length; i++) {
+ GNOME_Evolution_Calendar_CalTimezoneInfo *tzinfo;
+
+ tzinfo = seq->_buffer + i;
+
+ zone.location = g_strdup (tzinfo->location);
+ zone.latitude = tzinfo->latitude;
+ zone.longitude = tzinfo->longitude;
+
+ g_array_append_val (zones, zone);
+ }
+
+ return zones;
+}
+
+/**
+ * cal_client_get_builtin_timezone_info:
+ * @client: A calendar client.
+ *
+ * Returns information on the builtin timezones, i.e. their names and
+ * locations. This is so we can use the map to select a timezone.
+ *
+ * Return value: An array of #CalTimezoneInfo structures. The caller should not
+ * change or free this array. The CalClient will free it when it is destroyed.
+ **/
+GArray *
+cal_client_get_builtin_timezone_info (CalClient *client)
+{
+ CalClientPrivate *priv;
+ CORBA_Environment ev;
+ GNOME_Evolution_Calendar_CalTimezoneInfoSeq *seq;
+
+ g_return_val_if_fail (client != NULL, NULL);
+ g_return_val_if_fail (IS_CAL_CLIENT (client), NULL);
+
+ priv = client->priv;
+
+ /* If we have already got this data from the server just return it. */
+ if (priv->timezone_info)
+ return priv->timezone_info;
+
+ CORBA_exception_init (&ev);
+
+ seq = GNOME_Evolution_Calendar_Cal_getBuiltinTimezoneInfo (priv->cal,
+ &ev);
+ if (ev._major != CORBA_NO_EXCEPTION) {
+ g_message ("cal_client_get_builtin_timezone_info(): could not get the builtin timezone info");
+ CORBA_exception_free (&ev);
+ return NULL;
+ }
+ CORBA_exception_free (&ev);
+
+ priv->timezone_info = build_timezone_info_array (seq);
+ CORBA_free (seq);
+
+ return priv->timezone_info;
+}
+
+/**
+ * cal_client_free_builtin_timezone_info:
+ * @zones: An array of timezone info returned from
+ * cal_client_get_builtin_timezone_info().
+ *
+ * Frees the builtin timezone information structures.
+ **/
+static void
+cal_client_free_builtin_timezone_info (GArray *zones)
+{
+ CalTimezoneInfo *zone;
+ int i;
+
+ for (i = 0; i < zones->len; i++) {
+ zone = &g_array_index (zones, CalTimezoneInfo, i);
+ g_free (zone->location);
+ }
+
+ g_array_free (zones, TRUE);
+}
+
/**
* cal_client_get_query:
* @client: A calendar client.