diff options
author | Damon Chaplin <damon@ximian.com> | 2001-06-19 13:23:16 +0800 |
---|---|---|
committer | Damon Chaplin <damon@src.gnome.org> | 2001-06-19 13:23:16 +0800 |
commit | 84dc93b8de0c5944982f66559bfc1cc74edb19db (patch) | |
tree | 92a9e795070ea5eec32eed0bae87020c98f85245 /calendar/gui/dialogs/e-timezone-dialog.c | |
parent | 15d3afd9d6efcc62264d8de14f2272b41c1f6891 (diff) | |
download | gsoc2013-evolution-84dc93b8de0c5944982f66559bfc1cc74edb19db.tar gsoc2013-evolution-84dc93b8de0c5944982f66559bfc1cc74edb19db.tar.gz gsoc2013-evolution-84dc93b8de0c5944982f66559bfc1cc74edb19db.tar.bz2 gsoc2013-evolution-84dc93b8de0c5944982f66559bfc1cc74edb19db.tar.lz gsoc2013-evolution-84dc93b8de0c5944982f66559bfc1cc74edb19db.tar.xz gsoc2013-evolution-84dc93b8de0c5944982f66559bfc1cc74edb19db.tar.zst gsoc2013-evolution-84dc93b8de0c5944982f66559bfc1cc74edb19db.zip |
added timezone fields. Also moved the 'All Day' flag into an alignment so
2001-06-19 Damon Chaplin <damon@ximian.com>
* gui/dialogs/task-details-page.glade:
* gui/dialogs/task-page.glade:
* gui/dialogs/event-page.glade: added timezone fields. Also moved the
'All Day' flag into an alignment so it doesn't mess up the height of
the other widgets.
* gui/dialogs/task-details-page.c:
* gui/dialogs/task-page.c:
* gui/dialogs/event-page.c: added code to handle the timezone fields.
This still needs to be hooked up when the libical code is finished.
* gui/dialogs/e-timezone-dialog.c (on_map_leave): new function to
clear the preview label and turn off the highlighted point on the
map when you move the mouse outside it.
(find_selected_point): new function to try to find the point
corresponding to the text in the combo.
(on_combo_changed): call the above function to update the selected
point.
(on_map_leave): turn off the preview point & label when the mouse
leaves the map.
(e_timezone_dialog_set_cal_client): changed it so that selecting "None"
clears the entry.
* gui/dialogs/comp-editor-page.[hc]: added set_cal_client() virtual
method since some pages need to access the CalClient to get timezone
information. Also added comp_editor_page_set_cal_client() to call
the virtual method.
* gui/dialogs/comp-editor.c (comp_editor_set_cal_client): called
comp_editor_page_set_cal_client() on each page.
* gui/calendar-config.c: added functions to get & set the timezone.
svn path=/trunk/; revision=10285
Diffstat (limited to 'calendar/gui/dialogs/e-timezone-dialog.c')
-rw-r--r-- | calendar/gui/dialogs/e-timezone-dialog.c | 118 |
1 files changed, 106 insertions, 12 deletions
diff --git a/calendar/gui/dialogs/e-timezone-dialog.c b/calendar/gui/dialogs/e-timezone-dialog.c index 7e9fce6cb8..d515ede197 100644 --- a/calendar/gui/dialogs/e-timezone-dialog.c +++ b/calendar/gui/dialogs/e-timezone-dialog.c @@ -69,6 +69,9 @@ static gboolean on_map_timeout (gpointer data); static gboolean on_map_motion (GtkWidget *widget, GdkEventMotion *event, gpointer data); +static gboolean on_map_leave (GtkWidget *widget, + GdkEventCrossing *event, + gpointer data); static gboolean on_map_visibility_changed (GtkWidget *w, GdkEventVisibility *event, gpointer data); @@ -78,6 +81,10 @@ static gboolean on_map_button_pressed (GtkWidget *w, static char* get_zone_from_point (ETimezoneDialog *etd, EMapPoint *point); +static void find_selected_point (ETimezoneDialog *etd); +static void on_combo_changed (GtkEditable *entry, + ETimezoneDialog *etd); + static GtkObjectClass *parent_class; @@ -198,6 +205,7 @@ e_timezone_dialog_construct (ETimezoneDialog *etd) map = GTK_WIDGET (e_map_new ()); priv->map = E_MAP (map); gtk_widget_set_events (map, gtk_widget_get_events (map) + | GDK_LEAVE_NOTIFY_MASK | GDK_VISIBILITY_NOTIFY_MASK); gtk_entry_set_editable (GTK_ENTRY (GTK_COMBO (priv->timezone_combo)->entry), FALSE); @@ -207,11 +215,16 @@ e_timezone_dialog_construct (ETimezoneDialog *etd) gtk_signal_connect (GTK_OBJECT (map), "motion-notify-event", GTK_SIGNAL_FUNC (on_map_motion), etd); + gtk_signal_connect (GTK_OBJECT (map), "leave-notify-event", + GTK_SIGNAL_FUNC (on_map_leave), etd); gtk_signal_connect (GTK_OBJECT (map), "visibility-notify-event", GTK_SIGNAL_FUNC (on_map_visibility_changed), etd); gtk_signal_connect (GTK_OBJECT (map), "button-press-event", GTK_SIGNAL_FUNC (on_map_button_pressed), etd); + gtk_signal_connect (GTK_OBJECT (GTK_COMBO (priv->timezone_combo)->entry), "changed", + GTK_SIGNAL_FUNC (on_combo_changed), etd); + return etd; error: @@ -325,6 +338,31 @@ on_map_motion (GtkWidget *widget, GdkEventMotion *event, gpointer data) static gboolean +on_map_leave (GtkWidget *widget, GdkEventCrossing *event, gpointer data) +{ + ETimezoneDialog *etd; + ETimezoneDialogPrivate *priv; + char *old_zone; + + etd = E_TIMEZONE_DIALOG (data); + priv = etd->priv; + + if (priv->point_hover && priv->point_hover != priv->point_selected) + e_map_point_set_color_rgba (priv->map, priv->point_hover, + E_TIMEZONE_DIALOG_MAP_POINT_NORMAL_RGBA); + + priv->point_hover = NULL; + + /* Clear the timezone preview label, if it isn't already empty. */ + gtk_label_get (GTK_LABEL (priv->timezone_preview), &old_zone); + if (strcmp (old_zone, "")) + gtk_label_set_text (GTK_LABEL (priv->timezone_preview), ""); + + return FALSE; +} + + +static gboolean on_map_visibility_changed (GtkWidget *w, GdkEventVisibility *event, gpointer data) { @@ -433,7 +471,8 @@ e_timezone_dialog_set_cal_client (ETimezoneDialog *etd, { ETimezoneDialogPrivate *priv; CalTimezoneInfo *zone; - GList *tzlist = NULL; + GtkWidget *listitem; + GtkCombo *combo; char *current_zone; int i; @@ -443,6 +482,11 @@ e_timezone_dialog_set_cal_client (ETimezoneDialog *etd, priv = etd->priv; + combo = GTK_COMBO (priv->timezone_combo); + + /* Clear any existing items */ + gtk_list_clear_items (GTK_LIST (combo->list), 0, -1); + priv->zones = cal_client_get_builtin_timezone_info (client); if (!priv->zones) { @@ -450,9 +494,17 @@ e_timezone_dialog_set_cal_client (ETimezoneDialog *etd, return; } - /* Put the "None" and "UTC" entries at the top of the combo's list. */ - tzlist = g_list_prepend (tzlist, _("None")); - tzlist = g_list_prepend (tzlist, _("UTC")); + /* Put the "None" and "UTC" entries at the top of the combo's list. + When "None" is selected we want the field to be cleared. */ + listitem = gtk_list_item_new_with_label (_("None")); + gtk_widget_show (listitem); + gtk_container_add (GTK_CONTAINER (combo->list), listitem); + gtk_combo_set_item_string (combo, GTK_ITEM (listitem), ""); + + /* Note: We don't translate timezone names at the moment. */ + listitem = gtk_list_item_new_with_label ("UTC"); + gtk_widget_show (listitem); + gtk_container_add (GTK_CONTAINER (combo->list), listitem); current_zone = gtk_entry_get_text (GTK_ENTRY (GTK_COMBO (priv->timezone_combo)->entry)); @@ -469,14 +521,11 @@ e_timezone_dialog_set_cal_client (ETimezoneDialog *etd, zone->longitude, zone->latitude, E_TIMEZONE_DIALOG_MAP_POINT_NORMAL_RGBA); } - tzlist = g_list_prepend (tzlist, zone->location); - } - - tzlist = g_list_reverse (tzlist); - gtk_combo_set_popdown_strings (GTK_COMBO (priv->timezone_combo), - tzlist); - g_list_free (tzlist); + listitem = gtk_list_item_new_with_label (zone->location); + gtk_widget_show (listitem); + gtk_container_add (GTK_CONTAINER (combo->list), listitem); + } } @@ -506,8 +555,9 @@ e_timezone_dialog_set_timezone (ETimezoneDialog *etd, priv = etd->priv; gtk_entry_set_text (GTK_ENTRY (GTK_COMBO (priv->timezone_combo)->entry), - get_zone_from_point (etd, priv->point_selected)); + timezone); + find_selected_point (etd); } @@ -524,3 +574,47 @@ e_timezone_dialog_get_toplevel (ETimezoneDialog *etd) return priv->app; } + +/* This tries to find the timezone corresponding to the text in the combo, + and selects the point so that it flashes. */ +static void +find_selected_point (ETimezoneDialog *etd) +{ + ETimezoneDialogPrivate *priv; + CalTimezoneInfo *zone; + char *current_zone; + EMapPoint *point = NULL; + int i; + + priv = etd->priv; + + if (priv->zones == NULL) + return; + + current_zone = gtk_entry_get_text (GTK_ENTRY (GTK_COMBO (priv->timezone_combo)->entry)); + + for (i = 0; i < priv->zones->len; i++) { + zone = &g_array_index (priv->zones, CalTimezoneInfo, i); + if (!strcmp (current_zone, zone->location)) { + point = e_map_get_closest_point (priv->map, + zone->longitude, + zone->latitude, + FALSE); + + break; + } + } + + if (priv->point_selected) + e_map_point_set_color_rgba (priv->map, priv->point_selected, + E_TIMEZONE_DIALOG_MAP_POINT_NORMAL_RGBA); + + priv->point_selected = point; +} + + +static void +on_combo_changed (GtkEditable *entry, ETimezoneDialog *etd) +{ + find_selected_point (etd); +} |