Re: [evolution-patches] calendar, mail and exchange: patch for bug #231968



Hi,

I am sending a modified patch. This patch also takes care of few
compilation warning messages. Please review the patch.

Thanks,
Shakti


On Thu, 2005-07-28 at 16:11 +0530, chenthill wrote:
> 
> On Wed, 2005-07-27 at 14:36 +0530, shakti wrote:
> > +#include "e-calendar-view.h"
> +       GtkWidget *view;
> these are not required.
> 
> The masks set in e-cal-menu.c should be used here for
> enabling/disabling the menu items.
> 
> thanks, chenthill.  
> _______________________________________________
> evolution-patches mailing list
> evolution-patches lists ximian com
> http://lists.ximian.com/mailman/listinfo/evolution-patches
Index: ChangeLog
===================================================================
RCS file: /cvs/gnome/evolution/calendar/ChangeLog,v
retrieving revision 1.2780
diff -u -p -r1.2780 ChangeLog
--- ChangeLog	25 Jul 2005 11:50:54 -0000	1.2780
+++ ChangeLog	28 Jul 2005 12:02:35 -0000
@@ -1,3 +1,16 @@
+2005-07-26  Shakti Sen <shprasad novell com>
+
+	* gui/tasks-control.c (tasks_control_sensitize_commands): Added support
+	for the Target selection for 'Tasks'.
+	* gui/e-calendar-table.c (e_calendar_table_open_selected): Resolved
+	one undefined symbol.
+	* gui/e-tasks.c: Renamed the function name from 'e_tasks_get_tasks_menu'
+	to 'e_tasks_get_tasks_menu'
+	* gui/e-tasks.h: Added the declaration for 'e_tasks_get_tasks_menu'.
+	Thus fixes few warning messages.
+
+	Fixes bug #231968.
+
 2005-07-25  Chenthill Palanisamy  <pchenthill novell com>
 
 	* gui/e-cal-popup.c: 
