From ee804aafe11507b85a3626480aa406b16b8104da Mon Sep 17 00:00:00 2001 From: Chenthill Palanisamy Date: Wed, 16 Nov 2005 13:53:47 +0000 Subject: UI changes for task editor. svn path=/trunk/; revision=30626 --- calendar/gui/dialogs/task-editor.c | 395 +++++++++++++++++++++++++++++-------- 1 file changed, 317 insertions(+), 78 deletions(-) (limited to 'calendar/gui/dialogs/task-editor.c') diff --git a/calendar/gui/dialogs/task-editor.c b/calendar/gui/dialogs/task-editor.c index b5fdc9bd24..e61c527c78 100644 --- a/calendar/gui/dialogs/task-editor.c +++ b/calendar/gui/dialogs/task-editor.c @@ -31,17 +31,21 @@ #include #include +#include +#include + #include "task-page.h" #include "task-details-page.h" #include "meeting-page.h" #include "cancel-comp.h" +#include "../calendar-config.h" #include "task-editor.h" struct _TaskEditorPrivate { TaskPage *task_page; TaskDetailsPage *task_details_page; - MeetingPage *meet_page; - + + GtkWidget *task_details_window; EMeetingStore *model; gboolean assignment_shown; @@ -56,11 +60,6 @@ static void task_editor_edit_comp (CompEditor *editor, ECalComponent *comp); static gboolean task_editor_send_comp (CompEditor *editor, ECalComponentItipMethod method); static void task_editor_finalize (GObject *object); -static void assign_task_cmd (GtkWidget *widget, gpointer data); -static void refresh_task_cmd (GtkWidget *widget, gpointer data); -static void cancel_task_cmd (GtkWidget *widget, gpointer data); -static void forward_cmd (GtkWidget *widget, gpointer data); - static void model_row_change_insert_cb (GtkTreeModel *model, GtkTreePath *path, GtkTreeIter *iter, gpointer data); static void model_row_delete_cb (GtkTreeModel *model, GtkTreePath *path, gpointer data); @@ -104,11 +103,213 @@ client_changed_cb (CompEditorPage *page, ECal *client, gpointer user_data) // set_menu_sens (TASK_EDITOR (user_data)); } +static void +menu_view_role_cb (BonoboUIComponent *component, + const char *path, + Bonobo_UIComponent_EventType type, + const char *state, + gpointer user_data) +{ + TaskEditor *te = (TaskEditor *) user_data; + + if (type != Bonobo_UIComponent_STATE_CHANGED) + return; + task_page_set_view_role (te->priv->task_page, atoi(state)); + calendar_config_set_show_role (atoi(state)); +} + +static void +menu_view_status_cb (BonoboUIComponent *component, + const char *path, + Bonobo_UIComponent_EventType type, + const char *state, + gpointer user_data) +{ + TaskEditor *te = (TaskEditor *) user_data; + + if (type != Bonobo_UIComponent_STATE_CHANGED) + return; + + task_page_set_view_status (te->priv->task_page, atoi(state)); + calendar_config_set_show_status (atoi(state)); +} + +static void +menu_view_type_cb (BonoboUIComponent *component, + const char *path, + Bonobo_UIComponent_EventType type, + const char *state, + gpointer user_data) +{ + TaskEditor *te = (TaskEditor *) user_data; + + if (type != Bonobo_UIComponent_STATE_CHANGED) + return; + task_page_set_view_type (te->priv->task_page, atoi(state)); + calendar_config_set_show_type (atoi(state)); +} + +static void +menu_view_rsvp_cb (BonoboUIComponent *component, + const char *path, + Bonobo_UIComponent_EventType type, + const char *state, + gpointer user_data) +{ + TaskEditor *te = (TaskEditor *) user_data; + + if (type != Bonobo_UIComponent_STATE_CHANGED) + return; + task_page_set_view_rsvp (te->priv->task_page, atoi(state)); + calendar_config_set_show_rsvp (atoi(state)); +} + +static void +menu_show_time_zone_cb (BonoboUIComponent *component, + const char *path, + Bonobo_UIComponent_EventType type, + const char *state, + gpointer user_data) +{ + TaskEditor *te = (TaskEditor *) user_data; + + if (type != Bonobo_UIComponent_STATE_CHANGED) + return; + task_page_set_show_timezone (te->priv->task_page, atoi(state)); + calendar_config_set_show_timezone (atoi(state)); +} + +static void +menu_show_categories_cb (BonoboUIComponent *component, + const char *path, + Bonobo_UIComponent_EventType type, + const char *state, + gpointer user_data) +{ + TaskEditor *te = (TaskEditor *) user_data; + + if (type != Bonobo_UIComponent_STATE_CHANGED) + return; + + task_page_set_show_categories (te->priv->task_page, atoi(state)); + calendar_config_set_show_categories (atoi(state)); +} + +static void +menu_class_public_cb (BonoboUIComponent *ui_component, + const char *path, + Bonobo_UIComponent_EventType type, + const char *state, + gpointer user_data) +{ + TaskEditor *te = (TaskEditor *) user_data; + + if (state[0] == '0') + return; + printf("Setting to public\n"); + task_page_set_classification (te->priv->task_page, E_CAL_COMPONENT_CLASS_PUBLIC); +} + +static void +menu_class_private_cb (BonoboUIComponent *ui_component, + const char *path, + Bonobo_UIComponent_EventType type, + const char *state, + gpointer user_data) +{ + TaskEditor *te = (TaskEditor *) user_data; + if (state[0] == '0') + return; + + printf("Setting to private\n"); + task_page_set_classification (te->priv->task_page, E_CAL_COMPONENT_CLASS_PRIVATE); +} + +static void +menu_class_confidential_cb (BonoboUIComponent *ui_component, + const char *path, + Bonobo_UIComponent_EventType type, + const char *state, + gpointer user_data) +{ + TaskEditor *te = (TaskEditor *) user_data; + if (state[0] == '0') + return; + + printf("Setting to confidential\n"); + task_page_set_classification (te->priv->task_page, E_CAL_COMPONENT_CLASS_CONFIDENTIAL); +} + + +static void +menu_option_status_cb (BonoboUIComponent *ui_component, + const char *path, + Bonobo_UIComponent_EventType type, + const char *state, + gpointer user_data) +{ + TaskEditor *te = (TaskEditor *) user_data; + + gtk_widget_show (te->priv->task_details_window); +} + +static void +menu_insert_send_options_cmd (BonoboUIComponent *uic, + void *data, + const char *path) +{ + TaskEditor *te = (TaskEditor *) data; + + task_page_sendoptions_clicked_cb (te->priv->task_page); +} + +static void +menu_show_time_zone_cmd (BonoboUIComponent *uic, + void *data, + const char *path) +{ /* TODO implement it + TaskEditor *te = (TaskEditor *) data; + + task_page_set_show_timezone (te->priv->task_page, atoi(state)); + calendar_config_set_show_timezone (atoi(state)); */ +} + +static void +menu_option_status_cmd (BonoboUIComponent *uic, + void *data, + const char *path) +{ + /* TODO implement it + TaskEditor *te = (TaskEditor *) data; + + task_page_set_view_status (te->priv->task_page, atoi(state)); + calendar_config_set_show_status (atoi(state)); */ +} + +static BonoboUIVerb verbs [] = { + + BONOBO_UI_VERB ("ViewTimeZone", menu_show_time_zone_cmd), + BONOBO_UI_VERB ("OptionStatus", menu_option_status_cmd), + BONOBO_UI_VERB ("InsertSendOptions", menu_insert_send_options_cmd), + BONOBO_UI_VERB_END +}; + +static EPixmap pixmaps[] = { + E_PIXMAP ("/Toolbar/ViewTimeZone", "stock_timezone", E_ICON_SIZE_LARGE_TOOLBAR), + E_PIXMAP ("/Toolbar/OptionStatus", "stock_view-details", E_ICON_SIZE_LARGE_TOOLBAR), + E_PIXMAP ("/commands/OptionStatus", "stock_view-details", E_ICON_SIZE_LARGE_TOOLBAR), + + E_PIXMAP_END +}; + + /* Object initialization function for the task editor */ static void task_editor_init (TaskEditor *te) { TaskEditorPrivate *priv; + CompEditor *editor = COMP_EDITOR(te); + gboolean status; priv = g_new0 (TaskEditorPrivate, 1); te->priv = priv; @@ -118,6 +319,88 @@ task_editor_init (TaskEditor *te) priv->updating = FALSE; priv->is_assigned = FALSE; + bonobo_ui_component_freeze (editor->uic, NULL); + + bonobo_ui_component_add_verb_list_with_data (editor->uic, verbs, te); + + bonobo_ui_util_set_ui (editor->uic, PREFIX, + EVOLUTION_UIDIR "/evolution-task-editor.xml", + "evolution-task-editor", NULL); + + /* Show hide the status fields */ + status = calendar_config_get_show_status (); + bonobo_ui_component_set_prop ( + editor->uic, "/commands/ViewStatus", + "state", status ? "1" : "0", NULL); + bonobo_ui_component_add_listener ( + editor->uic, "ViewStatus", + menu_view_status_cb, editor); + + /* Show hide the type fields */ + status = calendar_config_get_show_type (); + bonobo_ui_component_set_prop ( + editor->uic, "/commands/ViewType", + "state", status ? "1" : "0", NULL); + bonobo_ui_component_add_listener ( + editor->uic, "ViewType", + menu_view_type_cb, editor); + + /* Show hide the role fields */ + status = calendar_config_get_show_role (); + bonobo_ui_component_set_prop ( + editor->uic, "/commands/ViewRole", + "state", status ? "1" : "0", NULL); + bonobo_ui_component_add_listener ( + editor->uic, "ViewRole", + menu_view_role_cb, editor); + + /* Show hide the rsvp fields */ + status = calendar_config_get_show_rsvp (); + bonobo_ui_component_set_prop ( + editor->uic, "/commands/ViewRSVP", + "state", status ? "1" : "0", NULL); + bonobo_ui_component_add_listener ( + editor->uic, "ViewRSVP", + menu_view_rsvp_cb, editor); + + status = calendar_config_get_show_timezone (); + bonobo_ui_component_set_prop ( + editor->uic, "/commands/ViewTimeZone", + "state", status ? "1" : "0", NULL); + bonobo_ui_component_add_listener ( + editor->uic, "ViewTimeZone", + menu_show_time_zone_cb, editor); + + status = calendar_config_get_show_categories (); + bonobo_ui_component_set_prop ( + editor->uic, "/commands/ViewCategories", + "state", status ? "1" : "0", NULL); + bonobo_ui_component_add_listener ( + editor->uic, "ViewCategories", + menu_show_categories_cb, editor); + + bonobo_ui_component_set_prop ( + editor->uic, "/commands/ActionClassPublic", + "state", "1", NULL); + bonobo_ui_component_add_listener ( + editor->uic, "ActionClassPublic", + menu_class_public_cb, editor); + bonobo_ui_component_add_listener ( + editor->uic, "ActionClassPrivate", + menu_class_private_cb, editor); + bonobo_ui_component_add_listener ( + editor->uic, "ActionClassConfidential", + menu_class_confidential_cb, editor); + + bonobo_ui_component_add_listener ( + editor->uic, "OptionStatus", + menu_option_status_cb, editor); + + e_pixmaps_update (editor->uic, pixmaps); + + bonobo_ui_component_thaw (editor->uic, NULL); + + comp_editor_set_help_section (COMP_EDITOR (te), "usage-calendar-todo"); } @@ -126,10 +409,11 @@ task_editor_construct (TaskEditor *te, ECal *client) { TaskEditorPrivate *priv; gboolean read_only = FALSE; + CompEditor *editor = COMP_EDITOR (te); priv = te->priv; - priv->task_page = task_page_new (); + priv->task_page = task_page_new (priv->model, client, editor->uic); g_object_ref (priv->task_page); gtk_object_sink (GTK_OBJECT (priv->task_page)); comp_editor_append_page (COMP_EDITOR (te), @@ -138,12 +422,20 @@ task_editor_construct (TaskEditor *te, ECal *client) g_signal_connect (G_OBJECT (priv->task_page), "client_changed", G_CALLBACK (client_changed_cb), te); + priv->task_details_window = gtk_dialog_new_with_buttons (_("Task Details"), + (GtkWindow *) te, GTK_DIALOG_MODAL, + "gtk-close", GTK_RESPONSE_CLOSE, + NULL); + g_signal_connect (priv->task_details_window, "response", G_CALLBACK(gtk_widget_hide), NULL); + priv->task_details_page = task_details_page_new (); g_object_ref (priv->task_details_page); gtk_object_sink (GTK_OBJECT (priv->task_details_page)); - comp_editor_append_page (COMP_EDITOR (te), - COMP_EDITOR_PAGE (priv->task_details_page), - _("_Status"), TRUE); + gtk_container_add ((GtkContainer *) GTK_DIALOG(priv->task_details_window)->vbox, + comp_editor_page_get_widget ((CompEditorPage *)priv->task_details_page)); + gtk_widget_show_all (priv->task_details_window); + gtk_widget_hide (priv->task_details_window); + comp_editor_append_page (editor, COMP_EDITOR_PAGE (priv->task_details_page), NULL, FALSE); if (!e_cal_is_read_only (client, &read_only, NULL)) read_only = TRUE; @@ -151,14 +443,17 @@ task_editor_construct (TaskEditor *te, ECal *client) if (priv->is_assigned) { if (e_cal_get_static_capability (client, CAL_STATIC_CAPABILITY_REQ_SEND_OPTIONS)) task_page_show_options (priv->task_page); - + + task_page_set_assignment (priv->task_page, TRUE); comp_editor_set_group_item (COMP_EDITOR (te), TRUE); - priv->meet_page = meeting_page_new (priv->model, client); - g_object_ref (priv->meet_page); - gtk_object_sink (GTK_OBJECT (priv->meet_page)); - comp_editor_append_page (COMP_EDITOR (te), - COMP_EDITOR_PAGE (priv->meet_page), - _("Assig_nment"), TRUE); + } else { + task_page_set_assignment (priv->task_page, FALSE); + + bonobo_ui_component_set_prop (editor->uic, "/commands/InsertSendOptions", "hidden", "1", NULL); + bonobo_ui_component_set_prop (editor->uic, "/commands/ViewRole", "hidden", "1", NULL); + bonobo_ui_component_set_prop (editor->uic, "/commands/ViewRSVP", "hidden", "1", NULL); + bonobo_ui_component_set_prop (editor->uic, "/commands/ViewType", "hidden", "1", NULL); + bonobo_ui_component_set_prop (editor->uic, "/commands/ViewStatus", "hidden", "1", NULL); } comp_editor_set_e_cal (COMP_EDITOR (te), client); @@ -206,21 +501,12 @@ task_editor_edit_comp (CompEditor *editor, ECalComponent *comp) e_cal_component_get_organizer (comp, &organizer); e_cal_component_get_attendee_list (comp, &attendees); - /* Clear things up */ - e_meeting_store_remove_all_attendees (priv->model); - - if (attendees == NULL) { - comp_editor_remove_page (editor, COMP_EDITOR_PAGE (priv->meet_page)); - priv->assignment_shown = FALSE; - } else { + if (attendees != NULL) { GSList *l; int row; - task_page_hide_options (priv->task_page); - if (!priv->assignment_shown) - comp_editor_append_page (COMP_EDITOR (te), - COMP_EDITOR_PAGE (priv->meet_page), - _("Assig_nment"), TRUE); + task_page_hide_options (priv->task_page); + task_page_set_assignment (priv->task_page, TRUE); for (l = attendees; l != NULL; l = l->next) { ECalComponentAttendee *ca = l->data; @@ -285,7 +571,7 @@ task_editor_send_comp (CompEditor *editor, ECalComponentItipMethod method) method == E_CAL_COMPONENT_METHOD_CANCEL) goto parent; - comp = meeting_page_get_cancel_comp (priv->meet_page); + comp = task_page_get_cancel_comp (priv->task_page); if (comp != NULL) { ECal *client; gboolean result; @@ -329,11 +615,6 @@ task_editor_finalize (GObject *object) priv->task_details_page = NULL; } - if (priv->meet_page) { - g_object_unref (priv->meet_page); - priv->meet_page = NULL; - } - if (priv->model) { g_object_unref (priv->model); priv->model = NULL; @@ -375,9 +656,6 @@ show_assignment (TaskEditor *te) task_page_set_assignment (priv->task_page, TRUE); if (!priv->assignment_shown) { - comp_editor_append_page (COMP_EDITOR (te), - COMP_EDITOR_PAGE (priv->meet_page), - _("Assig_nment"), TRUE); priv->assignment_shown = TRUE; comp_editor_set_needs_send (COMP_EDITOR (te), priv->assignment_shown); @@ -395,45 +673,6 @@ task_editor_show_assignment (TaskEditor *te) show_assignment (te); } -static void -assign_task_cmd (GtkWidget *widget, gpointer data) -{ - TaskEditor *te = TASK_EDITOR (data); - - show_assignment (te); -} - -static void -refresh_task_cmd (GtkWidget *widget, gpointer data) -{ - TaskEditor *te = TASK_EDITOR (data); - - comp_editor_send_comp (COMP_EDITOR (te), E_CAL_COMPONENT_METHOD_REFRESH); -} - -static void -cancel_task_cmd (GtkWidget *widget, gpointer data) -{ - TaskEditor *te = TASK_EDITOR (data); - ECalComponent *comp; - - comp = comp_editor_get_current_comp (COMP_EDITOR (te)); - if (cancel_component_dialog ((GtkWindow *) te, - comp_editor_get_e_cal (COMP_EDITOR (te)), comp, FALSE)) { - comp_editor_send_comp (COMP_EDITOR (te), E_CAL_COMPONENT_METHOD_CANCEL); - comp_editor_delete_comp (COMP_EDITOR (te)); - } -} - -static void -forward_cmd (GtkWidget *widget, gpointer data) -{ - TaskEditor *te = TASK_EDITOR (data); - - if (comp_editor_save_comp (COMP_EDITOR (te), TRUE)) - comp_editor_send_comp (COMP_EDITOR (te), E_CAL_COMPONENT_METHOD_PUBLISH); -} - static void model_changed (TaskEditor *te) { -- cgit v1.2.3