aboutsummaryrefslogtreecommitdiffstats
path: root/calendar/gui/tasks-control.c
diff options
context:
space:
mode:
authorShakti Sen <shprasad@novell.com>2005-08-02 21:50:54 +0800
committerShakti Prasad Sen <shaktis@src.gnome.org>2005-08-02 21:50:54 +0800
commit5739bae429a2743066ad644dc9d32f1d8021e6da (patch)
tree284643bdd1a55ef4013709f746240fdf1239200f /calendar/gui/tasks-control.c
parent90d630ecd19935e696b9279ef9d7d4c6a5486739 (diff)
downloadgsoc2013-evolution-5739bae429a2743066ad644dc9d32f1d8021e6da.tar
gsoc2013-evolution-5739bae429a2743066ad644dc9d32f1d8021e6da.tar.gz
gsoc2013-evolution-5739bae429a2743066ad644dc9d32f1d8021e6da.tar.bz2
gsoc2013-evolution-5739bae429a2743066ad644dc9d32f1d8021e6da.tar.lz
gsoc2013-evolution-5739bae429a2743066ad644dc9d32f1d8021e6da.tar.xz
gsoc2013-evolution-5739bae429a2743066ad644dc9d32f1d8021e6da.tar.zst
gsoc2013-evolution-5739bae429a2743066ad644dc9d32f1d8021e6da.zip
Added support for the Target selection for 'Tasks'. Resolved one undefined
2005-08-01 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. * gui/e-cal-menu.c (e_cal_menu_target_new_select): Set the mask for E_CAL_MENU_SELECT_ASSIGNABLE. Fixes bug #231968. svn path=/trunk/; revision=29957
Diffstat (limited to 'calendar/gui/tasks-control.c')
-rw-r--r--calendar/gui/tasks-control.c94
1 files changed, 55 insertions, 39 deletions
diff --git a/calendar/gui/tasks-control.c b/calendar/gui/tasks-control.c
index 0931215112..927035c3a8 100644
--- a/calendar/gui/tasks-control.c
+++ b/calendar/gui/tasks-control.c
@@ -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 (BonoboControl *control,
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_ASSIGNABLE },
+ { "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 (BonoboControl *control, ETasks *tasks, int n_s
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 (BonoboControl *control, ETasks *tasks, int n_s
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 *control, ETasks *tasks)
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 *control, ETasks *tasks)
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);