diff options
author | Federico Mena Quintero <federico@ximian.com> | 2001-05-22 06:38:37 +0800 |
---|---|---|
committer | Federico Mena Quintero <federico@src.gnome.org> | 2001-05-22 06:38:37 +0800 |
commit | ffcb9b625c4f5e4191cb465df865f841171eec12 (patch) | |
tree | 1699c28e08dfcf07db2df6a39749fd6defbbae87 /calendar | |
parent | f825ab30af5fb433efde95cbe3aced99f2059b48 (diff) | |
download | gsoc2013-evolution-ffcb9b625c4f5e4191cb465df865f841171eec12.tar gsoc2013-evolution-ffcb9b625c4f5e4191cb465df865f841171eec12.tar.gz gsoc2013-evolution-ffcb9b625c4f5e4191cb465df865f841171eec12.tar.bz2 gsoc2013-evolution-ffcb9b625c4f5e4191cb465df865f841171eec12.tar.lz gsoc2013-evolution-ffcb9b625c4f5e4191cb465df865f841171eec12.tar.xz gsoc2013-evolution-ffcb9b625c4f5e4191cb465df865f841171eec12.tar.zst gsoc2013-evolution-ffcb9b625c4f5e4191cb465df865f841171eec12.zip |
Fix bug #2831; the tasks toolbar and menu now have a button to delete the
2001-05-21 Federico Mena Quintero <federico@ximian.com>
Fix bug #2831; the tasks toolbar and menu now have a button to
delete the selected tasks.
* gui/e-calendar-table.c (e_calendar_table_delete_selected): New
function.
(delete_cb): Use e_calendar_table_delete_selected().
(e_calendar_table_get_table): New function.
* gui/tasks-control.c (tasks_control_new_task_cmd): Handle the
delete command.
(selection_changed_cb): Change the sensitivity of the TasksDelete
command when the selection in the table changes.
* gui/e-tasks.c (table_selection_change_cb): Notify upstream when
the ETable selection changes.
svn path=/trunk/; revision=9910
Diffstat (limited to 'calendar')
-rw-r--r-- | calendar/ChangeLog | 18 | ||||
-rw-r--r-- | calendar/gui/e-calendar-table.c | 147 | ||||
-rw-r--r-- | calendar/gui/e-calendar-table.h | 5 | ||||
-rw-r--r-- | calendar/gui/e-tasks.c | 56 | ||||
-rw-r--r-- | calendar/gui/e-tasks.h | 4 | ||||
-rw-r--r-- | calendar/gui/tasks-control.c | 42 |
6 files changed, 213 insertions, 59 deletions
diff --git a/calendar/ChangeLog b/calendar/ChangeLog index 62bb518bd7..249a9ae465 100644 --- a/calendar/ChangeLog +++ b/calendar/ChangeLog @@ -1,3 +1,21 @@ +2001-05-21 Federico Mena Quintero <federico@ximian.com> + + Fix bug #2831; the tasks toolbar and menu now have a button to + delete the selected tasks. + + * gui/e-calendar-table.c (e_calendar_table_delete_selected): New + function. + (delete_cb): Use e_calendar_table_delete_selected(). + (e_calendar_table_get_table): New function. + + * gui/tasks-control.c (tasks_control_new_task_cmd): Handle the + delete command. + (selection_changed_cb): Change the sensitivity of the TasksDelete + command when the selection in the table changes. + + * gui/e-tasks.c (table_selection_change_cb): Notify upstream when + the ETable selection changes. + 2001-05-18 Federico Mena Quintero <federico@ximian.com> Fix bug #2829. diff --git a/calendar/gui/e-calendar-table.c b/calendar/gui/e-calendar-table.c index 23104866ca..685a56d9f9 100644 --- a/calendar/gui/e-calendar-table.c +++ b/calendar/gui/e-calendar-table.c @@ -31,7 +31,6 @@ #include <config.h> #include <sys/stat.h> #include <unistd.h> -#include <gal/e-table/e-table-scrolled.h> #include <gal/e-table/e-cell-checkbox.h> #include <gal/e-table/e-cell-toggle.h> #include <gal/e-table/e-cell-text.h> @@ -526,60 +525,22 @@ e_calendar_table_set_cal_client (ECalendarTable *cal_table, CALOBJ_TYPE_TODO); } - -/* Opens a task in the task editor */ -static void -open_task (ECalendarTable *cal_table, CalComponent *comp) -{ - TaskEditor *tedit; - - tedit = task_editor_new (); - task_editor_set_cal_client (tedit, calendar_model_get_cal_client (cal_table->model)); - task_editor_set_todo_object (tedit, comp); - task_editor_focus (tedit); -} - -/* Opens the task in the specified row */ -static void -open_task_by_row (ECalendarTable *cal_table, int row) -{ - CalComponent *comp; - - comp = calendar_model_get_component (cal_table->model, row); - open_task (cal_table, comp); -} - -static void -e_calendar_table_on_double_click (ETable *table, - gint row, - gint col, - GdkEvent *event, - ECalendarTable *cal_table) -{ - open_task_by_row (cal_table, row); -} - -/* Used from e_table_selected_row_foreach() */ -static void -mark_row_complete_cb (int model_row, gpointer data) -{ - ECalendarTable *cal_table; - - cal_table = E_CALENDAR_TABLE (data); - calendar_model_mark_task_complete (cal_table->model, model_row); -} - -/* Callback used for the "mark tasks as complete" menu item */ -static void -mark_as_complete_cb (GtkWidget *menuitem, gpointer data) +/** + * e_calendar_table_get_table: + * @cal_table: A calendar table. + * + * Queries the #ETable widget that the calendar table is using. + * + * Return value: The #ETable widget that the calendar table uses to display its + * data. + **/ +ETable * +e_calendar_table_get_table (ECalendarTable *cal_table) { - ECalendarTable *cal_table; - ETable *etable; - - cal_table = E_CALENDAR_TABLE (data); + g_return_val_if_fail (cal_table != NULL, NULL); + g_return_val_if_fail (E_IS_CALENDAR_TABLE (cal_table), NULL); - etable = e_table_scrolled_get_table (E_TABLE_SCROLLED (cal_table->etable)); - e_table_selected_row_foreach (etable, mark_row_complete_cb, cal_table); + return e_table_scrolled_get_table (E_TABLE_SCROLLED (cal_table->etable)); } /* Used from e_table_selected_row_foreach(); puts the selected row number in an @@ -676,16 +637,21 @@ delete_selected_components (ECalendarTable *cal_table) g_slist_free (uids); } -/* Callback for the "delete tasks" menu item */ -static void -delete_cb (GtkWidget *menuitem, gpointer data) +/** + * e_calendar_table_delete_selected: + * @cal_table: A calendar table. + * + * Deletes the selected components in the table; asks the user first. + **/ +void +e_calendar_table_delete_selected (ECalendarTable *cal_table) { - ECalendarTable *cal_table; ETable *etable; int n_selected; CalComponent *comp; - cal_table = E_CALENDAR_TABLE (data); + g_return_if_fail (cal_table != NULL); + g_return_if_fail (E_IS_CALENDAR_TABLE (cal_table)); etable = e_table_scrolled_get_table (E_TABLE_SCROLLED (cal_table->etable)); @@ -701,6 +667,71 @@ delete_cb (GtkWidget *menuitem, gpointer data) delete_selected_components (cal_table); } +/* Opens a task in the task editor */ +static void +open_task (ECalendarTable *cal_table, CalComponent *comp) +{ + TaskEditor *tedit; + + tedit = task_editor_new (); + task_editor_set_cal_client (tedit, calendar_model_get_cal_client (cal_table->model)); + task_editor_set_todo_object (tedit, comp); + task_editor_focus (tedit); +} + +/* Opens the task in the specified row */ +static void +open_task_by_row (ECalendarTable *cal_table, int row) +{ + CalComponent *comp; + + comp = calendar_model_get_component (cal_table->model, row); + open_task (cal_table, comp); +} + +static void +e_calendar_table_on_double_click (ETable *table, + gint row, + gint col, + GdkEvent *event, + ECalendarTable *cal_table) +{ + open_task_by_row (cal_table, row); +} + +/* Used from e_table_selected_row_foreach() */ +static void +mark_row_complete_cb (int model_row, gpointer data) +{ + ECalendarTable *cal_table; + + cal_table = E_CALENDAR_TABLE (data); + calendar_model_mark_task_complete (cal_table->model, model_row); +} + +/* Callback used for the "mark tasks as complete" menu item */ +static void +mark_as_complete_cb (GtkWidget *menuitem, gpointer data) +{ + ECalendarTable *cal_table; + ETable *etable; + + cal_table = E_CALENDAR_TABLE (data); + + etable = e_table_scrolled_get_table (E_TABLE_SCROLLED (cal_table->etable)); + e_table_selected_row_foreach (etable, mark_row_complete_cb, cal_table); +} + +/* Callback for the "delete tasks" menu item */ +static void +delete_cb (GtkWidget *menuitem, gpointer data) +{ + ECalendarTable *cal_table; + + cal_table = E_CALENDAR_TABLE (data); + e_calendar_table_delete_selected (cal_table); +} + static GnomeUIInfo tasks_popup_one[] = { GNOMEUIINFO_ITEM_NONE (N_("Edit this task"), NULL, e_calendar_table_on_open_task), GNOMEUIINFO_SEPARATOR, diff --git a/calendar/gui/e-calendar-table.h b/calendar/gui/e-calendar-table.h index e19ecf82e8..914a0bcd87 100644 --- a/calendar/gui/e-calendar-table.h +++ b/calendar/gui/e-calendar-table.h @@ -26,6 +26,7 @@ #define _E_CALENDAR_TABLE_H_ #include <gtk/gtktable.h> +#include <gal/e-table/e-table-scrolled.h> #include <widgets/misc/e-cell-date-edit.h> #include "calendar-model.h" @@ -98,6 +99,10 @@ CalendarModel *e_calendar_table_get_model (ECalendarTable *cal_table); void e_calendar_table_set_cal_client (ECalendarTable *cal_table, CalClient *client); +ETable *e_calendar_table_get_table (ECalendarTable *cal_table); + +void e_calendar_table_delete_selected (ECalendarTable *cal_table); + /* These load and save the state of the table (headers shown etc.) to/from the given file. */ void e_calendar_table_load_state (ECalendarTable *cal_table, diff --git a/calendar/gui/e-tasks.c b/calendar/gui/e-tasks.c index e69b2a4037..1686ac793a 100644 --- a/calendar/gui/e-tasks.c +++ b/calendar/gui/e-tasks.c @@ -77,8 +77,14 @@ static gint e_tasks_add_menu_item (gpointer key, gpointer value, gpointer data); +/* Signal IDs */ +enum { + SELECTION_CHANGED, + LAST_SIGNAL +}; static GtkTableClass *parent_class; +static guint e_tasks_signals[LAST_SIGNAL] = { 0 }; E_MAKE_TYPE (e_tasks, "ETasks", ETasks, @@ -96,7 +102,20 @@ e_tasks_class_init (ETasksClass *class) parent_class = gtk_type_class (GTK_TYPE_TABLE); + e_tasks_signals[SELECTION_CHANGED] = + gtk_signal_new ("selection_changed", + GTK_RUN_FIRST, + object_class->type, + GTK_SIGNAL_OFFSET (ETasksClass, selection_changed), + gtk_marshal_NONE__INT, + GTK_TYPE_NONE, 1, + GTK_TYPE_INT); + + gtk_object_class_add_signals (object_class, e_tasks_signals, LAST_SIGNAL); + object_class->destroy = e_tasks_destroy; + + class->selection_changed = NULL; } @@ -112,6 +131,19 @@ e_tasks_init (ETasks *tasks) setup_widgets (tasks); } +/* Callback used when the selection changes in the table. */ +static void +table_selection_change_cb (ETable *etable, gpointer data) +{ + ETasks *tasks; + int n_selected; + + tasks = E_TASKS (data); + + n_selected = e_table_selected_count (etable); + gtk_signal_emit (GTK_OBJECT (tasks), e_tasks_signals[SELECTION_CHANGED], + n_selected); +} #define E_TASKS_TABLE_DEFAULT_STATE \ "<?xml version=\"1.0\"?>" \ @@ -170,6 +202,9 @@ setup_widgets (ETasks *tasks) gtk_signal_connect (GTK_OBJECT (E_CALENDAR_TABLE (priv->tasks_view)->model), "categories-changed", GTK_SIGNAL_FUNC (e_tasks_on_categories_changed), tasks); + + gtk_signal_connect (GTK_OBJECT (etable), "selection_change", + GTK_SIGNAL_FUNC (table_selection_change_cb), tasks); } @@ -445,6 +480,27 @@ e_tasks_new_task (ETasks *tasks) task_editor_focus (tedit); } +/** + * e_tasks_delete_selected: + * @tasks: A tasks control widget. + * + * Deletes the selected tasks in the task list. + **/ +void +e_tasks_delete_selected (ETasks *tasks) +{ + ETasksPrivate *priv; + ECalendarTable *cal_table; + + g_return_if_fail (tasks != NULL); + g_return_if_fail (E_IS_TASKS (tasks)); + + priv = tasks->priv; + + cal_table = E_CALENDAR_TABLE (priv->tasks_view); + e_calendar_table_delete_selected (cal_table); +} + static void e_tasks_on_filter_selected (GtkMenuShell *menu_shell, diff --git a/calendar/gui/e-tasks.h b/calendar/gui/e-tasks.h index 21660c8c7e..ed6fd8199f 100644 --- a/calendar/gui/e-tasks.h +++ b/calendar/gui/e-tasks.h @@ -49,6 +49,9 @@ struct _ETasks { struct _ETasksClass { GtkTableClass parent_class; + + /* Notification signals */ + void (* selection_changed) (ETasks *tasks, int n_selected); }; @@ -63,6 +66,7 @@ gboolean e_tasks_open (ETasks *tasks, CalClient *e_tasks_get_cal_client (ETasks *tasks); void e_tasks_new_task (ETasks *tasks); +void e_tasks_delete_selected (ETasks *tasks); void e_tasks_setup_menus (ETasks *tasks, BonoboUIComponent *uic); diff --git a/calendar/gui/tasks-control.c b/calendar/gui/tasks-control.c index d3154de0d6..5269f21cdf 100644 --- a/calendar/gui/tasks-control.c +++ b/calendar/gui/tasks-control.c @@ -59,7 +59,32 @@ static void tasks_control_deactivate (BonoboControl *control); static void tasks_control_new_task_cmd (BonoboUIComponent *uic, gpointer data, const char *path); +static void tasks_control_delete_cmd (BonoboUIComponent *uic, + gpointer data, + const char *path); + +/* Callback used when the selection in the table changes */ +static void +selection_changed_cb (ETasks *tasks, int n_selected, gpointer data) +{ + BonoboControl *control; + BonoboUIComponent *uic; + Bonobo_UIContainer ui_container; + + control = BONOBO_CONTROL (data); + + uic = bonobo_control_get_ui_component (control); + g_assert (uic != NULL); + + ui_container = bonobo_ui_component_get_container (uic); + if (ui_container == CORBA_OBJECT_NIL) + return; + + bonobo_ui_component_set_prop (uic, "/commands/TasksDelete", "sensitive", + n_selected == 0 ? "0" : "1", + NULL); +} BonoboControl * tasks_control_new (void) @@ -85,6 +110,9 @@ tasks_control_new (void) GTK_SIGNAL_FUNC (tasks_control_activate_cb), tasks); + gtk_signal_connect (GTK_OBJECT (tasks), "selection_changed", + GTK_SIGNAL_FUNC (selection_changed_cb), control); + return control; } @@ -180,6 +208,7 @@ tasks_control_activate_cb (BonoboControl *control, static BonoboUIVerb verbs [] = { BONOBO_UI_VERB ("TasksNewTask", tasks_control_new_task_cmd), + BONOBO_UI_VERB ("TasksDelete", tasks_control_delete_cmd), BONOBO_UI_VERB_END }; @@ -236,8 +265,19 @@ tasks_control_new_task_cmd (BonoboUIComponent *uic, gpointer data, const char *path) { - ETasks *tasks = data; + ETasks *tasks; + tasks = E_TASKS (data); e_tasks_new_task (tasks); } +static void +tasks_control_delete_cmd (BonoboUIComponent *uic, + gpointer data, + const char *path) +{ + ETasks *tasks; + + tasks = E_TASKS (data); + e_tasks_delete_selected (tasks); +} |