From 1489dc4fd85172be1604b03666a5538ef8015bc7 Mon Sep 17 00:00:00 2001 From: Matthew Barnes Date: Fri, 15 Jun 2012 11:28:46 -0400 Subject: Disable 'Rename' if source is a collection member. For consistency with the Preferences window. We assume the display names are server-assigned and not user-assigned, at least not assigned through Evolution. --- modules/addressbook/e-book-shell-sidebar.c | 29 ++++++++++++++++++++++------- modules/addressbook/e-book-shell-sidebar.h | 5 +++-- modules/addressbook/e-book-shell-view.c | 13 +++++++++---- 3 files changed, 34 insertions(+), 13 deletions(-) (limited to 'modules/addressbook') diff --git a/modules/addressbook/e-book-shell-sidebar.c b/modules/addressbook/e-book-shell-sidebar.c index b7f8b61ef9..2f2d9391c5 100644 --- a/modules/addressbook/e-book-shell-sidebar.c +++ b/modules/addressbook/e-book-shell-sidebar.c @@ -145,29 +145,44 @@ book_shell_sidebar_check_state (EShellSidebar *shell_sidebar) { EBookShellSidebar *book_shell_sidebar; ESourceSelector *selector; + ESourceRegistry *registry; ESource *source; - gboolean removable = FALSE; - gboolean writable = FALSE; + gboolean is_writable = FALSE; + gboolean is_removable = FALSE; + gboolean in_collection = FALSE; gboolean has_primary_source = FALSE; guint32 state = 0; book_shell_sidebar = E_BOOK_SHELL_SIDEBAR (shell_sidebar); selector = e_book_shell_sidebar_get_selector (book_shell_sidebar); source = e_source_selector_ref_primary_selection (selector); + registry = e_source_selector_get_registry (selector); if (source != NULL) { + ESource *collection; + has_primary_source = TRUE; - removable = e_source_get_removable (source); - writable = e_source_get_writable (source); + is_writable = e_source_get_writable (source); + is_removable = e_source_get_removable (source); + + collection = e_source_registry_find_extension ( + registry, source, E_SOURCE_EXTENSION_COLLECTION); + if (collection != NULL) { + in_collection = TRUE; + g_object_unref (collection); + } + g_object_unref (source); } if (has_primary_source) state |= E_BOOK_SHELL_SIDEBAR_HAS_PRIMARY_SOURCE; - if (removable) - state |= E_BOOK_SHELL_SIDEBAR_PRIMARY_SOURCE_IS_REMOVABLE; - if (writable) + if (is_writable) state |= E_BOOK_SHELL_SIDEBAR_PRIMARY_SOURCE_IS_WRITABLE; + if (is_removable) + state |= E_BOOK_SHELL_SIDEBAR_PRIMARY_SOURCE_IS_REMOVABLE; + if (in_collection) + state |= E_BOOK_SHELL_SIDEBAR_PRIMARY_SOURCE_IN_COLLECTION; return state; } diff --git a/modules/addressbook/e-book-shell-sidebar.h b/modules/addressbook/e-book-shell-sidebar.h index 9e4d9ec015..9507681541 100644 --- a/modules/addressbook/e-book-shell-sidebar.h +++ b/modules/addressbook/e-book-shell-sidebar.h @@ -54,8 +54,9 @@ typedef struct _EBookShellSidebarPrivate EBookShellSidebarPrivate; enum { E_BOOK_SHELL_SIDEBAR_HAS_PRIMARY_SOURCE = 1 << 0, - E_BOOK_SHELL_SIDEBAR_PRIMARY_SOURCE_IS_REMOVABLE = 1 << 1, - E_BOOK_SHELL_SIDEBAR_PRIMARY_SOURCE_IS_WRITABLE = 1 << 2 + E_BOOK_SHELL_SIDEBAR_PRIMARY_SOURCE_IS_WRITABLE = 1 << 1, + E_BOOK_SHELL_SIDEBAR_PRIMARY_SOURCE_IS_REMOVABLE = 1 << 2, + E_BOOK_SHELL_SIDEBAR_PRIMARY_SOURCE_IN_COLLECTION = 1 << 3 }; struct _EBookShellSidebar { diff --git a/modules/addressbook/e-book-shell-view.c b/modules/addressbook/e-book-shell-view.c index 53136c2e02..c8ef07441d 100644 --- a/modules/addressbook/e-book-shell-view.c +++ b/modules/addressbook/e-book-shell-view.c @@ -201,8 +201,9 @@ book_shell_view_update_actions (EShellView *shell_view) gboolean any_contacts_selected; gboolean has_primary_source; gboolean multiple_contacts_selected; - gboolean primary_source_is_removable; gboolean primary_source_is_writable; + gboolean primary_source_is_removable; + gboolean primary_source_in_collection; gboolean single_contact_selected; gboolean selection_is_contact_list; gboolean selection_has_email; @@ -235,10 +236,12 @@ book_shell_view_update_actions (EShellView *shell_view) has_primary_source = (state & E_BOOK_SHELL_SIDEBAR_HAS_PRIMARY_SOURCE); - primary_source_is_removable = - (state & E_BOOK_SHELL_SIDEBAR_PRIMARY_SOURCE_IS_REMOVABLE); primary_source_is_writable = (state & E_BOOK_SHELL_SIDEBAR_PRIMARY_SOURCE_IS_WRITABLE); + primary_source_is_removable = + (state & E_BOOK_SHELL_SIDEBAR_PRIMARY_SOURCE_IS_REMOVABLE); + primary_source_in_collection = + (state & E_BOOK_SHELL_SIDEBAR_PRIMARY_SOURCE_IN_COLLECTION); any_contacts_selected = (single_contact_selected || multiple_contacts_selected); @@ -264,7 +267,9 @@ book_shell_view_update_actions (EShellView *shell_view) gtk_action_set_sensitive (action, sensitive); action = ACTION (ADDRESS_BOOK_RENAME); - sensitive = primary_source_is_writable; + sensitive = + primary_source_is_writable && + !primary_source_in_collection; gtk_action_set_sensitive (action, sensitive); action = ACTION (ADDRESS_BOOK_STOP); -- cgit v1.2.3