[evolution-patches] A patch for calendar based on trunk



Hi,

This patch is aimed for trunk. We have found a bug in calendar which can be reproduced as follows:
1.Invoke your evolution
2.Create a new task and the due date is before start date .
3.Save it
4.A perfect error message will be displayed "Due date is before start date"
5.delete the due date and start date
6.save and close it
7.In the task pane ,change the start date and due date

Actual result:
After #7,the due date of task can be before the start date and no corresponding error messages are given.

Enclosed is a patch to fix that. Would you like to spend a little time to review it?

Best regards
Index: calendar/ChangeLog
===================================================================
RCS file: /cvs/gnome/evolution/calendar/ChangeLog,v
retrieving revision 1.2141
diff -u -r1.2141 ChangeLog
--- calendar/ChangeLog	6 Feb 2004 03:03:39 -0000	1.2141
+++ calendar/ChangeLog	6 Feb 2004 08:04:33 -0000
@@ -1,3 +1,8 @@
+2004-02-06  Kidd Wang  <kidd wang sun com>
+
+	* 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 <jpr ximian com>
 
 	* Convert the calendar_config_get_timezone and
Index: calendar/gui/e-cal-model-tasks.c
===================================================================
RCS file: /cvs/gnome/evolution/calendar/gui/e-cal-model-tasks.c,v
retrieving revision 1.15
diff -u -r1.15 e-cal-model-tasks.c
--- calendar/gui/e-cal-model-tasks.c	24 Jan 2004 21:29:13 -0000	1.15
+++ calendar/gui/e-cal-model-tasks.c	6 Feb 2004 08:04:33 -0000
@@ -710,6 +710,9 @@
 	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 @@
 	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 @@
 		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 :


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]