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 /calendar/gui/e-calendar-view.c | |
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 'calendar/gui/e-calendar-view.c')
-rw-r--r-- | calendar/gui/e-calendar-view.c | 90 |
1 files changed, 79 insertions, 11 deletions
diff --git a/calendar/gui/e-calendar-view.c b/calendar/gui/e-calendar-view.c index 57973828a3..fd8650edad 100644 --- a/calendar/gui/e-calendar-view.c +++ b/calendar/gui/e-calendar-view.c @@ -74,11 +74,16 @@ struct _ECalendarViewPrivate { /* The default category */ gchar *default_category; + + GtkTargetList *copy_target_list; + GtkTargetList *paste_target_list; }; enum { PROP_0, - PROP_MODEL + PROP_COPY_TARGET_LIST, + PROP_MODEL, + PROP_PASTE_TARGET_LIST }; /* FIXME Why are we emitting these event signals here? Can't the model just be listened to? */ @@ -268,11 +273,23 @@ calendar_view_get_property (GObject *object, GParamSpec *pspec) { switch (property_id) { + case PROP_COPY_TARGET_LIST: + g_value_set_boxed ( + value, e_calendar_view_get_copy_target_list ( + E_CALENDAR_VIEW (object))); + return; + case PROP_MODEL: g_value_set_object ( value, e_calendar_view_get_model ( E_CALENDAR_VIEW (object))); return; + + case PROP_PASTE_TARGET_LIST: + g_value_set_boxed ( + value, e_calendar_view_get_paste_target_list ( + E_CALENDAR_VIEW (object))); + return; } G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec); @@ -293,6 +310,16 @@ calendar_view_dispose (GObject *object) priv->model = 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 (e_calendar_view_parent_class)->dispose (object); } @@ -318,13 +345,15 @@ calendar_view_update_actions (ESelectable *selectable, { ECalendarView *view; GtkAction *action; + GtkTargetList *target_list; GList *list, *iter; + gboolean can_paste = FALSE; gboolean sources_are_editable = TRUE; - gboolean clipboard_has_calendar; gboolean recurring = FALSE; gboolean sensitive; const gchar *tooltip; gint n_selected; + gint ii; view = E_CALENDAR_VIEW (selectable); @@ -353,9 +382,10 @@ calendar_view_update_actions (ESelectable *selectable, g_list_free (list); - clipboard_has_calendar = (clipboard_targets != NULL) && - e_targets_include_calendar ( - 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 = (n_selected > 0) && sources_are_editable; @@ -370,7 +400,7 @@ calendar_view_update_actions (ESelectable *selectable, gtk_action_set_tooltip (action, tooltip); action = e_focus_tracker_get_paste_clipboard_action (focus_tracker); - sensitive = sources_are_editable && clipboard_has_calendar; + sensitive = sources_are_editable && can_paste; tooltip = _("Paste events from the clipboard"); gtk_action_set_sensitive (action, sensitive); gtk_action_set_tooltip (action, tooltip); @@ -718,6 +748,12 @@ e_calendar_view_class_init (ECalendarViewClass *class) class->open_event = e_calendar_view_open_event; class->paste_text = NULL; + /* 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, @@ -729,6 +765,12 @@ e_calendar_view_class_init (ECalendarViewClass *class) G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY)); + /* Inherited from ESelectableInterface */ + g_object_class_override_property ( + object_class, + PROP_PASTE_TARGET_LIST, + "paste-target-list"); + signals[POPUP_EVENT] = g_signal_new ( "popup-event", G_TYPE_FROM_CLASS (class), @@ -820,7 +862,17 @@ e_calendar_view_class_init (ECalendarViewClass *class) static void e_calendar_view_init (ECalendarView *calendar_view) { + GtkTargetList *target_list; + calendar_view->priv = E_CALENDAR_VIEW_GET_PRIVATE (calendar_view); + + target_list = gtk_target_list_new (NULL, 0); + e_target_list_add_calendar_targets (target_list, 0); + calendar_view->priv->copy_target_list = target_list; + + target_list = gtk_target_list_new (NULL, 0); + e_target_list_add_calendar_targets (target_list, 0); + calendar_view->priv->paste_target_list = target_list; } static void @@ -1017,7 +1069,8 @@ const gchar * e_calendar_view_get_default_category (ECalendarView *cal_view) { g_return_val_if_fail (E_IS_CALENDAR_VIEW (cal_view), NULL); - return (const gchar *) cal_view->priv->default_category; + + return cal_view->priv->default_category; } /** @@ -1029,16 +1082,31 @@ e_calendar_view_get_default_category (ECalendarView *cal_view) * components from the given calendar view. */ void -e_calendar_view_set_default_category (ECalendarView *cal_view, const gchar *category) +e_calendar_view_set_default_category (ECalendarView *cal_view, + const gchar *category) { g_return_if_fail (E_IS_CALENDAR_VIEW (cal_view)); - if (cal_view->priv->default_category) - g_free (cal_view->priv->default_category); - + g_free (cal_view->priv->default_category); cal_view->priv->default_category = g_strdup (category); } +GtkTargetList * +e_calendar_view_get_copy_target_list (ECalendarView *cal_view) +{ + g_return_val_if_fail (E_IS_CALENDAR_VIEW (cal_view), NULL); + + return cal_view->priv->copy_target_list; +} + +GtkTargetList * +e_calendar_view_get_paste_target_list (ECalendarView *cal_view) +{ + g_return_val_if_fail (E_IS_CALENDAR_VIEW (cal_view), NULL); + + return cal_view->priv->paste_target_list; +} + GList * e_calendar_view_get_selected_events (ECalendarView *cal_view) { |