diff options
author | Chenthill Palanisamy <pchen@src.gnome.org> | 2005-06-08 23:41:12 +0800 |
---|---|---|
committer | Chenthill Palanisamy <pchen@src.gnome.org> | 2005-06-08 23:41:12 +0800 |
commit | 5a150fae3cc3aa122db2d4ee5f040604e09ed8c6 (patch) | |
tree | b647d44f4d69e384125d7612277c50318cebee42 /calendar | |
parent | bf7287dedcb5a5dc17d45339fdea81e3acec648a (diff) | |
download | gsoc2013-evolution-5a150fae3cc3aa122db2d4ee5f040604e09ed8c6.tar.gz gsoc2013-evolution-5a150fae3cc3aa122db2d4ee5f040604e09ed8c6.tar.zst gsoc2013-evolution-5a150fae3cc3aa122db2d4ee5f040604e09ed8c6.zip |
Disable the meeting editor if the user is not an organizer wherever
necessary
svn path=/trunk/; revision=29474
Diffstat (limited to 'calendar')
-rw-r--r-- | calendar/ChangeLog | 22 | ||||
-rw-r--r-- | calendar/gui/dialogs/event-editor.c | 17 | ||||
-rw-r--r-- | calendar/gui/dialogs/event-page.c | 39 | ||||
-rw-r--r-- | calendar/gui/dialogs/meeting-page.c | 8 | ||||
-rw-r--r-- | calendar/gui/dialogs/recurrence-page.c | 24 | ||||
-rw-r--r-- | calendar/gui/e-meeting-list-view.c | 108 |
6 files changed, 181 insertions, 37 deletions
diff --git a/calendar/ChangeLog b/calendar/ChangeLog index 9c01e22cd9..6f4cfa16ff 100644 --- a/calendar/ChangeLog +++ b/calendar/ChangeLog @@ -1,3 +1,25 @@ +2005-06-08 viren.l <viren@novell.com> + + * gui/dialogs/event-editor.c (event_editor_edit_comp): set COMP_EDITOR_PAGE_USER_ORG + flag. sensitizing attachment bar if user is organizer. + * gui/dialogs/event-page.c, gui/dialogs/recurrencepage.c, + gui/dialogs/meeting-page.c + (fill_widgets) + (sensitize_widget) + (sensitize_button): + sensitizing widgets if user is not an organizer.Boolean check + for user_org is achieved by using the flags in CompEditorPage structure. + check that variable while sensitizing widgets.Remove the scheduling page + if user is not organizer.Retrive values based on a key using hash table. + Added a call back for row_activation. Enabling and disabling the + "editing" property of the renderers based E_MEETING_STORE_EDIT_STATUS. + Also check whether user is creating new meeting or openning an existing + meeting and hence disable widgets appropriate. + * gui/e-meeting-list-view.c (build_table, edit_col_for_user, + edit_col_for_organizer, row_activation_cb): store renderers in hash table + using direct hashing since we can to enable/disable only column-wise since + tree view is used here. + 2005-06-07 Chenthill Palanisamy <pchenthill@novell.com> * gui/calendar-component.c: (create_new_event): diff --git a/calendar/gui/dialogs/event-editor.c b/calendar/gui/dialogs/event-editor.c index 223d4c4866..72b4d8246b 100644 --- a/calendar/gui/dialogs/event-editor.c +++ b/calendar/gui/dialogs/event-editor.c @@ -215,11 +215,16 @@ event_editor_edit_comp (CompEditor *editor, ECalComponent *comp) priv = ee->priv; priv->updating = TRUE; - - if (COMP_EDITOR_CLASS (event_editor_parent_class)->edit_comp) - COMP_EDITOR_CLASS (event_editor_parent_class)->edit_comp (editor, comp); + client = comp_editor_get_e_cal (COMP_EDITOR (editor)); + if (priv->is_meeting && itip_organizer_is_user (comp, client)) { + COMP_EDITOR_PAGE (priv->event_page)->flags |= COMP_EDITOR_PAGE_USER_ORG; + COMP_EDITOR_PAGE (priv->recur_page)->flags |= COMP_EDITOR_PAGE_USER_ORG; + } + + if (COMP_EDITOR_CLASS (event_editor_parent_class)->edit_comp) + COMP_EDITOR_CLASS (event_editor_parent_class)->edit_comp (editor, comp); /* Get meeting related stuff */ e_cal_component_get_organizer (comp, &organizer); @@ -294,6 +299,9 @@ event_editor_edit_comp (CompEditor *editor, ECalComponent *comp) e_cal_component_free_attendee_list (attendees); comp_editor_set_needs_send (COMP_EDITOR (ee), priv->meeting_shown && itip_organizer_is_user (comp, client)); + if (e_cal_component_has_organizer (comp) && (COMP_EDITOR_PAGE (priv->event_page)->flags & + COMP_EDITOR_PAGE_MEETING)) + comp_editor_sensitize_attachment_bar (editor, itip_organizer_is_user (comp, client)); priv->updating = FALSE; } @@ -420,7 +428,8 @@ show_meeting (EventEditor *ee) } if (comp_editor_get_flags (COMP_EDITOR (ee)) & COMP_EDITOR_DELEGATE) comp_editor_show_page (COMP_EDITOR (ee), COMP_EDITOR_PAGE (priv->meet_page)); - + if (comp_editor_get_existing_org (COMP_EDITOR (ee)) && !comp_editor_get_user_org (COMP_EDITOR (ee))) + comp_editor_remove_page (COMP_EDITOR (ee), COMP_EDITOR_PAGE (priv->sched_page)); } void diff --git a/calendar/gui/dialogs/event-page.c b/calendar/gui/dialogs/event-page.c index ae466e6d2f..3671e7267e 100644 --- a/calendar/gui/dialogs/event-page.c +++ b/calendar/gui/dialogs/event-page.c @@ -603,10 +603,12 @@ is_custom_alarm_store (EAlarmList *alarm_list_store, char *old_summary, CalUnit static void sensitize_widgets (EventPage *epage) { - gboolean read_only, custom, alarm; + gboolean read_only, custom, alarm, sens = TRUE; EventPagePrivate *priv; priv = epage->priv; + if (COMP_EDITOR_PAGE (epage)->flags & COMP_EDITOR_MEETING) + sens = COMP_EDITOR_PAGE (epage)->flags & COMP_EDITOR_PAGE_USER_ORG; if (!e_cal_is_read_only (COMP_EDITOR_PAGE (epage)->client, &read_only, NULL)) read_only = TRUE; @@ -614,28 +616,28 @@ sensitize_widgets (EventPage *epage) custom = is_custom_alarm_store (priv->alarm_list_store, priv->old_summary, priv->alarm_units, priv->alarm_interval, NULL); alarm = e_dialog_toggle_get (priv->alarm); - gtk_widget_set_sensitive (priv->summary_label, !read_only); - gtk_entry_set_editable (GTK_ENTRY (priv->summary), !read_only); - gtk_widget_set_sensitive (priv->location_label, !read_only); - gtk_entry_set_editable (GTK_ENTRY (priv->location), !read_only); - gtk_widget_set_sensitive (priv->start_time, !read_only); - gtk_widget_set_sensitive (priv->start_timezone, !read_only); - gtk_widget_set_sensitive (priv->end_time, !read_only); - gtk_widget_set_sensitive (priv->end_timezone, !read_only); - gtk_widget_set_sensitive (priv->all_day_event, !read_only); - gtk_widget_set_sensitive (priv->description, !read_only); - gtk_widget_set_sensitive (priv->classification, !read_only); - gtk_widget_set_sensitive (priv->show_time_as_busy, !read_only); - gtk_widget_set_sensitive (priv->alarm, !read_only); + gtk_widget_set_sensitive (priv->summary_label, !read_only && sens); + gtk_entry_set_editable (GTK_ENTRY (priv->summary), !read_only && sens); + gtk_widget_set_sensitive (priv->location_label, !read_only && sens); + gtk_entry_set_editable (GTK_ENTRY (priv->location), !read_only && sens); + gtk_widget_set_sensitive (priv->start_time, !read_only && sens); + gtk_widget_set_sensitive (priv->start_timezone, !read_only && sens); + gtk_widget_set_sensitive (priv->end_time, !read_only && sens); + gtk_widget_set_sensitive (priv->end_timezone, !read_only && sens); + gtk_widget_set_sensitive (priv->all_day_event, !read_only && sens); + gtk_widget_set_sensitive (priv->description, !read_only && sens); + gtk_widget_set_sensitive (priv->classification, !read_only && sens); + gtk_widget_set_sensitive (priv->show_time_as_busy, !read_only && sens); + gtk_widget_set_sensitive (priv->alarm, !read_only && sens); gtk_widget_set_sensitive (priv->alarm_time, !read_only && !custom && alarm); gtk_widget_set_sensitive (priv->alarm_custom, alarm); if (custom) gtk_widget_show (priv->alarm_warning); else gtk_widget_hide (priv->alarm_warning); - gtk_widget_set_sensitive (priv->categories_btn, !read_only); - gtk_widget_set_sensitive (priv->sendoptions_button, !read_only); - gtk_entry_set_editable (GTK_ENTRY (priv->categories), !read_only); + gtk_widget_set_sensitive (priv->categories_btn, !read_only && sens); + gtk_widget_set_sensitive (priv->sendoptions_button, !read_only && sens); + gtk_entry_set_editable (GTK_ENTRY (priv->categories), !read_only && sens); } void @@ -687,6 +689,9 @@ event_page_fill_widgets (CompEditorPage *page, ECalComponent *comp) epage = EVENT_PAGE (page); priv = epage->priv; + if (!e_cal_component_has_organizer (comp)) + page->flags |= COMP_EDITOR_PAGE_USER_ORG; + /* Don't send off changes during this time */ priv->updating = TRUE; diff --git a/calendar/gui/dialogs/meeting-page.c b/calendar/gui/dialogs/meeting-page.c index ee51c4e4ad..7290110a8d 100644 --- a/calendar/gui/dialogs/meeting-page.c +++ b/calendar/gui/dialogs/meeting-page.c @@ -337,10 +337,10 @@ sensitize_widgets (MeetingPage *mpage) g_error_free (error); } gtk_widget_set_sensitive (priv->organizer, !read_only); - gtk_widget_set_sensitive (priv->existing_organizer_btn, !read_only); - gtk_widget_set_sensitive (priv->add, !read_only && (priv->user_org || delegate)); - gtk_widget_set_sensitive (priv->remove, !read_only && (priv->user_org|| delegate)); - gtk_widget_set_sensitive (priv->invite, !read_only && (priv->user_org || delegate)); + gtk_widget_set_sensitive (priv->existing_organizer_btn, (!read_only && priv->user_org)); + gtk_widget_set_sensitive (priv->add, (!read_only && priv->user_org) || delegate); + gtk_widget_set_sensitive (priv->remove, (!read_only && priv->user_org) || delegate); + gtk_widget_set_sensitive (priv->invite, (!read_only && priv->user_org) || delegate); gtk_widget_set_sensitive (GTK_WIDGET (priv->list_view), !read_only); } diff --git a/calendar/gui/dialogs/recurrence-page.c b/calendar/gui/dialogs/recurrence-page.c index 8f528d230d..325b30fe2c 100644 --- a/calendar/gui/dialogs/recurrence-page.c +++ b/calendar/gui/dialogs/recurrence-page.c @@ -470,10 +470,11 @@ static void sensitize_recur_widgets (RecurrencePage *rpage) { RecurrencePagePrivate *priv; - gboolean recurs; + gboolean recurs, sens = TRUE; GtkWidget *label; priv = rpage->priv; + sens = COMP_EDITOR_PAGE (rpage)->flags & COMP_EDITOR_PAGE_USER_ORG; recurs = e_dialog_toggle_get (priv->recurs); @@ -481,7 +482,7 @@ sensitize_recur_widgets (RecurrencePage *rpage) if (e_cal_component_is_instance (priv->comp)) gtk_widget_set_sensitive (priv->preview_calendar, FALSE); else - gtk_widget_set_sensitive (priv->preview_calendar, TRUE); + gtk_widget_set_sensitive (priv->preview_calendar, TRUE && sens); if (GTK_BIN (priv->custom_warning_bin)->child) gtk_widget_destroy (GTK_BIN (priv->custom_warning_bin)->child); @@ -497,7 +498,7 @@ sensitize_recur_widgets (RecurrencePage *rpage) label); gtk_widget_show_all (priv->custom_warning_bin); } else if (recurs) { - gtk_widget_set_sensitive (priv->params, TRUE); + gtk_widget_set_sensitive (priv->params, sens); gtk_widget_show (priv->params); gtk_widget_hide (priv->custom_warning_bin); } else { @@ -510,14 +511,16 @@ sensitize_recur_widgets (RecurrencePage *rpage) static void sensitize_buttons (RecurrencePage *rpage) { - gboolean read_only; + gboolean read_only, sens = TRUE; gint selected_rows; RecurrencePagePrivate *priv; icalcomponent *icalcomp; const char *uid; priv = rpage->priv; - + if (COMP_EDITOR_PAGE (rpage)->flags & COMP_EDITOR_PAGE_MEETING) + sens = COMP_EDITOR_PAGE (rpage)->flags & COMP_EDITOR_PAGE_USER_ORG; + selected_rows = gtk_tree_selection_count_selected_rows ( gtk_tree_view_get_selection (GTK_TREE_VIEW (priv->exception_list))); @@ -551,10 +554,10 @@ sensitize_buttons (RecurrencePage *rpage) else gtk_widget_set_sensitive (priv->params, FALSE); - gtk_widget_set_sensitive (priv->recurs, !read_only); - gtk_widget_set_sensitive (priv->exception_add, !read_only && e_cal_component_has_recurrences (priv->comp)); - gtk_widget_set_sensitive (priv->exception_modify, !read_only && selected_rows > 0); - gtk_widget_set_sensitive (priv->exception_delete, !read_only && selected_rows > 0); + gtk_widget_set_sensitive (priv->recurs, !read_only && sens); + gtk_widget_set_sensitive (priv->exception_add, !read_only && e_cal_component_has_recurrences (priv->comp) && sens); + gtk_widget_set_sensitive (priv->exception_modify, !read_only && selected_rows > 0 && sens); + gtk_widget_set_sensitive (priv->exception_delete, !read_only && selected_rows > 0 && sens); } #if 0 @@ -1520,6 +1523,9 @@ recurrence_page_fill_widgets (CompEditorPage *page, ECalComponent *comp) priv->comp = e_cal_component_clone (comp); + if (!e_cal_component_has_organizer (comp)) + page->flags |= COMP_EDITOR_PAGE_USER_ORG; + /* Don't send off changes during this time */ priv->updating = TRUE; diff --git a/calendar/gui/e-meeting-list-view.c b/calendar/gui/e-meeting-list-view.c index 088301fc92..d834a3cf49 100644 --- a/calendar/gui/e-meeting-list-view.c +++ b/calendar/gui/e-meeting-list-view.c @@ -50,6 +50,8 @@ struct _EMeetingListViewPrivate { EMeetingStore *store; ENameSelector *name_selector; + + GHashTable *renderers; }; #define BUF_SIZE 1024 @@ -75,8 +77,15 @@ e_meeting_list_view_finalize (GObject *obj) EMeetingListView *view = E_MEETING_LIST_VIEW (obj); EMeetingListViewPrivate *priv = view->priv; - if (priv->name_selector) + if (priv->name_selector) { g_object_unref (priv->name_selector); + priv->name_selector = NULL; + } + + if (priv->renderers) { + g_hash_table_destroy (priv->renderers); + priv->renderers = NULL; + } g_free (priv); @@ -114,6 +123,8 @@ e_meeting_list_view_init (EMeetingListView *view) priv = g_new0 (EMeetingListViewPrivate, 1); view->priv = priv; + + priv->renderers = g_hash_table_new (g_direct_hash, g_int_equal); priv->name_selector = e_name_selector_new (); @@ -297,10 +308,15 @@ status_edited_cb (GtkCellRenderer *renderer, const gchar *path, const gchar *tex } static void -build_table (GtkTreeView *view) +build_table (EMeetingListView *lview) { GtkCellRenderer *renderer; + GtkTreeView *view = GTK_TREE_VIEW (lview); + EMeetingListViewPrivate *priv; + GHashTable *edit_table; + priv = lview->priv; + edit_table = priv->renderers; gtk_tree_view_set_headers_visible (view, TRUE); gtk_tree_view_set_rules_hint (view, TRUE); @@ -314,6 +330,7 @@ build_table (GtkTreeView *view) NULL); g_signal_connect (renderer, "cell_edited", G_CALLBACK (attendee_edited_cb), view); g_signal_connect (renderer, "editing-canceled", G_CALLBACK (attendee_editing_canceled_cb), view); + g_hash_table_insert (edit_table, GINT_TO_POINTER (E_MEETING_STORE_ATTENDEE_COL), renderer); renderer = e_cell_renderer_combo_new (); g_object_set (G_OBJECT (renderer), "list", get_type_strings (), "editable", TRUE, NULL); @@ -321,6 +338,7 @@ build_table (GtkTreeView *view) "text", E_MEETING_STORE_TYPE_COL, NULL); g_signal_connect (renderer, "edited", G_CALLBACK (type_edited_cb), view); + g_hash_table_insert (edit_table, GINT_TO_POINTER (E_MEETING_STORE_TYPE_COL), renderer); renderer = e_cell_renderer_combo_new (); g_object_set (G_OBJECT (renderer), "list", get_role_strings (), "editable", TRUE, NULL); @@ -328,6 +346,7 @@ build_table (GtkTreeView *view) "text", E_MEETING_STORE_ROLE_COL, NULL); g_signal_connect (renderer, "edited", G_CALLBACK (role_edited_cb), view); + g_hash_table_insert (edit_table, GINT_TO_POINTER (E_MEETING_STORE_ROLE_COL), renderer); renderer = e_cell_renderer_combo_new (); g_object_set (G_OBJECT (renderer), "list", get_rsvp_strings (), "editable", TRUE, NULL); @@ -335,6 +354,7 @@ build_table (GtkTreeView *view) "text", E_MEETING_STORE_RSVP_COL, NULL); g_signal_connect (renderer, "edited", G_CALLBACK (rsvp_edited_cb), view); + g_hash_table_insert (edit_table, GINT_TO_POINTER (E_MEETING_STORE_RSVP_COL), renderer); renderer = e_cell_renderer_combo_new (); g_object_set (G_OBJECT (renderer), "list", get_status_strings (), "editable", TRUE, NULL); @@ -342,19 +362,101 @@ build_table (GtkTreeView *view) "text", E_MEETING_STORE_STATUS_COL, NULL); g_signal_connect (renderer, "edited", G_CALLBACK (status_edited_cb), view); + g_hash_table_insert (edit_table, GINT_TO_POINTER (E_MEETING_STORE_STATUS_COL), renderer); + + priv->renderers = edit_table; +} + +static void +change_edit_cols_for_user (gpointer key, gpointer value, gpointer user_data) +{ + GtkCellRenderer *renderer = (GtkCellRenderer *) value; + int key_val = GPOINTER_TO_INT (key); + switch (key_val) + { + case E_MEETING_STORE_ATTENDEE_COL: + g_object_set (G_OBJECT (renderer), "editable", FALSE, NULL); + break; + case E_MEETING_STORE_ROLE_COL: + g_object_set (G_OBJECT (renderer), "editable", FALSE, NULL); + break; + case E_MEETING_STORE_TYPE_COL: + g_object_set (G_OBJECT (renderer), "editable", FALSE, NULL); + break; + case E_MEETING_STORE_RSVP_COL: + g_object_set (G_OBJECT (renderer), "editable", TRUE, NULL); + break; + case E_MEETING_STORE_STATUS_COL: + g_object_set (G_OBJECT (renderer), "editable", TRUE, NULL); + break; + } +} + +static void +change_edit_cols_for_organizer (gpointer key, gpointer value, gpointer user_data) +{ + GtkCellRenderer *renderer = (GtkCellRenderer *) value; + guint edit_level = GPOINTER_TO_INT (user_data); + g_object_set (G_OBJECT (renderer), "editable", GINT_TO_POINTER (edit_level), NULL); +} + +static void +row_activated_cb (GtkTreeSelection *selection, EMeetingListView *view) +{ + EMeetingAttendee *existing_attendee; + EMeetingListViewPrivate *priv; + GtkTreeIter iter; + int row; + EMeetingAttendeeEditLevel el; + gint edit_level; + GtkTreeModel *model; + GtkTreePath *path; + + priv = view->priv; + + + if (gtk_tree_selection_get_selected (selection, &model, &iter)) { + path = gtk_tree_model_get_path (model, &iter); + } + row = gtk_tree_path_get_indices (path)[0]; + existing_attendee = e_meeting_store_find_attendee_at_row (priv->store, row); + el = e_meeting_attendee_get_edit_level (existing_attendee); + + switch (el) + { + case E_MEETING_ATTENDEE_EDIT_NONE: + edit_level = FALSE; + g_hash_table_foreach (priv->renderers, change_edit_cols_for_organizer, GINT_TO_POINTER (edit_level)); + break; + + case E_MEETING_ATTENDEE_EDIT_FULL: + edit_level = TRUE; + g_hash_table_foreach (priv->renderers, change_edit_cols_for_organizer, GINT_TO_POINTER (edit_level)); + break; + + case E_MEETING_ATTENDEE_EDIT_STATUS: + edit_level = FALSE; + g_hash_table_foreach (priv->renderers, change_edit_cols_for_user, GINT_TO_POINTER (edit_level)); + break; + } + } + EMeetingListView * e_meeting_list_view_new (EMeetingStore *store) { EMeetingListView *view = g_object_new (E_TYPE_MEETING_LIST_VIEW, NULL); + GtkTreeSelection *selection; if (view) { view->priv->store = store; gtk_tree_view_set_model (GTK_TREE_VIEW (view), GTK_TREE_MODEL (store)); - build_table (GTK_TREE_VIEW (view)); + build_table (view); } + selection = gtk_tree_view_get_selection (GTK_TREE_VIEW(view)); + g_signal_connect (selection, "changed", G_CALLBACK (row_activated_cb), view); return view; } |