diff options
author | Matthew Barnes <mbarnes@src.gnome.org> | 2008-09-26 10:42:23 +0800 |
---|---|---|
committer | Matthew Barnes <mbarnes@src.gnome.org> | 2008-09-26 10:42:23 +0800 |
commit | cb78b84aecf1c011e0b013cc94a079e2dc0eabbc (patch) | |
tree | e6fbbd6a08aa152bbb79f3ebd9eee80ae6c35f7c /calendar/modules | |
parent | 9515b98403f2f7ef77dc6c51f82505fccef08c2b (diff) | |
download | gsoc2013-evolution-cb78b84aecf1c011e0b013cc94a079e2dc0eabbc.tar.gz gsoc2013-evolution-cb78b84aecf1c011e0b013cc94a079e2dc0eabbc.tar.zst gsoc2013-evolution-cb78b84aecf1c011e0b013cc94a079e2dc0eabbc.zip |
Tasks and memos progress. Hoping to merge ECalendarTable and EMemoTable,
or at least make EMemoTable derived from ECalendarTable. Possibly do the
same with other calendar/memo class pairs.
svn path=/branches/kill-bonobo/; revision=36454
Diffstat (limited to 'calendar/modules')
-rw-r--r-- | calendar/modules/e-memo-shell-content.c | 8 | ||||
-rw-r--r-- | calendar/modules/e-memo-shell-view-actions.c | 207 | ||||
-rw-r--r-- | calendar/modules/e-memo-shell-view-private.c | 104 | ||||
-rw-r--r-- | calendar/modules/e-memo-shell-view-private.h | 11 | ||||
-rw-r--r-- | calendar/modules/e-task-shell-view-private.c | 271 | ||||
-rw-r--r-- | calendar/modules/e-task-shell-view-private.h | 18 |
6 files changed, 587 insertions, 32 deletions
diff --git a/calendar/modules/e-memo-shell-content.c b/calendar/modules/e-memo-shell-content.c index a3a3104b47..a7b50fc967 100644 --- a/calendar/modules/e-memo-shell-content.c +++ b/calendar/modules/e-memo-shell-content.c @@ -90,15 +90,13 @@ memo_shell_content_display_view_cb (EMemoShellContent *memo_shell_content, GalView *gal_view) { EMemoTable *memo_table; - ETableScrolled *table_scrolled; ETable *table; if (!GAL_IS_VIEW_ETABLE (gal_view)) return; memo_table = E_MEMO_TABLE (memo_shell_content->priv->memo_table); - table_scrolled = E_TABLE_SCROLLED (memo_table->etable); - table = e_table_scrolled_get_table (table_scrolled); + table = e_memo_table_get_table (memo_table); gal_view_etable_attach_table (GAL_VIEW_ETABLE (gal_view), table); } @@ -184,7 +182,6 @@ memo_shell_content_model_row_changed_cb (EMemoShellContent *memo_shell_content, { ECalModelComponent *comp_data; EMemoTable *memo_table; - ETableScrolled *table_scrolled; ETable *table; const gchar *current_uid; const gchar *uid; @@ -202,8 +199,7 @@ memo_shell_content_model_row_changed_cb (EMemoShellContent *memo_shell_content, return; memo_table = E_MEMO_TABLE (memo_shell_content->priv->memo_table); - table_scrolled = E_TABLE_SCROLLED (memo_table->etable); - table = e_table_scrolled_get_table (table_scrolled); + table = e_memo_table_get_table (memo_table); memo_shell_content_cursor_change_cb (memo_shell_content, 0, table); } diff --git a/calendar/modules/e-memo-shell-view-actions.c b/calendar/modules/e-memo-shell-view-actions.c index e20ec46949..29dacabafc 100644 --- a/calendar/modules/e-memo-shell-view-actions.c +++ b/calendar/modules/e-memo-shell-view-actions.c @@ -82,6 +82,35 @@ action_memo_delete_cb (GtkAction *action, } static void +action_memo_forward_cb (GtkAction *action, + EMemoShellView *memo_shell_view) +{ + EMemoShellContent *memo_shell_content; + EMemoTable *memo_table; + ECalModelComponent *comp_data; + ECalComponent *comp; + icalcomponent *clone; + ECalComponentItipMethod method; + GSList *list; + + memo_shell_content = memo_shell_view->priv->memo_shell_content; + memo_table = e_memo_shell_content_get_memo_table (memo_shell_content); + + list = e_memo_table_get_selected (memo_table); + g_return_if_fail (list != NULL); + comp_data = list->data; + g_slist_free (list); + + /* XXX We only forward the first selected memo. */ + comp = e_cal_component_new (); + clone = icalcomponent_new_clone (comp_data->icalcomp); + method = E_CAL_COMPONENT_METHOD_PUBLISH; + e_cal_component_set_icalcomponent (comp, clone); + itip_send_comp (method, comp, comp_data->client, NULL, NULL, NULL); + g_object_unref (comp); +} + +static void action_memo_list_copy_cb (GtkAction *action, EMemoShellView *memo_shell_view) { @@ -108,6 +137,40 @@ action_memo_list_new_cb (GtkAction *action, } static void +action_memo_list_print_cb (GtkAction *action, + EMemoShellView *memo_shell_view) +{ + EMemoShellContent *memo_shell_content; + EMemoTable *memo_table; + ETable *table; + GtkPrintOperationAction print_action; + + memo_shell_content = memo_shell_view->priv->memo_shell_content; + 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_table (table, _("Print Memos"), _("Memos"), print_action); +} + +static void +action_memo_list_print_preview_cb (GtkAction *action, + EMemoShellView *memo_shell_view) +{ + EMemoShellContent *memo_shell_content; + EMemoTable *memo_table; + ETable *table; + GtkPrintOperationAction print_action; + + memo_shell_content = memo_shell_view->priv->memo_shell_content; + 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_table (table, _("Print Memos"), _("Memos"), print_action); +} + +static void action_memo_list_properties_cb (GtkAction *action, EMemoShellView *memo_shell_view) { @@ -134,10 +197,54 @@ action_memo_open_cb (GtkAction *action, { EMemoShellContent *memo_shell_content; EMemoTable *memo_table; + ECalModelComponent *comp_data; + GSList *list; memo_shell_content = memo_shell_view->priv->memo_shell_content; memo_table = e_memo_shell_content_get_memo_table (memo_shell_content); - e_memo_table_open_selected (memo_table); + + list = e_memo_table_get_selected (memo_table); + g_return_if_fail (list != NULL); + comp_data = list->data; + g_slist_free (list); + + /* XXX We only open the first selected memo. */ + e_memo_shell_view_open_memo (memo_shell_view, comp_data); +} + +static void +action_memo_open_url_cb (GtkAction *action, + EMemoShellView *memo_shell_view) +{ + EMemoShellContent *memo_shell_content; + EMemoTable *memo_table; + ECalModelComponent *comp_data; + icalproperty *prop; + GdkScreen *screen; + const gchar *uri; + GSList *list; + GError *error = NULL; + + memo_shell_content = memo_shell_view->priv->memo_shell_content; + memo_table = e_memo_shell_content_get_memo_table (memo_shell_content); + + list = e_memo_table_get_selected (memo_table); + g_return_if_fail (list != NULL); + comp_data = list->data; + + /* XXX We only open the URI of the first selected memo. */ + prop = icalcomponent_get_first_property ( + comp_data->icalcomp, ICAL_URL_PROPERTY); + g_return_if_fail (prop == NULL); + + screen = gtk_widget_get_screen (GTK_WIDGET (memo_shell_view)); + uri = icalproperty_get_url (prop); + gtk_show_uri (screen, uri, GDK_CURRENT_TIME, &error); + + if (error != NULL) { + g_warning ("%s", error->message); + g_error_free (error); + } } static void @@ -158,32 +265,63 @@ action_memo_print_cb (GtkAction *action, { EMemoShellContent *memo_shell_content; EMemoTable *memo_table; - ETable *table; + ECalModelComponent *comp_data; + ECalComponent *comp; + icalcomponent *clone; + GtkPrintOperationAction print_action; + GSList *list; memo_shell_content = memo_shell_view->priv->memo_shell_content; memo_table = e_memo_shell_content_get_memo_table (memo_shell_content); - table = e_memo_table_get_table (memo_table); - print_table ( - table, _("Print Memos"), _("Memos"), - GTK_PRINT_OPERATION_ACTION_PRINT_DIALOG); + list = e_memo_table_get_selected (memo_table); + g_return_if_fail (list != NULL); + comp_data = list->data; + g_slist_free (list); + + /* XXX We only print the first selected memo. */ + comp = e_cal_component_new (); + clone = icalcomponent_new_clone (comp_data->icalcomp); + print_action = GTK_PRINT_OPERATION_ACTION_PRINT_DIALOG; + e_cal_component_set_icalcomponent (comp, clone); + print_comp (comp, comp_data->client, print_action); + g_object_unref (comp); } static void -action_memo_print_preview_cb (GtkAction *action, - EMemoShellView *memo_shell_view) +action_memo_save_as_cb (GtkAction *action, + EMemoShellView *memo_shell_view) { EMemoShellContent *memo_shell_content; EMemoTable *memo_table; - ETable *table; + ECalModelComponent *comp_data; + GSList *list; + gchar *filename; + gchar *string; memo_shell_content = memo_shell_view->priv->memo_shell_content; memo_table = e_memo_shell_content_get_memo_table (memo_shell_content); - table = e_memo_table_get_table (memo_table); - print_table ( - table, _("Print Memos"), _("Memos"), - GTK_PRINT_OPERATION_ACTION_PREVIEW); + list = e_memo_table_get_selected (memo_table); + g_return_if_fail (list != NULL); + comp_data = list->data; + g_slist_free (list); + + filename = e_file_dialog_save (_("Save as..."), NULL); + if (filename == NULL) + return; + + string = e_cal_get_component_as_string ( + comp_data->client, comp_data->icalcomp); + if (string == NULL) { + g_warning ("Could not convert memo to a string"); + return; + } + + e_write_file_uri (filename, string); + + g_free (filename); + g_free (string); } static GtkActionEntry memo_entries[] = { @@ -211,11 +349,18 @@ static GtkActionEntry memo_entries[] = { { "memo-delete", GTK_STOCK_DELETE, - NULL, + N_("Delete Memo"), NULL, N_("Delete selected memos"), G_CALLBACK (action_memo_delete_cb) }, + { "memo-forward", + "mail-forward", + N_("_Forward as iCalendar"), + NULL, + NULL, /* XXX Add a tooltip! */ + G_CALLBACK (action_memo_forward_cb) }, + { "memo-list-copy", GTK_STOCK_COPY, N_("_Copy..."), @@ -237,6 +382,20 @@ static GtkActionEntry memo_entries[] = { N_("Create a new memo list"), G_CALLBACK (action_memo_list_new_cb) }, + { "memo-list-print", + GTK_STOCK_PRINT, + NULL, + NULL, + N_("Print the list of memos"), + G_CALLBACK (action_memo_list_print_cb) }, + + { "memo-list-print-preview", + GTK_STOCK_PRINT_PREVIEW, + NULL, + NULL, + N_("Preview the list of memos to be printed"), + G_CALLBACK (action_memo_list_print_preview_cb) }, + { "memo-list-properties", GTK_STOCK_PROPERTIES, NULL, @@ -251,19 +410,26 @@ static GtkActionEntry memo_entries[] = { N_("View the selected memo"), G_CALLBACK (action_memo_open_cb) }, + { "memo-open-url", + NULL, + N_("Open _Web Page"), + NULL, + NULL, /* XXX Add a tooltip! */ + G_CALLBACK (action_memo_open_url_cb) }, + { "memo-print", GTK_STOCK_PRINT, NULL, NULL, - N_("Print the list of memos"), + N_("Print the selected memo"), G_CALLBACK (action_memo_print_cb) }, - { "memo-print-preview", - GTK_STOCK_PRINT_PREVIEW, + { "memo-save-as", + GTK_STOCK_SAVE_AS, NULL, NULL, - N_("Preview the list of memos to be printed"), - G_CALLBACK (action_memo_print_preview_cb) }, + NULL, /* XXX Add a tooltip! */ + G_CALLBACK (action_memo_save_as_cb) } }; static GtkToggleActionEntry memo_toggle_entries[] = { @@ -326,6 +492,7 @@ e_memo_shell_view_actions_update (EMemoShellView *memo_shell_view) EShellView *shell_view; EShellWindow *shell_window; GtkAction *action; + const gchar *label; gboolean read_only = TRUE; gboolean sensitive; gint n_selected; @@ -364,4 +531,6 @@ e_memo_shell_view_actions_update (EMemoShellView *memo_shell_view) action = ACTION (MEMO_DELETE); sensitive = (n_selected > 0) && !read_only; gtk_action_set_sensitive (action, sensitive); + label = ngettext ("Delete Memo", "Delete Memos", n_selected); + g_object_set (action, "label", label, NULL); } diff --git a/calendar/modules/e-memo-shell-view-private.c b/calendar/modules/e-memo-shell-view-private.c index a6ce81a560..076ed3fc5d 100644 --- a/calendar/modules/e-memo-shell-view-private.c +++ b/calendar/modules/e-memo-shell-view-private.c @@ -155,8 +155,24 @@ memo_shell_view_add_source (EMemoShellView *memo_shell_view, } static void -memo_shell_view_user_created_cb (EMemoShellView *memo_shell_view, - EMemoTable *memo_table) +memo_shell_view_table_popup_event_cb (EMemoShellView *memo_shell_view, + GdkEvent *event) +{ + EShellView *shell_view; + EShellWindow *shell_window; + const gchar *widget_path; + + shell_view = E_SHELL_VIEW (memo_shell_view); + shell_window = e_shell_view_get_shell_window (shell_view); + widget_path = "/memo-popup"; + + e_memo_shell_view_actions_update (memo_shell_view); + e_shell_window_show_popup_menu (shell_window, widget_path, event); +} + +static void +memo_shell_view_table_user_created_cb (EMemoShellView *memo_shell_view, + EMemoTable *memo_table) { ECal *client; ESource *source; @@ -275,8 +291,23 @@ e_memo_shell_view_private_constructed (EMemoShellView *memo_shell_view) priv->memo_shell_content); g_signal_connect_swapped ( + memo_table, "open-component", + G_CALLBACK (e_memo_shell_view_open_memo), + memo_shell_view); + + g_signal_connect_swapped ( + memo_table, "popup-event", + G_CALLBACK (memo_shell_view_table_popup_event_cb), + memo_shell_view); + + g_signal_connect_swapped ( + memo_table, "status-message", + G_CALLBACK (e_memo_shell_view_set_status_message), + memo_shell_view); + + g_signal_connect_swapped ( memo_table, "user-created", - G_CALLBACK (memo_shell_view_user_created_cb), + G_CALLBACK (memo_shell_view_table_user_created_cb), memo_shell_view); e_memo_shell_view_actions_update (memo_shell_view); @@ -296,6 +327,13 @@ e_memo_shell_view_private_dispose (EMemoShellView *memo_shell_view) g_hash_table_remove_all (priv->client_table); DISPOSE (priv->default_client); + + if (memo_shell_view->priv->activity != NULL) { + /* XXX Activity is not cancellable. */ + e_activity_complete (memo_shell_view->priv->activity); + g_object_unref (memo_shell_view->priv->activity); + memo_shell_view->priv->activity = NULL; + } } void @@ -307,10 +345,68 @@ e_memo_shell_view_private_finalize (EMemoShellView *memo_shell_view) } void +e_memo_shell_view_open_memo (EMemoShellView *memo_shell_view, + ECalModelComponent *comp_data) +{ + CompEditor *editor; + CompEditorFlags flags = 0; + ECalComponent *comp; + icalcomponent *clone; + const gchar *uid; + + g_return_if_fail (E_IS_MEMO_SHELL_VIEW (memo_shell_view)); + g_return_if_fail (E_IS_CAL_MODEL_COMPONENT (comp_data)); + + uid = icalcomponent_get_uid (comp_data->icalcomp); + editor = comp_editor_find_instance (uid); + + if (editor == NULL) + goto exit; + + comp = e_cal_component_new (); + clone = icalcomponent_new_clone (comp_data->icalcomp); + e_cal_component_set_icalcomponent (comp, clone); + + if (e_cal_component_has_organizer (comp)) + flags |= COMP_EDITOR_IS_SHARED; + + if (itip_organizer_is_user (comp, comp_data->client)) + flags |= COMP_EDITOR_USER_ORG; + + editor = memo_editor_new (comp_data->client, flags); + comp_editor_edit_comp (editor, comp); + + g_object_unref (comp); + +exit: + gtk_window_present (GTK_WINDOW (editor)); +} + +void e_memo_shell_view_set_status_message (EMemoShellView *memo_shell_view, const gchar *status_message) { + EActivity *activity; + EShellView *shell_view; + g_return_if_fail (E_IS_MEMO_SHELL_VIEW (memo_shell_view)); - /* FIXME */ + activity = memo_shell_view->priv->activity; + shell_view = E_SHELL_VIEW (memo_shell_view); + + if (status_message == NULL || *status_message == '\0') { + if (activity != NULL) { + e_activity_complete (activity); + g_object_unref (activity); + activity = NULL; + } + + } else if (activity == NULL) { + activity = e_activity_new (status_message); + e_shell_view_add_activity (shell_view, activity); + + } else + e_activity_set_primary_text (activity, status_message); + + memo_shell_view->priv->activity = activity; } diff --git a/calendar/modules/e-memo-shell-view-private.h b/calendar/modules/e-memo-shell-view-private.h index 1fb44c12a6..7d8958eae7 100644 --- a/calendar/modules/e-memo-shell-view-private.h +++ b/calendar/modules/e-memo-shell-view-private.h @@ -26,14 +26,16 @@ #include <string.h> #include <glib/gi18n.h> +#include "e-util/e-dialog-utils.h" #include "e-util/e-error.h" #include "e-util/e-util.h" +#include "calendar/common/authentication.h" #include "calendar/gui/misc.h" #include "calendar/gui/e-calendar-selector.h" #include "calendar/gui/e-memo-preview.h" -#include "calendar/common/authentication.h" #include "calendar/gui/dialogs/calendar-setup.h" +#include "calendar/gui/dialogs/memo-editor.h" #include "e-memo-shell-content.h" #include "e-memo-shell-sidebar.h" @@ -76,9 +78,11 @@ struct _EMemoShellViewPrivate { EMemoShellContent *memo_shell_content; EMemoShellSidebar *memo_shell_sidebar; - /* UID -> ECal */ + /* UID -> Client */ GHashTable *client_table; ECal *default_client; + + EActivity *activity; }; void e_memo_shell_view_private_init @@ -97,6 +101,9 @@ void e_memo_shell_view_actions_init (EMemoShellView *memo_shell_view); void e_memo_shell_view_actions_update (EMemoShellView *memo_shell_view); +void e_memo_shell_view_open_memo + (EMemoShellView *memo_shell_view, + ECalModelComponent *comp_data); void e_memo_shell_view_set_status_message (EMemoShellView *memo_shell_view, const gchar *status_message); diff --git a/calendar/modules/e-task-shell-view-private.c b/calendar/modules/e-task-shell-view-private.c index 465f715ecd..b16ac80edb 100644 --- a/calendar/modules/e-task-shell-view-private.c +++ b/calendar/modules/e-task-shell-view-private.c @@ -23,6 +23,174 @@ #include <widgets/menus/gal-view-factory-etable.h> static void +task_shell_view_backend_died_cb (ETaskShellView *task_shell_view, + ECal *client) +{ + 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); + + g_object_unref (source); +} + +static void +task_shell_view_backend_error_cb (ETaskShellView *task_shell_view, + const gchar *message, + ECal *client) +{ + 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); + + 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_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) +{ + 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); + + g_signal_connect_swapped ( + client, "cal-opened", + G_CALLBACK (task_shell_view_client_opened_cb), + task_shell_view); + + e_cal_open_async (client, FALSE); + + return TRUE; +} + +static void +task_shell_view_table_popup_event_cb (ETaskShellView *task_shell_view, + GdkEvent *event) +{ + EShellView *shell_view; + EShellWindow *shell_window; + const gchar *widget_path; + + shell_view = E_SHELL_VIEW (task_shell_view); + shell_window = e_shell_view_get_shell_window (shell_view); + widget_path = "/task-popup"; + + e_task_shell_view_actions_update (task_shell_view); + e_shell_window_show_popup_menu (shell_window, widget_path, event); +} + +static void +task_shell_view_table_user_created (ETaskShellView *task_shell_view, + ETaskTable *task_table) +{ + ECal *client; + ESource *source; + + if (task_table->user_created_cal != NULL) + client = task_table->user_created_cal; + else { + ECalModel *model; + + model = e_task_table_get_model (task_table); + client = e_cal_model_get_default_client (model); + } + + source = e_cal_get_source (client); + task_shell_view_add_source (task_shell_view, source); +} + +static void task_shell_view_load_view_collection (EShellViewClass *shell_view_class) { GalViewCollection *collection; @@ -78,14 +246,21 @@ 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; if (!gal_view_collection_loaded (shell_view_class->view_collection)) task_shell_view_load_view_collection (shell_view_class); @@ -102,6 +277,7 @@ e_task_shell_view_private_constructed (ETaskShellView *task_shell_view) EShellContent *shell_content; EShellSidebar *shell_sidebar; EShellView *shell_view; + ETaskTable *task_table; shell_view = E_SHELL_VIEW (task_shell_view); shell_content = e_shell_view_get_shell_content (shell_view); @@ -110,6 +286,31 @@ e_task_shell_view_private_constructed (ETaskShellView *task_shell_view) /* Cache these to avoid lots of awkward casting. */ priv->task_shell_content = g_object_ref (shell_content); priv->task_shell_sidebar = g_object_ref (shell_sidebar); + + task_table = e_task_shell_content_get_task_table ( + priv->task_shell_content); + + g_signal_connect_swapped ( + task_table, "open-component", + G_CALLBACK (e_task_shell_view_open_task), + task_shell_view); + + g_signal_connect_swapped ( + task_table, "popup-event", + G_CALLBACK (task_shell_view_table_popup_event_cb), + task_shell_view); + + g_signal_connect_swapped ( + task_table, "status-message", + G_CALLBACK (e_task_shell_view_set_status_message), + task_shell_view); + + g_signal_connect_swapped ( + task_table, "user-created", + G_CALLBACK (task_shell_view_table_user_created_cb), + task_shell_view); + + e_task_shell_view_actions_update (task_shell_view); } void @@ -123,19 +324,87 @@ e_task_shell_view_private_dispose (ETaskShellView *task_shell_view) 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); + g_object_unref (task_shell_view->priv->activity); + task_shell_view->priv->activity = NULL; + } } void e_task_shell_view_private_finalize (ETaskShellView *task_shell_view) { ETaskShellViewPrivate *priv = task_shell_view->priv; + + g_hash_table_destroy (priv->client_table); +} + +void +e_task_shell_view_open_task (ETaskShellView *task_shell_view, + ECalModelComponent *comp_data) +{ + CompEditor *editor; + CompEditorFlags flags = 0; + ECalComponent *comp; + icalcomponent *clone; + const gchar *uid; + + g_return_if_fail (E_IS_TASK_SHELL_VIEW (task_shell_view)); + g_return_if_fail (E_IS_CAL_MODEL_COMPONENT (comp_data)); + + uid = icalcomponent_get_uid (comp_data->icalcomp); + editor = comp_editor_find_instance (uid); + + if (editor == NULL) + goto exit; + + comp = e_cal_component_new (); + clone = icalcomponent_new_clone (comp_data->icalcomp); + e_cal_component_set_icalcomponent (comp, clone); + + /* FIXME Do special stuff if task is assigned. */ + + editor = task_editor_new (comp_data->client, flags); + comp_editor_edit_comp (editor, comp); + + g_object_ref (comp); + + /* FIXME More special stuff here... */ + +exit: + gtk_window_present (GTK_WINDOW (editor)); } void e_task_shell_view_set_status_message (ETaskShellView *task_shell_view, const gchar *status_message) { + EActivity *activity; + EShellView *shell_view; + g_return_if_fail (E_IS_TASK_SHELL_VIEW (task_shell_view)); - /* FIXME */ + activity = task_shell_view->priv->activity; + shell_view = E_SHELL_VIEW (task_shell_view); + + if (status_message == NULL || *status_message == '\0') { + if (activity != NULL) { + e_activity_complete (activity); + g_object_unref (activity); + activity = NULL; + } + + } else if (activity == NULL) { + activity = e_activity_new (status_message); + e_shell_view_add_activity (shell_view, activity); + + } else + e_activity_set_primary_text (activity, status_message); + + task_shell_view->priv->activity = activity; } diff --git a/calendar/modules/e-task-shell-view-private.h b/calendar/modules/e-task-shell-view-private.h index 697ec7a120..ac6accfbcf 100644 --- a/calendar/modules/e-task-shell-view-private.h +++ b/calendar/modules/e-task-shell-view-private.h @@ -26,8 +26,17 @@ #include <string.h> #include <glib/gi18n.h> +#include "e-util/e-dialog-utils.h" +#include "e-util/e-error.h" #include "e-util/e-util.h" +#include "calendar/common/authentication.h" +#include "calendar/gui/misc.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" + #include "e-task-shell-content.h" #include "e-task-shell-sidebar.h" #include "e-task-shell-view-actions.h" @@ -68,6 +77,12 @@ struct _ETaskShellViewPrivate { /* These are just for convenience. */ ETaskShellContent *task_shell_content; ETaskShellSidebar *task_shell_sidebar; + + /* UID -> Client */ + GHashTable *client_table; + ECal *default_client; + + EActivity *activity; }; void e_task_shell_view_private_init @@ -86,6 +101,9 @@ void e_task_shell_view_actions_init (ETaskShellView *task_shell_view); void e_task_shell_view_actions_update (ETaskShellView *task_shell_view); +void e_task_shell_view_open_task + (ETaskShellView *task_shell_view, + ECalModelComponent *comp_data); void e_task_shell_view_set_status_message (ETaskShellView *task_shell_view, const gchar *status_message); |