diff options
author | Milan Crha <mcrha@redhat.com> | 2009-01-12 22:49:16 +0800 |
---|---|---|
committer | Milan Crha <mcrha@src.gnome.org> | 2009-01-12 22:49:16 +0800 |
commit | 1df00c7d517794881faefd45b3ae230a6b0d8204 (patch) | |
tree | d0467011443c4a929e682edddee997a202e6a6d9 /calendar/gui/dialogs/cal-prefs-dialog.c | |
parent | 83cfa8202cec8ed81e4e836b2a09787941dc4c4d (diff) | |
download | gsoc2013-evolution-1df00c7d517794881faefd45b3ae230a6b0d8204.tar.gz gsoc2013-evolution-1df00c7d517794881faefd45b3ae230a6b0d8204.tar.zst gsoc2013-evolution-1df00c7d517794881faefd45b3ae230a6b0d8204.zip |
** Fix for bug #563364
2009-01-12 Milan Crha <mcrha@redhat.com>
** Fix for bug #563364
* gui/e-day-view-time-item.h: (EDayViewTimeItem):
* gui/e-day-view-time-item.c: (e_day_view_time_item_class_init),
(e_day_view_time_item_init), (e_day_view_time_item_finalize),
(e_day_view_time_item_get_column_width), (edvti_draw_zone),
(e_day_view_time_item_draw), (edvti_second_zone_changed_cb),
(edvti_on_select_zone), (edvti_on_set_zone),
(e_day_view_time_item_show_popup_menu):
Show two timezones in the day view's time column.
* gui/apps_evolution_calendar.schemas.in:
* gui/calendar-config-keys.h:
* gui/calendar-config.h:
* gui/calendar-config.c: (calendar_config_get_day_second_zones),
(calendar_config_free_day_second_zones),
(calendar_config_set_day_second_zone),
(calendar_config_get_day_second_zone),
(calendar_config_select_day_second_zone),
(calendar_config_add_notification_day_second_zone):
Access configuration for the second day time zone.
* gui/dialogs/cal-prefs-dialog.glade:
* gui/dialogs/cal-prefs-dialog.h: (struct _CalendarPrefsDialog):
* gui/dialogs/cal-prefs-dialog.c: (update_day_second_zone_caption),
(on_set_day_second_zone), (on_select_day_second_zone),
(day_second_zone_clicked), (setup_changes), (show_config),
(calendar_prefs_dialog_construct):
Manage the second day zone in a Preferences dialog.
svn path=/trunk/; revision=37060
Diffstat (limited to 'calendar/gui/dialogs/cal-prefs-dialog.c')
-rw-r--r-- | calendar/gui/dialogs/cal-prefs-dialog.c | 100 |
1 files changed, 100 insertions, 0 deletions
diff --git a/calendar/gui/dialogs/cal-prefs-dialog.c b/calendar/gui/dialogs/cal-prefs-dialog.c index 8ba51259e5..38871c2f89 100644 --- a/calendar/gui/dialogs/cal-prefs-dialog.c +++ b/calendar/gui/dialogs/cal-prefs-dialog.c @@ -132,6 +132,101 @@ timezone_changed (GtkWidget *widget, CalendarPrefsDialog *prefs) } static void +update_day_second_zone_caption (CalendarPrefsDialog *prefs) +{ + char *location; + const char *caption; + icaltimezone *zone; + + g_return_if_fail (prefs != NULL); + + caption = _("None"); + + location = calendar_config_get_day_second_zone (); + if (location && *location) { + zone = icaltimezone_get_builtin_timezone (location); + if (zone && icaltimezone_get_display_name (zone)) { + caption = icaltimezone_get_display_name (zone); + } + } + g_free (location); + + gtk_button_set_label (GTK_BUTTON (prefs->day_second_zone), caption); +} + +static void +on_set_day_second_zone (GtkWidget *item, CalendarPrefsDialog *prefs) +{ + if (!gtk_check_menu_item_get_active (GTK_CHECK_MENU_ITEM (item))) + return; + + calendar_config_set_day_second_zone (g_object_get_data (G_OBJECT (item), "timezone")); + update_day_second_zone_caption (prefs); +} + +static void +on_select_day_second_zone (GtkWidget *item, CalendarPrefsDialog *prefs) +{ + g_return_if_fail (prefs != NULL); + + calendar_config_select_day_second_zone (); + update_day_second_zone_caption (prefs); +} + +static void +day_second_zone_clicked (GtkWidget *widget, CalendarPrefsDialog *prefs) +{ + GtkWidget *menu, *item; + GSList *group = NULL, *recent_zones, *s; + char *location; + icaltimezone *zone, *second_zone = NULL; + + menu = gtk_menu_new (); + + location = calendar_config_get_day_second_zone (); + if (location && *location) + second_zone = icaltimezone_get_builtin_timezone (location); + g_free (location); + + group = NULL; + item = gtk_radio_menu_item_new_with_label (group, _("None")); + group = gtk_radio_menu_item_get_group (GTK_RADIO_MENU_ITEM (item)); + if (!second_zone) + gtk_check_menu_item_set_active (GTK_CHECK_MENU_ITEM (item), TRUE); + gtk_menu_shell_append (GTK_MENU_SHELL (menu), item); + g_signal_connect (item, "toggled", G_CALLBACK (on_set_day_second_zone), prefs); + + recent_zones = calendar_config_get_day_second_zones (); + for (s = recent_zones; s != NULL; s = s->next) { + zone = icaltimezone_get_builtin_timezone (s->data); + if (!zone) + continue; + + item = gtk_radio_menu_item_new_with_label (group, icaltimezone_get_display_name (zone)); + group = gtk_radio_menu_item_get_group (GTK_RADIO_MENU_ITEM (item)); + /* both comes from builtin, thus no problem to compare pointers */ + if (zone == second_zone) + gtk_check_menu_item_set_active (GTK_CHECK_MENU_ITEM (item), TRUE); + gtk_menu_shell_append (GTK_MENU_SHELL (menu), item); + g_object_set_data_full (G_OBJECT (item), "timezone", g_strdup (s->data), g_free); + g_signal_connect (item, "toggled", G_CALLBACK (on_set_day_second_zone), prefs); + } + calendar_config_free_day_second_zones (recent_zones); + + item = gtk_separator_menu_item_new (); + gtk_menu_shell_append (GTK_MENU_SHELL (menu), item); + + item = gtk_menu_item_new_with_label (_("Select...")); + g_signal_connect (item, "activate", G_CALLBACK (on_select_day_second_zone), prefs); + gtk_menu_shell_append (GTK_MENU_SHELL (menu), item); + + gtk_widget_show_all (menu); + + gtk_menu_popup (GTK_MENU (menu), NULL, NULL, NULL, NULL, + 0, gtk_get_current_event_time ()); +} + +static void daylight_saving_changed (GtkWidget *widget, CalendarPrefsDialog *prefs) { gboolean set = gtk_toggle_button_get_active ((GtkToggleButton *) prefs->daylight_saving); @@ -373,6 +468,7 @@ setup_changes (CalendarPrefsDialog *prefs) g_signal_connect (G_OBJECT (prefs->working_days[i]), "toggled", G_CALLBACK (working_days_changed), prefs); g_signal_connect (G_OBJECT (prefs->timezone), "changed", G_CALLBACK (timezone_changed), prefs); + g_signal_connect (G_OBJECT (prefs->day_second_zone), "clicked", G_CALLBACK (day_second_zone_clicked), prefs); g_signal_connect (G_OBJECT (prefs->daylight_saving), "toggled", G_CALLBACK (daylight_saving_changed), prefs); g_signal_connect (G_OBJECT (prefs->start_of_day), "changed", G_CALLBACK (start_of_day_changed), prefs); @@ -513,6 +609,9 @@ show_config (CalendarPrefsDialog *prefs) set = calendar_config_get_daylight_saving (); gtk_toggle_button_set_active ((GtkToggleButton *) prefs->daylight_saving, set); + /* Day's second zone */ + update_day_second_zone_caption (prefs); + /* Working Days. */ working_days = calendar_config_get_working_days (); mask = 1 << 0; @@ -637,6 +736,7 @@ calendar_prefs_dialog_construct (CalendarPrefsDialog *prefs) /* General tab */ prefs->timezone = glade_xml_get_widget (gui, "timezone"); + prefs->day_second_zone = glade_xml_get_widget (gui, "day_second_zone"); prefs->daylight_saving = glade_xml_get_widget (gui, "daylight_cb"); for (i = 0; i < 7; i++) prefs->working_days[i] = glade_xml_get_widget (gui, working_day_names[i]); |