static void book_shell_view_update_actions (EShellView *shell_view) { EShellContent *shell_content; EShellSidebar *shell_sidebar; EShellWindow *shell_window; GtkAction *action; const gchar *label; gboolean sensitive; guint32 state; /* Be descriptive. */ gboolean any_contacts_selected; gboolean has_primary_source; gboolean multiple_contacts_selected; gboolean primary_source_is_writable; gboolean primary_source_is_removable; gboolean primary_source_is_remote_deletable; gboolean primary_source_in_collection; gboolean refresh_supported; gboolean single_contact_selected; gboolean selection_is_contact_list; gboolean selection_has_email; gboolean source_is_busy; gboolean source_is_editable; /* Chain up to parent's update_actions() method. */ E_SHELL_VIEW_CLASS (e_book_shell_view_parent_class)-> update_actions (shell_view); shell_window = e_shell_view_get_shell_window (shell_view); shell_content = e_shell_view_get_shell_content (shell_view); state = e_shell_content_check_state (shell_content); single_contact_selected = (state & E_BOOK_SHELL_CONTENT_SELECTION_SINGLE); multiple_contacts_selected = (state & E_BOOK_SHELL_CONTENT_SELECTION_MULTIPLE); selection_has_email = (state & E_BOOK_SHELL_CONTENT_SELECTION_HAS_EMAIL); selection_is_contact_list = (state & E_BOOK_SHELL_CONTENT_SELECTION_IS_CONTACT_LIST); source_is_busy = (state & E_BOOK_SHELL_CONTENT_SOURCE_IS_BUSY); source_is_editable = (state & E_BOOK_SHELL_CONTENT_SOURCE_IS_EDITABLE); shell_sidebar = e_shell_view_get_shell_sidebar (shell_view); state = e_shell_sidebar_check_state (shell_sidebar); has_primary_source = (state & E_BOOK_SHELL_SIDEBAR_HAS_PRIMARY_SOURCE); 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_is_remote_deletable = (state & E_BOOK_SHELL_SIDEBAR_PRIMARY_SOURCE_IS_REMOTE_DELETABLE); primary_source_in_collection = (state & E_BOOK_SHELL_SIDEBAR_PRIMARY_SOURCE_IN_COLLECTION); refresh_supported = (state & E_BOOK_SHELL_SIDEBAR_SOURCE_SUPPORTS_REFRESH); any_contacts_selected = (single_contact_selected || multiple_contacts_selected); action = ACTION (ADDRESS_BOOK_MOVE); sensitive = source_is_editable; gtk_action_set_sensitive (action, sensitive); action = ACTION (ADDRESS_BOOK_DELETE); sensitive = primary_source_is_removable || primary_source_is_remote_deletable; gtk_action_set_sensitive (action, sensitive); action = ACTION (ADDRESS_BOOK_PRINT); sensitive = has_primary_source; gtk_action_set_sensitive (action, sensitive); action = ACTION (ADDRESS_BOOK_PRINT_PREVIEW); sensitive = has_primary_source; gtk_action_set_sensitive (action, sensitive); action = ACTION (ADDRESS_BOOK_PROPERTIES); sensitive = primary_source_is_writable; gtk_action_set_sensitive (action, sensitive); action = ACTION (ADDRESS_BOOK_REFRESH); sensitive = refresh_supported; gtk_action_set_sensitive (action, sensitive); action = ACTION (ADDRESS_BOOK_RENAME); sensitive = primary_source_is_writable && !primary_source_in_collection; gtk_action_set_sensitive (action, sensitive); action = ACTION (ADDRESS_BOOK_STOP); sensitive = source_is_busy; gtk_action_set_sensitive (action, sensitive); action = ACTION (CONTACT_COPY); sensitive = any_contacts_selected; gtk_action_set_sensitive (action, sensitive); action = ACTION (CONTACT_DELETE); sensitive = source_is_editable && any_contacts_selected; gtk_action_set_sensitive (action, sensitive); action = ACTION (CONTACT_FIND); sensitive = single_contact_selected; gtk_action_set_sensitive (action, sensitive); action = ACTION (CONTACT_FORWARD); sensitive = any_contacts_selected; gtk_action_set_sensitive (action, sensitive); if (multiple_contacts_selected) label = _("_Forward Contacts"); else label = _("_Forward Contact"); gtk_action_set_label (action, label); action = ACTION (CONTACT_MOVE); sensitive = source_is_editable && any_contacts_selected; gtk_action_set_sensitive (action, sensitive); action = ACTION (CONTACT_NEW); sensitive = source_is_editable; gtk_action_set_sensitive (action, sensitive); action = ACTION (CONTACT_NEW_LIST); sensitive = source_is_editable; gtk_action_set_sensitive (action, sensitive); action = ACTION (CONTACT_OPEN); sensitive = any_contacts_selected; gtk_action_set_sensitive (action, sensitive); action = ACTION (CONTACT_PRINT); sensitive = any_contacts_selected; gtk_action_set_sensitive (action, sensitive); action = ACTION (CONTACT_SAVE_AS); sensitive = any_contacts_selected; gtk_action_set_sensitive (action, sensitive); action = ACTION (CONTACT_SEND_MESSAGE); sensitive = any_contacts_selected && selection_has_email; gtk_action_set_sensitive (action, sensitive); if (multiple_contacts_selected) label = _("_Send Message to Contacts"); else if (selection_is_contact_list) label = _("_Send Message to List"); else label = _("_Send Message to Contact"); gtk_action_set_label (action, label); }
static void memo_shell_view_update_actions (EShellView *shell_view) { EShellContent *shell_content; EShellSidebar *shell_sidebar; EShellWindow *shell_window; GtkAction *action; const gchar *label; gboolean sensitive; guint32 state; /* Be descriptive. */ gboolean any_memos_selected; gboolean has_primary_source; gboolean multiple_memos_selected; gboolean primary_source_is_writable; gboolean primary_source_is_removable; gboolean primary_source_is_remote_deletable; gboolean primary_source_in_collection; gboolean selection_has_url; gboolean single_memo_selected; gboolean sources_are_editable; gboolean refresh_supported; /* Chain up to parent's update_actions() method. */ E_SHELL_VIEW_CLASS (e_memo_shell_view_parent_class)-> update_actions (shell_view); shell_window = e_shell_view_get_shell_window (shell_view); shell_content = e_shell_view_get_shell_content (shell_view); state = e_shell_content_check_state (shell_content); single_memo_selected = (state & E_MEMO_SHELL_CONTENT_SELECTION_SINGLE); multiple_memos_selected = (state & E_MEMO_SHELL_CONTENT_SELECTION_MULTIPLE); sources_are_editable = (state & E_MEMO_SHELL_CONTENT_SELECTION_CAN_EDIT); selection_has_url = (state & E_MEMO_SHELL_CONTENT_SELECTION_HAS_URL); shell_sidebar = e_shell_view_get_shell_sidebar (shell_view); state = e_shell_sidebar_check_state (shell_sidebar); has_primary_source = (state & E_MEMO_SHELL_SIDEBAR_HAS_PRIMARY_SOURCE); primary_source_is_writable = (state & E_MEMO_SHELL_SIDEBAR_PRIMARY_SOURCE_IS_WRITABLE); primary_source_is_removable = (state & E_MEMO_SHELL_SIDEBAR_PRIMARY_SOURCE_IS_REMOVABLE); primary_source_is_remote_deletable = (state & E_MEMO_SHELL_SIDEBAR_PRIMARY_SOURCE_IS_REMOTE_DELETABLE); primary_source_in_collection = (state & E_MEMO_SHELL_SIDEBAR_PRIMARY_SOURCE_IN_COLLECTION); refresh_supported = (state & E_MEMO_SHELL_SIDEBAR_SOURCE_SUPPORTS_REFRESH); any_memos_selected = (single_memo_selected || multiple_memos_selected); action = ACTION (MEMO_DELETE); sensitive = any_memos_selected && sources_are_editable; gtk_action_set_sensitive (action, sensitive); if (multiple_memos_selected) label = _("Delete Memos"); else label = _("Delete Memo"); gtk_action_set_label (action, label); action = ACTION (MEMO_FIND); sensitive = single_memo_selected; gtk_action_set_sensitive (action, sensitive); action = ACTION (MEMO_FORWARD); sensitive = single_memo_selected; gtk_action_set_sensitive (action, sensitive); action = ACTION (MEMO_LIST_COPY); sensitive = has_primary_source; gtk_action_set_sensitive (action, sensitive); action = ACTION (MEMO_LIST_DELETE); sensitive = primary_source_is_removable || primary_source_is_remote_deletable; gtk_action_set_sensitive (action, sensitive); action = ACTION (MEMO_LIST_PROPERTIES); sensitive = primary_source_is_writable; gtk_action_set_sensitive (action, sensitive); action = ACTION (MEMO_LIST_REFRESH); sensitive = refresh_supported; gtk_action_set_sensitive (action, sensitive); action = ACTION (MEMO_LIST_RENAME); sensitive = primary_source_is_writable && !primary_source_in_collection; gtk_action_set_sensitive (action, sensitive); action = ACTION (MEMO_OPEN); sensitive = single_memo_selected; gtk_action_set_sensitive (action, sensitive); action = ACTION (MEMO_OPEN_URL); sensitive = single_memo_selected && selection_has_url; gtk_action_set_sensitive (action, sensitive); action = ACTION (MEMO_PRINT); sensitive = single_memo_selected; gtk_action_set_sensitive (action, sensitive); action = ACTION (MEMO_SAVE_AS); sensitive = single_memo_selected; gtk_action_set_sensitive (action, sensitive); }