From c12e485e47f5ac99f0ddd7f7e90b9ab28b077c3d Mon Sep 17 00:00:00 2001 From: Matthew Barnes Date: Wed, 11 Nov 2009 23:52:08 -0500 Subject: Simplify clipboard handling in addressbook. --- modules/addressbook/e-book-shell-content.c | 6 ++++++ modules/addressbook/e-book-shell-content.h | 3 ++- modules/addressbook/e-book-shell-view.c | 5 ++++- modules/calendar/e-cal-shell-view-private.h | 2 +- 4 files changed, 13 insertions(+), 3 deletions(-) (limited to 'modules') diff --git a/modules/addressbook/e-book-shell-content.c b/modules/addressbook/e-book-shell-content.c index 898bd2df39..4eccc971df 100644 --- a/modules/addressbook/e-book-shell-content.c +++ b/modules/addressbook/e-book-shell-content.c @@ -24,6 +24,7 @@ #include #include "e-util/e-binding.h" +#include "e-util/e-selection.h" #include "e-util/gconf-bridge.h" #include "widgets/misc/e-paned.h" @@ -258,6 +259,7 @@ book_shell_content_check_state (EShellContent *shell_content) ESelectionModel *selection_model; EAddressbookModel *model; EAddressbookView *view; + GtkClipboard *clipboard; guint32 state = 0; gint n_contacts; gint n_selected; @@ -272,6 +274,8 @@ book_shell_content_check_state (EShellContent *shell_content) n_selected = (selection_model != NULL) ? e_selection_model_selected_count (selection_model) : 0; + clipboard = gtk_clipboard_get (GDK_SELECTION_CLIPBOARD); + /* FIXME Finish the rest of the flags. */ if (n_selected == 1) state |= E_BOOK_SHELL_CONTENT_SELECTION_SINGLE; @@ -283,6 +287,8 @@ book_shell_content_check_state (EShellContent *shell_content) state |= E_BOOK_SHELL_CONTENT_SOURCE_IS_EDITABLE; if (n_contacts == 0) state |= E_BOOK_SHELL_CONTENT_SOURCE_IS_EMPTY; + if (e_clipboard_wait_is_directory_available (clipboard)) + state |= E_BOOK_SHELL_CONTENT_CLIPBOARD_HAS_DIRECTORY; return state; } diff --git a/modules/addressbook/e-book-shell-content.h b/modules/addressbook/e-book-shell-content.h index da78c01274..31f8c35838 100644 --- a/modules/addressbook/e-book-shell-content.h +++ b/modules/addressbook/e-book-shell-content.h @@ -64,7 +64,8 @@ enum { E_BOOK_SHELL_CONTENT_SELECTION_HAS_MAILTO_URI = 1 << 5, E_BOOK_SHELL_CONTENT_SOURCE_IS_BUSY = 1 << 6, E_BOOK_SHELL_CONTENT_SOURCE_IS_EDITABLE = 1 << 7, - E_BOOK_SHELL_CONTENT_SOURCE_IS_EMPTY = 1 << 8 + E_BOOK_SHELL_CONTENT_SOURCE_IS_EMPTY = 1 << 8, + E_BOOK_SHELL_CONTENT_CLIPBOARD_HAS_DIRECTORY = 1 << 9 }; struct _EBookShellContent { diff --git a/modules/addressbook/e-book-shell-view.c b/modules/addressbook/e-book-shell-view.c index 8ea97caddc..88a503b024 100644 --- a/modules/addressbook/e-book-shell-view.c +++ b/modules/addressbook/e-book-shell-view.c @@ -246,6 +246,7 @@ book_shell_view_update_actions (EShellView *shell_view) gboolean source_is_busy; gboolean source_is_editable; gboolean source_is_empty; + gboolean clipboard_has_directory; priv = E_BOOK_SHELL_VIEW_GET_PRIVATE (shell_view); @@ -268,6 +269,8 @@ book_shell_view_update_actions (EShellView *shell_view) (state & E_BOOK_SHELL_CONTENT_SOURCE_IS_EDITABLE); source_is_empty = (state & E_BOOK_SHELL_CONTENT_SOURCE_IS_EMPTY); + clipboard_has_directory = + (state & E_BOOK_SHELL_CONTENT_CLIPBOARD_HAS_DIRECTORY); shell_sidebar = e_shell_view_get_shell_sidebar (shell_view); state = e_shell_sidebar_check_state (shell_sidebar); @@ -301,7 +304,7 @@ book_shell_view_update_actions (EShellView *shell_view) gtk_action_set_sensitive (action, sensitive); action = ACTION (CONTACT_CLIPBOARD_PASTE); - sensitive = source_is_editable; + sensitive = source_is_editable && clipboard_has_directory; gtk_action_set_sensitive (action, sensitive); action = ACTION (CONTACT_COPY); diff --git a/modules/calendar/e-cal-shell-view-private.h b/modules/calendar/e-cal-shell-view-private.h index 7f6413c747..1f447bc162 100644 --- a/modules/calendar/e-cal-shell-view-private.h +++ b/modules/calendar/e-cal-shell-view-private.h @@ -32,6 +32,7 @@ #include #include "e-util/e-binding.h" +#include "e-util/e-selection.h" #include "e-util/e-dialog-utils.h" #include "e-util/e-file-utils.h" #include "e-util/e-error.h" @@ -44,7 +45,6 @@ #include "calendar/gui/comp-util.h" #include "calendar/gui/e-cal-list-view.h" #include "calendar/gui/e-cal-model-tasks.h" -#include "calendar/gui/e-cal-selection.h" #include "calendar/gui/e-calendar-view.h" #include "calendar/gui/e-day-view.h" #include "calendar/gui/e-week-view.h" -- cgit v1.2.3