diff options
author | Matthew Barnes <mbarnes@src.gnome.org> | 2008-10-03 12:43:40 +0800 |
---|---|---|
committer | Matthew Barnes <mbarnes@src.gnome.org> | 2008-10-03 12:43:40 +0800 |
commit | 086a96050b16f6dabd99a391b5a4faf0411963a1 (patch) | |
tree | 73a4c2efb11f255ff1685114a051d731a6a12e13 /calendar/modules | |
parent | 791c982c456fca453978358d2e919082419b7808 (diff) | |
download | gsoc2013-evolution-086a96050b16f6dabd99a391b5a4faf0411963a1.tar gsoc2013-evolution-086a96050b16f6dabd99a391b5a4faf0411963a1.tar.gz gsoc2013-evolution-086a96050b16f6dabd99a391b5a4faf0411963a1.tar.bz2 gsoc2013-evolution-086a96050b16f6dabd99a391b5a4faf0411963a1.tar.lz gsoc2013-evolution-086a96050b16f6dabd99a391b5a4faf0411963a1.tar.xz gsoc2013-evolution-086a96050b16f6dabd99a391b5a4faf0411963a1.tar.zst gsoc2013-evolution-086a96050b16f6dabd99a391b5a4faf0411963a1.zip |
Tasks progress. Merge EMemoPreview back into ECalComponentPreview.
svn path=/branches/kill-bonobo/; revision=36538
Diffstat (limited to 'calendar/modules')
-rw-r--r-- | calendar/modules/e-cal-shell-module.c | 2 | ||||
-rw-r--r-- | calendar/modules/e-cal-shell-view.c | 1 | ||||
-rw-r--r-- | calendar/modules/e-memo-shell-content.c | 28 | ||||
-rw-r--r-- | calendar/modules/e-memo-shell-content.h | 5 | ||||
-rw-r--r-- | calendar/modules/e-memo-shell-module.c | 2 | ||||
-rw-r--r-- | calendar/modules/e-memo-shell-view-actions.c | 8 | ||||
-rw-r--r-- | calendar/modules/e-memo-shell-view-private.c | 23 | ||||
-rw-r--r-- | calendar/modules/e-memo-shell-view-private.h | 12 | ||||
-rw-r--r-- | calendar/modules/e-memo-shell-view.c | 1 | ||||
-rw-r--r-- | calendar/modules/e-task-shell-content.c | 28 | ||||
-rw-r--r-- | calendar/modules/e-task-shell-module.c | 76 | ||||
-rw-r--r-- | calendar/modules/e-task-shell-view-actions.c | 410 | ||||
-rw-r--r-- | calendar/modules/e-task-shell-view-actions.h | 46 | ||||
-rw-r--r-- | calendar/modules/e-task-shell-view-private.c | 247 | ||||
-rw-r--r-- | calendar/modules/e-task-shell-view-private.h | 33 | ||||
-rw-r--r-- | calendar/modules/e-task-shell-view.c | 142 |
16 files changed, 784 insertions, 280 deletions
diff --git a/calendar/modules/e-cal-shell-module.c b/calendar/modules/e-cal-shell-module.c index a655774c39..f5cdbe0f48 100644 --- a/calendar/modules/e-cal-shell-module.c +++ b/calendar/modules/e-cal-shell-module.c @@ -37,7 +37,6 @@ #define MODULE_NAME "calendar" #define MODULE_ALIASES "" #define MODULE_SCHEMES "calendar" -#define MODULE_SEARCHES "caltypes.xml" #define MODULE_SORT_ORDER 400 #define CONTACTS_BASE_URI "contacts://" @@ -371,7 +370,6 @@ static EShellModuleInfo module_info = { MODULE_NAME, MODULE_ALIASES, MODULE_SCHEMES, - MODULE_SEARCHES, MODULE_SORT_ORDER }; diff --git a/calendar/modules/e-cal-shell-view.c b/calendar/modules/e-cal-shell-view.c index 30c2ce8272..06e433be31 100644 --- a/calendar/modules/e-cal-shell-view.c +++ b/calendar/modules/e-cal-shell-view.c @@ -107,6 +107,7 @@ cal_shell_view_class_init (ECalShellView *class, shell_view_class->icon_name = "evolution-cals"; shell_view_class->ui_definition = "evolution-calendars.ui"; shell_view_class->search_options = "/calendar-search-options"; + shell_view_class->search_rules = "caltypes.xml"; shell_view_class->type_module = type_module; shell_view_class->new_shell_sidebar = e_cal_shell_sidebar_new; shell_view_class->update_actions = cal_shell_view_update_actions; diff --git a/calendar/modules/e-memo-shell-content.c b/calendar/modules/e-memo-shell-content.c index d893e47b43..ba3650d141 100644 --- a/calendar/modules/e-memo-shell-content.c +++ b/calendar/modules/e-memo-shell-content.c @@ -131,18 +131,19 @@ memo_shell_content_cursor_change_cb (EMemoShellContent *memo_shell_content, gint row, ETable *table) { - EMemoPreview *memo_preview; + ECalComponentPreview *memo_preview; EMemoTable *memo_table; ECalModel *model; ECalModelComponent *comp_data; ECalComponent *comp; const gchar *uid; - memo_preview = E_MEMO_PREVIEW (memo_shell_content->priv->memo_preview); + memo_preview = E_CAL_COMPONENT_PREVIEW ( + memo_shell_content->priv->memo_preview); memo_table = E_MEMO_TABLE (memo_shell_content->priv->memo_table); if (e_table_selected_count (table) != 1) { - e_memo_preview_clear (memo_preview); + e_cal_component_preview_clear (memo_preview); return; } @@ -153,7 +154,8 @@ memo_shell_content_cursor_change_cb (EMemoShellContent *memo_shell_content, comp = e_cal_component_new (); e_cal_component_set_icalcomponent ( comp, icalcomponent_new_clone (comp_data->icalcomp)); - e_memo_preview_display (memo_preview, comp_data->client, comp); + e_cal_component_preview_display ( + memo_preview, comp_data->client, comp); e_cal_component_get_uid (comp, &uid); g_free (memo_shell_content->priv->current_uid); @@ -166,14 +168,15 @@ static void memo_shell_content_selection_change_cb (EMemoShellContent *memo_shell_content, ETable *table) { - EMemoPreview *memo_preview; + ECalComponentPreview *memo_preview; - memo_preview = E_MEMO_PREVIEW (memo_shell_content->priv->memo_preview); + memo_preview = E_CAL_COMPONENT_PREVIEW ( + memo_shell_content->priv->memo_preview); /* XXX Old code emits a "selection-changed" signal here. */ if (e_table_selected_count (table) != 1) - e_memo_preview_clear (memo_preview); + e_cal_component_preview_clear (memo_preview); } static void @@ -341,9 +344,9 @@ memo_shell_content_constructed (GObject *object) container = widget; - widget = e_memo_preview_new (); - e_memo_preview_set_default_timezone ( - E_MEMO_PREVIEW (widget), + widget = e_cal_component_preview_new (); + e_cal_component_preview_set_default_timezone ( + E_CAL_COMPONENT_PREVIEW (widget), calendar_config_get_icaltimezone ()); gtk_container_add (GTK_CONTAINER (container), widget); priv->memo_preview = g_object_ref (widget); @@ -485,13 +488,14 @@ e_memo_shell_content_new (EShellView *shell_view) "shell-view", shell_view, NULL); } -EMemoPreview * +ECalComponentPreview * e_memo_shell_content_get_memo_preview (EMemoShellContent *memo_shell_content) { g_return_val_if_fail ( E_IS_MEMO_SHELL_CONTENT (memo_shell_content), NULL); - return E_MEMO_PREVIEW (memo_shell_content->priv->memo_preview); + return E_CAL_COMPONENT_PREVIEW ( + memo_shell_content->priv->memo_preview); } EMemoTable * diff --git a/calendar/modules/e-memo-shell-content.h b/calendar/modules/e-memo-shell-content.h index 50809772bc..3965c24e8d 100644 --- a/calendar/modules/e-memo-shell-content.h +++ b/calendar/modules/e-memo-shell-content.h @@ -25,8 +25,8 @@ #include <shell/e-shell-content.h> #include <shell/e-shell-view.h> -#include <calendar/gui/e-memo-preview.h> #include <calendar/gui/e-memo-table.h> +#include <calendar/gui/e-cal-component-preview.h> #include <widgets/menus/gal-view-instance.h> @@ -66,7 +66,8 @@ struct _EMemoShellContentClass { GType e_memo_shell_content_get_type (void); GtkWidget * e_memo_shell_content_new (EShellView *shell_view); -EMemoPreview * e_memo_shell_content_get_memo_preview +ECalComponentPreview * + e_memo_shell_content_get_memo_preview (EMemoShellContent *memo_shell_content); EMemoTable * e_memo_shell_content_get_memo_table (EMemoShellContent *memo_shell_content); diff --git a/calendar/modules/e-memo-shell-module.c b/calendar/modules/e-memo-shell-module.c index eceed252a7..0590479bdb 100644 --- a/calendar/modules/e-memo-shell-module.c +++ b/calendar/modules/e-memo-shell-module.c @@ -41,7 +41,6 @@ #define MODULE_NAME "memos" #define MODULE_ALIASES "" #define MODULE_SCHEMES "memo" -#define MODULE_SEARCHES "memotypes.xml" #define MODULE_SORT_ORDER 500 #define WEB_BASE_URI "webcal://" @@ -334,7 +333,6 @@ static EShellModuleInfo module_info = { MODULE_NAME, MODULE_ALIASES, MODULE_SCHEMES, - MODULE_SEARCHES, MODULE_SORT_ORDER }; diff --git a/calendar/modules/e-memo-shell-view-actions.c b/calendar/modules/e-memo-shell-view-actions.c index b63c008d6b..6ec64b15c6 100644 --- a/calendar/modules/e-memo-shell-view-actions.c +++ b/calendar/modules/e-memo-shell-view-actions.c @@ -79,7 +79,7 @@ action_memo_delete_cb (GtkAction *action, EMemoShellView *memo_shell_view) { EMemoShellContent *memo_shell_content; - EMemoPreview *memo_preview; + ECalComponentPreview *memo_preview; EMemoTable *memo_table; const gchar *status_message; @@ -92,7 +92,7 @@ action_memo_delete_cb (GtkAction *action, e_memo_table_delete_selected (memo_table); e_memo_shell_view_set_status_message (memo_shell_view, NULL); - e_memo_preview_clear (memo_preview); + e_cal_component_preview_clear (memo_preview); } static void @@ -258,7 +258,7 @@ action_memo_list_print_preview_cb (GtkAction *action, memo_table = e_memo_shell_content_get_memo_table (memo_shell_content); table = e_memo_table_get_table (memo_table); - print_action = GTK_PRINT_OPERATION_ACTION_PRINT_DIALOG; + print_action = GTK_PRINT_OPERATION_ACTION_PREVIEW; print_table (table, _("Print Memos"), _("Memos"), print_action); } @@ -292,6 +292,8 @@ action_memo_list_select_one_cb (GtkAction *action, ESource *primary; GSList *list, *iter; + /* XXX ESourceSelector should provide a function for this. */ + memo_shell_sidebar = memo_shell_view->priv->memo_shell_sidebar; selector = e_memo_shell_sidebar_get_selector (memo_shell_sidebar); primary = e_source_selector_peek_primary_selection (selector); diff --git a/calendar/modules/e-memo-shell-view-private.c b/calendar/modules/e-memo-shell-view-private.c index a78129dff2..04ee8eecc3 100644 --- a/calendar/modules/e-memo-shell-view-private.c +++ b/calendar/modules/e-memo-shell-view-private.c @@ -204,11 +204,6 @@ e_memo_shell_view_private_constructed (EMemoShellView *memo_shell_view) selector = e_memo_shell_sidebar_get_selector (memo_shell_sidebar); g_signal_connect_swapped ( - shell_sidebar, "status-message", - G_CALLBACK (e_memo_shell_view_set_status_message), - memo_shell_view); - - g_signal_connect_swapped ( memo_table, "open-component", G_CALLBACK (e_memo_shell_view_open_memo), memo_shell_view); @@ -249,16 +244,21 @@ e_memo_shell_view_private_constructed (EMemoShellView *memo_shell_view) memo_shell_view); g_signal_connect_swapped ( - shell_sidebar, "client-added", + memo_shell_sidebar, "client-added", G_CALLBACK (memo_shell_view_selector_client_added_cb), memo_shell_view); g_signal_connect_swapped ( - shell_sidebar, "client-removed", + memo_shell_sidebar, "client-removed", G_CALLBACK (memo_shell_view_selector_client_removed_cb), memo_shell_view); g_signal_connect_swapped ( + memo_shell_sidebar, "status-message", + G_CALLBACK (e_memo_shell_view_set_status_message), + memo_shell_view); + + g_signal_connect_swapped ( selector, "popup-event", G_CALLBACK (memo_shell_view_selector_popup_event_cb), memo_shell_view); @@ -315,7 +315,7 @@ e_memo_shell_view_execute_search (EMemoShellView *memo_shell_view) EShellContent *shell_content; GtkAction *action; GString *string; - EMemoPreview *memo_preview; + ECalComponentPreview *memo_preview; EMemoTable *memo_table; ECalModel *model; FilterRule *rule; @@ -371,7 +371,7 @@ e_memo_shell_view_execute_search (EMemoShellView *memo_shell_view) "(and (has-categories? #f) %s", query); g_free (query); query = temp; - } else if (value != MEMO_FILTER_ANY_CATEGORY) { + } else if (value >= 0) { GList *categories; const gchar *category_name; gchar *temp; @@ -401,8 +401,9 @@ e_memo_shell_view_execute_search (EMemoShellView *memo_shell_view) e_cal_model_set_search_query (model, query); g_free (query); - memo_preview = e_memo_shell_content_get_memo_preview (memo_shell_content); - e_memo_preview_clear (memo_preview); + memo_preview = + e_memo_shell_content_get_memo_preview (memo_shell_content); + e_cal_component_preview_clear (memo_preview); } void diff --git a/calendar/modules/e-memo-shell-view-private.h b/calendar/modules/e-memo-shell-view-private.h index 6d59301301..0a68ef1f98 100644 --- a/calendar/modules/e-memo-shell-view-private.h +++ b/calendar/modules/e-memo-shell-view-private.h @@ -35,8 +35,8 @@ #include "e-util/gconf-bridge.h" #include "calendar/gui/comp-util.h" +#include "calendar/gui/e-cal-component-preview.h" #include "calendar/gui/e-calendar-selector.h" -#include "calendar/gui/e-memo-preview.h" #include "calendar/gui/print.h" #include "calendar/gui/dialogs/calendar-setup.h" #include "calendar/gui/dialogs/copy-source-dialog.h" @@ -67,14 +67,14 @@ G_BEGIN_DECLS -/* List these in the order to be displayed. - * Positive values are reserved for categories. */ +/* Filter items are displayed in ascending order. + * Non-negative values are reserved for categories. */ enum { - MEMO_FILTER_ANY_CATEGORY = -2, - MEMO_FILTER_UNMATCHED = -1 + MEMO_FILTER_ANY_CATEGORY = -2, + MEMO_FILTER_UNMATCHED = -1 }; -/* List these in the order to be displayed. */ +/* Search items are displayed in ascending order. */ enum { MEMO_SEARCH_SUMMARY_CONTAINS, MEMO_SEARCH_DESCRIPTION_CONTAINS, diff --git a/calendar/modules/e-memo-shell-view.c b/calendar/modules/e-memo-shell-view.c index 06876f6db8..17a28fb0d8 100644 --- a/calendar/modules/e-memo-shell-view.c +++ b/calendar/modules/e-memo-shell-view.c @@ -199,6 +199,7 @@ memo_shell_view_class_init (EMemoShellView *class, shell_view_class->icon_name = "evolution-memos"; shell_view_class->ui_definition = "evolution-memos.ui"; shell_view_class->search_options = "/memo-search-options"; + shell_view_class->search_rules = "memotypes.xml"; shell_view_class->type_module = type_module; shell_view_class->new_shell_content = e_memo_shell_content_new; shell_view_class->new_shell_sidebar = e_memo_shell_sidebar_new; diff --git a/calendar/modules/e-task-shell-content.c b/calendar/modules/e-task-shell-content.c index 97ceafee28..7cf7da3e7c 100644 --- a/calendar/modules/e-task-shell-content.c +++ b/calendar/modules/e-task-shell-content.c @@ -131,18 +131,19 @@ task_shell_content_cursor_change_cb (ETaskShellContent *task_shell_content, gint row, ETable *table) { - ETaskPreview *task_preview; + ECalComponentPreview *task_preview; ETaskTable *task_table; ECalModel *model; ECalModelComponent *comp_data; ECalComponent *comp; const gchar *uid; - task_preview = E_TASK_PREVIEW (task_shell_content->priv->task_preview); + task_preview = E_CAL_COMPONENT_PREVIEW ( + task_shell_content->priv->task_preview); task_table = E_TASK_TABLE (task_shell_content->priv->task_table); if (e_table_selected_count (table) != 1) { - e_task_preview_clear (task_preview); + e_cal_component_preview_clear (task_preview); return; } @@ -153,7 +154,8 @@ task_shell_content_cursor_change_cb (ETaskShellContent *task_shell_content, comp = e_cal_component_new (); e_cal_component_set_icalcomponent ( comp, icalcomponent_new_clone (comp_data->icalcomp)); - e_task_preview_display (task_preview, comp_data->client, comp); + e_cal_component_preview_display ( + task_preview, comp_data->client, comp); e_cal_component_get_uid (comp, &uid); g_free (task_shell_content->priv->current_uid); @@ -166,14 +168,15 @@ static void task_shell_content_selection_change_cb (ETaskShellContent *task_shell_content, ETable *table) { - ETaskPreview *task_preview; + ECalComponentPreview *task_preview; - task_preview = E_TASK_PREVIEW (task_shell_content->priv->task_preview); + task_preview = E_CAL_COMPONENT_PREVIEW ( + task_shell_content->priv->task_preview); /* XXX Old code emits a "selection-changed" signal here. */ if (e_table_selected_count (table) != 1) - e_task_preview_clear (task_preview); + e_cal_component_preview_clear (task_preview); } static void @@ -340,9 +343,9 @@ task_shell_content_constructed (GObject *object) container = widget; - widget = e_task_preview_new (); - e_task_preview_set_default_timezone ( - E_TASK_PREVIEW (widget), + widget = e_cal_component_preview_new (); + e_cal_component_preview_set_default_timezone ( + E_CAL_COMPONENT_PREVIEW (widget), calendar_config_get_icaltimezone ()); gtk_container_add (GTK_CONTAINER (container), widget); priv->task_preview = g_object_ref (widget); @@ -484,13 +487,14 @@ e_task_shell_content_new (EShellView *shell_view) "shell-view", shell_view, NULL); } -ETaskPreview * +ECalComponentPreview * e_task_shell_content_get_task_preview (ETaskShellContent *task_shell_content) { g_return_val_if_fail ( E_IS_TASK_SHELL_CONTENT (task_shell_content), NULL); - return E_TASK_PREVIEW (task_shell_content->priv->task_preview); + return E_CAL_COMPONENT_PREVIEW ( + task_shell_content->priv->task_preview); } ETaskTable * diff --git a/calendar/modules/e-task-shell-module.c b/calendar/modules/e-task-shell-module.c index 59f9c9db86..4b062646fd 100644 --- a/calendar/modules/e-task-shell-module.c +++ b/calendar/modules/e-task-shell-module.c @@ -37,7 +37,6 @@ #define MODULE_NAME "tasks" #define MODULE_ALIASES "" #define MODULE_SCHEMES "task" -#define MODULE_SEARCHES "tasktypes.xml" #define MODULE_SORT_ORDER 600 #define WEB_BASE_URI "webcal://" @@ -194,21 +193,83 @@ task_module_ensure_sources (EShellModule *shell_module) } static void -action_task_new_cb (GtkAction *action, - EShellWindow *shell_window) +task_module_cal_opened_cb (ECal *cal, + ECalendarStatus status, + GtkAction *action) { + ECalComponent *comp; + CompEditor *editor; + CompEditorFlags flags = 0; + const gchar *action_name; + + /* XXX Handle errors better. */ + if (status != E_CALENDAR_STATUS_OK) + return; + + action_name = gtk_action_get_name (action); + + flags |= COMP_EDITOR_NEW_ITEM; + if (strcmp (action_name, "task-assigned-new") == 0) { + flags |= COMP_EDITOR_IS_ASSIGNED; + flags |= COMP_EDITOR_USER_ORG; + } + + editor = task_editor_new (cal, flags); + comp = cal_comp_task_new_with_defaults (cal); + comp_editor_edit_comp (editor, comp); + + gtk_window_present (GTK_WINDOW (editor)); + + g_object_unref (comp); + g_object_unref (cal); } static void -action_task_assigned_new_cb (GtkAction *action, - EShellWindow *shell_window) +action_task_new_cb (GtkAction *action, + EShellWindow *shell_window) { + ECal *cal = NULL; + ECalSourceType source_type; + ESourceList *source_list; + gchar *uid; + + /* This callback is used for both tasks and assigned tasks. */ + + source_type = E_CAL_SOURCE_TYPE_TODO; + + if (!e_cal_get_sources (&source_list, source_type, NULL)) { + g_warning ("Could not get task sources from GConf!"); + return; + } + + uid = calendar_config_get_primary_tasks (); + + if (uid != NULL) { + ESource *source; + + source = e_source_list_peek_source_by_uid (source_list, uid); + if (source != NULL) + cal = auth_new_cal_from_source (source, source_type); + g_free (uid); + } + + if (cal == NULL) + cal = auth_new_cal_from_default (source_type); + + g_return_if_fail (cal != NULL); + + g_signal_connect ( + cal, "cal-opened", + G_CALLBACK (task_module_cal_opened_cb), action); + + e_cal_open_async (cal, FALSE); } static void action_task_list_new_cb (GtkAction *action, EShellWindow *shell_window) { + calendar_setup_new_task_list (GTK_WINDOW (shell_window)); } static GtkActionEntry item_entries[] = { @@ -216,7 +277,7 @@ static GtkActionEntry item_entries[] = { { "task-new", "stock_task", N_("_Task"), /* XXX Need C_() here */ - "<Control>t", + "<Shift><Control>t", N_("Create a new task"), G_CALLBACK (action_task_new_cb) }, @@ -225,7 +286,7 @@ static GtkActionEntry item_entries[] = { N_("Assigne_d Task"), NULL, N_("Create a new assigned task"), - G_CALLBACK (action_task_assigned_new_cb) } + G_CALLBACK (action_task_new_cb) } }; static GtkActionEntry source_entries[] = { @@ -268,7 +329,6 @@ static EShellModuleInfo module_info = { MODULE_NAME, MODULE_ALIASES, MODULE_SCHEMES, - MODULE_SEARCHES, MODULE_SORT_ORDER }; diff --git a/calendar/modules/e-task-shell-view-actions.c b/calendar/modules/e-task-shell-view-actions.c index 0b787d6e25..f1b8cd40f7 100644 --- a/calendar/modules/e-task-shell-view-actions.c +++ b/calendar/modules/e-task-shell-view-actions.c @@ -22,6 +22,44 @@ #include "e-task-shell-view-private.h" static void +action_gal_save_custom_view_cb (GtkAction *action, + ETaskShellView *task_shell_view) +{ + ETaskShellContent *task_shell_content; + EShellView *shell_view; + GalViewInstance *view_instance; + + shell_view = E_SHELL_VIEW (task_shell_view); + if (!e_shell_view_is_active (shell_view)) + return; + + task_shell_content = task_shell_view->priv->task_shell_content; + view_instance = e_task_shell_content_get_view_instance (task_shell_content); + gal_view_instance_save_as (view_instance); +} + +static void +action_search_execute_cb (GtkAction *action, + ETaskShellView *task_shell_view) +{ + EShellView *shell_view; + + shell_view = E_SHELL_VIEW (task_shell_view); + if (!e_shell_view_is_active (shell_view)) + return; + + e_task_shell_view_execute_search (task_shell_view); +} + +static void +action_search_filter_cb (GtkRadioAction *action, + GtkRadioAction *current, + ETaskShellView *task_shell_view) +{ + e_task_shell_view_execute_search (task_shell_view); +} + +static void action_task_assign_cb (GtkAction *action, ETaskShellView *task_shell_view) { @@ -85,7 +123,7 @@ action_task_delete_cb (GtkAction *action, ETaskShellView *task_shell_view) { ETaskShellContent *task_shell_content; - ETaskPreview *task_preview; + ECalComponentPreview *task_preview; ETaskTable *task_table; const gchar *status_message; @@ -98,7 +136,7 @@ action_task_delete_cb (GtkAction *action, e_task_table_delete_selected (task_table); e_task_shell_view_set_status_message (task_shell_view, NULL); - e_task_preview_clear (task_preview); + e_cal_component_preview_clear (task_preview); } static void @@ -134,20 +172,104 @@ static void action_task_list_copy_cb (GtkAction *action, ETaskShellView *task_shell_view) { - /* FIXME */ + ETaskShellSidebar *task_shell_sidebar; + EShellWindow *shell_window; + EShellView *shell_view; + ESourceSelector *selector; + ESource *source; + + shell_view = E_SHELL_VIEW (task_shell_view); + shell_window = e_shell_view_get_shell_window (shell_view); + + task_shell_sidebar = task_shell_view->priv->task_shell_sidebar; + selector = e_task_shell_sidebar_get_selector (task_shell_sidebar); + source = e_source_selector_peek_primary_selection (selector); + g_return_if_fail (E_IS_SOURCE (source)); + + copy_source_dialog ( + GTK_WINDOW (shell_window), + source, E_CAL_SOURCE_TYPE_TODO); } static void action_task_list_delete_cb (GtkAction *action, ETaskShellView *task_shell_view) { - /* FIXME */ + ETaskShellContent *task_shell_content; + ETaskShellSidebar *task_shell_sidebar; + EShellWindow *shell_window; + EShellView *shell_view; + ETaskTable *task_table; + ECal *client; + ECalModel *model; + ESourceSelector *selector; + ESourceGroup *source_group; + ESourceList *source_list; + ESource *source; + gint response; + gchar *uri; + GError *error = NULL; + + shell_view = E_SHELL_VIEW (task_shell_view); + shell_window = e_shell_view_get_shell_window (shell_view); + + task_shell_content = task_shell_view->priv->task_shell_content; + task_table = e_task_shell_content_get_task_table (task_shell_content); + model = e_task_table_get_model (task_table); + + task_shell_sidebar = task_shell_view->priv->task_shell_sidebar; + selector = e_task_shell_sidebar_get_selector (task_shell_sidebar); + source = e_source_selector_peek_primary_selection (selector); + g_return_if_fail (E_IS_SOURCE (source)); + + /* Ask for confirmation. */ + response = e_error_run ( + GTK_WINDOW (shell_window), + "calendar:prompt-delete-task-list", + e_source_peek_name (source)); + if (response != GTK_RESPONSE_YES) + return; + + uri = e_source_get_uri (source); + client = e_cal_model_get_client_for_uri (model, uri); + if (client == NULL) + client = e_cal_new_from_uri (uri, E_CAL_SOURCE_TYPE_JOURNAL); + g_free (uri); + + g_return_if_fail (client != NULL); + + if (!e_cal_remove (client, &error)) { + g_warning ("%s", error->message); + g_error_free (error); + return; + } + + if (e_source_selector_source_is_selected (selector, source)) { + e_task_shell_sidebar_remove_source ( + task_shell_sidebar, source); + e_source_selector_unselect_source (selector, source); + } + + source_group = e_source_peek_group (source); + e_source_group_remove_source (source_group, source); + + source_list = task_shell_view->priv->source_list; + if (!e_source_list_sync (source_list, &error)) { + g_warning ("%s", error->message); + g_error_free (error); + } } static void action_task_list_new_cb (GtkAction *action, ETaskShellView *task_shell_view) { + EShellView *shell_view; + EShellWindow *shell_window; + + shell_view = E_SHELL_VIEW (task_shell_view); + shell_window = e_shell_view_get_shell_window (shell_view); + calendar_setup_new_task_list (GTK_WINDOW (shell_window)); } static void @@ -157,14 +279,14 @@ action_task_list_print_cb (GtkAction *action, ETaskShellContent *task_shell_content; ETaskTable *task_table; ETable *table; + GtkPrintOperationAction print_action; task_shell_content = task_shell_view->priv->task_shell_content; task_table = e_task_shell_content_get_task_table (task_shell_content); table = e_task_table_get_table (task_table); - print_table ( - table, _("Print Tasks"), _("Tasks"), - GTK_PRINT_OPERATION_ACTION_PRINT_DIALOG); + print_action = GTK_PRINT_OPERATION_ACTION_PRINT_DIALOG; + print_table (table, _("Print Tasks"), _("Tasks"), print_action); } static void @@ -174,20 +296,65 @@ action_task_list_print_preview_cb (GtkAction *action, ETaskShellContent *task_shell_content; ETaskTable *task_table; ETable *table; + GtkPrintOperationAction print_action; task_shell_content = task_shell_view->priv->task_shell_content; task_table = e_task_shell_content_get_task_table (task_shell_content); table = e_task_table_get_table (task_table); - print_table ( - table, _("Print Tasks"), _("Tasks"), - GTK_PRINT_OPERATION_ACTION_PREVIEW); + print_action = GTK_PRINT_OPERATION_ACTION_PREVIEW; + print_table (table, _("Print Tasks"), _("Tasks"), print_action); } static void action_task_list_properties_cb (GtkAction *action, ETaskShellView *task_shell_view) { + ETaskShellSidebar *task_shell_sidebar; + EShellView *shell_view; + EShellWindow *shell_window; + ESource *source; + ESourceSelector *selector; + + shell_view = E_SHELL_VIEW (task_shell_view); + shell_window = e_shell_view_get_shell_window (shell_view); + + task_shell_sidebar = task_shell_view->priv->task_shell_sidebar; + selector = e_task_shell_sidebar_get_selector (task_shell_sidebar); + source = e_source_selector_peek_primary_selection (selector); + g_return_if_fail (E_IS_SOURCE (source)); + + calendar_setup_edit_task_list (GTK_WINDOW (shell_window), source); +} + +static void +action_task_list_select_one_cb (GtkAction *action, + ETaskShellView *task_shell_view) +{ + ETaskShellSidebar *task_shell_sidebar; + ESourceSelector *selector; + ESource *primary; + GSList *list, *iter; + + /* XXX ESourceSelector should provide a function for this. */ + + task_shell_sidebar = task_shell_view->priv->task_shell_sidebar; + selector = e_task_shell_sidebar_get_selector (task_shell_sidebar); + primary = e_source_selector_peek_primary_selection (selector); + g_return_if_fail (primary != NULL); + + list = e_source_selector_get_selection (selector); + for (iter = list; iter != NULL; iter = iter->next) { + ESource *source = iter->data; + + if (source == primary) + continue; + + e_source_selector_unselect_source (selector, source); + } + e_source_selector_free_selection (list); + + e_source_selector_select_source (selector, primary); } static void @@ -238,6 +405,31 @@ static void action_task_new_cb (GtkAction *action, ETaskShellView *task_shell_view) { + ETaskShellContent *task_shell_content; + ETaskTable *task_table; + ECalModelComponent *comp_data; + ECal *client; + ECalComponent *comp; + CompEditor *editor; + GSList *list; + + task_shell_content = task_shell_view->priv->task_shell_content; + task_table = e_task_shell_content_get_task_table (task_shell_content); + + list = e_task_table_get_selected (task_table); + g_return_if_fail (list != NULL); + comp_data = list->data; + g_slist_free (list); + + client = comp_data->client; + editor = task_editor_new (client, COMP_EDITOR_NEW_ITEM); + comp = cal_comp_task_new_with_defaults (client); + comp_editor_edit_comp (editor, comp); + + gtk_window_present (GTK_WINDOW (editor)); + + g_object_unref (comp); + g_object_unref (client); } static void @@ -246,11 +438,19 @@ action_task_open_cb (GtkAction *action, { ETaskShellContent *task_shell_content; ETaskTable *task_table; + ECalModelComponent *comp_data; + GSList *list; task_shell_content = task_shell_view->priv->task_shell_content; task_table = e_task_shell_content_get_task_table (task_shell_content); - e_task_table_open_selected (task_table); + list = e_task_table_get_selected (task_table); + g_return_if_fail (list != NULL); + comp_data = list->data; + g_slist_free (list); + + /* XXX We only open the first selected task. */ + e_task_shell_view_open_task (task_shell_view, comp_data); } static void @@ -464,6 +664,13 @@ static GtkActionEntry task_entries[] = { N_("Mark selected tasks as complete"), G_CALLBACK (action_task_mark_complete_cb) }, + { "task-mark-incomplete", + NULL, + N_("Mar_k as Incomplete"), + NULL, + N_("Mark selected tasks as incomplete"), + G_CALLBACK (action_task_mark_incomplete_cb) }, + { "task-new", "stock_task", N_("New _Task"), @@ -518,6 +725,75 @@ static GtkToggleActionEntry task_toggle_entries[] = { TRUE } }; +static GtkRadioActionEntry task_filter_entries[] = { + + { "task-filter-active-tasks", + NULL, + N_("Active Tasks"), + NULL, + NULL, /* XXX Add a tooltip! */ + TASK_FILTER_ACTIVE_TASKS }, + + { "task-filter-any-category", + NULL, + N_("Any Category"), + NULL, + NULL, /* XXX Add a tooltip! */ + TASK_FILTER_ANY_CATEGORY }, + + { "task-filter-completed-tasks", + NULL, + N_("Completed Tasks"), + NULL, + NULL, /* XXX Add a tooltip! */ + TASK_FILTER_COMPLETED_TASKS }, + + { "task-filter-next-7-days-tasks", + NULL, + N_("Next 7 Days' Tasks"), + NULL, + NULL, /* XXX Add a tooltip! */ + TASK_FILTER_NEXT_7_DAYS_TASKS }, + + { "task-filter-overdue-tasks", + NULL, + N_("Overdue Tasks"), + NULL, + NULL, /* XXX Add a tooltip! */ + TASK_FILTER_OVERDUE_TASKS }, + + { "task-filter-tasks-with-attachments", + NULL, + N_("Tasks with Attachments"), + NULL, + NULL, /* XXX Add a tooltip! */ + TASK_FILTER_TASKS_WITH_ATTACHMENTS } +}; + +static GtkRadioActionEntry task_search_entries[] = { + + { "task-search-any-field-contains", + NULL, + N_("Any field contains"), + NULL, + NULL, /* XXX Add a tooltip! */ + TASK_SEARCH_ANY_FIELD_CONTAINS }, + + { "task-search-description-contains", + NULL, + N_("Description contains"), + NULL, + NULL, /* XXX Add a tooltip! */ + TASK_SEARCH_DESCRIPTION_CONTAINS }, + + { "task-search-summary-contains", + NULL, + N_("Summary contains"), + NULL, + NULL, /* XXX Add a tooltip! */ + TASK_SEARCH_SUMMARY_CONTAINS } +}; + void e_task_shell_view_actions_init (ETaskShellView *task_shell_view) { @@ -536,8 +812,6 @@ e_task_shell_view_actions_init (ETaskShellView *task_shell_view) manager = e_shell_window_get_ui_manager (shell_window); domain = GETTEXT_PACKAGE; - e_load_ui_definition (manager, "evolution-tasks.ui"); - action_group = task_shell_view->priv->task_actions; gtk_action_group_set_translation_domain (action_group, domain); gtk_action_group_add_actions ( @@ -546,6 +820,11 @@ e_task_shell_view_actions_init (ETaskShellView *task_shell_view) gtk_action_group_add_toggle_actions ( action_group, task_toggle_entries, G_N_ELEMENTS (task_toggle_entries), task_shell_view); + gtk_action_group_add_radio_actions ( + action_group, task_search_entries, + G_N_ELEMENTS (task_search_entries), + TASK_SEARCH_SUMMARY_CONTAINS, + NULL, NULL); gtk_ui_manager_insert_action_group (manager, action_group, 0); /* Bind GObject properties to GConf keys. */ @@ -560,58 +839,71 @@ e_task_shell_view_actions_init (ETaskShellView *task_shell_view) action = ACTION (TASK_DELETE); g_object_set (action, "short-label", _("Delete"), NULL); + + g_signal_connect ( + ACTION (GAL_SAVE_CUSTOM_VIEW), "activate", + G_CALLBACK (action_gal_save_custom_view_cb), task_shell_view); + + g_signal_connect ( + ACTION (SEARCH_EXECUTE), "activate", + G_CALLBACK (action_search_execute_cb), task_shell_view); } void -e_task_shell_view_actions_update (ETaskShellView *task_shell_view) +e_task_shell_view_update_search_filter (ETaskShellView *task_shell_view) { - ETaskShellContent *task_shell_content; - ECal *client; - ETable *table; - ECalModel *model; - ETaskTable *task_table; + EShellContent *shell_content; EShellView *shell_view; - EShellWindow *shell_window; - GtkAction *action; - const gchar *label; - gboolean read_only = TRUE; - gboolean sensitive; - gint n_selected; + GtkActionGroup *action_group; + GtkRadioAction *radio_action; + GList *list, *iter; + GSList *group; + gint ii; shell_view = E_SHELL_VIEW (task_shell_view); - shell_window = e_shell_view_get_shell_window (shell_view); - - task_shell_content = task_shell_view->priv->task_shell_content; - task_table = e_task_shell_content_get_task_table (task_shell_content); - - model = e_task_table_get_model (task_table); - client = e_cal_model_get_default_client (model); - - table = e_task_table_get_table (task_table); - n_selected = e_table_selected_count (table); - - if (client != NULL) - e_cal_is_read_only (client, &read_only, NULL); - - action = ACTION (TASK_OPEN); - sensitive = (n_selected == 1); - gtk_action_set_sensitive (action, sensitive); - - action = ACTION (TASK_CLIPBOARD_COPY); - sensitive = (n_selected > 0); - gtk_action_set_sensitive (action, sensitive); - - action = ACTION (TASK_CLIPBOARD_CUT); - sensitive = (n_selected > 0); - gtk_action_set_sensitive (action, sensitive); - - action = ACTION (TASK_CLIPBOARD_PASTE); - sensitive = (n_selected > 0); - gtk_action_set_sensitive (action, sensitive); + shell_content = e_shell_view_get_shell_content (shell_view); + action_group = task_shell_view->priv->filter_actions; + + e_action_group_remove_all_actions (action_group); + + /* Add the standard filter actions. */ + gtk_action_group_add_radio_actions ( + action_group, task_filter_entries, + G_N_ELEMENTS (task_filter_entries), + TASK_FILTER_ANY_CATEGORY, + G_CALLBACK (action_search_filter_cb), + task_shell_view); + + /* Retrieve the radio group from an action we just added. */ + list = gtk_action_group_list_actions (action_group); + radio_action = GTK_RADIO_ACTION (list->data); + group = gtk_radio_action_get_group (radio_action); + g_list_free (list); + + /* Build the category actions. */ + + list = e_categories_get_list (); + for (iter = list, ii = 0; iter != NULL; iter = iter->next, ii++) { + const gchar *category_name = iter->data; + GtkAction *action; + gchar *action_name; + + action_name = g_strdup_printf ( + "task-filter-category-%d", ii); + radio_action = gtk_radio_action_new ( + action_name, category_name, NULL, NULL, ii); + g_free (action_name); + + gtk_radio_action_set_group (radio_action, group); + group = gtk_radio_action_get_group (radio_action); + + /* The action group takes ownership of the action. */ + action = GTK_ACTION (radio_action); + gtk_action_group_add_action (action_group, action); + g_object_unref (radio_action); + } + g_list_free (list); - action = ACTION (TASK_DELETE); - sensitive = (n_selected > 0) && !read_only; - gtk_action_set_sensitive (action, sensitive); - label = ngettext ("Delete Task", "Delete Tasks", n_selected); - g_object_set (action, "label", label, NULL); + /* Use any action in the group; doesn't matter which. */ + e_shell_content_set_filter_action (shell_content, radio_action); } diff --git a/calendar/modules/e-task-shell-view-actions.h b/calendar/modules/e-task-shell-view-actions.h index dd09220f28..0b7212e469 100644 --- a/calendar/modules/e-task-shell-view-actions.h +++ b/calendar/modules/e-task-shell-view-actions.h @@ -39,16 +39,58 @@ E_SHELL_WINDOW_ACTION ((window), "task-forward") #define E_SHELL_WINDOW_ACTION_TASK_MARK_COMPLETE(window) \ E_SHELL_WINDOW_ACTION ((window), "task-mark-complete") +#define E_SHELL_WINDOW_ACTION_TASK_MARK_INCOMPLETE(window) \ + E_SHELL_WINDOW_ACTION ((window), "task-mark-incomplete") +#define E_SHELL_WINDOW_ACTION_TASK_NEW(window) \ + E_SHELL_WINDOW_ACTION ((window), "task-new") #define E_SHELL_WINDOW_ACTION_TASK_OPEN(window) \ E_SHELL_WINDOW_ACTION ((window), "task-open") +#define E_SHELL_WINDOW_ACTION_TASK_OPEN_URL(window) \ + E_SHELL_WINDOW_ACTION ((window), "task-open-url") #define E_SHELL_WINDOW_ACTION_TASK_PREVIEW(window) \ E_SHELL_WINDOW_ACTION ((window), "task-preview") #define E_SHELL_WINDOW_ACTION_TASK_PRINT(window) \ E_SHELL_WINDOW_ACTION ((window), "task-print") -#define E_SHELL_WINDOW_ACTION_TASK_PRINT_PREVIEW(window) \ - E_SHELL_WINDOW_ACTION ((window), "task-print-preview") #define E_SHELL_WINDOW_ACTION_TASK_PURGE(window) \ E_SHELL_WINDOW_ACTION ((window), "task-purge") +#define E_SHELL_WINDOW_ACTION_TASK_SAVE_AS(window) \ + E_SHELL_WINDOW_ACTION ((window), "task-save-as") + +/* Task List Actions */ +#define E_SHELL_WINDOW_ACTION_TASK_LIST_COPY(window) \ + E_SHELL_WINDOW_ACTION ((window), "task-list-copy") +#define E_SHELL_WINDOW_ACTION_TASK_LIST_DELETE(window) \ + E_SHELL_WINDOW_ACTION ((window), "task-list-delete") +#define E_SHELL_WINDOW_ACTION_TASK_LIST_NEW(window) \ + E_SHELL_WINDOW_ACTION ((window), "task-list-new") +#define E_SHELL_WINDOW_ACTION_TASK_LIST_PRINT(window) \ + E_SHELL_WINDOW_ACTION ((window), "task-list-print") +#define E_SHELL_WINDOW_ACTION_TASK_LIST_PRINT_PREVIEW(window) \ + E_SHELL_WINDOW_ACTION ((window), "task-list-print-preview") +#define E_SHELL_WINDOW_ACTION_TASK_LIST_PROPERTIES(window) \ + E_SHELL_WINDOW_ACTION ((window), "task-list-properties") + +/* Task Query Actions */ +#define E_SHELL_WINDOW_ACTION_TASK_FILTER_ACTIVE_TASKS(window) \ + E_SHELL_WINDOW_ACTION ((window), "task-filter-active-tasks") +#define E_SHELL_WINDOW_ACTION_TASK_FILTER_ANY_CATEGORY(window) \ + E_SHELL_WINDOW_ACTION ((window), "task-filter-any-category") +#define E_SHELL_WINDOW_ACTION_TASK_FILTER_COMPLETED_TASKS(window) \ + E_SHELL_WINDOW_ACTION ((window), "task-filter-completed-tasks") +#define E_SHELL_WINDOW_ACTION_TASK_FILTER_NEXT_7_DAYS_TASKS(window) \ + E_SHELL_WINDOW_ACTION ((window), "task-filter-next-7-days-tasks") +#define E_SHELL_WINDOW_ACTION_TASK_FILTER_OVERDUE_TASKS(window) \ + E_SHELL_WINDOW_ACTION ((window), "task-filter-overdue-tasks") +#define E_SHELL_WINDOW_ACTION_TASK_FILTER_TASKS_WITH_ATTACHMENTS(window) \ + E_SHELL_WINDOW_ACTION ((window), "task-filter-tasks-with-attachments") +#define E_SHELL_WINDOW_ACTION_TASK_FILTER_UNMATCHED(window) \ + E_SHELL_WINDOW_ACTION ((window), "task-filter-unmatched") +#define E_SHELL_WINDOW_ACTION_TASK_SEARCH_ANY_FIELD_CONTAINS(window) \ + E_SHELL_WINDOW_ACTION ((window), "task-search-any-field-contains") +#define E_SHELL_WINDOW_ACTION_TASK_SEARCH_DESCRIPTION_CONTAINS(window) \ + E_SHELL_WINDOW_ACTION ((window), "task-search-description-contains") +#define E_SHELL_WINDOW_ACTION_TASK_SEARCH_SUMMARY_CONTAINS(window) \ + E_SHELL_WINDOW_ACTION ((window), "task-search-summary-contains") /* Action Groups */ #define E_SHELL_WINDOW_ACTION_GROUP_TASKS(window) \ diff --git a/calendar/modules/e-task-shell-view-private.c b/calendar/modules/e-task-shell-view-private.c index d41f6e6033..741913f05a 100644 --- a/calendar/modules/e-task-shell-view-private.c +++ b/calendar/modules/e-task-shell-view-private.c @@ -24,175 +24,77 @@ #include <widgets/menus/gal-view-factory-etable.h> static void -task_shell_view_backend_died_cb (ETaskShellView *task_shell_view, - ECal *client) +task_shell_view_table_popup_event_cb (EShellView *shell_view, + GdkEventButton *event) { - EShellView *shell_view; - EShellWindow *shell_window; - GHashTable *client_table; - ESource *source; - const gchar *uid; - - shell_view = E_SHELL_VIEW (task_shell_view); - shell_window = e_shell_view_get_shell_window (shell_view); - - source = e_cal_get_source (client); - uid = e_source_peek_uid (source); - - g_object_ref (source); - - g_hash_table_remove (client_table, uid); - e_task_shell_view_set_status_message (task_shell_view, NULL); - - e_error_run ( - GTK_WINDOW (shell_window), - "calendar:tasks-crashed", NULL); + const gchar *widget_path; - g_object_unref (source); + widget_path = "/task-popup"; + e_shell_view_show_popup_menu (shell_view, widget_path, event); } static void -task_shell_view_backend_error_cb (ETaskShellView *task_shell_view, - const gchar *message, - ECal *client) +task_shell_view_table_user_created_cb (ETaskShellView *task_shell_view, + ETaskTable *task_table) { - EShellView *shell_view; - EShellWindow *shell_window; - GtkWidget *dialog; - const gchar *uri; - gchar *uri_no_passwd; - - shell_view = E_SHELL_VIEW (task_shell_view); - shell_window = e_shell_view_get_shell_window (shell_view); + ETaskShellSidebar *task_shell_sidebar; + ECalModel *model; + ECal *client; + ESource *source; - uri = e_cal_get_uri (client); - uri_no_passwd = get_uri_without_password (uri); + /* This is the "Click to Add" handler. */ - dialog = gtk_message_dialog_new ( - GTK_WINDOW (shell_window), - GTK_DIALOG_DESTROY_WITH_PARENT, - GTK_MESSAGE_ERROR, GTK_BUTTONS_OK, - _("Error on %s:\n%s"), - uri_no_passwd, message); + model = e_task_table_get_model (task_table); + client = e_cal_model_get_default_client (model); + source = e_cal_get_source (client); - gtk_dialog_run (GTK_DIALOG (dialog)); - gtk_widget_destroy (dialog); + task_shell_sidebar = task_shell_view->priv->task_shell_sidebar; + e_task_shell_sidebar_add_source (task_shell_sidebar, source); - g_free (uri_no_passwd); + e_cal_model_add_client (model, client); } static void -task_shell_view_client_opened_cb (ETaskShellView *task_shell_view, - ECalendarStatus status, - ECal *client) -{ - /* FIXME */ -} - -static gboolean -task_shell_view_add_source (ETaskShellView *task_shell_view, - ESource *source) +task_shell_view_selector_client_added_cb (ETaskShellView *task_shell_view, + ECal *client) { - ETaskShellSidebar *task_shell_sidebar; - ESourceSelector *selector; - GHashTable *client_table; - ECal *default_client; - ECal *client; - const gchar *uid; - const gchar *uri; - gchar *status_message; - - client_table = task_shell_view->priv->client_table; - default_client = task_shell_view->priv->default_client; - - uid = e_source_peek_uid (source); - client = g_hash_table_lookup (client_table, uid); - - if (client != NULL) - return TRUE; - - if (default_client != NULL) { - ESource *default_source; - const gchar *default_uid; - - default_source = e_cal_get_source (default_client); - default_uid = e_source_peek_uid (default_source); - - if (strcmp (uid, default_uid) == 0) - client = g_object_ref (default_client); - } - - if (client == NULL) - client = auth_new_cal_from_source ( - source, E_CAL_SOURCE_TYPE_TODO); - - if (client == NULL) - return FALSE; - - g_signal_connect_swapped ( - client, "backend-died", - G_CALLBACK (task_shell_view_backend_died_cb), - task_shell_view); - - g_signal_connect_swapped ( - client, "backend-error", - G_CALLBACK (task_shell_view_backend_error_cb), - task_shell_view); - - g_hash_table_insert (client_table, g_strdup (uid), client); - - uri = e_cal_get_uri (client); - - status_message = g_strdup_printf (_("Opening tasks at %s"), uri); - e_task_shell_view_set_status_message (task_shell_view, status_message); - g_free (status_message); - - task_shell_sidebar = task_shell_view->priv->task_shell_sidebar; - selector = e_task_shell_sidebar_get_selector (task_shell_sidebar); - e_source_selector_select_source (selector, source); - - g_signal_connect_swapped ( - client, "cal-opened", - G_CALLBACK (task_shell_view_client_opened_cb), - task_shell_view); + ETaskShellContent *task_shell_content; + ETaskTable *task_table; + ECalModel *model; - e_cal_open_async (client, FALSE); + task_shell_content = task_shell_view->priv->task_shell_content; + task_table = e_task_shell_content_get_task_table (task_shell_content); + model = e_task_table_get_model (task_table); - return TRUE; + e_cal_model_add_client (model, client); } static void -task_shell_view_table_popup_event_cb (ETaskShellView *task_shell_view, - GdkEventButton *event) +task_shell_view_selector_client_removed_cb (ETaskShellView *task_shell_view, + ECal *client) { - EShellView *shell_view; - const gchar *widget_path; + ETaskShellContent *task_shell_content; + ETaskTable *task_table; + ECalModel *model; - shell_view = E_SHELL_VIEW (task_shell_view); - widget_path = "/task-popup"; + task_shell_content = task_shell_view->priv->task_shell_content; + task_table = e_task_shell_content_get_task_table (task_shell_content); + model = e_task_table_get_model (task_table); - e_task_shell_view_actions_update (task_shell_view); - e_shell_view_show_popup_menu (shell_view, widget_path, event); + e_cal_model_remove_client (model, client); } -static void -task_shell_view_table_user_created (ETaskShellView *task_shell_view, - ETaskTable *task_table) +static gboolean +task_shell_view_selector_popup_event_cb (EShellView *shell_view, + ESource *primary_source, + GdkEventButton *event) { - ECal *client; - ESource *source; - - if (task_table->user_created_cal != NULL) - client = task_table->user_created_cal; - else { - ECalModel *model; + const gchar *widget_path; - model = e_task_table_get_model (task_table); - client = e_cal_model_get_default_client (model); - } + widget_path = "/task-list-popup"; + e_shell_view_show_popup_menu (shell_view, widget_path, event); - source = e_cal_get_source (client); - task_shell_view_add_source (task_shell_view, source); + return TRUE; } static void @@ -251,21 +153,15 @@ e_task_shell_view_private_init (ETaskShellView *task_shell_view, { ETaskShellViewPrivate *priv = task_shell_view->priv; ESourceList *source_list; - GHashTable *client_table; GObject *object; object = G_OBJECT (shell_view_class->type_module); source_list = g_object_get_data (object, "source-list"); g_return_if_fail (E_IS_SOURCE_LIST (source_list)); - client_table = g_hash_table_new_full ( - g_str_hash, g_str_equal, - (GDestroyNotify) g_free, - (GDestroyNotify) g_object_unref); - priv->source_list = g_object_ref (source_list); priv->task_actions = gtk_action_group_new ("tasks"); - priv->client_table = client_table; + priv->filter_actions = gtk_action_group_new ("tasks-filter"); if (!gal_view_collection_loaded (shell_view_class->view_collection)) task_shell_view_load_view_collection (shell_view_class); @@ -280,14 +176,18 @@ e_task_shell_view_private_constructed (ETaskShellView *task_shell_view) { ETaskShellViewPrivate *priv = task_shell_view->priv; ETaskShellContent *task_shell_content; + ETaskShellSidebar *task_shell_sidebar; + EShellView *shell_view; + EShellWindow *shell_window; EShellContent *shell_content; EShellSidebar *shell_sidebar; - EShellView *shell_view; ETaskTable *task_table; ECalModel *model; ETable *table; + ESourceSelector *selector; shell_view = E_SHELL_VIEW (task_shell_view); + shell_window = e_shell_view_get_shell_window (shell_view); shell_content = e_shell_view_get_shell_content (shell_view); shell_sidebar = e_shell_view_get_shell_sidebar (shell_view); @@ -300,6 +200,9 @@ e_task_shell_view_private_constructed (ETaskShellView *task_shell_view) model = e_task_table_get_model (task_table); table = e_task_table_get_table (task_table); + task_shell_sidebar = E_TASK_SHELL_SIDEBAR (shell_sidebar); + selector = e_task_shell_sidebar_get_selector (task_shell_sidebar); + g_signal_connect_swapped ( task_table, "open-component", G_CALLBACK (e_task_shell_view_open_task), @@ -340,8 +243,40 @@ e_task_shell_view_private_constructed (ETaskShellView *task_shell_view) G_CALLBACK (e_task_shell_view_update_sidebar), task_shell_view); + g_signal_connect_swapped ( + task_shell_sidebar, "client-added", + G_CALLBACK (task_shell_view_selector_client_added_cb), + task_shell_view); + + g_signal_connect_swapped ( + task_shell_sidebar, "client-removed", + G_CALLBACK (task_shell_view_selector_client_removed_cb), + task_shell_view); + + g_signal_connect_swapped ( + task_shell_sidebar, "status-message", + G_CALLBACK (e_task_shell_view_set_status_message), + task_shell_view); + + g_signal_connect_swapped ( + selector, "popup-event", + G_CALLBACK (task_shell_view_selector_popup_event_cb), + task_shell_view); + + g_signal_connect_swapped ( + selector, "primary-selection-changed", + G_CALLBACK (e_shell_view_update_actions), + task_shell_view); + + e_categories_register_change_listener ( + G_CALLBACK (e_task_shell_view_update_search_filter), + task_shell_view); + e_task_shell_view_actions_init (task_shell_view); e_task_shell_view_update_sidebar (task_shell_view); + e_task_shell_view_update_search_filter (task_shell_view); + + e_task_shell_view_execute_search (task_shell_view); } void @@ -352,13 +287,11 @@ e_task_shell_view_private_dispose (ETaskShellView *task_shell_view) DISPOSE (priv->source_list); DISPOSE (priv->task_actions); + DISPOSE (priv->filter_actions); DISPOSE (priv->task_shell_content); DISPOSE (priv->task_shell_sidebar); - g_hash_table_remove_all (priv->client_table); - DISPOSE (priv->default_client); - if (task_shell_view->priv->activity != NULL) { /* XXX Activity is no cancellable. */ e_activity_complete (task_shell_view->priv->activity); @@ -370,9 +303,13 @@ e_task_shell_view_private_dispose (ETaskShellView *task_shell_view) void e_task_shell_view_private_finalize (ETaskShellView *task_shell_view) { - ETaskShellViewPrivate *priv = task_shell_view->priv; + /* XXX Nothing to do? */ +} - g_hash_table_destroy (priv->client_table); +void +e_task_shell_view_execute_search (ETaskShellView *task_shell_view) +{ + /* FIXME */ } void diff --git a/calendar/modules/e-task-shell-view-private.h b/calendar/modules/e-task-shell-view-private.h index ed55a794df..ac198b936d 100644 --- a/calendar/modules/e-task-shell-view-private.h +++ b/calendar/modules/e-task-shell-view-private.h @@ -26,15 +26,18 @@ #include <string.h> #include <glib/gi18n.h> +#include <libedataserver/e-categories.h> +#include <libedataserver/e-sexp.h> #include "e-util/e-dialog-utils.h" #include "e-util/e-error.h" #include "e-util/e-util.h" +#include "e-util/gconf-bridge.h" #include "calendar/common/authentication.h" #include "calendar/gui/misc.h" +#include "calendar/gui/e-cal-component-preview.h" #include "calendar/gui/e-calendar-selector.h" -#include "calendar/gui/e-task-preview.h" #include "calendar/gui/dialogs/calendar-setup.h" #include "calendar/gui/dialogs/task-editor.h" @@ -63,6 +66,25 @@ G_BEGIN_DECLS +/* Filter items are displayed in ascending order. + * Non-negative values are reserved for categories. */ +enum { + TASK_FILTER_ANY_CATEGORY = -7, + TASK_FILTER_UNMATCHED = -6, + TASK_FILTER_NEXT_7_DAYS_TASKS = -5, + TASK_FILTER_ACTIVE_TASKS = -4, + TASK_FILTER_OVERDUE_TASKS = -3, + TASK_FILTER_COMPLETED_TASKS = -2, + TASK_FILTER_TASKS_WITH_ATTACHMENTS = -1 +}; + +/* Search items are displayed in ascending order. */ +enum { + TASK_SEARCH_SUMMARY_CONTAINS, + TASK_SEARCH_DESCRIPTION_CONTAINS, + TASK_SEARCH_ANY_FIELD_CONTAINS +}; + struct _ETaskShellViewPrivate { /*** Module Data ***/ @@ -72,6 +94,7 @@ struct _ETaskShellViewPrivate { /*** UI Management ***/ GtkActionGroup *task_actions; + GtkActionGroup *filter_actions; /*** Other Stuff ***/ @@ -79,10 +102,6 @@ struct _ETaskShellViewPrivate { ETaskShellContent *task_shell_content; ETaskShellSidebar *task_shell_sidebar; - /* UID -> Client */ - GHashTable *client_table; - ECal *default_client; - EActivity *activity; }; @@ -100,7 +119,7 @@ void e_task_shell_view_private_finalize void e_task_shell_view_actions_init (ETaskShellView *task_shell_view); -void e_task_shell_view_actions_update +void e_task_shell_view_execute_search (ETaskShellView *task_shell_view); void e_task_shell_view_open_task (ETaskShellView *task_shell_view, @@ -110,6 +129,8 @@ void e_task_shell_view_set_status_message const gchar *status_message); void e_task_shell_view_update_sidebar (ETaskShellView *task_shell_view); +void e_task_shell_view_update_search_filter + (ETaskShellView *task_shell_view); G_END_DECLS diff --git a/calendar/modules/e-task-shell-view.c b/calendar/modules/e-task-shell-view.c index c5284a6397..6de83e90eb 100644 --- a/calendar/modules/e-task-shell-view.c +++ b/calendar/modules/e-task-shell-view.c @@ -74,6 +74,145 @@ task_shell_view_constructed (GObject *object) } static void +task_shell_view_update_actions (EShellView *shell_view) +{ + ETaskShellViewPrivate *priv; + ETaskShellContent *task_shell_content; + ETaskShellSidebar *task_shell_sidebar; + EShellWindow *shell_window; + ESourceSelector *selector; + ETable *table; + ETaskTable *task_table; + ESource *source; + GtkAction *action; + GSList *list, *iter; + const gchar *label; + const gchar *uri = NULL; + gboolean user_created_source; + gboolean assignable = TRUE; + gboolean editable = TRUE; + gboolean has_url = FALSE; + gboolean sensitive; + gint n_selected; + gint n_complete = 0; + gint n_incomplete = 0; + + priv = E_TASK_SHELL_VIEW_GET_PRIVATE (shell_view); + + shell_window = e_shell_view_get_shell_window (shell_view); + + task_shell_content = priv->task_shell_content; + task_table = e_task_shell_content_get_task_table (task_shell_content); + + task_shell_sidebar = priv->task_shell_sidebar; + selector = e_task_shell_sidebar_get_selector (task_shell_sidebar); + + table = e_task_table_get_table (task_table); + n_selected = e_table_selected_count (table); + + list = e_task_table_get_selected (task_table); + for (iter = list; iter != NULL; iter = iter->next) { + ECalModelComponent *comp_data = iter->data; + icalproperty *prop; + const gchar *cap; + gboolean read_only; + + e_cal_is_read_only (comp_data->client, &read_only, NULL); + editable &= !read_only; + + cap = CAL_STATIC_CAPABILITY_NO_TASK_ASSIGNMENT; + if (e_cal_get_static_capability (comp_data->client, cap)) + assignable = FALSE; + + cap = CAL_STATIC_NO_CONV_TO_ASSIGN_TASK; + if (e_cal_get_static_capability (comp_data->client, cap)) + assignable = FALSE; + + prop = icalcomponent_get_first_property ( + comp_data->icalcomp, ICAL_URL_PROPERTY); + has_url |= (prop != NULL); + + prop = icalcomponent_get_first_property ( + comp_data->icalcomp, ICAL_COMPLETED_PROPERTY); + if (prop != NULL) + n_complete++; + else + n_incomplete++; + } + g_slist_free (list); + + source = e_source_selector_peek_primary_selection (selector); + if (source != NULL) + uri = e_source_peek_relative_uri (source); + user_created_source = (uri != NULL && strcmp (uri, "system") != 0); + + action = ACTION (TASK_ASSIGN); + sensitive = (n_selected == 1) && editable && assignable; + + action = ACTION (TASK_CLIPBOARD_COPY); + sensitive = (n_selected > 0); + gtk_action_set_sensitive (action, sensitive); + + action = ACTION (TASK_CLIPBOARD_CUT); + sensitive = (n_selected > 0) && editable; + gtk_action_set_sensitive (action, sensitive); + + action = ACTION (TASK_CLIPBOARD_PASTE); + sensitive = editable; + gtk_action_set_sensitive (action, sensitive); + + action = ACTION (TASK_DELETE); + sensitive = (n_selected > 0) && editable; + gtk_action_set_sensitive (action, sensitive); + label = ngettext ("Delete Task", "Delete Tasks", n_selected); + g_object_set (action, "label", label, NULL); + + action = ACTION (TASK_FORWARD); + sensitive = (n_selected == 1); + gtk_action_set_sensitive (action, sensitive); + + action = ACTION (TASK_LIST_COPY); + sensitive = (source != NULL); + gtk_action_set_sensitive (action, sensitive); + + action = ACTION (TASK_LIST_DELETE); + sensitive = user_created_source; + gtk_action_set_sensitive (action, sensitive); + + action = ACTION (TASK_LIST_PROPERTIES); + sensitive = (source != NULL); + gtk_action_set_sensitive (action, sensitive); + + action = ACTION (TASK_MARK_COMPLETE); + sensitive = (n_selected > 0) && editable && (n_incomplete > 0); + gtk_action_set_sensitive (action, sensitive); + + action = ACTION (TASK_MARK_INCOMPLETE); + sensitive = (n_selected > 0) && editable && (n_complete > 0); + gtk_action_set_sensitive (action, sensitive); + + action = ACTION (TASK_OPEN); + sensitive = (n_selected == 1); + gtk_action_set_sensitive (action, sensitive); + + action = ACTION (TASK_OPEN_URL); + sensitive = (n_selected == 1) && has_url; + gtk_action_set_sensitive (action, sensitive); + + action = ACTION (TASK_PRINT); + sensitive = (n_selected == 1); + gtk_action_set_sensitive (action, sensitive); + + action = ACTION (TASK_PURGE); + sensitive = editable; + gtk_action_set_sensitive (action, sensitive); + + action = ACTION (TASK_SAVE_AS); + sensitive = (n_selected == 1); + gtk_action_set_sensitive (action, sensitive); +} + +static void task_shell_view_class_init (ETaskShellView *class, GTypeModule *type_module) { @@ -94,8 +233,11 @@ task_shell_view_class_init (ETaskShellView *class, shell_view_class->icon_name = "evolution-tasks"; shell_view_class->ui_definition = "evolution-tasks.ui"; shell_view_class->search_options = "/task-search-options"; + shell_view_class->search_rules = "tasktypes.xml"; shell_view_class->type_module = type_module; + shell_view_class->new_shell_content = e_task_shell_content_new; shell_view_class->new_shell_sidebar = e_task_shell_sidebar_new; + shell_view_class->update_actions = task_shell_view_update_actions; g_object_class_install_property ( object_class, |