Index: gui/e-calendar-table.c
===================================================================
RCS file: /cvs/gnome/evolution/calendar/gui/e-calendar-table.c,v
retrieving revision 1.136
diff -u -p -r1.136 e-calendar-table.c
--- gui/e-calendar-table.c	25 Jul 2005 07:53:18 -0000	1.136
+++ gui/e-calendar-table.c	28 Jul 2005 12:02:35 -0000
@@ -589,7 +589,7 @@ e_calendar_table_open_selected (ECalenda
 	ECalModelComponent *comp_data;
 	icalproperty *prop;
 
-	comp_data = get_selected_comp (cal_table);
+	comp_data = e_calendar_table_get_selected_comp (cal_table);
 	prop = icalcomponent_get_first_property (comp_data->icalcomp, ICAL_ATTENDEE_PROPERTY);
 	if (comp_data != NULL)
 		e_calendar_table_open_task (cal_table, comp_data, prop ? TRUE : FALSE);
Index: gui/e-tasks.c
===================================================================
RCS file: /cvs/gnome/evolution/calendar/gui/e-tasks.c,v
retrieving revision 1.117
diff -u -p -r1.117 e-tasks.c
--- gui/e-tasks.c	22 Jul 2005 07:38:37 -0000	1.117
+++ gui/e-tasks.c	28 Jul 2005 12:02:35 -0000
@@ -101,7 +101,6 @@ static void update_view (ETasks *tasks);
 
 static void config_categories_changed_cb (EConfigListener *config_listener, const char *key, gpointer user_data);
 static void backend_error_cb (ECal *client, const char *message, gpointer data);
-ECalMenu *gnome_tasks_get_tasks_menu (ETasks *tasks);
 
 /* Signal IDs */
 enum {
@@ -167,7 +166,7 @@ table_cursor_change_cb (ETable *etable, 
 }
 
 ECalMenu *
-gnome_tasks_get_tasks_menu (ETasks *tasks)
+e_tasks_get_tasks_menu (ETasks *tasks)
 {
         g_return_val_if_fail (E_IS_TASKS (tasks), NULL);
 
Index: gui/e-tasks.h
===================================================================
RCS file: /cvs/gnome/evolution/calendar/gui/e-tasks.h,v
retrieving revision 1.24
diff -u -p -r1.24 e-tasks.h
--- gui/e-tasks.h	29 Apr 2004 19:36:53 -0000	1.24
+++ gui/e-tasks.h	28 Jul 2005 12:02:35 -0000
@@ -82,6 +82,7 @@ void       e_tasks_delete_completed  (ET
 void e_tasks_setup_view_menus (ETasks *tasks, BonoboUIComponent *uic);
 void e_tasks_discard_view_menus (ETasks *tasks);
 
+struct _ECalMenu *e_tasks_get_tasks_menu (ETasks *tasks);
 ECalendarTable *e_tasks_get_calendar_table (ETasks *tasks);
 
 #endif /* _E_TASKS_H_ */
Index: gui/tasks-control.c
===================================================================
RCS file: /cvs/gnome/evolution/calendar/gui/tasks-control.c,v
retrieving revision 1.81
diff -u -p -r1.81 tasks-control.c
--- gui/tasks-control.c	25 Jul 2005 07:53:18 -0000	1.81
+++ gui/tasks-control.c	28 Jul 2005 12:02:35 -0000
@@ -54,6 +54,8 @@
 #include "tasks-control.h"
 #include "evolution-shell-component-utils.h"
 #include "e-util/e-menu.h"
+#include "e-cal-menu.h"
+#include "e-util/e-menu.h"
 #include "itip-utils.h"
 
 #define FIXED_MARGIN                            .05
@@ -140,6 +142,40 @@ tasks_control_activate_cb		(BonoboContro
 		tasks_control_deactivate (control, tasks);
 }
 
+struct _tasks_sensitize_item {
+	char *command;
+	guint32 enable;
+};
+
+static void
+sensitize_items(BonoboUIComponent *uic, struct _tasks_sensitize_item *items, guint32 mask)
+{
+	while (items->command) {
+		char command[32];
+
+		g_assert(strlen(items->command)<21);
+		sprintf(command, "/commands/%s", items->command);
+
+		bonobo_ui_component_set_prop (uic, command, "sensitive",
+					      (items->enable & mask) == 0 ? "1" : "0",
+					      NULL);
+		items++;
+	}
+}
+
+static struct _tasks_sensitize_item tasks_sensitize_table[] = {
+	{ "TasksOpenTask", E_CAL_MENU_SELECT_ONE },
+	{ "TasksCut", E_CAL_MENU_SELECT_ANY | E_CAL_MENU_SELECT_EDITABLE },
+	{ "TasksCopy", E_CAL_MENU_SELECT_ANY },
+	{ "TasksPaste", E_CAL_MENU_SELECT_EDITABLE },
+	{ "TasksDelete", E_CAL_MENU_SELECT_ANY | E_CAL_MENU_SELECT_EDITABLE },
+	{ "TasksMarkComplete", E_CAL_MENU_SELECT_ANY | E_CAL_MENU_SELECT_EDITABLE },
+	{ "TasksPurge", E_CAL_MENU_SELECT_EDITABLE },
+	{ "TasksAssign", E_CAL_MENU_SELECT_ONE | E_CAL_MENU_SELECT_EDITABLE | E_CAL_MENU_SELECT_HASURL },
+	{ "TasksForward", E_CAL_MENU_SELECT_ONE },
+	{ 0 }
+};
+
 /* Sensitizes the UI Component menu/toolbar commands based on the number of
  * selected tasks.
  */
@@ -150,10 +186,11 @@ tasks_control_sensitize_commands (Bonobo
 	gboolean read_only = TRUE;
 	ECal *ecal;
 	ECalModel *model;
+	ECalMenu *menu;
+	ECalMenuTargetSelect *t;
+	GPtrArray *events;
+	GSList *selected = NULL, *l = NULL;
 	ECalendarTable *cal_table;
-	ECalModelComponent *comp_data;
-	icalproperty *prop;
-	gboolean is_assigned = FALSE;
 
 	uic = bonobo_control_get_ui_component (control);
 	g_assert (uic != NULL);
@@ -161,48 +198,27 @@ tasks_control_sensitize_commands (Bonobo
 	if (bonobo_ui_component_get_container (uic) == CORBA_OBJECT_NIL)
 		return;
 
+	menu = e_tasks_get_tasks_menu (tasks);
 	cal_table = e_tasks_get_calendar_table (tasks);
 	model = e_calendar_table_get_model (cal_table);
+	events = g_ptr_array_new ();
+	selected = e_calendar_table_get_selected (cal_table);
+
+	for (l = selected;l;l = g_slist_next (l)) {
+		g_ptr_array_add (events, e_cal_model_copy_component_data ((ECalModelComponent *)l->data));
+	}
+
+	g_slist_free (selected);
+
+	t = e_cal_menu_target_new_select (menu, model, events);
 
-	if (n_selected == 1) {
-		comp_data = e_calendar_table_get_selected_comp (cal_table);
-		prop = icalcomponent_get_first_property (comp_data->icalcomp, ICAL_ATTENDEE_PROPERTY);
-		is_assigned = prop ? TRUE : FALSE;
-	}	
-	
 	ecal = e_cal_model_get_default_client (model);
 
 	if (ecal) 
 		e_cal_is_read_only (ecal, &read_only, NULL);
 		
-
-	bonobo_ui_component_set_prop (uic, "/commands/TasksOpenTask", "sensitive",
-				      n_selected != 1 ? "0" : "1",
-				      NULL);
-	bonobo_ui_component_set_prop (uic, "/commands/TasksCut", "sensitive",
-				      n_selected == 0 || read_only ? "0" : "1",
-				      NULL);
-	bonobo_ui_component_set_prop (uic, "/commands/TasksCopy", "sensitive",
-				      n_selected == 0 ? "0" : "1",
-				      NULL);
-	bonobo_ui_component_set_prop (uic, "/commands/TasksPaste", "sensitive",
-				      read_only ? "0" : "1",
-				      NULL);
-	bonobo_ui_component_set_prop (uic, "/commands/TasksDelete", "sensitive",
-				      n_selected == 0 || read_only ? "0" : "1",
-				      NULL);
-	bonobo_ui_component_set_prop (uic, "/commands/TasksMarkComplete", "sensitive",
-				      n_selected == 0 || read_only ? "0" : "1",
-				      NULL);
-	bonobo_ui_component_set_prop (uic, "/commands/TasksPurge", "sensitive",
-				      read_only ? "0" : "1",
-				      NULL);
-	bonobo_ui_component_set_prop (uic, "/commands/TasksAssign", "sensitive",
-				      (is_assigned || read_only || n_selected != 1) ? "0" : "1",
-				      NULL);
-	bonobo_ui_component_set_prop (uic, "/commands/TasksForward", "sensitive",
-				      n_selected != 1 ? "0" : "1", 
-				      NULL);
+	sensitize_items (uic, tasks_sensitize_table, t->target.mask);
+	e_menu_update_target ((EMenu *)menu, (EMenuTarget *)t);
 }
 
 /* Callback used when the selection in the table changes */
@@ -266,7 +282,7 @@ tasks_control_activate (BonoboControl *c
 
 	g_signal_connect (tasks, "selection_changed", G_CALLBACK (selection_changed_cb), control);
 
-	e_menu_activate ((EMenu *)gnome_tasks_get_tasks_menu (tasks), uic, 1);
+	e_menu_activate ((EMenu *)e_tasks_get_tasks_menu (tasks), uic, 1);
 	cal_table = e_tasks_get_calendar_table (tasks);
 	etable = e_calendar_table_get_table (cal_table);
 	n_selected = e_table_selected_count (etable);
@@ -291,7 +307,7 @@ tasks_control_deactivate (BonoboControl 
 
 	g_assert (uic != NULL);
 
-	e_menu_activate ((EMenu *)gnome_tasks_get_tasks_menu (tasks), uic, 0);
+	e_menu_activate ((EMenu *)e_tasks_get_tasks_menu (tasks), uic, 0);
 	e_tasks_set_ui_component (tasks, NULL);
 
 	e_tasks_discard_view_menus (tasks);


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