aboutsummaryrefslogtreecommitdiffstats
path: root/calendar/gui/e-timezone-entry.c
diff options
context:
space:
mode:
authorDamon Chaplin <damon@ximian.com>2001-07-03 12:21:37 +0800
committerDamon Chaplin <damon@src.gnome.org>2001-07-03 12:21:37 +0800
commit642d32d63f226cd1ba049a9d979132e1a1cef94d (patch)
treebe4ef8fb72ca41391007554a6cbe97af41533555 /calendar/gui/e-timezone-entry.c
parentbacd3a85a434032316b3e63b95282175ce2b0659 (diff)
downloadgsoc2013-evolution-642d32d63f226cd1ba049a9d979132e1a1cef94d.tar
gsoc2013-evolution-642d32d63f226cd1ba049a9d979132e1a1cef94d.tar.gz
gsoc2013-evolution-642d32d63f226cd1ba049a9d979132e1a1cef94d.tar.bz2
gsoc2013-evolution-642d32d63f226cd1ba049a9d979132e1a1cef94d.tar.lz
gsoc2013-evolution-642d32d63f226cd1ba049a9d979132e1a1cef94d.tar.xz
gsoc2013-evolution-642d32d63f226cd1ba049a9d979132e1a1cef94d.tar.zst
gsoc2013-evolution-642d32d63f226cd1ba049a9d979132e1a1cef94d.zip
cal-client/cal-client.[hc] cal-util/cal-component.c
2001-07-03 Damon Chaplin <damon@ximian.com> * cal-client/cal-client.[hc] * cal-util/cal-component.c * cal-util/cal-recur.[hc] * cal-util/test-recur.c * cal-util/timeutil.c * gui/calendar-config.c * gui/calendar-model.[hc] * gui/comp-util.[hc] * gui/e-calendar-table.c * gui/e-day-view-main-item.c * gui/e-day-view-top-item.c * gui/e-day-view.[hc] * gui/e-itip-control.c * gui/e-timezone-entry.[hc] * gui/e-week-view.[hc] * gui/gnome-cal.[hc] * gui/goto.c * gui/tag-calendar.[hc] * gui/dialogs/cal-prefs-dialog.c * gui/dialogs/comp-editor-page.[hc] * gui/dialogs/comp-editor-util.[hc] * gui/dialogs/comp-editor.c * gui/dialogs/e-timezone-dialog.[hc] * gui/dialogs/event-page.c * gui/dialogs/meeting-page.c * gui/dialogs/recurrence-page.c * gui/dialogs/task-details-page.c * gui/dialogs/task-details-page.glade * gui/dialogs/task-page.c * idl/evolution-calendar.idl * pcs/cal-backend-file.c * pcs/cal-backend.c * pcs/cal-backend.h * pcs/cal.c * pcs/query.c: timezone changes everywhere. There's still quite a few things to update, and its not working well at present. svn path=/trunk/; revision=10729
Diffstat (limited to 'calendar/gui/e-timezone-entry.c')
-rw-r--r--calendar/gui/e-timezone-entry.c90
1 files changed, 81 insertions, 9 deletions
diff --git a/calendar/gui/e-timezone-entry.c b/calendar/gui/e-timezone-entry.c
index ff54a92da4..e7e64f0934 100644
--- a/calendar/gui/e-timezone-entry.c
+++ b/calendar/gui/e-timezone-entry.c
@@ -40,6 +40,17 @@
struct _ETimezoneEntryPrivate {
+ /* This is the timezone set in e_timezone_entry_set_timezone().
+ Note that we don't copy it or use a ref count - we assume it is
+ never destroyed for the lifetime of this widget. */
+ icaltimezone *zone;
+
+ /* This is TRUE if the timezone has been changed since being set.
+ If it hasn't, we can just return zone, If it has, we return the
+ builtin timezone with tzid. (It can only be changed to a builtin
+ timezone, or to 'local time', i.e. no timezone.) */
+ gboolean changed;
+
GtkWidget *entry;
GtkWidget *button;
};
@@ -60,6 +71,8 @@ static void on_entry_changed (GtkEntry *entry,
static void on_button_clicked (GtkWidget *widget,
ETimezoneEntry *tentry);
+static char* e_timezone_entry_get_display_name (icaltimezone *zone);
+
static GtkHBoxClass *parent_class;
static guint timezone_entry_signals[LAST_SIGNAL] = { 0 };
@@ -127,6 +140,9 @@ e_timezone_entry_init (ETimezoneEntry *tentry)
tentry->priv = priv = g_new0 (ETimezoneEntryPrivate, 1);
+ priv->zone = NULL;
+ priv->changed = FALSE;
+
priv->entry = gtk_entry_new ();
gtk_entry_set_editable (GTK_ENTRY (priv->entry), FALSE);
/*gtk_widget_set_usize (priv->date_entry, 90, 0);*/
@@ -190,19 +206,33 @@ on_button_clicked (GtkWidget *widget,
ETimezoneEntryPrivate *priv;
ETimezoneDialog *timezone_dialog;
GtkWidget *dialog;
- char *zone;
+ char *tzid = NULL, *display_name, *old_display_name;
priv = tentry->priv;
+ display_name = gtk_entry_get_text (GTK_ENTRY (priv->entry));
+
+ if (priv->zone)
+ tzid = icaltimezone_get_tzid (priv->zone);
+
timezone_dialog = e_timezone_dialog_new ();
- zone = e_timezone_entry_get_timezone (tentry);
- e_timezone_dialog_set_timezone (timezone_dialog, zone);
+ e_timezone_dialog_set_timezone (timezone_dialog, tzid, display_name);
dialog = e_timezone_dialog_get_toplevel (timezone_dialog);
if (gnome_dialog_run_and_close (GNOME_DIALOG (dialog)) == 0) {
- zone = e_timezone_dialog_get_timezone (E_TIMEZONE_DIALOG (timezone_dialog));
- e_timezone_entry_set_timezone (tentry, zone);
+ tzid = e_timezone_dialog_get_timezone (E_TIMEZONE_DIALOG (timezone_dialog), &display_name);
+ old_display_name = gtk_entry_get_text (GTK_ENTRY (priv->entry));
+ /* See if the timezone has been changed. It can only have been
+ changed to a builtin timezone, in which case the returned
+ TZID will be NULL. */
+ if (strcmp (old_display_name, display_name)
+ || (!tzid && priv->zone)) {
+ priv->changed = TRUE;
+ priv->zone = NULL;
+ }
+
+ gtk_entry_set_text (GTK_ENTRY (priv->entry), display_name);
}
gtk_object_unref (GTK_OBJECT (timezone_dialog));
@@ -217,20 +247,62 @@ on_entry_changed (GtkEntry *entry,
}
-char*
+icaltimezone*
e_timezone_entry_get_timezone (ETimezoneEntry *tentry)
{
+ ETimezoneEntryPrivate *priv;
+ char *display_name;
+
g_return_val_if_fail (E_IS_TIMEZONE_ENTRY (tentry), NULL);
- return gtk_entry_get_text (GTK_ENTRY (tentry->priv->entry));
+ priv = tentry->priv;
+
+ /* If the timezone hasn't been change, we can just return the same
+ zone we were passed in. */
+ if (!priv->changed)
+ return priv->zone;
+
+ /* If the timezone has changed, it can only have been changed to a
+ builtin timezone or 'local time' (i.e. no timezone). */
+ display_name = gtk_entry_get_text (GTK_ENTRY (priv->entry));
+
+ if (display_name && display_name[0])
+ return icaltimezone_get_builtin_timezone (display_name);
+ return NULL;
}
void
e_timezone_entry_set_timezone (ETimezoneEntry *tentry,
- char *timezone)
+ icaltimezone *zone)
{
+ ETimezoneEntryPrivate *priv;
+
g_return_if_fail (E_IS_TIMEZONE_ENTRY (tentry));
- gtk_entry_set_text (GTK_ENTRY (tentry->priv->entry), timezone);
+ priv = tentry->priv;
+
+ priv->zone = zone;
+ priv->changed = FALSE;
+
+ gtk_entry_set_text (GTK_ENTRY (priv->entry),
+ e_timezone_entry_get_display_name (zone));
+}
+
+
+/* Returns the timezone name to display to the user. . We prefer to use the
+ Olson city name, but fall back on the TZNAME, or finally the TZID. We don't
+ want to use "" as it may be wrongly interpreted as a 'local time'. */
+static char*
+e_timezone_entry_get_display_name (icaltimezone *zone)
+{
+ char *display_name;
+
+ display_name = icaltimezone_get_location (zone);
+ if (!display_name)
+ display_name = icaltimezone_get_tznames (zone);
+ if (!display_name)
+ display_name = icaltimezone_get_tzid (zone);
+
+ return display_name;
}