aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDan Winship <danw@src.gnome.org>2003-03-12 06:23:44 +0800
committerDan Winship <danw@src.gnome.org>2003-03-12 06:23:44 +0800
commitb0984bd0af9be0e2d53ee5e1b091cee509b70517 (patch)
tree026ecda8ce8b085bf838c9bb834ab6e2c191a4e8
parentbbde1e136a8f576dfc9b0246b4744929786444da (diff)
downloadgsoc2013-evolution-b0984bd0af9be0e2d53ee5e1b091cee509b70517.tar
gsoc2013-evolution-b0984bd0af9be0e2d53ee5e1b091cee509b70517.tar.gz
gsoc2013-evolution-b0984bd0af9be0e2d53ee5e1b091cee509b70517.tar.bz2
gsoc2013-evolution-b0984bd0af9be0e2d53ee5e1b091cee509b70517.tar.lz
gsoc2013-evolution-b0984bd0af9be0e2d53ee5e1b091cee509b70517.tar.xz
gsoc2013-evolution-b0984bd0af9be0e2d53ee5e1b091cee509b70517.tar.zst
gsoc2013-evolution-b0984bd0af9be0e2d53ee5e1b091cee509b70517.zip
Update for timezone dialog API changes.
* gui/calendar-config.c (on_timezone_set): Update for timezone dialog API changes. * gui/e-timezone-entry.c: Likewise svn path=/trunk/; revision=20256
-rw-r--r--calendar/ChangeLog7
-rw-r--r--calendar/gui/calendar-config.c7
-rw-r--r--calendar/gui/e-timezone-entry.c126
3 files changed, 38 insertions, 102 deletions
diff --git a/calendar/ChangeLog b/calendar/ChangeLog
index ee5997cfef..3cc2ecfa80 100644
--- a/calendar/ChangeLog
+++ b/calendar/ChangeLog
@@ -1,3 +1,10 @@
+2003-03-11 Dan Winship <danw@ximian.com>
+
+ * gui/calendar-config.c (on_timezone_set): Update for timezone
+ dialog API changes.
+
+ * gui/e-timezone-entry.c: Likewise
+
2003-03-11 Rodrigo Moya <rodrigo@ximian.com>
* gui/gnome-cal.c (gnome_calendar_open): issue more descriptive
diff --git a/calendar/gui/calendar-config.c b/calendar/gui/calendar-config.c
index b42b70b69c..fd5dd0f3a3 100644
--- a/calendar/gui/calendar-config.c
+++ b/calendar/gui/calendar-config.c
@@ -676,14 +676,9 @@ on_timezone_set (GnomeDialog *dialog,
int button,
ETimezoneDialog *etd)
{
- const char *display_name;
icaltimezone *zone;
- e_timezone_dialog_get_timezone (etd, &display_name);
-
- /* We know it can only be a builtin timezone, since there is no way
- to set it to anything else. */
- zone = e_timezone_dialog_get_builtin_timezone (display_name);
+ zone = e_timezone_dialog_get_timezone (etd);
if (zone) {
calendar_config_set_timezone (icaltimezone_get_location (zone));
diff --git a/calendar/gui/e-timezone-entry.c b/calendar/gui/e-timezone-entry.c
index 89116212f6..e439fe2273 100644
--- a/calendar/gui/e-timezone-entry.c
+++ b/calendar/gui/e-timezone-entry.c
@@ -43,24 +43,19 @@
#include "art/timezone-16.xpm"
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. */
+ /* The current timezone, set in e_timezone_entry_set_timezone()
+ or from the timezone dialog. 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;
/* This can be set to the default timezone. If the current timezone
setting in the ETimezoneEntry matches this, then the entry field
is hidden. This makes the user interface simpler. */
icaltimezone *default_zone;
+
+ GtkWidget *entry;
+ GtkWidget *button;
};
@@ -79,10 +74,7 @@ static void on_entry_changed (GtkEntry *entry,
static void on_button_clicked (GtkWidget *widget,
ETimezoneEntry *tentry);
-static char* e_timezone_entry_get_display_name (ETimezoneEntry *tentry,
- icaltimezone *zone);
-
-static void e_timezone_entry_set_entry_visibility (ETimezoneEntry *tentry);
+static void e_timezone_entry_set_entry (ETimezoneEntry *tentry);
static GtkHBoxClass *parent_class;
@@ -128,7 +120,6 @@ e_timezone_entry_init (ETimezoneEntry *tentry)
tentry->priv = priv = g_new0 (ETimezoneEntryPrivate, 1);
priv->zone = NULL;
- priv->changed = FALSE;
priv->default_zone = NULL;
priv->entry = gtk_entry_new ();
@@ -199,37 +190,18 @@ on_button_clicked (GtkWidget *widget,
ETimezoneEntryPrivate *priv;
ETimezoneDialog *timezone_dialog;
GtkWidget *dialog;
- char *tzid = NULL;
- const gchar *old_display_name;
- const gchar *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 ();
- /* e_timezone_dialog_set_timezone() should really take (const gchar *) */
- e_timezone_dialog_set_timezone (timezone_dialog, tzid, (gchar *) display_name);
+ e_timezone_dialog_set_timezone (timezone_dialog, priv->zone);
dialog = e_timezone_dialog_get_toplevel (timezone_dialog);
if (gtk_dialog_run (GTK_DIALOG (dialog)) == GTK_RESPONSE_ACCEPT) {
- 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);
- e_timezone_entry_set_entry_visibility (tentry);
+ priv->zone = e_timezone_dialog_get_timezone (timezone_dialog);
+ e_timezone_entry_set_entry (tentry);
}
g_object_unref (timezone_dialog);
@@ -248,22 +220,12 @@ icaltimezone*
e_timezone_entry_get_timezone (ETimezoneEntry *tentry)
{
ETimezoneEntryPrivate *priv;
- const char *display_name;
g_return_val_if_fail (E_IS_TIMEZONE_ENTRY (tentry), NULL);
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));
-
- return e_timezone_dialog_get_builtin_timezone (display_name);
+ return priv->zone;
}
@@ -272,49 +234,14 @@ e_timezone_entry_set_timezone (ETimezoneEntry *tentry,
icaltimezone *zone)
{
ETimezoneEntryPrivate *priv;
- gchar *display_name;
g_return_if_fail (E_IS_TIMEZONE_ENTRY (tentry));
priv = tentry->priv;
priv->zone = zone;
- priv->changed = FALSE;
-
- display_name = e_timezone_entry_get_display_name (tentry, zone);
- gtk_entry_set_text (GTK_ENTRY (priv->entry),
- display_name ? display_name : "");
- g_free (display_name);
- e_timezone_entry_set_entry_visibility (tentry);
-}
-
-
-/* Returns the timezone name to display to the user, in the locale's encoding.
- 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'. If zone is NULL, NULL is returned. The returned string
- should be freed. */
-static char*
-e_timezone_entry_get_display_name (ETimezoneEntry *tentry,
- icaltimezone *zone)
-{
- char *display_name;
-
- if (!zone)
- return NULL;
-
- /* Get the UTF-8 display name from the icaltimezone. */
- display_name = icaltimezone_get_display_name (zone);
-
- /* We check if it is one of our builtin timezone names, in which case
- we call gettext to translate it. If it isn't a builtin timezone
- name, we don't. */
- if (icaltimezone_get_builtin_timezone (display_name)) {
- return g_strdup (_(display_name));
- } else {
- return g_strdup (display_name);
- }
+ e_timezone_entry_set_entry (tentry);
}
@@ -333,26 +260,33 @@ e_timezone_entry_set_default_timezone (ETimezoneEntry *tentry,
priv->default_zone = zone;
- e_timezone_entry_set_entry_visibility (tentry);
+ e_timezone_entry_set_entry (tentry);
}
static void
-e_timezone_entry_set_entry_visibility (ETimezoneEntry *tentry)
+e_timezone_entry_set_entry (ETimezoneEntry *tentry)
{
ETimezoneEntryPrivate *priv;
- icaltimezone *zone;
- gboolean show_entry = TRUE;
+ const char *display_name;
priv = tentry->priv;
- if (priv->default_zone) {
- zone = e_timezone_entry_get_timezone (tentry);
- if (zone == priv->default_zone)
- show_entry = FALSE;
- }
+ if (priv->zone) {
+ display_name = icaltimezone_get_display_name (priv->zone);
+
+ /* We check if it is one of our builtin timezone
+ names, in which case we call gettext to translate
+ it. If it isn't a builtin timezone name, we
+ don't. */
+ if (icaltimezone_get_builtin_timezone (display_name))
+ display_name = _(display_name);
+ } else
+ display_name = "";
+
+ gtk_entry_set_text (GTK_ENTRY (priv->entry), display_name);
- if (show_entry)
+ if (!priv->default_zone || (priv->zone != priv->default_zone))
gtk_widget_show (priv->entry);
else
gtk_widget_hide (priv->entry);