diff options
author | Matthew Barnes <mbarnes@src.gnome.org> | 2008-10-04 03:24:59 +0800 |
---|---|---|
committer | Matthew Barnes <mbarnes@src.gnome.org> | 2008-10-04 03:24:59 +0800 |
commit | 253e90b8de63d9c064a0df05cf0e2e153f913474 (patch) | |
tree | ba6608ca96849f8f0801e4e81f7ed2aef06d391d /calendar/modules | |
parent | 086a96050b16f6dabd99a391b5a4faf0411963a1 (diff) | |
download | gsoc2013-evolution-253e90b8de63d9c064a0df05cf0e2e153f913474.tar.gz gsoc2013-evolution-253e90b8de63d9c064a0df05cf0e2e153f913474.tar.zst gsoc2013-evolution-253e90b8de63d9c064a0df05cf0e2e153f913474.zip |
Tasks is working. Still need to deal with some loose ends and test it all.
svn path=/branches/kill-bonobo/; revision=36551
Diffstat (limited to 'calendar/modules')
-rw-r--r-- | calendar/modules/e-memo-shell-content.c | 2 | ||||
-rw-r--r-- | calendar/modules/e-memo-shell-sidebar.c | 20 | ||||
-rw-r--r-- | calendar/modules/e-memo-shell-view-actions.c | 4 | ||||
-rw-r--r-- | calendar/modules/e-memo-shell-view-private.c | 2 | ||||
-rw-r--r-- | calendar/modules/e-task-shell-content.c | 40 | ||||
-rw-r--r-- | calendar/modules/e-task-shell-content.h | 8 | ||||
-rw-r--r-- | calendar/modules/e-task-shell-module.c | 4 | ||||
-rw-r--r-- | calendar/modules/e-task-shell-sidebar.c | 473 | ||||
-rw-r--r-- | calendar/modules/e-task-shell-sidebar.h | 14 | ||||
-rw-r--r-- | calendar/modules/e-task-shell-view-actions.c | 102 | ||||
-rw-r--r-- | calendar/modules/e-task-shell-view-actions.h | 2 | ||||
-rw-r--r-- | calendar/modules/e-task-shell-view-private.c | 99 | ||||
-rw-r--r-- | calendar/modules/e-task-shell-view-private.h | 5 | ||||
-rw-r--r-- | calendar/modules/e-task-shell-view.c | 8 |
14 files changed, 689 insertions, 94 deletions
diff --git a/calendar/modules/e-memo-shell-content.c b/calendar/modules/e-memo-shell-content.c index ba3650d141..72ecbbf2f8 100644 --- a/calendar/modules/e-memo-shell-content.c +++ b/calendar/modules/e-memo-shell-content.c @@ -1,5 +1,5 @@ /* - * e-memo-shell-content.h + * e-memo-shell-content.c * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public diff --git a/calendar/modules/e-memo-shell-sidebar.c b/calendar/modules/e-memo-shell-sidebar.c index 3a2730120c..63629f2108 100644 --- a/calendar/modules/e-memo-shell-sidebar.c +++ b/calendar/modules/e-memo-shell-sidebar.c @@ -91,23 +91,23 @@ memo_shell_sidebar_update_timezone (EMemoShellSidebar *memo_shell_sidebar) { GHashTable *client_table; icaltimezone *zone; - GList *keys; + GList *values; zone = calendar_config_get_icaltimezone (); client_table = memo_shell_sidebar->priv->client_table; - keys = g_hash_table_get_values (client_table); + values = g_hash_table_get_values (client_table); - while (keys != NULL) { - ECal *client = keys->data; + while (values != NULL) { + ECal *client = values->data; if (e_cal_get_load_state (client) == E_CAL_LOAD_LOADED) e_cal_set_default_timezone (client, zone, NULL); - keys = g_list_delete_link (keys, keys); + values = g_list_delete_link (values, values); } - /* XXX Need to call e_memo_preview_set_default_timezone() here - * but the sidebar is not really supposed to access content + /* XXX Need to call e_cal_component_preview_set_default_timezone() + * here but the sidebar is not really supposed to access content * stuff. I guess we could emit an "update-timezone" signal * here, but that feels wrong. Maybe this whole thing should * be in EMemoShellView instead. */ @@ -454,8 +454,8 @@ memo_shell_sidebar_client_removed (EMemoShellSidebar *memo_shell_sidebar, ESource *source; const gchar *uid; - selector = E_SOURCE_SELECTOR (memo_shell_sidebar->priv->selector); client_table = memo_shell_sidebar->priv->client_table; + selector = e_memo_shell_sidebar_get_selector (memo_shell_sidebar); g_signal_handlers_disconnect_matched ( client, G_SIGNAL_MATCH_DATA, 0, 0, @@ -607,7 +607,7 @@ e_memo_shell_sidebar_add_source (EMemoShellSidebar *memo_shell_sidebar, g_return_if_fail (E_IS_SOURCE (source)); client_table = memo_shell_sidebar->priv->client_table; - selector = E_SOURCE_SELECTOR (memo_shell_sidebar->priv->selector); + selector = e_memo_shell_sidebar_get_selector (memo_shell_sidebar); uid = e_source_peek_uid (source); client = g_hash_table_lookup (client_table, uid); @@ -657,7 +657,7 @@ e_memo_shell_sidebar_remove_source (EMemoShellSidebar *memo_shell_sidebar, g_return_if_fail (E_IS_SOURCE (source)); client_table = memo_shell_sidebar->priv->client_table; - selector = E_SOURCE_SELECTOR (memo_shell_sidebar->priv->selector); + selector = e_memo_shell_sidebar_get_selector (memo_shell_sidebar); uid = e_source_peek_uid (source); client = g_hash_table_lookup (client_table, uid); diff --git a/calendar/modules/e-memo-shell-view-actions.c b/calendar/modules/e-memo-shell-view-actions.c index 6ec64b15c6..00b27de0b3 100644 --- a/calendar/modules/e-memo-shell-view-actions.c +++ b/calendar/modules/e-memo-shell-view-actions.c @@ -530,7 +530,7 @@ static GtkActionEntry memo_entries[] = { { "memo-forward", "mail-forward", - N_("_Forward as iCalendar"), + N_("_Forward as iCalendar..."), "<Control>f", NULL, /* XXX Add a tooltip! */ G_CALLBACK (action_memo_forward_cb) }, @@ -614,7 +614,7 @@ static GtkActionEntry memo_entries[] = { { "memo-save-as", GTK_STOCK_SAVE_AS, - NULL, + N_("_Save as iCalendar..."), NULL, NULL, /* XXX Add a tooltip! */ G_CALLBACK (action_memo_save_as_cb) } diff --git a/calendar/modules/e-memo-shell-view-private.c b/calendar/modules/e-memo-shell-view-private.c index 04ee8eecc3..e8ff33570e 100644 --- a/calendar/modules/e-memo-shell-view-private.c +++ b/calendar/modules/e-memo-shell-view-private.c @@ -362,7 +362,7 @@ e_memo_shell_view_execute_search (EMemoShellView *memo_shell_view) query = g_strdup_printf (format, string->str); g_string_free (string, TRUE); - /* Filter by category. */ + /* Apply selected filter. */ value = e_shell_content_get_filter_value (shell_content); if (value == MEMO_FILTER_UNMATCHED) { gchar *temp; diff --git a/calendar/modules/e-task-shell-content.c b/calendar/modules/e-task-shell-content.c index 7cf7da3e7c..9599e35d3b 100644 --- a/calendar/modules/e-task-shell-content.c +++ b/calendar/modules/e-task-shell-content.c @@ -1,5 +1,5 @@ /* - * e-task-shell-content.h + * e-task-shell-content.c * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public @@ -25,6 +25,7 @@ #include "e-util/gconf-bridge.h" +#include "calendar/gui/calendar-config.h" #include "calendar/gui/e-calendar-table.h" #include "calendar/gui/e-calendar-table-config.h" @@ -34,14 +35,14 @@ (G_TYPE_INSTANCE_GET_PRIVATE \ ((obj), E_TYPE_TASK_SHELL_CONTENT, ETaskShellContentPrivate)) -#define E_TASK_TABLE_DEFAULT_STATE \ +#define E_CALENDAR_TABLE_DEFAULT_STATE \ "<?xml version=\"1.0\"?>" \ "<ETableState>" \ " <column source=\"13\"/>" \ " <column source=\"14\"/>" \ " <column source=\"9\"/>" \ " <column source=\"5\"/>" \ - " <grouping/> + " <grouping/>" \ "</ETableState>" struct _ETaskShellContentPrivate { @@ -49,7 +50,7 @@ struct _ETaskShellContentPrivate { GtkWidget *task_table; GtkWidget *task_preview; - ETaskTableConfig *table_config; + ECalendarTableConfig *table_config; GalViewInstance *view_instance; gchar *current_uid; @@ -97,7 +98,7 @@ task_shell_content_display_view_cb (ETaskShellContent *task_shell_content, return; task_table = E_CALENDAR_TABLE (task_shell_content->priv->task_table); - table = e_task_table_get_table (task_table); + table = e_calendar_table_get_table (task_table); gal_view_etable_attach_table (GAL_VIEW_ETABLE (gal_view), table); } @@ -132,7 +133,7 @@ task_shell_content_cursor_change_cb (ETaskShellContent *task_shell_content, ETable *table) { ECalComponentPreview *task_preview; - ETaskTable *task_table; + ECalendarTable *task_table; ECalModel *model; ECalModelComponent *comp_data; ECalComponent *comp; @@ -140,14 +141,14 @@ task_shell_content_cursor_change_cb (ETaskShellContent *task_shell_content, task_preview = E_CAL_COMPONENT_PREVIEW ( task_shell_content->priv->task_preview); - task_table = E_TASK_TABLE (task_shell_content->priv->task_table); + task_table = E_CALENDAR_TABLE (task_shell_content->priv->task_table); if (e_table_selected_count (table) != 1) { e_cal_component_preview_clear (task_preview); return; } - model = e_task_table_get_model (task_table); + model = e_calendar_table_get_model (task_table); row = e_table_get_cursor_row (table); comp_data = e_cal_model_get_component_at (model, row); @@ -185,7 +186,7 @@ task_shell_content_model_row_changed_cb (ETaskShellContent *task_shell_content, ETableModel *model) { ECalModelComponent *comp_data; - ETaskTable *task_table; + ECalendarTable *task_table; ETable *table; const gchar *current_uid; const gchar *uid; @@ -202,8 +203,8 @@ task_shell_content_model_row_changed_cb (ETaskShellContent *task_shell_content, if (g_strcmp0 (uid, current_uid) != 0) return; - task_table = E_TASK_TABLE (task_shell_content->priv->task_table); - table = e_task_table_get_table (task_table); + task_table = E_CALENDAR_TABLE (task_shell_content->priv->task_table); + table = e_calendar_table_get_table (task_table); task_shell_content_cursor_change_cb (task_shell_content, 0, table); } @@ -328,7 +329,7 @@ task_shell_content_constructed (GObject *object) container = widget; - widget = e_task_table_new (shell_view); + widget = e_calendar_table_new (shell_view); gtk_paned_add1 (GTK_PANED (container), widget); priv->task_table = g_object_ref (widget); gtk_widget_show (widget); @@ -340,6 +341,7 @@ task_shell_content_constructed (GObject *object) gtk_scrolled_window_set_shadow_type ( GTK_SCROLLED_WINDOW (widget), GTK_SHADOW_IN); gtk_paned_add2 (GTK_PANED (container), widget); + gtk_widget_show (widget); container = widget; @@ -353,14 +355,14 @@ task_shell_content_constructed (GObject *object) /* Configure the task table. */ - widget = E_TASK_TABLE (priv->task_table)->etable; + widget = E_CALENDAR_TABLE (priv->task_table)->etable; table = e_table_scrolled_get_table (E_TABLE_SCROLLED (widget)); - model = e_task_table_get_model (E_TASK_TABLE (priv->task_table)); + model = e_calendar_table_get_model (E_CALENDAR_TABLE (priv->task_table)); - priv->table_config = e_task_table_config_new ( - E_TASK_TABLE (priv->task_table)); + priv->table_config = e_calendar_table_config_new ( + E_CALENDAR_TABLE (priv->task_table)); - e_table_set_state (table, E_TASK_TABLE_DEFAULT_STATE); + e_table_set_state (table, E_CALENDAR_TABLE_DEFAULT_STATE); e_table_drag_source_set ( table, GDK_BUTTON1_MASK, @@ -497,13 +499,13 @@ e_task_shell_content_get_task_preview (ETaskShellContent *task_shell_content) task_shell_content->priv->task_preview); } -ETaskTable * +ECalendarTable * e_task_shell_content_get_task_table (ETaskShellContent *task_shell_content) { g_return_val_if_fail ( E_IS_TASK_SHELL_CONTENT (task_shell_content), NULL); - return E_TASK_TABLE (task_shell_content->priv->task_table); + return E_CALENDAR_TABLE (task_shell_content->priv->task_table); } GalViewInstance * diff --git a/calendar/modules/e-task-shell-content.h b/calendar/modules/e-task-shell-content.h index 9cf40fdf3e..dad6702a0c 100644 --- a/calendar/modules/e-task-shell-content.h +++ b/calendar/modules/e-task-shell-content.h @@ -25,6 +25,9 @@ #include <shell/e-shell-content.h> #include <shell/e-shell-view.h> +#include <calendar/gui/e-calendar-table.h> +#include <calendar/gui/e-cal-component-preview.h> + #include <widgets/menus/gal-view-instance.h> /* Standard GObject macros */ @@ -63,6 +66,11 @@ struct _ETaskShellContentClass { GType e_task_shell_content_get_type (void); GtkWidget * e_task_shell_content_new (EShellView *shell_view); +ECalComponentPreview * + e_task_shell_content_get_task_preview + (ETaskShellContent *task_shell_content); +ECalendarTable *e_task_shell_content_get_task_table + (ETaskShellContent *task_shell_content); GalViewInstance * e_task_shell_content_get_view_instance (ETaskShellContent *task_shell_content); diff --git a/calendar/modules/e-task-shell-module.c b/calendar/modules/e-task-shell-module.c index 4b062646fd..010ba1f924 100644 --- a/calendar/modules/e-task-shell-module.c +++ b/calendar/modules/e-task-shell-module.c @@ -30,7 +30,11 @@ #include "shell/e-shell-module.h" #include "shell/e-shell-window.h" +#include "calendar/common/authentication.h" #include "calendar/gui/calendar-config.h" +#include "calendar/gui/comp-util.h" +#include "calendar/gui/dialogs/calendar-setup.h" +#include "calendar/gui/dialogs/task-editor.h" #include "e-task-shell-view.h" diff --git a/calendar/modules/e-task-shell-sidebar.c b/calendar/modules/e-task-shell-sidebar.c index ae2927f964..52d28776b4 100644 --- a/calendar/modules/e-task-shell-sidebar.c +++ b/calendar/modules/e-task-shell-sidebar.c @@ -21,9 +21,15 @@ #include "e-task-shell-sidebar.h" +#include <string.h> #include <glib/gi18n.h> +#include <libecal/e-cal.h> +#include "e-util/e-error.h" +#include "calendar/common/authentication.h" +#include "calendar/gui/calendar-config.h" #include "calendar/gui/e-calendar-selector.h" +#include "calendar/gui/misc.h" #include "e-task-shell-view.h" @@ -33,6 +39,9 @@ struct _ETaskShellSidebarPrivate { GtkWidget *selector; + + /* UID -> Client */ + GHashTable *client_table; }; enum { @@ -40,7 +49,255 @@ enum { PROP_SELECTOR }; +enum { + CLIENT_ADDED, + CLIENT_REMOVED, + STATUS_MESSAGE, + LAST_SIGNAL +}; + static gpointer parent_class; +static guint signals[LAST_SIGNAL]; + +static void +task_shell_sidebar_emit_client_added (ETaskShellSidebar *task_shell_sidebar, + ECal *client) +{ + guint signal_id = signals[CLIENT_ADDED]; + + g_signal_emit (task_shell_sidebar, signal_id, 0, client); +} + +static void +task_shell_sidebar_emit_client_removed (ETaskShellSidebar *task_shell_sidebar, + ECal *client) +{ + guint signal_id = signals[CLIENT_REMOVED]; + + g_signal_emit (task_shell_sidebar, signal_id, 0, client); +} + +static void +task_shell_sidebar_emit_status_message (ETaskShellSidebar *task_shell_sidebar, + const gchar *status_message) +{ + guint signal_id = signals[STATUS_MESSAGE]; + + g_signal_emit (task_shell_sidebar, signal_id, 0, status_message); +} + +static void +task_shell_sidebar_update_timezone (ETaskShellSidebar *task_shell_sidebar) +{ + GHashTable *client_table; + icaltimezone *zone; + GList *values; + + zone = calendar_config_get_icaltimezone (); + client_table = task_shell_sidebar->priv->client_table; + values = g_hash_table_get_values (client_table); + + while (values != NULL) { + ECal *client = values->data; + + if (e_cal_get_load_state (client) == E_CAL_LOAD_LOADED) + e_cal_set_default_timezone (client, zone, NULL); + + values = g_list_delete_link (values, values); + } + + /* XXX Need to call e_cal_component_preview_set_default_timezone() + * here but the sidebar is not really supposed to access content + * stuff. I guess we could emit an "update-timezone" signal + * here, but that feels wrong. Maybe this whole thing should + * be in ETaskShellView instead. */ +} + +static void +task_shell_sidebar_backend_died_cb (ETaskShellSidebar *task_shell_sidebar, + ECal *client) +{ + EShellView *shell_view; + EShellWindow *shell_window; + EShellSidebar *shell_sidebar; + GHashTable *client_table; + ESource *source; + const gchar *uid; + + client_table = task_shell_sidebar->priv->client_table; + + shell_sidebar = E_SHELL_SIDEBAR (task_shell_sidebar); + shell_view = e_shell_sidebar_get_shell_view (shell_sidebar); + 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); + task_shell_sidebar_emit_status_message (task_shell_sidebar, NULL); + + e_error_run ( + GTK_WINDOW (shell_window), + "calendar:tasks-crashed", NULL); + + g_object_unref (source); +} + +static void +task_shell_sidebar_backend_error_cb (ETaskShellSidebar *task_shell_sidebar, + const gchar *message, + ECal *client) +{ + EShellView *shell_view; + EShellWindow *shell_window; + EShellSidebar *shell_sidebar; + GtkWidget *dialog; + const gchar *uri; + gchar *uri_no_passwd; + + shell_sidebar = E_SHELL_SIDEBAR (task_shell_sidebar); + shell_view = e_shell_sidebar_get_shell_view (shell_sidebar); + shell_window = e_shell_view_get_shell_window (shell_view); + + uri = e_cal_get_uri (client); + uri_no_passwd = get_uri_without_password (uri); + + 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); + + gtk_dialog_run (GTK_DIALOG (dialog)); + gtk_widget_destroy (dialog); + + g_free (uri_no_passwd); +} + +static void +task_shell_sidebar_client_opened_cb (ETaskShellSidebar *task_shell_sidebar, + ECalendarStatus status, + ECal *client) +{ + EShellView *shell_view; + EShellWindow *shell_window; + EShellSidebar *shell_sidebar; + ESource *source; + + source = e_cal_get_source (client); + + shell_sidebar = E_SHELL_SIDEBAR (task_shell_sidebar); + shell_view = e_shell_sidebar_get_shell_view (shell_sidebar); + shell_window = e_shell_view_get_shell_window (shell_view); + + switch (status) { + case E_CALENDAR_STATUS_OK: + g_signal_handlers_disconnect_matched ( + client, G_SIGNAL_MATCH_FUNC, 0, 0, NULL, + task_shell_sidebar_client_opened_cb, NULL); + + task_shell_sidebar_emit_status_message ( + task_shell_sidebar, _("Loading tasks")); + task_shell_sidebar_emit_client_added ( + task_shell_sidebar, client); + task_shell_sidebar_emit_status_message ( + task_shell_sidebar, NULL); + break; + + case E_CALENDAR_STATUS_BUSY: + break; + + case E_CALENDAR_STATUS_REPOSITORY_OFFLINE: + e_error_run ( + GTK_WINDOW (shell_window), + "calendar:prompt-no-contents-offline-tasks", + NULL); + break; + + default: + task_shell_sidebar_emit_client_removed ( + task_shell_sidebar, client); + break; + } +} + +static void +task_shell_sidebar_row_changed_cb (ETaskShellSidebar *task_shell_sidebar, + GtkTreePath *tree_path, + GtkTreeIter *tree_iter, + GtkTreeModel *tree_model) +{ + ESourceSelector *selector; + ESource *source; + + /* XXX ESourceSelector's underlying tree store has only one + * column: ESource objects. While we're not supposed to + * know this, listening for "row-changed" signals from + * the model is easier to deal with than the selector's + * "selection-changed" signal, which doesn't tell you + * _which_ row changed. */ + + selector = e_task_shell_sidebar_get_selector (task_shell_sidebar); + gtk_tree_model_get (tree_model, tree_iter, 0, &source, -1); + + /* XXX This signal gets emitted a lot while the model is being + * rebuilt, during which time we won't get a valid ESource. + * ESourceSelector should probably block this signal while + * rebuilding the model, but we'll be forgiving and not + * emit a warning. */ + if (!E_IS_SOURCE (source)) + return; + + if (e_source_selector_source_is_selected (selector, source)) + e_task_shell_sidebar_add_source (task_shell_sidebar, source); + else + e_task_shell_sidebar_remove_source (task_shell_sidebar, source); +} + +static void +task_shell_sidebar_selection_changed_cb (ETaskShellSidebar *task_shell_sidebar, + ESourceSelector *selector) +{ + GSList *list, *iter; + + /* This signal is emitted less frequently than "row-changed", + * especially when the model is being rebuilt. So we'll take + * it easy on poor GConf. */ + + list = e_source_selector_get_selection (selector); + + for (iter = list; iter != NULL; iter = iter->next) { + ESource *source = iter->data; + + iter->data = (gpointer) e_source_peek_uid (source); + g_object_unref (source); + } + + calendar_config_set_tasks_selected (list); + + g_slist_free (list); +} + +static void +task_shell_sidebar_primary_selection_changed_cb (ETaskShellSidebar *task_shell_sidebar, + ESourceSelector *selector) +{ + ESource *source; + const gchar *uid; + + /* XXX ESourceSelector needs a "primary-selection-uid" property + * so we can just bind the property with GConfBridge. */ + + source = e_source_selector_peek_primary_selection (selector); + if (source == NULL) + return; + + uid = e_source_peek_uid (source); + calendar_config_set_primary_tasks (uid); +} static void task_shell_sidebar_get_property (GObject *object, @@ -71,20 +328,40 @@ task_shell_sidebar_dispose (GObject *object) priv->selector = NULL; } + g_hash_table_remove_all (priv->client_table); + /* Chain up to parent's dispose() method. */ G_OBJECT_CLASS (parent_class)->dispose (object); } static void +task_shell_sidebar_finalize (GObject *object) +{ + ETaskShellSidebarPrivate *priv; + + priv = E_TASK_SHELL_SIDEBAR_GET_PRIVATE (object); + + g_hash_table_destroy (priv->client_table); + + /* Chain up to parent's finalize() method. */ + G_OBJECT_CLASS (parent_class)->finalize (object); +} + +static void task_shell_sidebar_constructed (GObject *object) { ETaskShellSidebarPrivate *priv; EShellView *shell_view; EShellSidebar *shell_sidebar; ETaskShellView *task_shell_view; + ESourceSelector *selector; ESourceList *source_list; + ESource *source; GtkContainer *container; + GtkTreeModel *model; GtkWidget *widget; + GSList *list, *iter; + gchar *uid; priv = E_TASK_SHELL_SIDEBAR_GET_PRIVATE (object); @@ -114,6 +391,83 @@ task_shell_sidebar_constructed (GObject *object) gtk_container_add (container, widget); priv->selector = g_object_ref (widget); gtk_widget_show (widget); + + /* Restore the selector state from the last session. */ + + selector = E_SOURCE_SELECTOR (priv->selector); + model = gtk_tree_view_get_model (GTK_TREE_VIEW (widget)); + + g_signal_connect_swapped ( + model, "row-changed", + G_CALLBACK (task_shell_sidebar_row_changed_cb), + object); + + source = NULL; + uid = calendar_config_get_primary_tasks (); + if (uid != NULL) + source = e_source_list_peek_source_by_uid (source_list, uid); + if (source == NULL) + source = e_source_list_peek_source_any (source_list); + if (source != NULL) + e_source_selector_set_primary_selection (selector, source); + g_free (uid); + + list = calendar_config_get_tasks_selected (); + for (iter = list; iter != NULL; iter = iter->next) { + uid = iter->data; + source = e_source_list_peek_source_by_uid (source_list, uid); + g_free (uid); + + if (source == NULL) + continue; + + e_source_selector_select_source (selector, source); + } + g_slist_free (list); + + /* Listen for subsequent changes to the selector. */ + + g_signal_connect_swapped ( + widget, "selection-changed", + G_CALLBACK (task_shell_sidebar_selection_changed_cb), + object); + + g_signal_connect_swapped ( + widget, "primary-selection-changed", + G_CALLBACK (task_shell_sidebar_selection_changed_cb), + object); +} + +static void +task_shell_sidebar_client_added (ETaskShellSidebar *task_shell_sidebar, + ECal *client) +{ + task_shell_sidebar_update_timezone (task_shell_sidebar); +} + +static void +task_shell_sidebar_client_removed (ETaskShellSidebar *task_shell_sidebar, + ECal *client) +{ + ESourceSelector *selector; + GHashTable *client_table; + ESource *source; + const gchar *uid; + + client_table = task_shell_sidebar->priv->client_table; + selector = e_task_shell_sidebar_get_selector (task_shell_sidebar); + + g_signal_handlers_disconnect_matched ( + client, G_SIGNAL_MATCH_DATA, 0, 0, + NULL, NULL, task_shell_sidebar); + + source = e_cal_get_source (client); + e_source_selector_unselect_source (selector, source); + + uid = e_source_peek_uid (source); + g_hash_table_remove (client_table, uid); + + task_shell_sidebar_emit_status_message (task_shell_sidebar, NULL); } static void @@ -127,8 +481,12 @@ task_shell_sidebar_class_init (ETaskShellSidebarClass *class) object_class = G_OBJECT_CLASS (class); object_class->get_property = task_shell_sidebar_get_property; object_class->dispose = task_shell_sidebar_dispose; + object_class->finalize = task_shell_sidebar_finalize; object_class->constructed = task_shell_sidebar_constructed; + class->client_added = task_shell_sidebar_client_added; + class->client_removed = task_shell_sidebar_client_removed; + g_object_class_install_property ( object_class, PROP_SELECTOR, @@ -138,14 +496,53 @@ task_shell_sidebar_class_init (ETaskShellSidebarClass *class) _("This widget displays groups of task lists"), E_TYPE_SOURCE_SELECTOR, G_PARAM_READABLE)); + + signals[CLIENT_ADDED] = g_signal_new ( + "client-added", + G_OBJECT_CLASS_TYPE (object_class), + G_SIGNAL_RUN_LAST, + G_STRUCT_OFFSET (ETaskShellSidebarClass, client_added), + NULL, NULL, + g_cclosure_marshal_VOID__OBJECT, + G_TYPE_NONE, 1, + E_TYPE_CAL); + + signals[CLIENT_REMOVED] = g_signal_new ( + "client-removed", + G_OBJECT_CLASS_TYPE (object_class), + G_SIGNAL_RUN_LAST, + G_STRUCT_OFFSET (ETaskShellSidebarClass, client_removed), + NULL, NULL, + g_cclosure_marshal_VOID__OBJECT, + G_TYPE_NONE, 1, + E_TYPE_CAL); + + signals[STATUS_MESSAGE] = g_signal_new ( + "status-message", + G_OBJECT_CLASS_TYPE (object_class), + G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION, + G_STRUCT_OFFSET (ETaskShellSidebarClass, status_message), + NULL, NULL, + g_cclosure_marshal_VOID__STRING, + G_TYPE_NONE, 1, + G_TYPE_STRING); } static void task_shell_sidebar_init (ETaskShellSidebar *task_shell_sidebar) { + GHashTable *client_table; + + client_table = g_hash_table_new_full ( + g_str_hash, g_str_equal, + (GDestroyNotify) g_free, + (GDestroyNotify) g_object_unref); + task_shell_sidebar->priv = E_TASK_SHELL_SIDEBAR_GET_PRIVATE (task_shell_sidebar); + task_shell_sidebar->priv->client_table = client_table; + /* Postpone widget construction until we have a shell view. */ } @@ -194,3 +591,79 @@ e_task_shell_sidebar_get_selector (ETaskShellSidebar *task_shell_sidebar) return E_SOURCE_SELECTOR (task_shell_sidebar->priv->selector); } + +void +e_task_shell_sidebar_add_source (ETaskShellSidebar *task_shell_sidebar, + ESource *source) +{ + ESourceSelector *selector; + GHashTable *client_table; + ECal *client; + const gchar *uid; + const gchar *uri; + gchar *message; + + g_return_if_fail (E_IS_TASK_SHELL_SIDEBAR (task_shell_sidebar)); + g_return_if_fail (E_IS_SOURCE (source)); + + client_table = task_shell_sidebar->priv->client_table; + selector = e_task_shell_sidebar_get_selector (task_shell_sidebar); + + uid = e_source_peek_uid (source); + client = g_hash_table_lookup (client_table, uid); + + if (client != NULL) + return; + + client = auth_new_cal_from_source (source, E_CAL_SOURCE_TYPE_TODO); + g_return_if_fail (client != NULL); + + g_signal_connect_swapped ( + client, "backend-died", + G_CALLBACK (task_shell_sidebar_backend_died_cb), + task_shell_sidebar); + + g_signal_connect_swapped ( + client, "backend-error", + G_CALLBACK (task_shell_sidebar_backend_error_cb), + task_shell_sidebar); + + g_hash_table_insert (client_table, g_strdup (uid), client); + e_source_selector_select_source (selector, source); + + uri = e_cal_get_uri (client); + message = g_strdup_printf (_("Opening tasks at %s"), uri); + task_shell_sidebar_emit_status_message (task_shell_sidebar, message); + g_free (message); + + g_signal_connect_swapped ( + client, "cal-opened", + G_CALLBACK (task_shell_sidebar_client_opened_cb), + task_shell_sidebar); + + e_cal_open_async (client, FALSE); +} + +void +e_task_shell_sidebar_remove_source (ETaskShellSidebar *task_shell_sidebar, + ESource *source) +{ + ESourceSelector *selector; + GHashTable *client_table; + ECal *client; + const gchar *uid; + + g_return_if_fail (E_IS_TASK_SHELL_SIDEBAR (task_shell_sidebar)); + g_return_if_fail (E_IS_SOURCE (source)); + + client_table = task_shell_sidebar->priv->client_table; + selector = e_task_shell_sidebar_get_selector (task_shell_sidebar); + + uid = e_source_peek_uid (source); + client = g_hash_table_lookup (client_table, uid); + + if (client == NULL) + return; + + task_shell_sidebar_emit_client_removed (task_shell_sidebar, client); +} diff --git a/calendar/modules/e-task-shell-sidebar.h b/calendar/modules/e-task-shell-sidebar.h index 54398ca1d9..6b926685d8 100644 --- a/calendar/modules/e-task-shell-sidebar.h +++ b/calendar/modules/e-task-shell-sidebar.h @@ -22,6 +22,7 @@ #ifndef E_TASK_SHELL_SIDEBAR_H #define E_TASK_SHELL_SIDEBAR_H +#include <libecal/e-cal.h> #include <libedataserverui/e-source-selector.h> #include <shell/e-shell-sidebar.h> @@ -59,6 +60,14 @@ struct _ETaskShellSidebar { struct _ETaskShellSidebarClass { EShellSidebarClass parent_class; + + /* Signals */ + void (*client_added) (ETaskShellSidebar *task_shell_sidebar, + ECal *client); + void (*client_removed) (ETaskShellSidebar *task_shell_sidebar, + ECal *client); + void (*status_message) (ETaskShellSidebar *task_shell_sidebar, + const gchar *status_message); }; GType e_task_shell_sidebar_get_type (void); @@ -66,6 +75,11 @@ GtkWidget * e_task_shell_sidebar_new (EShellView *shell_view); ESourceSelector * e_task_shell_sidebar_get_selector (ETaskShellSidebar *task_shell_sidebar); +void e_task_shell_sidebar_add_source (ETaskShellSidebar *task_shell_sidebar, + ESource *source); +void e_task_shell_sidebar_remove_source + (ETaskShellSidebar *task_shell_sidebar, + ESource *source); G_END_DECLS diff --git a/calendar/modules/e-task-shell-view-actions.c b/calendar/modules/e-task-shell-view-actions.c index f1b8cd40f7..00911677fa 100644 --- a/calendar/modules/e-task-shell-view-actions.c +++ b/calendar/modules/e-task-shell-view-actions.c @@ -64,14 +64,14 @@ action_task_assign_cb (GtkAction *action, ETaskShellView *task_shell_view) { ETaskShellContent *task_shell_content; - ETaskTable *task_table; + ECalendarTable *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); - list = e_task_table_get_selected (task_table); + list = e_calendar_table_get_selected (task_table); g_return_if_fail (list != NULL); comp_data = list->data; g_slist_free (list); @@ -87,11 +87,11 @@ action_task_clipboard_copy_cb (GtkAction *action, ETaskShellView *task_shell_view) { ETaskShellContent *task_shell_content; - ETaskTable *task_table; + ECalendarTable *task_table; 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_copy_clipboard (task_table); + e_calendar_table_copy_clipboard (task_table); } static void @@ -99,11 +99,11 @@ action_task_clipboard_cut_cb (GtkAction *action, ETaskShellView *task_shell_view) { ETaskShellContent *task_shell_content; - ETaskTable *task_table; + ECalendarTable *task_table; 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_cut_clipboard (task_table); + e_calendar_table_cut_clipboard (task_table); } static void @@ -111,11 +111,11 @@ action_task_clipboard_paste_cb (GtkAction *action, ETaskShellView *task_shell_view) { ETaskShellContent *task_shell_content; - ETaskTable *task_table; + ECalendarTable *task_table; 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_paste_clipboard (task_table); + e_calendar_table_paste_clipboard (task_table); } static void @@ -124,7 +124,7 @@ action_task_delete_cb (GtkAction *action, { ETaskShellContent *task_shell_content; ECalComponentPreview *task_preview; - ETaskTable *task_table; + ECalendarTable *task_table; const gchar *status_message; task_shell_content = task_shell_view->priv->task_shell_content; @@ -133,7 +133,7 @@ action_task_delete_cb (GtkAction *action, status_message = _("Deleting selected tasks..."); e_task_shell_view_set_status_message (task_shell_view, status_message); - e_task_table_delete_selected (task_table); + e_calendar_table_delete_selected (task_table); e_task_shell_view_set_status_message (task_shell_view, NULL); e_cal_component_preview_clear (task_preview); @@ -144,7 +144,7 @@ action_task_forward_cb (GtkAction *action, ETaskShellView *task_shell_view) { ETaskShellContent *task_shell_content; - ETaskTable *task_table; + ECalendarTable *task_table; ECalModelComponent *comp_data; ECalComponent *comp; icalcomponent *clone; @@ -154,7 +154,7 @@ action_task_forward_cb (GtkAction *action, 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); + list = e_calendar_table_get_selected (task_table); g_return_if_fail (list != NULL); comp_data = list->data; g_slist_free (list); @@ -199,7 +199,7 @@ action_task_list_delete_cb (GtkAction *action, ETaskShellSidebar *task_shell_sidebar; EShellWindow *shell_window; EShellView *shell_view; - ETaskTable *task_table; + ECalendarTable *task_table; ECal *client; ECalModel *model; ESourceSelector *selector; @@ -215,7 +215,7 @@ action_task_list_delete_cb (GtkAction *action, 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); + model = e_calendar_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); @@ -277,13 +277,13 @@ action_task_list_print_cb (GtkAction *action, ETaskShellView *task_shell_view) { ETaskShellContent *task_shell_content; - ETaskTable *task_table; + ECalendarTable *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); + table = e_calendar_table_get_table (task_table); print_action = GTK_PRINT_OPERATION_ACTION_PRINT_DIALOG; print_table (table, _("Print Tasks"), _("Tasks"), print_action); @@ -294,13 +294,13 @@ action_task_list_print_preview_cb (GtkAction *action, ETaskShellView *task_shell_view) { ETaskShellContent *task_shell_content; - ETaskTable *task_table; + ECalendarTable *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); + table = e_calendar_table_get_table (task_table); print_action = GTK_PRINT_OPERATION_ACTION_PREVIEW; print_table (table, _("Print Tasks"), _("Tasks"), print_action); @@ -362,18 +362,19 @@ action_task_mark_complete_cb (GtkAction *action, ETaskShellView *task_shell_view) { ETaskShellContent *task_shell_content; - ETaskTable *task_table; + ECalendarTable *task_table; ECalModel *model; GSList *list, *iter; 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); - model = e_task_table_get_model (task_table); + list = e_calendar_table_get_selected (task_table); + model = e_calendar_table_get_model (task_table); for (iter = list; iter != NULL; iter = iter->next) { ECalModelComponent *comp_data = iter->data; - e_cal_model_tasks_mark_comp_complete (model, comp_data); + e_cal_model_tasks_mark_comp_complete ( + E_CAL_MODEL_TASKS (model), comp_data); } g_slist_free (list); @@ -384,18 +385,19 @@ action_task_mark_incomplete_cb (GtkAction *action, ETaskShellView *task_shell_view) { ETaskShellContent *task_shell_content; - ETaskTable *task_table; + ECalendarTable *task_table; ECalModel *model; GSList *list, *iter; 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); - model = e_task_table_get_model (task_table); + list = e_calendar_table_get_selected (task_table); + model = e_calendar_table_get_model (task_table); for (iter = list; iter != NULL; iter = iter->next) { ECalModelComponent *comp_data = iter->data; - e_cal_model_tasks_mark_comp_incomplete (model, comp_data); + e_cal_model_tasks_mark_comp_incomplete ( + E_CAL_MODEL_TASKS (model), comp_data); } g_slist_free (list); @@ -406,7 +408,7 @@ action_task_new_cb (GtkAction *action, ETaskShellView *task_shell_view) { ETaskShellContent *task_shell_content; - ETaskTable *task_table; + ECalendarTable *task_table; ECalModelComponent *comp_data; ECal *client; ECalComponent *comp; @@ -416,7 +418,7 @@ action_task_new_cb (GtkAction *action, 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); + list = e_calendar_table_get_selected (task_table); g_return_if_fail (list != NULL); comp_data = list->data; g_slist_free (list); @@ -437,14 +439,14 @@ action_task_open_cb (GtkAction *action, ETaskShellView *task_shell_view) { ETaskShellContent *task_shell_content; - ETaskTable *task_table; + ECalendarTable *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); - list = e_task_table_get_selected (task_table); + list = e_calendar_table_get_selected (task_table); g_return_if_fail (list != NULL); comp_data = list->data; g_slist_free (list); @@ -458,7 +460,7 @@ action_task_open_url_cb (GtkAction *action, ETaskShellView *task_shell_view) { ETaskShellContent *task_shell_content; - ETaskTable *task_table; + ECalendarTable *task_table; ECalModelComponent *comp_data; icalproperty *prop; GdkScreen *screen; @@ -469,7 +471,7 @@ action_task_open_url_cb (GtkAction *action, 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); + list = e_calendar_table_get_selected (task_table); g_return_if_fail (list != NULL); comp_data = list->data; @@ -505,7 +507,7 @@ action_task_print_cb (GtkAction *action, ETaskShellView *task_shell_view) { ETaskShellContent *task_shell_content; - ETaskTable *task_table; + ECalendarTable *task_table; ECalModelComponent *comp_data; ECalComponent *comp; icalcomponent *clone; @@ -513,9 +515,9 @@ action_task_print_cb (GtkAction *action, GSList *list; task_shell_content = task_shell_view->priv->task_shell_content; - task_table = e_memo_shell_content_get_task_table (task_shell_content); + task_table = e_task_shell_content_get_task_table (task_shell_content); - list = e_task_table_get_selected (task_table); + list = e_calendar_table_get_selected (task_table); g_return_if_fail (list != NULL); comp_data = list->data; g_slist_free (list); @@ -540,7 +542,7 @@ action_task_save_as_cb (GtkAction *action, ETaskShellView *task_shell_view) { ETaskShellContent *task_shell_content; - ETaskTable *task_table; + ECalendarTable *task_table; ECalModelComponent *comp_data; GSList *list; gchar *filename; @@ -549,7 +551,7 @@ action_task_save_as_cb (GtkAction *action, 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); + list = e_calendar_table_get_selected (task_table); g_return_if_fail (list != NULL); comp_data = list->data; g_slist_free (list); @@ -558,7 +560,7 @@ action_task_save_as_cb (GtkAction *action, if (filename == NULL) return; - string = e_cal_component_as_string ( + string = e_cal_get_component_as_string ( comp_data->client, comp_data->icalcomp); if (string == NULL) { g_warning ("Could not convert task to a string"); @@ -603,14 +605,14 @@ static GtkActionEntry task_entries[] = { { "task-delete", GTK_STOCK_DELETE, - N_("Delete Task"), + N_("_Delete Task"), NULL, N_("Delete selected tasks"), G_CALLBACK (action_task_delete_cb) }, { "task-forward", "mail-forward", - N_("_Forward as iCalendar"), + N_("_Forward as iCalendar..."), "<Control>f", NULL, /* XXX Add a tooltip! */ G_CALLBACK (action_task_forward_cb) }, @@ -657,6 +659,13 @@ static GtkActionEntry task_entries[] = { NULL, /* XXX Add a tooltip! */ G_CALLBACK (action_task_list_properties_cb) }, + { "task-list-select-one", + "stock_check-filled", + N_("Show _Only This Task List"), + NULL, + NULL, /* XXX Add a tooltip! */ + G_CALLBACK (action_task_list_select_one_cb) }, + { "task-mark-complete", NULL, N_("_Mark as Complete"), @@ -708,10 +717,19 @@ static GtkActionEntry task_entries[] = { { "task-save-as", GTK_STOCK_SAVE_AS, - NULL, + N_("_Save as iCalendar..."), NULL, NULL, /* XXX Add a tooltip! */ - G_CALLBACK (action_task_save_as_cb) } + G_CALLBACK (action_task_save_as_cb) }, + + /*** Menus ***/ + + { "task-actions-menu", + NULL, + N_("_Actions"), + NULL, + NULL, + NULL } }; static GtkToggleActionEntry task_toggle_entries[] = { diff --git a/calendar/modules/e-task-shell-view-actions.h b/calendar/modules/e-task-shell-view-actions.h index 0b7212e469..48aa01811c 100644 --- a/calendar/modules/e-task-shell-view-actions.h +++ b/calendar/modules/e-task-shell-view-actions.h @@ -30,7 +30,7 @@ #define E_SHELL_WINDOW_ACTION_TASK_CLIPBOARD_COPY(window) \ E_SHELL_WINDOW_ACTION ((window), "task-clipboard-copy") #define E_SHELL_WINDOW_ACTION_TASK_CLIPBOARD_CUT(window) \ - E_SHELL_WINDOW_ACTION ((window), "task-clibpard-cut") + E_SHELL_WINDOW_ACTION ((window), "task-clipboard-cut") #define E_SHELL_WINDOW_ACTION_TASK_CLIPBOARD_PASTE(window) \ E_SHELL_WINDOW_ACTION ((window), "task-clipboard-paste") #define E_SHELL_WINDOW_ACTION_TASK_DELETE(window) \ diff --git a/calendar/modules/e-task-shell-view-private.c b/calendar/modules/e-task-shell-view-private.c index 741913f05a..825b039420 100644 --- a/calendar/modules/e-task-shell-view-private.c +++ b/calendar/modules/e-task-shell-view-private.c @@ -35,7 +35,7 @@ task_shell_view_table_popup_event_cb (EShellView *shell_view, static void task_shell_view_table_user_created_cb (ETaskShellView *task_shell_view, - ETaskTable *task_table) + ECalendarTable *task_table) { ETaskShellSidebar *task_shell_sidebar; ECalModel *model; @@ -44,7 +44,7 @@ task_shell_view_table_user_created_cb (ETaskShellView *task_shell_view, /* This is the "Click to Add" handler. */ - model = e_task_table_get_model (task_table); + model = e_calendar_table_get_model (task_table); client = e_cal_model_get_default_client (model); source = e_cal_get_source (client); @@ -59,12 +59,12 @@ task_shell_view_selector_client_added_cb (ETaskShellView *task_shell_view, ECal *client) { ETaskShellContent *task_shell_content; - ETaskTable *task_table; + ECalendarTable *task_table; ECalModel *model; 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); + model = e_calendar_table_get_model (task_table); e_cal_model_add_client (model, client); } @@ -74,12 +74,12 @@ task_shell_view_selector_client_removed_cb (ETaskShellView *task_shell_view, ECal *client) { ETaskShellContent *task_shell_content; - ETaskTable *task_table; + ECalendarTable *task_table; ECalModel *model; 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); + model = e_calendar_table_get_model (task_table); e_cal_model_remove_client (model, client); } @@ -181,7 +181,7 @@ e_task_shell_view_private_constructed (ETaskShellView *task_shell_view) EShellWindow *shell_window; EShellContent *shell_content; EShellSidebar *shell_sidebar; - ETaskTable *task_table; + ECalendarTable *task_table; ECalModel *model; ETable *table; ESourceSelector *selector; @@ -197,8 +197,8 @@ e_task_shell_view_private_constructed (ETaskShellView *task_shell_view) task_shell_content = E_TASK_SHELL_CONTENT (shell_content); task_table = e_task_shell_content_get_task_table (task_shell_content); - model = e_task_table_get_model (task_table); - table = e_task_table_get_table (task_table); + model = e_calendar_table_get_model (task_table); + table = e_calendar_table_get_table (task_table); task_shell_sidebar = E_TASK_SHELL_SIDEBAR (shell_sidebar); selector = e_task_shell_sidebar_get_selector (task_shell_sidebar); @@ -309,7 +309,80 @@ e_task_shell_view_private_finalize (ETaskShellView *task_shell_view) void e_task_shell_view_execute_search (ETaskShellView *task_shell_view) { + ETaskShellContent *task_shell_content; + EShellView *shell_view; + EShellWindow *shell_window; + EShellContent *shell_content; + GtkAction *action; + GString *string; + ECalComponentPreview *task_preview; + ECalendarTable *task_table; + ECalModel *model; + FilterRule *rule; + const gchar *format; + const gchar *text; + gchar *query; + gint value; + + shell_view = E_SHELL_VIEW (task_shell_view); + shell_content = e_shell_view_get_shell_content (shell_view); + text = e_shell_content_get_search_text (shell_content); + + shell_window = e_shell_view_get_shell_window (shell_view); + action = ACTION (TASK_SEARCH_ANY_FIELD_CONTAINS); + value = gtk_radio_action_get_current_value ( + GTK_RADIO_ACTION (action)); + + if (text == NULL || *text == '\0') { + text = ""; + value = TASK_SEARCH_SUMMARY_CONTAINS; + } + + switch (value) { + default: + text = ""; + /* fall through */ + + case TASK_SEARCH_SUMMARY_CONTAINS: + format = "(contains? \"summary\" %s)"; + break; + + case TASK_SEARCH_DESCRIPTION_CONTAINS: + format = "(contains? \"description\" %s)"; + break; + + case TASK_SEARCH_ANY_FIELD_CONTAINS: + format = "(contains? \"any\" %s)"; + break; + } + + /* Build the query. */ + string = g_string_new (""); + e_sexp_encode_string (string, text); + query = g_strdup_printf (format, string->str); + g_string_free (string, TRUE); + + /* Apply selected filter. */ + value = e_shell_content_get_filter_value (shell_content); /* FIXME */ + + /* XXX This is wrong. We need to programmatically construct a + * FilterRule, tell it to build code, and pass the resulting + * expression string to ECalModel. */ + rule = filter_rule_new (); + e_shell_content_set_search_rule (shell_content, rule); + g_object_unref (rule); + + /* Submit the query. */ + task_shell_content = task_shell_view->priv->task_shell_content; + task_table = e_task_shell_content_get_task_table (task_shell_content); + model = e_calendar_table_get_model (task_table); + e_cal_model_set_search_query (model, query); + g_free (query); + + task_preview = + e_task_shell_content_get_task_preview (task_shell_content); + e_cal_component_preview_clear (task_preview); } void @@ -344,7 +417,7 @@ e_task_shell_view_open_task (ETaskShellView *task_shell_view, if (itip_organizer_is_user (comp, comp_data->client)) flags |= COMP_EDITOR_USER_ORG; - if (!itip_organizer_has_attendees (comp)) + if (!e_cal_component_has_attendees (comp)) flags |= COMP_EDITOR_USER_ORG; editor = task_editor_new (comp_data->client, flags); @@ -396,7 +469,7 @@ e_task_shell_view_update_sidebar (ETaskShellView *task_shell_view) ETaskShellContent *task_shell_content; EShellView *shell_view; EShellSidebar *shell_sidebar; - ETaskTable *task_table; + ECalendarTable *task_table; ECalModel *model; ETable *table; GString *string; @@ -410,8 +483,8 @@ e_task_shell_view_update_sidebar (ETaskShellView *task_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); - table = e_task_table_get_table (task_table); + model = e_calendar_table_get_model (task_table); + table = e_calendar_table_get_table (task_table); n_rows = e_table_model_row_count (E_TABLE_MODEL (model)); n_selected = e_table_selected_count (table); diff --git a/calendar/modules/e-task-shell-view-private.h b/calendar/modules/e-task-shell-view-private.h index ac198b936d..e5de26d721 100644 --- a/calendar/modules/e-task-shell-view-private.h +++ b/calendar/modules/e-task-shell-view-private.h @@ -35,10 +35,13 @@ #include "e-util/gconf-bridge.h" #include "calendar/common/authentication.h" -#include "calendar/gui/misc.h" +#include "calendar/gui/comp-util.h" #include "calendar/gui/e-cal-component-preview.h" +#include "calendar/gui/e-cal-model-tasks.h" #include "calendar/gui/e-calendar-selector.h" +#include "calendar/gui/print.h" #include "calendar/gui/dialogs/calendar-setup.h" +#include "calendar/gui/dialogs/copy-source-dialog.h" #include "calendar/gui/dialogs/task-editor.h" #include "e-task-shell-content.h" diff --git a/calendar/modules/e-task-shell-view.c b/calendar/modules/e-task-shell-view.c index 6de83e90eb..8ff7e16c91 100644 --- a/calendar/modules/e-task-shell-view.c +++ b/calendar/modules/e-task-shell-view.c @@ -82,7 +82,7 @@ task_shell_view_update_actions (EShellView *shell_view) EShellWindow *shell_window; ESourceSelector *selector; ETable *table; - ETaskTable *task_table; + ECalendarTable *task_table; ESource *source; GtkAction *action; GSList *list, *iter; @@ -107,10 +107,10 @@ task_shell_view_update_actions (EShellView *shell_view) 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); + table = e_calendar_table_get_table (task_table); n_selected = e_table_selected_count (table); - list = e_task_table_get_selected (task_table); + list = e_calendar_table_get_selected (task_table); for (iter = list; iter != NULL; iter = iter->next) { ECalModelComponent *comp_data = iter->data; icalproperty *prop; @@ -124,7 +124,7 @@ task_shell_view_update_actions (EShellView *shell_view) if (e_cal_get_static_capability (comp_data->client, cap)) assignable = FALSE; - cap = CAL_STATIC_NO_CONV_TO_ASSIGN_TASK; + cap = CAL_STATIC_CAPABILITY_NO_CONV_TO_ASSIGN_TASK; if (e_cal_get_static_capability (comp_data->client, cap)) assignable = FALSE; |