diff options
author | Milan Crha <mcrha@redhat.com> | 2013-06-21 21:56:34 +0800 |
---|---|---|
committer | Milan Crha <mcrha@redhat.com> | 2013-06-21 21:56:34 +0800 |
commit | 4a101290fdb546296f7bc0a9a34ba342e741895a (patch) | |
tree | 3a5cecac900e672a87f2865a8288f30dbeea4c34 /calendar | |
parent | 97c70105b71adc9b7cb9f4db15bf44f98133a82c (diff) | |
download | gsoc2013-evolution-4a101290fdb546296f7bc0a9a34ba342e741895a.tar gsoc2013-evolution-4a101290fdb546296f7bc0a9a34ba342e741895a.tar.gz gsoc2013-evolution-4a101290fdb546296f7bc0a9a34ba342e741895a.tar.bz2 gsoc2013-evolution-4a101290fdb546296f7bc0a9a34ba342e741895a.tar.lz gsoc2013-evolution-4a101290fdb546296f7bc0a9a34ba342e741895a.tar.xz gsoc2013-evolution-4a101290fdb546296f7bc0a9a34ba342e741895a.tar.zst gsoc2013-evolution-4a101290fdb546296f7bc0a9a34ba342e741895a.zip |
Calendar views inline text edit with Ctrl+C/V/X does not work
The shortcuts Ctrl+C/V/X are used for whole calendar items
copy/paste/cut, not for text when editing event details inline, either
in a day/week view or in a list view. By tracking the is-editing property
of respective cell editor and using it when enabling/disabling clipboard
actions makes the respective text operations work as expected.
Diffstat (limited to 'calendar')
-rw-r--r-- | calendar/gui/e-cal-list-view.c | 51 | ||||
-rw-r--r-- | calendar/gui/e-cal-list-view.h | 2 | ||||
-rw-r--r-- | calendar/gui/e-calendar-view.c | 52 | ||||
-rw-r--r-- | calendar/gui/e-calendar-view.h | 2 | ||||
-rw-r--r-- | calendar/gui/e-day-view.c | 28 | ||||
-rw-r--r-- | calendar/gui/e-day-view.h | 2 | ||||
-rw-r--r-- | calendar/gui/e-memo-table.c | 10 | ||||
-rw-r--r-- | calendar/gui/e-task-table.c | 10 | ||||
-rw-r--r-- | calendar/gui/e-week-view.c | 40 | ||||
-rw-r--r-- | calendar/gui/e-week-view.h | 2 |
10 files changed, 181 insertions, 18 deletions
diff --git a/calendar/gui/e-cal-list-view.c b/calendar/gui/e-cal-list-view.c index 94722c0319..275cc0c0dd 100644 --- a/calendar/gui/e-cal-list-view.c +++ b/calendar/gui/e-cal-list-view.c @@ -48,6 +48,11 @@ #include "calendar-config.h" #include "misc.h" +enum { + PROP_0, + PROP_IS_EDITING +}; + static void e_cal_list_view_dispose (GObject *object); static GList *e_cal_list_view_get_selected_events (ECalendarView *cal_view); @@ -68,6 +73,24 @@ static void e_cal_list_view_cursor_change_cb (ETable *etable, gint row, gpointer G_DEFINE_TYPE (ECalListView, e_cal_list_view, E_TYPE_CALENDAR_VIEW) static void +e_cal_list_view_get_property (GObject *object, + guint property_id, + GValue *value, + GParamSpec *pspec) +{ + ECalListView *eclv = E_CAL_LIST_VIEW (object); + + switch (property_id) { + case PROP_IS_EDITING: + g_value_set_boolean (value, e_cal_list_view_is_editing (eclv)); + break; + default: + G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec); + break; + } +} + +static void e_cal_list_view_class_init (ECalListViewClass *class) { GObjectClass *object_class; @@ -80,12 +103,18 @@ e_cal_list_view_class_init (ECalListViewClass *class) /* Method override */ object_class->dispose = e_cal_list_view_dispose; + object_class->get_property = e_cal_list_view_get_property; widget_class->popup_menu = e_cal_list_view_popup_menu; view_class->get_selected_events = e_cal_list_view_get_selected_events; view_class->get_selected_time_range = e_cal_list_view_get_selected_time_range; view_class->get_visible_time_range = e_cal_list_view_get_visible_time_range; + + g_object_class_override_property ( + object_class, + PROP_IS_EDITING, + "is-editing"); } static void @@ -147,6 +176,16 @@ e_cal_list_view_save_state (ECalListView *cal_list_view, } static void +e_cal_list_view_table_editing_changed_cb (ETable *table, + GParamSpec *param, + ECalListView *eclv) +{ + g_return_if_fail (E_IS_CAL_LIST_VIEW (eclv)); + + g_object_notify (G_OBJECT (eclv), "is-editing"); +} + +static void setup_e_table (ECalListView *cal_list_view) { ECalModel *model; @@ -300,6 +339,10 @@ setup_e_table (ECalListView *cal_list_view) cal_list_view->table, "cursor_change", G_CALLBACK (e_cal_list_view_cursor_change_cb), cal_list_view); + g_signal_connect_after ( + cal_list_view->table, "notify::is-editing", + G_CALLBACK (e_cal_list_view_table_editing_changed_cb), + cal_list_view); } /** @@ -563,3 +606,11 @@ e_cal_list_view_get_range_shown (ECalListView *cal_list_view, *days_shown = g_date_days_between (start_date, &end_date); return TRUE; } + +gboolean +e_cal_list_view_is_editing (ECalListView *eclv) +{ + g_return_val_if_fail (E_IS_CAL_LIST_VIEW (eclv), FALSE); + + return eclv->table && e_table_is_editing (eclv->table); +} diff --git a/calendar/gui/e-cal-list-view.h b/calendar/gui/e-cal-list-view.h index e5eff477a2..e434033a00 100644 --- a/calendar/gui/e-cal-list-view.h +++ b/calendar/gui/e-cal-list-view.h @@ -91,6 +91,8 @@ void e_cal_list_view_save_state (ECalListView *cal_list_view, gchar *filename); gboolean e_cal_list_view_get_range_shown (ECalListView *cal_list_view, GDate *start_date, gint *days_shown); +gboolean e_cal_list_view_is_editing (ECalListView *eclv); + G_END_DECLS #endif /* _E_CAL_LIST_VIEW_H_ */ diff --git a/calendar/gui/e-calendar-view.c b/calendar/gui/e-calendar-view.c index 8228e68285..54df73aac3 100644 --- a/calendar/gui/e-calendar-view.c +++ b/calendar/gui/e-calendar-view.c @@ -79,7 +79,8 @@ enum { PROP_COPY_TARGET_LIST, PROP_MODEL, PROP_PASTE_TARGET_LIST, - PROP_TIME_DIVISIONS + PROP_TIME_DIVISIONS, + PROP_IS_EDITING }; /* FIXME Why are we emitting these event signals here? Can't the model just be listened to? */ @@ -313,6 +314,10 @@ calendar_view_get_property (GObject *object, value, e_calendar_view_get_time_divisions ( E_CALENDAR_VIEW (object))); return; + + case PROP_IS_EDITING: + g_value_set_boolean (value, e_calendar_view_is_editing (E_CALENDAR_VIEW (object))); + return; } G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec); @@ -398,12 +403,14 @@ calendar_view_update_actions (ESelectable *selectable, gboolean can_paste = FALSE; gboolean sources_are_editable = TRUE; gboolean recurring = FALSE; + gboolean is_editing; gboolean sensitive; const gchar *tooltip; gint n_selected; gint ii; view = E_CALENDAR_VIEW (selectable); + is_editing = e_calendar_view_is_editing (view); list = e_calendar_view_get_selected_events (view); n_selected = g_list_length (list); @@ -434,25 +441,25 @@ calendar_view_update_actions (ESelectable *selectable, target_list, clipboard_targets[ii], NULL); action = e_focus_tracker_get_cut_clipboard_action (focus_tracker); - sensitive = (n_selected > 0) && sources_are_editable; + sensitive = (n_selected > 0) && sources_are_editable && !is_editing; tooltip = _("Cut selected events to the clipboard"); gtk_action_set_sensitive (action, sensitive); gtk_action_set_tooltip (action, tooltip); action = e_focus_tracker_get_copy_clipboard_action (focus_tracker); - sensitive = (n_selected > 0); + sensitive = (n_selected > 0) && !is_editing; tooltip = _("Copy selected events to the clipboard"); gtk_action_set_sensitive (action, sensitive); gtk_action_set_tooltip (action, tooltip); action = e_focus_tracker_get_paste_clipboard_action (focus_tracker); - sensitive = sources_are_editable && can_paste; + sensitive = sources_are_editable && can_paste && !is_editing; tooltip = _("Paste events from the clipboard"); gtk_action_set_sensitive (action, sensitive); gtk_action_set_tooltip (action, tooltip); action = e_focus_tracker_get_delete_selection_action (focus_tracker); - sensitive = (n_selected > 0) && sources_are_editable && !recurring; + sensitive = (n_selected > 0) && sources_are_editable && !recurring && !is_editing; tooltip = _("Delete selected events"); gtk_action_set_sensitive (action, sensitive); gtk_action_set_tooltip (action, tooltip); @@ -884,6 +891,16 @@ e_calendar_view_class_init (ECalendarViewClass *class) 30, G_PARAM_READWRITE)); + g_object_class_install_property ( + object_class, + PROP_IS_EDITING, + g_param_spec_boolean ( + "is-editing", + "Whether is in an editing mode", + "Whether is in an editing mode", + FALSE, + G_PARAM_READABLE)); + signals[POPUP_EVENT] = g_signal_new ( "popup-event", G_TYPE_FROM_CLASS (class), @@ -2348,3 +2365,28 @@ is_array_index_in_bounds_func (GArray *array, return TRUE; } + +gboolean +e_calendar_view_is_editing (ECalendarView *cal_view) +{ + static gboolean in = FALSE; + gboolean is_editing = FALSE; + + g_return_val_if_fail (E_IS_CALENDAR_VIEW (cal_view), FALSE); + + /* this should be called from the main thread only, + and each descendant overrides the property, + thus might cause no call recursion */ + if (in) { + g_warn_if_reached (); + return FALSE; + } + + in = TRUE; + + g_object_get (G_OBJECT (cal_view), "is-editing", &is_editing, NULL); + + in = FALSE; + + return is_editing; +} diff --git a/calendar/gui/e-calendar-view.h b/calendar/gui/e-calendar-view.h index 9ed1173533..8e55587cc1 100644 --- a/calendar/gui/e-calendar-view.h +++ b/calendar/gui/e-calendar-view.h @@ -274,6 +274,8 @@ void draw_curved_rectangle (cairo_t *cr, GdkColor get_today_background (GdkColor event_background); +gboolean e_calendar_view_is_editing (ECalendarView *cal_view); + G_END_DECLS #endif /* E_CALENDAR_VIEW_H */ diff --git a/calendar/gui/e-day-view.c b/calendar/gui/e-day-view.c index 541b62ac20..6dae27fa18 100644 --- a/calendar/gui/e-day-view.c +++ b/calendar/gui/e-day-view.c @@ -434,7 +434,8 @@ enum { PROP_0, PROP_MARCUS_BAINS_SHOW_LINE, PROP_MARCUS_BAINS_DAY_VIEW_COLOR, - PROP_MARCUS_BAINS_TIME_BAR_COLOR + PROP_MARCUS_BAINS_TIME_BAR_COLOR, + PROP_IS_EDITING }; G_DEFINE_TYPE (EDayView, e_day_view, E_TYPE_CALENDAR_VIEW) @@ -755,6 +756,10 @@ day_view_get_property (GObject *object, e_day_view_marcus_bains_get_time_bar_color ( E_DAY_VIEW (object))); return; + + case PROP_IS_EDITING: + g_value_set_boolean (value, e_day_view_is_editing (E_DAY_VIEW (object))); + return; } G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec); @@ -1595,6 +1600,11 @@ e_day_view_class_init (EDayViewClass *class) G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS)); + g_object_class_override_property ( + object_class, + PROP_IS_EDITING, + "is-editing"); + /* init the accessibility support for e_day_view */ e_day_view_a11y_init (); } @@ -2570,6 +2580,7 @@ e_day_view_remove_event_cb (EDayView *day_view, if (day_view->editing_event_num == event_num && day_view->editing_event_day == day) { day_view->editing_event_num = -1; day_view->editing_event_day = -1; + g_object_notify (G_OBJECT (day_view), "is-editing"); } if (day_view->popup_event_num == event_num && day_view->popup_event_day == day) { @@ -4920,6 +4931,7 @@ static void e_day_view_free_events (EDayView *day_view) { gint day; + gboolean did_editing = day_view->editing_event_day != -1; /* Reset all our indices. */ day_view->editing_event_day = -1; @@ -4935,6 +4947,9 @@ e_day_view_free_events (EDayView *day_view) for (day = 0; day < E_DAY_VIEW_MAX_DAYS; day++) e_day_view_free_event_array (day_view, day_view->events[day]); + + if (did_editing) + g_object_notify (G_OBJECT (day_view), "is-editing"); } static void @@ -7066,6 +7081,8 @@ e_day_view_on_editing_started (EDayView *day_view, } g_signal_emit_by_name (day_view, "selection_changed"); + + g_object_notify (G_OBJECT (day_view), "is-editing"); } static void @@ -7259,6 +7276,8 @@ e_day_view_on_editing_stopped (EDayView *day_view, g_free (text); g_signal_emit_by_name (day_view, "selection_changed"); + + g_object_notify (G_OBJECT (day_view), "is-editing"); } /* FIXME: It is possible that we may produce an invalid time due to daylight @@ -8894,3 +8913,10 @@ e_day_view_get_num_events_selected (EDayView *day_view) return (day_view->editing_event_day != -1) ? 1 : 0; } +gboolean +e_day_view_is_editing (EDayView *day_view) +{ + g_return_val_if_fail (E_IS_DAY_VIEW (day_view), FALSE); + + return day_view->editing_event_day != -1; +} diff --git a/calendar/gui/e-day-view.h b/calendar/gui/e-day-view.h index b22253d387..19d735d6d2 100644 --- a/calendar/gui/e-day-view.h +++ b/calendar/gui/e-day-view.h @@ -564,6 +564,8 @@ void e_day_view_ensure_rows_visible (EDayView *day_view, gint start_row, gint end_row); +gboolean e_day_view_is_editing (EDayView *day_view); + G_END_DECLS #endif /* E_DAY_VIEW_H */ diff --git a/calendar/gui/e-memo-table.c b/calendar/gui/e-memo-table.c index f229bcf7a2..580f378083 100644 --- a/calendar/gui/e-memo-table.c +++ b/calendar/gui/e-memo-table.c @@ -700,6 +700,7 @@ memo_table_update_actions (ESelectable *selectable, GSList *list, *iter; gboolean can_paste = FALSE; gboolean sources_are_editable = TRUE; + gboolean is_editing; gboolean sensitive; const gchar *tooltip; gint n_selected; @@ -707,6 +708,7 @@ memo_table_update_actions (ESelectable *selectable, memo_table = E_MEMO_TABLE (selectable); n_selected = e_table_selected_count (E_TABLE (memo_table)); + is_editing = e_table_is_editing (E_TABLE (memo_table)); list = e_memo_table_get_selected (memo_table); for (iter = list; iter != NULL && sources_are_editable; iter = iter->next) { @@ -723,25 +725,25 @@ memo_table_update_actions (ESelectable *selectable, target_list, clipboard_targets[ii], NULL); action = e_focus_tracker_get_cut_clipboard_action (focus_tracker); - sensitive = (n_selected > 0) && sources_are_editable; + sensitive = (n_selected > 0) && sources_are_editable && !is_editing; tooltip = _("Cut selected memos to the clipboard"); gtk_action_set_sensitive (action, sensitive); gtk_action_set_tooltip (action, tooltip); action = e_focus_tracker_get_copy_clipboard_action (focus_tracker); - sensitive = (n_selected > 0); + sensitive = (n_selected > 0) && !is_editing; tooltip = _("Copy selected memos to the clipboard"); gtk_action_set_sensitive (action, sensitive); gtk_action_set_tooltip (action, tooltip); action = e_focus_tracker_get_paste_clipboard_action (focus_tracker); - sensitive = sources_are_editable && can_paste; + sensitive = sources_are_editable && can_paste && !is_editing; tooltip = _("Paste memos from the clipboard"); gtk_action_set_sensitive (action, sensitive); gtk_action_set_tooltip (action, tooltip); action = e_focus_tracker_get_delete_selection_action (focus_tracker); - sensitive = (n_selected > 0) && sources_are_editable; + sensitive = (n_selected > 0) && sources_are_editable && !is_editing; tooltip = _("Delete selected memos"); gtk_action_set_sensitive (action, sensitive); gtk_action_set_tooltip (action, tooltip); diff --git a/calendar/gui/e-task-table.c b/calendar/gui/e-task-table.c index 0ec834ff6b..d16719cd4c 100644 --- a/calendar/gui/e-task-table.c +++ b/calendar/gui/e-task-table.c @@ -998,6 +998,7 @@ task_table_update_actions (ESelectable *selectable, GSList *list, *iter; gboolean can_paste = FALSE; gboolean sources_are_editable = TRUE; + gboolean is_editing; gboolean sensitive; const gchar *tooltip; gint n_selected; @@ -1005,6 +1006,7 @@ task_table_update_actions (ESelectable *selectable, task_table = E_TASK_TABLE (selectable); n_selected = e_table_selected_count (E_TABLE (task_table)); + is_editing = e_table_is_editing (E_TABLE (task_table)); list = e_task_table_get_selected (task_table); for (iter = list; iter != NULL && sources_are_editable; iter = iter->next) { @@ -1021,25 +1023,25 @@ task_table_update_actions (ESelectable *selectable, target_list, clipboard_targets[ii], NULL); action = e_focus_tracker_get_cut_clipboard_action (focus_tracker); - sensitive = (n_selected > 0) && sources_are_editable; + sensitive = (n_selected > 0) && sources_are_editable && !is_editing; tooltip = _("Cut selected tasks to the clipboard"); gtk_action_set_sensitive (action, sensitive); gtk_action_set_tooltip (action, tooltip); action = e_focus_tracker_get_copy_clipboard_action (focus_tracker); - sensitive = (n_selected > 0); + sensitive = (n_selected > 0) && !is_editing; tooltip = _("Copy selected tasks to the clipboard"); gtk_action_set_sensitive (action, sensitive); gtk_action_set_tooltip (action, tooltip); action = e_focus_tracker_get_paste_clipboard_action (focus_tracker); - sensitive = sources_are_editable && can_paste; + sensitive = sources_are_editable && can_paste && !is_editing; tooltip = _("Paste tasks from the clipboard"); gtk_action_set_sensitive (action, sensitive); gtk_action_set_tooltip (action, tooltip); action = e_focus_tracker_get_delete_selection_action (focus_tracker); - sensitive = (n_selected > 0) && sources_are_editable; + sensitive = (n_selected > 0) && sources_are_editable && !is_editing; tooltip = _("Delete selected tasks"); gtk_action_set_sensitive (action, sensitive); gtk_action_set_tooltip (action, tooltip); diff --git a/calendar/gui/e-week-view.c b/calendar/gui/e-week-view.c index 8d1e8815de..b2bc509dfa 100644 --- a/calendar/gui/e-week-view.c +++ b/calendar/gui/e-week-view.c @@ -199,7 +199,8 @@ G_DEFINE_TYPE (EWeekView, e_week_view, E_TYPE_CALENDAR_VIEW) enum { PROP_0, PROP_COMPRESS_WEEKEND, - PROP_SHOW_EVENT_END_TIMES + PROP_SHOW_EVENT_END_TIMES, + PROP_IS_EDITING }; static gint map_left[] = {0, 1, 2, 0, 1, 2, 2}; @@ -704,6 +705,10 @@ week_view_get_property (GObject *object, e_week_view_get_show_event_end_times ( E_WEEK_VIEW (object))); return; + + case PROP_IS_EDITING: + g_value_set_boolean (value, e_week_view_is_editing (E_WEEK_VIEW (object))); + return; } G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec); @@ -1192,8 +1197,11 @@ week_view_get_selected_events (ECalendarView *cal_view) g_return_val_if_fail (E_IS_WEEK_VIEW (week_view), NULL); if (week_view->editing_event_num != -1) { - if (!is_array_index_in_bounds (week_view->events, week_view->editing_event_num)) + if (!is_array_index_in_bounds (week_view->events, week_view->editing_event_num)) { + week_view->editing_event_num = -1; + g_object_notify (G_OBJECT (week_view), "is-editing"); return NULL; + } event = &g_array_index (week_view->events, EWeekViewEvent, week_view->editing_event_num); @@ -1471,6 +1479,11 @@ e_week_view_class_init (EWeekViewClass *class) G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS)); + g_object_class_override_property ( + object_class, + PROP_IS_EDITING, + "is-editing"); + /* init the accessibility support for e_week_view */ e_week_view_a11y_init (); } @@ -2445,8 +2458,10 @@ e_week_view_remove_event_cb (EWeekView *week_view, /* If we were editing this event, set editing_event_num to -1 so * on_editing_stopped doesn't try to update the event. */ - if (week_view->editing_event_num == event_num) + if (week_view->editing_event_num == event_num) { week_view->editing_event_num = -1; + g_object_notify (G_OBJECT (week_view), "is-editing"); + } if (week_view->popup_event_num == event_num) week_view->popup_event_num = -1; @@ -2940,6 +2955,7 @@ e_week_view_free_events (EWeekView *week_view) EWeekViewEvent *event; EWeekViewEventSpan *span; gint event_num, span_num, num_days, day; + gboolean did_editing = week_view->editing_event_num != -1; /* Reset all our indices. */ week_view->pressed_event_num = -1; @@ -2983,6 +2999,9 @@ e_week_view_free_events (EWeekView *week_view) for (day = 0; day < E_WEEK_VIEW_MAX_WEEKS * 7; day++) { gnome_canvas_item_hide (week_view->jump_buttons[day]); } + + if (did_editing) + g_object_notify (G_OBJECT (week_view), "is-editing"); } /* This adds one event to the view, adding it to the appropriate array. */ @@ -4233,6 +4252,8 @@ e_week_view_on_editing_started (EWeekView *week_view, } g_signal_emit_by_name (week_view, "selection_changed"); + + g_object_notify (G_OBJECT (week_view), "is-editing"); } static void @@ -4278,8 +4299,10 @@ e_week_view_on_editing_stopped (EWeekView *week_view, /* Check that the event is still valid. */ uid = icalcomponent_get_uid (event->comp_data->icalcomp); - if (!uid) + if (!uid) { + g_object_notify (G_OBJECT (week_view), "is-editing"); return; + } text = NULL; g_object_set (span->text_item, "handle_popup", FALSE, NULL); @@ -4431,6 +4454,8 @@ e_week_view_on_editing_stopped (EWeekView *week_view, g_object_unref (comp); g_signal_emit_by_name (week_view, "selection_changed"); + + g_object_notify (G_OBJECT (week_view), "is-editing"); } gboolean @@ -4925,3 +4950,10 @@ e_week_view_is_jump_button_visible (EWeekView *week_view, return FALSE; } +gboolean +e_week_view_is_editing (EWeekView *week_view) +{ + g_return_val_if_fail (E_IS_WEEK_VIEW (week_view), FALSE); + + return week_view->editing_event_num != -1; +} diff --git a/calendar/gui/e-week-view.h b/calendar/gui/e-week-view.h index 00181d1d89..f10967a5e0 100644 --- a/calendar/gui/e-week-view.h +++ b/calendar/gui/e-week-view.h @@ -441,6 +441,8 @@ void e_week_view_jump_to_button_item (EWeekView *week_view, void e_week_view_scroll_a_step (EWeekView *week_view, ECalViewMoveDirection direction); +gboolean e_week_view_is_editing (EWeekView *week_view); + G_END_DECLS #endif /* E_WEEK_VIEW_H */ |