evolution/evolution-2.5.5.1-commit-enter-on-calendar.patch

243 lines
8.0 KiB
Diff
Raw Normal View History

--- evolution-2.5.5.1/calendar/gui/e-day-view.c.commit-enter-on-calendar 2006-01-16 09:42:17.000000000 -0500
+++ evolution-2.5.5.1/calendar/gui/e-day-view.c 2006-01-25 23:48:24.000000000 -0500
@@ -334,6 +334,10 @@
gint event_num,
gchar *initial_text);
static void e_day_view_stop_editing_event (EDayView *day_view);
+static gboolean e_day_view_text_keypress (GnomeCanvasItem *item,
+ guint keyval,
+ guint state,
+ EDayView *day_view);
static gboolean e_day_view_on_text_item_event (GnomeCanvasItem *item,
GdkEvent *event,
EDayView *day_view);
@@ -4484,6 +4488,8 @@
G_CALLBACK (e_day_view_on_text_item_event), day_view);
g_signal_emit_by_name (G_OBJECT(day_view),
"event_added", event);
+ g_signal_connect (event->canvas_item, "keypress",
+ G_CALLBACK (e_day_view_text_keypress), day_view);
e_day_view_update_long_event_label (day_view, event_num);
}
@@ -4667,6 +4673,8 @@
G_CALLBACK (e_day_view_on_text_item_event), day_view);
g_signal_emit_by_name (G_OBJECT(day_view),
"event_added", event);
+ g_signal_connect (event->canvas_item, "keypress",
+ G_CALLBACK (e_day_view_text_keypress), day_view);
e_day_view_update_event_label (day_view, day, event_num);
}
@@ -5824,46 +5832,74 @@
}
static gboolean
+e_day_view_text_keypress (GnomeCanvasItem *item,
+ guint keyval,
+ guint state,
+ EDayView *day_view)
+{
+ gboolean retval = FALSE;
+
+ tooltip_destroy (day_view, item);
+
+ if (keyval == GDK_Return) {
+ EText *text = E_TEXT (item);
+ gint new_pos = 0;
+
+ /*
+ * HACK: last character which should be \n needs to be deleted
+ * here so that GDK_Return was already processed on EText
+ * before E_TEXT_KEYPRESS event is emitted.
+ */
+ if (text->selection_end >= 1)
+ new_pos = text->selection_end - 1;
+
+ text->selection_end = e_text_model_validate_position (text->model, new_pos);
+ e_text_delete_selection (text);
+
+ day_view->resize_event_num = -1;
+
+ /* We set the keyboard focus to the EDayView, so the
+ EText item loses it and stops the edit. */
+ gtk_widget_grab_focus (GTK_WIDGET (day_view));
+
+ /* Stop the signal last or we will also stop any
+ other events getting to the EText item. */
+ gtk_signal_emit_stop_by_name (GTK_OBJECT (item),
+ "event");
+
+ retval = TRUE;
+ } else if (keyval == GDK_Escape) {
+ cancel_editing (day_view);
+ gtk_signal_emit_stop_by_name (GTK_OBJECT (item), "event");
+ /* focus should go to day view when stop editing */
+ gtk_widget_grab_focus (GTK_WIDGET (day_view));
+
+ retval = TRUE;
+ } else if ((keyval == GDK_Up)
+ && (state & GDK_SHIFT_MASK)
+ && (state & GDK_CONTROL_MASK)
+ && !(state & GDK_MOD1_MASK)) {
+ e_day_view_change_event_end_time_up (day_view);
+
+ retval = TRUE;
+ } else if ((keyval == GDK_Down)
+ && (state & GDK_SHIFT_MASK)
+ && (state & GDK_CONTROL_MASK)
+ && !(state & GDK_MOD1_MASK)) {
+ e_day_view_change_event_end_time_down (day_view);
+
+ retval = TRUE;
+ }
+
+ return retval;
+}
+
+static gboolean
e_day_view_on_text_item_event (GnomeCanvasItem *item,
GdkEvent *event,
EDayView *day_view)
{
switch (event->type) {
- case GDK_KEY_PRESS:
- tooltip_destroy (day_view, item);
- if (event && event->key.keyval == GDK_Return) {
- day_view->resize_event_num = -1;
- day_view->resize_event_num = -1;
-
- /* We set the keyboard focus to the EDayView, so the
- EText item loses it and stops the edit. */
- gtk_widget_grab_focus (GTK_WIDGET (day_view));
-
- /* Stop the signal last or we will also stop any
- other events getting to the EText item. */
- gtk_signal_emit_stop_by_name (GTK_OBJECT (item),
- "event");
- return TRUE;
- } else if (event->key.keyval == GDK_Escape) {
- cancel_editing (day_view);
- gtk_signal_emit_stop_by_name (GTK_OBJECT (item), "event");
- /* focus should go to day view when stop editing */
- gtk_widget_grab_focus (GTK_WIDGET (day_view));
- return TRUE;
- } else if ((event->key.keyval == GDK_Up)
- && (event->key.state & GDK_SHIFT_MASK)
- && (event->key.state & GDK_CONTROL_MASK)
- && !(event->key.state & GDK_MOD1_MASK)) {
- e_day_view_change_event_end_time_up (day_view);
- return TRUE;
- } else if ((event->key.keyval == GDK_Down)
- && (event->key.state & GDK_SHIFT_MASK)
- && (event->key.state & GDK_CONTROL_MASK)
- && !(event->key.state & GDK_MOD1_MASK)) {
- e_day_view_change_event_end_time_down (day_view);
- return TRUE;
- }
- break;
case GDK_2BUTTON_PRESS:
#if 0
g_print ("Item got double-click\n");
--- evolution-2.5.5.1/calendar/gui/e-week-view.c.commit-enter-on-calendar 2006-01-16 09:42:17.000000000 -0500
+++ evolution-2.5.5.1/calendar/gui/e-week-view.c 2006-01-25 23:46:43.000000000 -0500
@@ -175,6 +175,10 @@
const gchar *uid,
EWeekViewForeachEventCallback callback,
gpointer data);
+static gboolean e_week_view_text_keypress (GnomeCanvasItem *item,
+ guint keyval,
+ guint state,
+ EWeekView *week_view);
static gboolean e_week_view_on_text_item_event (GnomeCanvasItem *item,
GdkEvent *event,
EWeekView *week_view);
@@ -2771,6 +2775,8 @@
week_view);
g_signal_emit_by_name (G_OBJECT(week_view),
"event_added", event);
+ g_signal_connect (span->text_item, "keypress",
+ G_CALLBACK (e_week_view_text_keypress), week_view);
}
@@ -3028,6 +3034,51 @@
}
static gboolean
+e_week_view_text_keypress (GnomeCanvasItem *item,
+ guint keyval,
+ guint state,
+ EWeekView *week_view)
+{
+ gboolean retval = FALSE;
+
+ tooltip_destroy (week_view, item);
+
+ if (keyval == GDK_Return) {
+ EText *text = E_TEXT (item);
+ gint new_pos = 0;
+
+ /*
+ * HACK: last charater which should be \n needs to be deleted
+ * here so that GDK_Return was already processed on EText
+ * before E_TEXT_KEYPRESS event is emitted.
+ */
+ if (text->selection_end >= 1)
+ new_pos = text->selection_end - 1;
+
+ text->selection_end = e_text_model_validate_position (text->model, new_pos);
+ e_text_delete_selection (text);
+
+ /* We set the keyboard focus to the EDayView, so the
+ EText item loses it and stops the edit. */
+ gtk_widget_grab_focus (GTK_WIDGET (week_view));
+
+ /* Stop the signal last or we will also stop any
+ other events getting to the EText item. */
+ gtk_signal_emit_stop_by_name (GTK_OBJECT (item),
+ "event");
+ retval = TRUE;
+ } else if (keyval == GDK_Escape) {
+ cancel_editing (week_view);
+ gtk_signal_emit_stop_by_name (GTK_OBJECT (item), "event");
+ /* focus should go to week view when stop editing */
+ gtk_widget_grab_focus (GTK_WIDGET (week_view));
+ retval = TRUE;
+ }
+
+ return retval;
+}
+
+static gboolean
e_week_view_on_text_item_event (GnomeCanvasItem *item,
GdkEvent *gdkevent,
EWeekView *week_view)
@@ -3044,26 +3095,6 @@
#endif
switch (gdkevent->type) {
- case GDK_KEY_PRESS:
- tooltip_destroy (week_view, item);
- if (gdkevent && gdkevent->key.keyval == GDK_Return) {
- /* We set the keyboard focus to the EDayView, so the
- EText item loses it and stops the edit. */
- gtk_widget_grab_focus (GTK_WIDGET (week_view));
-
- /* Stop the signal last or we will also stop any
- other events getting to the EText item. */
- gtk_signal_emit_stop_by_name (GTK_OBJECT (item),
- "event");
- return TRUE;
- } else if (gdkevent->key.keyval == GDK_Escape) {
- cancel_editing (week_view);
- gtk_signal_emit_stop_by_name (GTK_OBJECT (item), "event");
- /* focus should go to week view when stop editing */
- gtk_widget_grab_focus (GTK_WIDGET (week_view));
- return TRUE;
- }
- break;
case GDK_2BUTTON_PRESS:
if (!e_week_view_find_event_from_item (week_view, item,
&event_num, &span_num))