From c4b9eb546503c11711704d88f7ffd311e6d95c74 Mon Sep 17 00:00:00 2001 From: Harry Lu Date: Mon, 9 Feb 2004 05:55:29 +0000 Subject: refuse to update the task info if due date is before start date. * gui/e-cal-model-tasks.c: (ecmt_set_value_at): refuse to update the task info if due date is before start date. svn path=/trunk/; revision=24676 --- calendar/ChangeLog | 5 +++++ calendar/gui/e-cal-model-tasks.c | 42 ++++++++++++++++++++++++++++++++++++---- 2 files changed, 43 insertions(+), 4 deletions(-) (limited to 'calendar') diff --git a/calendar/ChangeLog b/calendar/ChangeLog index fdeb173ac3..7a5e44bb8f 100644 --- a/calendar/ChangeLog +++ b/calendar/ChangeLog @@ -1,3 +1,8 @@ +2004-02-09 Kidd Wang + + * gui/e-cal-model-tasks.c: (ecmt_set_value_at): refuse to update + the task info if due date is before start date. + 2004-02-05 JP Rosevear * Convert the calendar_config_get_timezone and diff --git a/calendar/gui/e-cal-model-tasks.c b/calendar/gui/e-cal-model-tasks.c index 99c337905f..78ea87cf4d 100644 --- a/calendar/gui/e-cal-model-tasks.c +++ b/calendar/gui/e-cal-model-tasks.c @@ -710,6 +710,9 @@ ecmt_set_value_at (ETableModel *etm, int col, int row, const void *value) ECalModelTasksPrivate *priv; ECalModelComponent *comp_data; ECalModelTasks *model = (ECalModelTasks *) etm; + icaltimetype start_tt, due_tt; + ECellDateEditValue *dv; + GtkWidget *dialog; g_return_if_fail (E_IS_CAL_MODEL_TASKS (model)); @@ -718,15 +721,32 @@ ecmt_set_value_at (ETableModel *etm, int col, int row, const void *value) g_return_if_fail (col >= 0 && col < E_CAL_MODEL_TASKS_FIELD_LAST); g_return_if_fail (row >= 0 && row < e_table_model_row_count (etm)); + comp_data = e_cal_model_get_component_at (E_CAL_MODEL (model), row); + if (!comp_data) + return; + if (col < E_CAL_MODEL_FIELD_LAST) { + if (col == E_CAL_MODEL_FIELD_DTSTART) { + dv = (ECellDateEditValue *) value; + start_tt = dv->tt; + due_tt = icalcomponent_get_due (comp_data->icalcomp); + + if (icaltime_compare (start_tt, due_tt) > 0) { + dialog = gtk_message_dialog_new (NULL, 0, + GTK_MESSAGE_ERROR, + GTK_BUTTONS_OK, + _("Due date is before start date!")); + g_signal_connect (dialog, "response", G_CALLBACK(gtk_widget_destroy), NULL); + gtk_widget_show (dialog); + + return; + } + } + E_TABLE_MODEL_CLASS (parent_class)->set_value_at (etm, col, row, value); return; } - comp_data = e_cal_model_get_component_at (E_CAL_MODEL (model), row); - if (!comp_data) - return; - switch (col) { case E_CAL_MODEL_TASKS_FIELD_COMPLETED : set_completed (model, comp_data, value); @@ -735,6 +755,20 @@ ecmt_set_value_at (ETableModel *etm, int col, int row, const void *value) set_complete (comp_data, value); break; case E_CAL_MODEL_TASKS_FIELD_DUE : + dv = (ECellDateEditValue *) value; + start_tt = icalcomponent_get_dtstart (comp_data->icalcomp); + due_tt = dv->tt; + + if (icaltime_compare (start_tt, due_tt) > 0) { + dialog = gtk_message_dialog_new (NULL, 0, + GTK_MESSAGE_ERROR, + GTK_BUTTONS_OK, + _("Due date is before start date!")); + g_signal_connect (dialog, "response", G_CALLBACK(gtk_widget_destroy), NULL); + gtk_widget_show (dialog); + + return; + } set_due (comp_data, value); break; case E_CAL_MODEL_TASKS_FIELD_GEO : -- cgit