From 2e3a3cf26e4d1894707703b15340529b8874466c Mon Sep 17 00:00:00 2001 From: Matthew Barnes Date: Thu, 15 Jan 2009 03:39:43 +0000 Subject: Merge revisions 37047:37074 from trunk. svn path=/branches/kill-bonobo/; revision=37075 --- calendar/gui/dialogs/cal-prefs-dialog.c | 100 +++++++++++++++ calendar/gui/dialogs/cal-prefs-dialog.glade | 188 ++++++++++++++++++++-------- calendar/gui/dialogs/cal-prefs-dialog.h | 1 + calendar/gui/dialogs/recurrence-page.c | 31 +++++ 4 files changed, 269 insertions(+), 51 deletions(-) (limited to 'calendar/gui/dialogs') 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 @@ -131,6 +131,101 @@ timezone_changed (GtkWidget *widget, CalendarPrefsDialog *prefs) calendar_config_set_timezone (icaltimezone_get_location (zone)); } +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) { @@ -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]); diff --git a/calendar/gui/dialogs/cal-prefs-dialog.glade b/calendar/gui/dialogs/cal-prefs-dialog.glade index d3003bdb6f..0282d17d4d 100644 --- a/calendar/gui/dialogs/cal-prefs-dialog.glade +++ b/calendar/gui/dialogs/cal-prefs-dialog.glade @@ -6,7 +6,7 @@ True - window1 + window1 GTK_WINDOW_TOPLEVEL GTK_WIN_POS_NONE False @@ -96,46 +96,37 @@ True - 3 + 4 2 False 6 6 - + True - Time _zone: - True - False - GTK_JUSTIFY_LEFT - False - False - 0 - 0.5 - 0 - 0 - timezone - PANGO_ELLIPSIZE_NONE - -1 - False - 0 + make_timezone_entry + 0 + 0 + Thu, 13 Jan 2005 04:18:03 GMT + + + - 0 - 1 + 1 + 2 0 1 - fill - + fill - + True - Time format: - False + Time _zone: + True False GTK_JUSTIFY_LEFT False @@ -144,6 +135,7 @@ 0.5 0 0 + timezone PANGO_ELLIPSIZE_NONE -1 False @@ -152,30 +144,32 @@ 0 1 - 2 - 3 + 0 + 1 fill - + True - make_timezone_entry - 0 - 0 - Thu, 13 Jan 2005 04:18:03 GMT - - - + True + Adjust for daylight sa_ving time + True + GTK_RELIEF_NORMAL + True + False + False + True 1 2 - 0 - 1 - fill + 1 + 2 + fill + @@ -235,24 +229,116 @@ - + True - True - Adjust for daylight sa_ving time + Time format: + False + False + GTK_JUSTIFY_LEFT + False + False + 0 + 0.5 + 0 + 0 + PANGO_ELLIPSIZE_NONE + -1 + False + 0 + + + 0 + 1 + 2 + 3 + fill + + + + + + + True + Se_cond zone: True - GTK_RELIEF_NORMAL - True - False - False - True + False + GTK_JUSTIFY_LEFT + False + False + 0 + 0.5 + 0 + 0 + day_second_zone + PANGO_ELLIPSIZE_NONE + -1 + False + 0 + + + 0 + 1 + 3 + 4 + fill + + + + + + + True + False + 0 + + + + True + True + None + True + GTK_RELIEF_NORMAL + True + + + 0 + True + True + + + + + + True + (Shown in a Day View) + False + False + GTK_JUSTIFY_LEFT + False + False + 0.5 + 0.5 + 6 + 0 + PANGO_ELLIPSIZE_NONE + -1 + False + 0 + + + 0 + False + False + + 1 2 - 1 - 2 + 3 + 4 fill - + fill @@ -348,7 +434,7 @@ 0.5 0 0 - week_start_day + week_start_day PANGO_ELLIPSIZE_NONE -1 False @@ -405,7 +491,7 @@ 0.5 0 0 - start_of_day + start_of_day PANGO_ELLIPSIZE_NONE -1 False diff --git a/calendar/gui/dialogs/cal-prefs-dialog.h b/calendar/gui/dialogs/cal-prefs-dialog.h index 49d4c56482..bb51d9d50d 100644 --- a/calendar/gui/dialogs/cal-prefs-dialog.h +++ b/calendar/gui/dialogs/cal-prefs-dialog.h @@ -43,6 +43,7 @@ struct _CalendarPrefsDialog { /* General tab */ GtkWidget *timezone; + GtkWidget *day_second_zone; GtkWidget *daylight_saving; GtkWidget *working_days[7]; GtkWidget *week_start_day; diff --git a/calendar/gui/dialogs/recurrence-page.c b/calendar/gui/dialogs/recurrence-page.c index 8a93c4dfee..15171d52ed 100644 --- a/calendar/gui/dialogs/recurrence-page.c +++ b/calendar/gui/dialogs/recurrence-page.c @@ -903,6 +903,37 @@ fill_component (RecurrencePage *rpage, ECalComponent *comp) e_cal_component_set_exdate_list (comp, list); e_cal_component_free_exdate_list (list); + if (GTK_WIDGET_VISIBLE (priv->ending_menu) && GTK_WIDGET_IS_SENSITIVE (priv->ending_menu) && + e_dialog_option_menu_get (priv->ending_menu, ending_types_map) == ENDING_UNTIL) { + /* check whether the "until" date is in the future */ + struct icaltimetype tt; + gboolean ok = TRUE; + + if (e_date_edit_get_date (E_DATE_EDIT (priv->ending_date_edit), &tt.year, &tt.month, &tt.day)) { + ECalComponentDateTime dtstart; + + /* the dtstart should be set already */ + e_cal_component_get_dtstart (comp, &dtstart); + + tt.is_date = 1; + tt.zone = NULL; + + if (dtstart.value && icaltime_is_valid_time (*dtstart.value)) { + ok = icaltime_compare_date_only (*dtstart.value, tt) <= 0; + + if (!ok) + e_date_edit_set_date (E_DATE_EDIT (priv->ending_date_edit), dtstart.value->year, dtstart.value->month, dtstart.value->day); + } + + e_cal_component_free_datetime (&dtstart); + } + + if (!ok) { + comp_editor_page_display_validation_error (COMP_EDITOR_PAGE (rpage), _("End time of the recurrence was before event's start"), priv->ending_date_edit); + return FALSE; + } + } + return TRUE; } -- cgit v1.2.3