Index: e-calendar-table.c
===================================================================
RCS file: /cvs/gnome/evolution/calendar/gui/e-calendar-table.c,v
retrieving revision 1.132
diff -u -p -r1.132 e-calendar-table.c
--- e-calendar-table.c	25 Jan 2005 11:18:16 -0000	1.132
+++ e-calendar-table.c	9 May 2005 05:55:34 -0000
@@ -1183,6 +1183,27 @@ ect_popup_free(EPopup *ep, GSList *items
 	g_slist_free(items);
 }
 
+typedef struct _CompleteData{
+	ECalendarTable *cal_table;
+	guint complete_count;
+	guint uncomplete_count;
+}CompleteData;
+
+static void
+mark_row_state_cb (int model_row, gpointer data)
+{
+	ECalendarTable *cal_table;
+	CompleteData *complete_data = data;
+	
+	cal_table = complete_data->cal_table;
+
+	if ( e_table_model_value_at (cal_table->model, E_CAL_MODEL_TASKS_FIELD_COMPLETED, model_row))
+		complete_data->complete_count++;
+	else
+		complete_data->uncomplete_count++;
+}
+
+
 static gint
 e_calendar_table_show_popup_menu (ETable *table,
 				  GdkEvent *gdk_event,
@@ -1194,11 +1215,23 @@ e_calendar_table_show_popup_menu (ETable
 	ECalPopup *ep;
 	ECalPopupTargetSelect *t;
 	int i;
+	gboolean is_all_completed = FALSE;
+	CompleteData status_completion;
 
 	selection = get_selected_objects (cal_table);
 	if (!selection)
 		return TRUE;
 
+	status_completion.cal_table = cal_table;
+	status_completion.complete_count = 0;
+	status_completion.uncomplete_count = 0;
+	e_table_selected_row_foreach (table, mark_row_state_cb, &status_completion);
+
+	if (status_completion.complete_count == 0 )
+		is_all_completed = FALSE;
+	else if ( status_completion.uncomplete_count ==0)
+		is_all_completed = TRUE;
+
 	/** @HookPoint-ECalPopup: Tasks Table Context Menu
 	 * @Id: org.gnome.evolution.tasks.table.popup
 	 * @Class: org.gnome.evolution.calendar.popup:1.0
@@ -1217,7 +1250,11 @@ e_calendar_table_show_popup_menu (ETable
 	t->target.widget = (GtkWidget *)cal_table;
 
 	for (i=0;i<sizeof(tasks_popup_items)/sizeof(tasks_popup_items[0]);i++)
+		{
+		if ( (tasks_popup_items[i].activate ==  mark_as_complete_cb) && is_all_completed)
+			continue;
 		menus = g_slist_prepend(menus, &tasks_popup_items[i]);
+		}
 	e_popup_add_items((EPopup *)ep, menus, NULL, ect_popup_free, cal_table);
 
 	menu = e_popup_create_menu_once((EPopup *)ep, (EPopupTarget *)t, 0);
Index: tasks-control.c
===================================================================
RCS file: /cvs/gnome/evolution/calendar/gui/tasks-control.c,v
retrieving revision 1.79
diff -u -p -r1.79 tasks-control.c
--- tasks-control.c	21 Jan 2005 18:15:42 -0000	1.79
+++ tasks-control.c	9 May 2005 05:55:35 -0000
@@ -50,6 +50,7 @@
 #include "calendar-commands.h"
 #include "e-tasks.h"
 #include "e-calendar-table.h"
+#include "e-cal-model-tasks.h"
 #include "print.h"
 #include "tasks-control.h"
 #include "evolution-shell-component-utils.h"
@@ -131,6 +132,54 @@ tasks_control_activate_cb		(BonoboContro
 		tasks_control_deactivate (control, tasks);
 }
 
+typedef struct _CompleteData{
+	ECalendarTable *cal_table;
+	guint complete_count;
+	guint uncomplete_count;
+}CompleteData;
+
+static void
+mark_row_state_cb (int model_row, gpointer data)
+{
+	ECalendarTable *cal_table;
+	CompleteData *complete_data = data;
+	
+	cal_table = complete_data->cal_table;
+
+	if ( e_table_model_value_at (cal_table->model, E_CAL_MODEL_TASKS_FIELD_COMPLETED, model_row))
+		complete_data->complete_count++;
+	else
+		complete_data->uncomplete_count++;
+}
+
+static gboolean
+get_is_all_tasks_completed (ETasks *tasks)
+{
+	CompleteData status_completion;
+	ECalendarTable *cal_table;
+	ETable *table;
+	ECalModel *model;
+	ECal *ecal;
+	gboolean is_all_completed = FALSE;
+
+	cal_table = e_tasks_get_calendar_table (tasks);
+	table = e_calendar_table_get_table (cal_table);
+	model = e_calendar_table_get_model (cal_table);
+	ecal = e_cal_model_get_default_client (model);
+
+	status_completion.cal_table = cal_table;
+	status_completion.complete_count = 0;
+	status_completion.uncomplete_count = 0;
+	e_table_selected_row_foreach (table, mark_row_state_cb, &status_completion);
+
+	if (status_completion.complete_count == 0 )
+		is_all_completed = FALSE;
+	else if ( status_completion.uncomplete_count ==0)
+		is_all_completed = TRUE;
+	
+	return is_all_completed;
+}
+
 /* Sensitizes the UI Component menu/toolbar commands based on the number of
  * selected tasks.
  */
@@ -141,6 +190,8 @@ tasks_control_sensitize_commands (Bonobo
 	gboolean read_only = TRUE;
 	ECal *ecal;
 	ECalModel *model;
+	gboolean is_all_completed = FALSE;
+	ECalendarTable *cal_table;
 
 	uic = bonobo_control_get_ui_component (control);
 	g_assert (uic != NULL);
@@ -153,6 +204,9 @@ tasks_control_sensitize_commands (Bonobo
 	if (ecal)
 		e_cal_is_read_only (ecal, &read_only, NULL);
 
+	if (!read_only)
+		is_all_completed = get_is_all_tasks_completed(tasks);
+
 	bonobo_ui_component_set_prop (uic, "/commands/TasksOpenTask", "sensitive",
 				      n_selected != 1 ? "0" : "1",
 				      NULL);
@@ -169,7 +223,7 @@ tasks_control_sensitize_commands (Bonobo
 				      n_selected == 0 || read_only ? "0" : "1",
 				      NULL);
 	bonobo_ui_component_set_prop (uic, "/commands/TasksMarkComplete", "sensitive",
-				      n_selected == 0 || read_only ? "0" : "1",
+				      n_selected == 0 || read_only || is_all_completed ? "0" : "1",
 				      NULL);
 	bonobo_ui_component_set_prop (uic, "/commands/TasksPurge", "sensitive",
 				      read_only ? "0" : "1",
@@ -347,9 +401,27 @@ tasks_control_complete_cmd		(BonoboUICom
 					 const char		*path)
 {
 	ETasks *tasks;
+	gboolean is_all_completed = FALSE;
+	gboolean read_only = TRUE;
+	ECal *ecal;
+	ECalModel *model;
 
 	tasks = E_TASKS (data);
 	e_tasks_complete_selected (tasks);
+
+	model = e_calendar_table_get_model (e_tasks_get_calendar_table (tasks));
+	ecal = e_cal_model_get_default_client (model);
+	
+	if (ecal)
+		e_cal_is_read_only (ecal, &read_only, NULL);
+	
+	if (!read_only)
+		is_all_completed = get_is_all_tasks_completed (tasks);
+
+	bonobo_ui_component_set_prop (uic, "/commands/TasksMarkComplete", "sensitive",
+				      read_only || is_all_completed ? "0" : "1",
+				      NULL);	
+	
 }
 
 static gboolean
