diff options
author | Rodrigo Moya <rodrigo@ximian.com> | 2002-10-09 01:58:08 +0800 |
---|---|---|
committer | Rodrigo Moya <rodrigo@src.gnome.org> | 2002-10-09 01:58:08 +0800 |
commit | 155223435b0a80bcc8fa3a6ff0b03d2031ae2403 (patch) | |
tree | f07a33bdadfa139fe0b2e58b8c3366f874850d09 /calendar | |
parent | 00c1d84f673924046b9eecf478c6ec5f87ab3b18 (diff) | |
download | gsoc2013-evolution-155223435b0a80bcc8fa3a6ff0b03d2031ae2403.tar gsoc2013-evolution-155223435b0a80bcc8fa3a6ff0b03d2031ae2403.tar.gz gsoc2013-evolution-155223435b0a80bcc8fa3a6ff0b03d2031ae2403.tar.bz2 gsoc2013-evolution-155223435b0a80bcc8fa3a6ff0b03d2031ae2403.tar.lz gsoc2013-evolution-155223435b0a80bcc8fa3a6ff0b03d2031ae2403.tar.xz gsoc2013-evolution-155223435b0a80bcc8fa3a6ff0b03d2031ae2403.tar.zst gsoc2013-evolution-155223435b0a80bcc8fa3a6ff0b03d2031ae2403.zip |
Fixes #11434
2002-10-08 Rodrigo Moya <rodrigo@ximian.com>
Fixes #11434
* gui/dialogs/comp-editor-page.[ch]
(comp_editor_page_display_validation_error): new function.
* gui/dialogs/event-page.c (event_page_fill_component):
* gui/dialogs/recurrence-page.c (fill_component):
* gui/dialogs/task-details-page.c (task_details_page_fill_component):
* gui/dialogs/task-page.c (task_page_fill_component): added
checks for all date values, and return FALSE if we find
some invalid date/times.
* gui/dialogs/comp-editor.c (save_comp): activate the page that
returns error in fill_component.
svn path=/trunk/; revision=18352
Diffstat (limited to 'calendar')
-rw-r--r-- | calendar/ChangeLog | 17 | ||||
-rw-r--r-- | calendar/gui/dialogs/comp-editor-page.c | 35 | ||||
-rw-r--r-- | calendar/gui/dialogs/comp-editor-page.h | 3 | ||||
-rw-r--r-- | calendar/gui/dialogs/comp-editor.c | 1 | ||||
-rw-r--r-- | calendar/gui/dialogs/event-page.c | 18 | ||||
-rw-r--r-- | calendar/gui/dialogs/recurrence-page.c | 6 | ||||
-rw-r--r-- | calendar/gui/dialogs/task-details-page.c | 8 | ||||
-rw-r--r-- | calendar/gui/dialogs/task-page.c | 14 |
8 files changed, 102 insertions, 0 deletions
diff --git a/calendar/ChangeLog b/calendar/ChangeLog index 4d9df14caf..edaaa58c14 100644 --- a/calendar/ChangeLog +++ b/calendar/ChangeLog @@ -1,3 +1,20 @@ +2002-10-08 Rodrigo Moya <rodrigo@ximian.com> + + Fixes #11434 + + * gui/dialogs/comp-editor-page.[ch] + (comp_editor_page_display_validation_error): new function. + + * gui/dialogs/event-page.c (event_page_fill_component): + * gui/dialogs/recurrence-page.c (fill_component): + * gui/dialogs/task-details-page.c (task_details_page_fill_component): + * gui/dialogs/task-page.c (task_page_fill_component): added + checks for all date values, and return FALSE if we find + some invalid date/times. + + * gui/dialogs/comp-editor.c (save_comp): activate the page that + returns error in fill_component. + 2002-10-08 JP Rosevear <jpr@ximian.com> * gui/dialogs/cal-prefs-dialog.c diff --git a/calendar/gui/dialogs/comp-editor-page.c b/calendar/gui/dialogs/comp-editor-page.c index b1fabf28be..d2de97586e 100644 --- a/calendar/gui/dialogs/comp-editor-page.c +++ b/calendar/gui/dialogs/comp-editor-page.c @@ -23,6 +23,10 @@ #endif #include <gtk/gtksignal.h> +#include <libgnome/gnome-defs.h> +#include <libgnome/gnome-i18n.h> +#include <libgnomeui/gnome-dialog.h> +#include <libgnomeui/gnome-dialog-util.h> #include "comp-editor-page.h" @@ -384,3 +388,34 @@ comp_editor_page_notify_dates_changed (CompEditorPage *page, comp_editor_page_signals[DATES_CHANGED], dates); } + +/** + * comp_editor_page_display_validation_error: + * @page: An editor page. + * @msg: Error message to display. + * @field: Widget that caused the validation error. + * + * Displays an error message about a validation problem in the + * given field. Once the error message has been displayed, the + * focus is set to the widget that caused the validation error. + */ +void +comp_editor_page_display_validation_error (CompEditorPage *page, + const char *msg, + GtkWidget *field) +{ + GtkWidget *dialog; + char *real_msg; + + g_return_if_fail (IS_COMP_EDITOR_PAGE (page)); + g_return_if_fail (msg != NULL); + g_return_if_fail (GTK_IS_WIDGET (field)); + + real_msg = g_strdup_printf (_("Validation error: %s"), msg); + dialog = gnome_error_dialog (real_msg); + gnome_dialog_run_and_close (GNOME_DIALOG (dialog)); + + gtk_widget_grab_focus (field); + + g_free (real_msg); +} diff --git a/calendar/gui/dialogs/comp-editor-page.h b/calendar/gui/dialogs/comp-editor-page.h index 1b84cb16b7..4e5eadebda 100644 --- a/calendar/gui/dialogs/comp-editor-page.h +++ b/calendar/gui/dialogs/comp-editor-page.h @@ -100,6 +100,9 @@ void comp_editor_page_notify_summary_changed (CompEditorPage *page, const char *summary); void comp_editor_page_notify_dates_changed (CompEditorPage *page, CompEditorPageDates *dates); +void comp_editor_display_validation_error (CompEditorPage *page, + const char *msg, + GtkWidget *field); diff --git a/calendar/gui/dialogs/comp-editor.c b/calendar/gui/dialogs/comp-editor.c index 57eee0cef1..a1bf930579 100644 --- a/calendar/gui/dialogs/comp-editor.c +++ b/calendar/gui/dialogs/comp-editor.c @@ -317,6 +317,7 @@ save_comp (CompEditor *editor) for (l = priv->pages; l != NULL; l = l->next) { if (!comp_editor_page_fill_component (l->data, clone)) { gtk_object_unref (GTK_OBJECT (clone)); + comp_editor_show_page (editor, COMP_EDITOR_PAGE (l->data)); return FALSE; } } diff --git a/calendar/gui/dialogs/event-page.c b/calendar/gui/dialogs/event-page.c index c21b7ef5d8..89fb0b2a89 100644 --- a/calendar/gui/dialogs/event-page.c +++ b/calendar/gui/dialogs/event-page.c @@ -27,6 +27,8 @@ #include <gtk/gtksignal.h> #include <gtk/gtktogglebutton.h> +#include <libgnome/gnome-defs.h> +#include <libgnome/gnome-i18n.h> #include <glade/glade.h> #include <gal/widgets/e-unicode.h> #include <gal/widgets/e-categories.h> @@ -650,12 +652,20 @@ event_page_fill_component (CompEditorPage *page, CalComponent *comp) end_date.value = &end_tt; end_date.tzid = NULL; + if (!e_date_edit_date_is_valid (E_DATE_EDIT (priv->start_time))) { + comp_editor_page_display_validation_error (page, _("Start date is wrong"), priv->start_time); + return FALSE; + } start_date_set = e_date_edit_get_date (E_DATE_EDIT (priv->start_time), &start_tt.year, &start_tt.month, &start_tt.day); g_assert (start_date_set); + if (!e_date_edit_date_is_valid (E_DATE_EDIT (priv->end_time))) { + comp_editor_page_display_validation_error (page, _("End date is wrong"), priv->end_time); + return FALSE; + } end_date_set = e_date_edit_get_date (E_DATE_EDIT (priv->end_time), &end_tt.year, &end_tt.month, @@ -675,9 +685,17 @@ event_page_fill_component (CompEditorPage *page, CalComponent *comp) } else { icaltimezone *start_zone, *end_zone; + if (!e_date_edit_time_is_valid (E_DATE_EDIT (priv->start_time))) { + comp_editor_page_display_validation_error (page, _("Start time is wrong"), priv->start_time); + return FALSE; + } e_date_edit_get_time_of_day (E_DATE_EDIT (priv->start_time), &start_tt.hour, &start_tt.minute); + if (!e_date_edit_time_is_valid (E_DATE_EDIT (priv->end_time))) { + comp_editor_page_display_validation_error (page, _("End time is wrong"), priv->end_time); + return FALSE; + } e_date_edit_get_time_of_day (E_DATE_EDIT (priv->end_time), &end_tt.hour, &end_tt.minute); diff --git a/calendar/gui/dialogs/recurrence-page.c b/calendar/gui/dialogs/recurrence-page.c index db3a2e7279..cee05b5c60 100644 --- a/calendar/gui/dialogs/recurrence-page.c +++ b/calendar/gui/dialogs/recurrence-page.c @@ -893,6 +893,12 @@ fill_component (RecurrencePage *rpage, CalComponent *comp) dt = gtk_clist_get_row_data (exception_list, i); g_assert (dt != NULL); + if (!icaltime_is_valid_time (*dt->value)) { + comp_editor_page_display_validation_error (COMP_EDITOR_PAGE (rpage), + _("Recurrent date is wrong"), + exception_list); + return FALSE; + } *cdt->value = *dt->value; cdt->tzid = g_strdup (dt->tzid); diff --git a/calendar/gui/dialogs/task-details-page.c b/calendar/gui/dialogs/task-details-page.c index d92b5c18e7..c138ddeda6 100644 --- a/calendar/gui/dialogs/task-details-page.c +++ b/calendar/gui/dialogs/task-details-page.c @@ -27,6 +27,8 @@ #include <gtk/gtksignal.h> #include <gtk/gtktogglebutton.h> +#include <libgnome/gnome-defs.h> +#include <libgnome/gnome-i18n.h> #include <glade/glade.h> #include <gal/widgets/e-unicode.h> #include <widgets/misc/e-dateedit.h> @@ -413,6 +415,12 @@ task_details_page_fill_component (CompEditorPage *page, CalComponent *comp) icaltime.is_utc = 1; /* Completed Date. */ + if (!e_date_edit_date_is_valid (E_DATE_EDIT (priv->completed_date)) || + !e_date_edit_time_is_valid (E_DATE_EDIT (priv->completed_date))) { + comp_editor_page_display_validation_error (page, _("Completed date is wrong"), priv->completed_date); + return FALSE; + } + date_set = e_date_edit_get_date (E_DATE_EDIT (priv->completed_date), &icaltime.year, &icaltime.month, diff --git a/calendar/gui/dialogs/task-page.c b/calendar/gui/dialogs/task-page.c index 8e8c30e43a..62732c9eb0 100644 --- a/calendar/gui/dialogs/task-page.c +++ b/calendar/gui/dialogs/task-page.c @@ -31,6 +31,8 @@ #include <gtk/gtktogglebutton.h> #include <gtk/gtkspinbutton.h> #include <gtk/gtkoptionmenu.h> +#include <libgnome/gnome-defs.h> +#include <libgnome/gnome-i18n.h> #include <glade/glade.h> #include <gal/widgets/e-unicode.h> #include <gal/widgets/e-categories.h> @@ -533,6 +535,12 @@ task_page_fill_component (CompEditorPage *page, CalComponent *comp) date.tzid = NULL; /* Due Date. */ + if (!e_date_edit_date_is_valid (E_DATE_EDIT (priv->due_date)) || + !e_date_edit_time_is_valid (E_DATE_EDIT (priv->due_date))) { + comp_editor_page_display_validation_error (page, _("Due date is wrong"), priv->due_date); + return FALSE; + } + date_set = e_date_edit_get_date (E_DATE_EDIT (priv->due_date), &icaltime.year, &icaltime.month, @@ -554,6 +562,12 @@ task_page_fill_component (CompEditorPage *page, CalComponent *comp) } /* Start Date. */ + if (!e_date_edit_date_is_valid (E_DATE_EDIT (priv->start_date)) || + !e_date_edit_time_is_valid (E_DATE_EDIT (priv->start_date))) { + comp_editor_page_display_validation_error (page, _("Start date is wrong"), priv->start_date); + return FALSE; + } + icaltime = icaltime_null_time (); date_set = e_date_edit_get_date (E_DATE_EDIT (priv->start_date), &icaltime.year, |