diff options
author | Matthew Barnes <mbarnes@redhat.com> | 2010-01-17 02:34:32 +0800 |
---|---|---|
committer | Matthew Barnes <mbarnes@redhat.com> | 2010-01-18 01:11:08 +0800 |
commit | 3e7c7808cc65c22bc40a7d1d30ffa0044097a6ff (patch) | |
tree | d74cd0017e310c79b796eba3df7bfb8947a673d7 /addressbook/gui | |
parent | 2cf0c27e2ece428dd2af1945f6fececbe9dbcc15 (diff) | |
download | gsoc2013-evolution-3e7c7808cc65c22bc40a7d1d30ffa0044097a6ff.tar.gz gsoc2013-evolution-3e7c7808cc65c22bc40a7d1d30ffa0044097a6ff.tar.zst gsoc2013-evolution-3e7c7808cc65c22bc40a7d1d30ffa0044097a6ff.zip |
Improve clipboard behavior.
Add "copy-target-list" and "paste-target-list" to the ESelectable
interface. These are underutilized for the moment, but will eventually
be used to help integrate drag-and-drop support into ESelectable.
Add cut and paste support to EWebView, along with a new "editable"
property and new clipboard signals "copy-clipboard", "cut-clipboard" and
"paste-clipboard".
In EFocusTracker, listen for "owner-changed" signals from the default
clipboard as another trigger to update actions, particularly the Paste
action. (Unfortunately this doesn't work for EWebView since GtkHtml
implements its own clipboard.)
In EMsgComposer, convert GtkhtmlEditor's clipboard methods to empty
stubs, since EFocusTracker will now trigger EWebView's clipboard
actions. Also, intercept EWebView::paste-clipboard signals and improve
the interaction between the HTML editor and the attachment bar based on
use cases in bug #603715.
Diffstat (limited to 'addressbook/gui')
-rw-r--r-- | addressbook/gui/widgets/e-addressbook-view.c | 90 | ||||
-rw-r--r-- | addressbook/gui/widgets/e-addressbook-view.h | 4 |
2 files changed, 86 insertions, 8 deletions
diff --git a/addressbook/gui/widgets/e-addressbook-view.c b/addressbook/gui/widgets/e-addressbook-view.c index cc540c14c3..48058ad415 100644 --- a/addressbook/gui/widgets/e-addressbook-view.c +++ b/addressbook/gui/widgets/e-addressbook-view.c @@ -36,6 +36,7 @@ #include "addressbook/printing/e-contact-print.h" #include "ea-addressbook.h" +#include "e-util/e-binding.h" #include "e-util/e-print.h" #include "e-util/e-selection.h" #include "e-util/e-util.h" @@ -90,11 +91,16 @@ struct _EAddressbookViewPrivate { gchar *search_text; gint search_id; EFilterRule *advanced_search; + + GtkTargetList *copy_target_list; + GtkTargetList *paste_target_list; }; enum { PROP_0, + PROP_COPY_TARGET_LIST, PROP_MODEL, + PROP_PASTE_TARGET_LIST, PROP_SHELL_VIEW, PROP_SOURCE }; @@ -437,21 +443,38 @@ addressbook_view_get_property (GObject *object, GParamSpec *pspec) { switch (property_id) { + case PROP_COPY_TARGET_LIST: + g_value_set_boxed ( + value, + e_addressbook_view_get_copy_target_list ( + E_ADDRESSBOOK_VIEW (object))); + return; + case PROP_MODEL: g_value_set_object ( - value, e_addressbook_view_get_model ( + value, + e_addressbook_view_get_model ( + E_ADDRESSBOOK_VIEW (object))); + return; + + case PROP_PASTE_TARGET_LIST: + g_value_set_boxed ( + value, + e_addressbook_view_get_paste_target_list ( E_ADDRESSBOOK_VIEW (object))); return; case PROP_SHELL_VIEW: g_value_set_object ( - value, e_addressbook_view_get_shell_view ( + value, + e_addressbook_view_get_shell_view ( E_ADDRESSBOOK_VIEW (object))); return; case PROP_SOURCE: g_value_set_object ( - value, e_addressbook_view_get_source ( + value, + e_addressbook_view_get_source ( E_ADDRESSBOOK_VIEW (object))); return; } @@ -511,6 +534,16 @@ addressbook_view_dispose (GObject *object) priv->advanced_search = NULL; } + if (priv->copy_target_list != NULL) { + gtk_target_list_unref (priv->copy_target_list); + priv->copy_target_list = NULL; + } + + if (priv->paste_target_list != NULL) { + gtk_target_list_unref (priv->paste_target_list); + priv->paste_target_list = NULL; + } + /* Chain up to parent's dispose() method. */ G_OBJECT_CLASS (parent_class)->dispose (object); } @@ -548,12 +581,14 @@ addressbook_view_update_actions (ESelectable *selectable, EAddressbookModel *model; ESelectionModel *selection_model; GtkAction *action; - gboolean clipboard_has_directory; + GtkTargetList *target_list; + gboolean can_paste = FALSE; gboolean source_is_editable; gboolean sensitive; const gchar *tooltip; gint n_contacts; gint n_selected; + gint ii; view = E_ADDRESSBOOK_VIEW (selectable); model = e_addressbook_view_get_model (view); @@ -565,9 +600,10 @@ addressbook_view_update_actions (ESelectable *selectable, n_selected = (selection_model != NULL) ? e_selection_model_selected_count (selection_model) : 0; - clipboard_has_directory = (clipboard_targets != NULL) && - e_targets_include_directory ( - clipboard_targets, n_clipboard_targets); + target_list = e_selectable_get_paste_target_list (selectable); + for (ii = 0; ii < n_clipboard_targets && !can_paste; ii++) + can_paste = gtk_target_list_find ( + target_list, clipboard_targets[ii], NULL); action = e_focus_tracker_get_cut_clipboard_action (focus_tracker); sensitive = source_is_editable && (n_selected > 0); @@ -582,7 +618,7 @@ addressbook_view_update_actions (ESelectable *selectable, gtk_action_set_tooltip (action, tooltip); action = e_focus_tracker_get_paste_clipboard_action (focus_tracker); - sensitive = source_is_editable && clipboard_has_directory; + sensitive = source_is_editable && can_paste; tooltip = _("Paste contacts from the clipboard"); gtk_action_set_sensitive (action, sensitive); gtk_action_set_tooltip (action, tooltip); @@ -702,6 +738,12 @@ addressbook_view_class_init (EAddressbookViewClass *class) object_class->dispose = addressbook_view_dispose; object_class->constructed = addressbook_view_constructed; + /* Inherited from ESelectableInterface */ + g_object_class_override_property ( + object_class, + PROP_COPY_TARGET_LIST, + "copy-target-list"); + g_object_class_install_property ( object_class, PROP_MODEL, @@ -712,6 +754,12 @@ addressbook_view_class_init (EAddressbookViewClass *class) E_TYPE_ADDRESSBOOK_MODEL, G_PARAM_READABLE)); + /* Inherited from ESelectableInterface */ + g_object_class_override_property ( + object_class, + PROP_PASTE_TARGET_LIST, + "paste-target-list"); + g_object_class_install_property ( object_class, PROP_SHELL_VIEW, @@ -780,10 +828,20 @@ addressbook_view_class_init (EAddressbookViewClass *class) static void addressbook_view_init (EAddressbookView *view) { + GtkTargetList *target_list; + view->priv = E_ADDRESSBOOK_VIEW_GET_PRIVATE (view); view->priv->model = e_addressbook_model_new (); + target_list = gtk_target_list_new (NULL, 0); + e_target_list_add_directory_targets (target_list, 0); + view->priv->copy_target_list = target_list; + + target_list = gtk_target_list_new (NULL, 0); + e_target_list_add_directory_targets (target_list, 0); + view->priv->paste_target_list = target_list; + gtk_scrolled_window_set_policy ( GTK_SCROLLED_WINDOW (view), GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC); @@ -972,6 +1030,22 @@ e_addressbook_view_get_source (EAddressbookView *view) return view->priv->source; } +GtkTargetList * +e_addressbook_view_get_copy_target_list (EAddressbookView *view) +{ + g_return_val_if_fail (E_IS_ADDRESSBOOK_VIEW (view), NULL); + + return view->priv->copy_target_list; +} + +GtkTargetList * +e_addressbook_view_get_paste_target_list (EAddressbookView *view) +{ + g_return_val_if_fail (E_IS_ADDRESSBOOK_VIEW (view), NULL); + + return view->priv->paste_target_list; +} + static void status_message (EAddressbookView *view, const gchar *status) diff --git a/addressbook/gui/widgets/e-addressbook-view.h b/addressbook/gui/widgets/e-addressbook-view.h index 55f114a538..4b85293cd5 100644 --- a/addressbook/gui/widgets/e-addressbook-view.h +++ b/addressbook/gui/widgets/e-addressbook-view.h @@ -96,6 +96,10 @@ ESelectionModel * EShellView * e_addressbook_view_get_shell_view (EAddressbookView *view); ESource * e_addressbook_view_get_source (EAddressbookView *view); +GtkTargetList * e_addressbook_view_get_copy_target_list + (EAddressbookView *view); +GtkTargetList * e_addressbook_view_get_paste_target_list + (EAddressbookView *view); void e_addressbook_view_view (EAddressbookView *view); void e_addressbook_view_print (EAddressbookView *view, gboolean selection_only, |