[evolution/clutter-calendar-v2] More fun.
- From: Srinivasa Ragavan <sragavan src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [evolution/clutter-calendar-v2] More fun.
- Date: Mon, 27 Sep 2010 05:47:12 +0000 (UTC)
commit 37c8c33588789429ef563b8fe21ab50ad058177c
Author: Srinivasa Ragavan <sragavan gnome org>
Date: Mon Sep 27 11:13:36 2010 +0530
More fun.
calendar/gui/e-day-view-clutter-event-item.c | 214 +++++++++++++++++++++++---
calendar/gui/e-day-view.c | 194 +++++++++++++++++-------
calendar/gui/e-day-view.h | 19 +++
3 files changed, 350 insertions(+), 77 deletions(-)
---
diff --git a/calendar/gui/e-day-view-clutter-event-item.c b/calendar/gui/e-day-view-clutter-event-item.c
index ffde201..fe96e37 100644
--- a/calendar/gui/e-day-view-clutter-event-item.c
+++ b/calendar/gui/e-day-view-clutter-event-item.c
@@ -63,6 +63,7 @@ struct _EDayViewClutterEventItemPrivate {
EDayView *day_view;
gboolean long_event;
+ gboolean short_event;
int x1;
int y1;
@@ -193,7 +194,31 @@ day_view_clutter_event_item_button_press (EDayViewClutterEventItem *event_item,
{
EDayView *day_view;
ECalendarViewPosition pos;
- EDayViewEvent *event;
+ //EDayViewEvent *event;
+ int day = event_item->priv->day_num;
+
+ GdkEventButton *event;
+ gboolean ret;
+
+ day_view = event_item->priv->day_view;
+
+ if (bevent->button.click_count > 1 )
+ event = gdk_event_new (GDK_2BUTTON_PRESS);
+ else
+ event = gdk_event_new (GDK_BUTTON_PRESS);
+
+ event->time = bevent->button.time;
+ event->button = bevent->button.button;
+ event->x = (gfloat) bevent->button.x;
+ event->y = (gfloat) bevent->button.y;
+
+ if (event_item->priv->day_num == E_DAY_VIEW_LONG_EVENT)
+ ret = e_day_view_on_top_canvas_button_press (day_view->top_canvas, event, day_view);
+ else
+ ret = e_day_view_on_main_canvas_button_press (day_view->main_canvas, event, day_view);
+ gdk_event_free (event);
+
+ return ret;
#if 0
day_view = event_item->priv->day_view;
@@ -275,6 +300,27 @@ day_view_clutter_event_item_button_release (EDayViewClutterEventItem *event_item
{
EDayView *day_view;
+ GdkEventButton *bevent;
+ gboolean ret;
+
+ day_view = event_item->priv->day_view;
+
+ bevent = gdk_event_new (GDK_BUTTON_RELEASE);
+
+ bevent->time = event->button.time;
+ bevent->button = event->button.button;
+ bevent->x = (gfloat) event->button.x;
+ bevent->y = (gfloat) event->button.y;
+
+ ret = e_day_view_on_main_canvas_button_release (day_view->main_canvas, bevent, day_view);
+ gdk_event_free (bevent);
+ day_view->pressed_event_num = -1;
+
+ day_view->editing_event_num = event_item->priv->event_num;
+ day_view->editing_event_day = event_item->priv->day_num;
+ printf("Setting %d %d\n", event_item->priv->event_num, event_item->priv->day_num);
+ return ret;
+
#if 0
day_view = event_item->priv->day_view;
@@ -506,6 +552,11 @@ day_view_clutter_event_item_draw_long (EDayViewClutterEventItem *main_item)
clutter_cairo_texture_set_surface_size (main_item->priv->texture, item_w, item_h);
clutter_cairo_texture_clear (main_item->priv->texture);
+ clutter_actor_set_size (main_item->priv->text_item, item_w, item_h);
+ clutter_actor_set_size (main_item, item_w, item_h);
+
+ if (event->just_added)
+ clutter_actor_set_opacity (main_item, 0);
cr = clutter_cairo_texture_create (main_item->priv->texture);
event_x = item_x;
@@ -843,6 +894,12 @@ day_view_clutter_event_item_draw_long (EDayViewClutterEventItem *main_item)
g_object_unref (comp);
cairo_destroy (cr);
+
+ if (event->just_added) {
+ event->just_added = FALSE;
+ clutter_actor_animate (main_item, CLUTTER_LINEAR,
+ 400, "opacity", 255, NULL);
+ }
}
static void
@@ -926,6 +983,9 @@ day_view_clutter_event_item_draw_normal (EDayViewClutterEventItem *main_item)
return;
clutter_cairo_texture_set_surface_size (main_item->priv->texture, item_w, item_h);
+ clutter_actor_set_size (main_item->priv->text_item, item_w, item_h);
+ clutter_actor_set_size (main_item, item_w, item_h);
+
clutter_cairo_texture_clear (main_item->priv->texture);
cr = clutter_cairo_texture_create (main_item->priv->texture);
@@ -946,6 +1006,9 @@ day_view_clutter_event_item_draw_normal (EDayViewClutterEventItem *main_item)
if (!is_comp_data_valid (event))
return;
+ if (event->just_added)
+ clutter_actor_set_opacity (main_item, 0);
+
/* Fill in the event background. Note that for events in the first
column of the day, we might not want to paint over the vertical bar,
since that is used for multiple events. But then you can't see
@@ -1172,6 +1235,8 @@ day_view_clutter_event_item_draw_normal (EDayViewClutterEventItem *main_item)
if (is_editing)
short_event = TRUE;
+ main_item->priv->short_event = short_event;
+
if (gradient) {
pat = cairo_pattern_create_linear (item_x + E_DAY_VIEW_BAR_WIDTH + 1.75, item_y + 7.75,
item_x + E_DAY_VIEW_BAR_WIDTH + 1.75, item_y + item_h - 7.75);
@@ -1513,14 +1578,15 @@ day_view_clutter_event_item_draw_normal (EDayViewClutterEventItem *main_item)
if (icon_x < item_w) {
PangoLayout *layout;
GdkColor col = e_day_view_get_text_color (day_view, event, day_view);
-
+ int ypad = short_event ? 0 : (E_DAY_VIEW_ICON_HEIGHT + E_DAY_VIEW_ICON_Y_PAD);
+
cairo_save (cr);
gdk_cairo_set_source_color (cr, &col);
icon_x += E_DAY_VIEW_EVENT_X_PAD;
- cairo_rectangle (cr, icon_x , 2, item_w-icon_x, item_h - 2 - (2 *E_DAY_VIEW_EVENT_BORDER_HEIGHT)
- - (2 *E_DAY_VIEW_ICON_Y_PAD));
+ cairo_rectangle (cr, icon_x , 2 + ypad, item_w-icon_x, item_h - 2 - (2 *E_DAY_VIEW_EVENT_BORDER_HEIGHT)
+ - (2 *E_DAY_VIEW_ICON_Y_PAD) - ypad);
cairo_clip (cr);
layout = gtk_widget_create_pango_layout (GTK_WIDGET (day_view), NULL);
pango_layout_set_width (layout, (item_w - icon_x - 1) * PANGO_SCALE);
@@ -1530,7 +1596,7 @@ day_view_clutter_event_item_draw_normal (EDayViewClutterEventItem *main_item)
pango_layout_set_text (layout, main_item->priv->text, -1);
cairo_move_to (cr,
icon_x,
- 2);
+ 2+ypad);
pango_cairo_show_layout (cr, layout);
@@ -1546,6 +1612,12 @@ day_view_clutter_event_item_draw_normal (EDayViewClutterEventItem *main_item)
g_free (text);
g_object_unref (comp);
cairo_destroy (cr);
+
+ if (event->just_added) {
+ event->just_added = FALSE;
+ clutter_actor_animate (main_item, CLUTTER_LINEAR,
+ 400, "opacity", 255, NULL);
+ }
}
@@ -1741,11 +1813,9 @@ static void
handle_activate (ClutterActor *actor,
EDayViewClutterEventItem *item)
{
-#if 0
gtk_widget_grab_focus (item->priv->day_view);
e_day_view_cancel_editing (item->priv->day_view);
e_day_view_on_editing_stopped (item->priv->day_view, NULL, TRUE);
-#endif
}
static gboolean
@@ -1756,7 +1826,7 @@ handle_text_item_event (ClutterActor *actor,
EDayView *day_view = item->priv->day_view;
switch (event->type) {
-#if 0
+
case CLUTTER_BUTTON_PRESS:
if (event->button.button == 3) {
e_day_view_cancel_editing (item->priv->day_view);
@@ -1777,7 +1847,7 @@ handle_text_item_event (ClutterActor *actor,
}
return FALSE;
-#endif
+
default:
break;
}
@@ -1816,9 +1886,11 @@ e_day_view_clutter_event_item_new (EDayView *view, gint day, gint event_num, gbo
item->priv->text_item = clutter_text_new ();
g_signal_connect (item->priv->text_item, "event", G_CALLBACK(handle_text_item_event), item);
clutter_text_set_activatable (item->priv->text_item, TRUE);
- clutter_text_set_single_line_mode (item->priv->text_item, TRUE);
+ clutter_text_set_single_line_mode (item->priv->text_item, long_event ? TRUE: FALSE);
+ if (!long_event)
+ clutter_text_set_line_wrap_mode (item->priv->text_item, PANGO_WRAP_CHAR);
g_signal_connect (item->priv->text_item, "activate", G_CALLBACK(handle_activate), item);
- clutter_text_set_line_wrap (item->priv->text_item, FALSE);
+ clutter_text_set_line_wrap (item->priv->text_item, !long_event ? TRUE: FALSE);
clutter_text_set_editable (item->priv->text_item, TRUE);
clutter_actor_set_reactive (item->priv->text_item, TRUE);
clutter_actor_hide (item->priv->text_item);
@@ -1868,7 +1940,7 @@ struct _anim_data {
};
static void
-rotate_stage2 (ClutterAnimation *amim, struct _anim_data *data)
+rotate_xstage2 (ClutterAnimation *amim, struct _anim_data *data)
{
float height=0, width=0;
ClutterActor *item = data->item;
@@ -1890,7 +1962,7 @@ rotate_stage2 (ClutterAnimation *amim, struct _anim_data *data)
}
static void
-rotate_stage1 (ClutterAnimation *amim, struct _anim_data *data)
+rotate_xstage1 (ClutterAnimation *amim, struct _anim_data *data)
{
data->cb1 (data->data1);
@@ -1904,14 +1976,14 @@ rotate_stage1 (ClutterAnimation *amim, struct _anim_data *data)
clutter_actor_animate (data->item, CLUTTER_EASE_IN_SINE,
200,
"rotation-angle-x", 360.0,
- "signal-after::completed", rotate_stage2, data,
+ "signal-after::completed", rotate_xstage2, data,
NULL);
}
static void
-wvce_animate_rotate (ClutterActor *item,
+wvce_animate_rotate_x (ClutterActor *item,
void (*cb1) (gpointer),
gpointer data1,
void (*cb2) (gpointer),
@@ -1935,7 +2007,79 @@ wvce_animate_rotate (ClutterActor *item,
clutter_actor_animate (item, CLUTTER_EASE_OUT_SINE,
200,
"rotation-angle-x", 90.0,
- "signal-after::completed", rotate_stage1, data,
+ "signal-after::completed", rotate_xstage1, data,
+ NULL);
+}
+
+static void
+rotate_ystage2 (ClutterAnimation *amim, struct _anim_data *data)
+{
+ float height=0, width=0;
+ ClutterActor *item = data->item;
+
+ clutter_actor_get_size (item, &width, &height);
+
+ clutter_actor_set_anchor_point (item, 0.0, 0.0);
+ clutter_actor_move_by (item, -width/2, 0);
+
+ clutter_actor_set_rotation (data->item,
+ CLUTTER_Y_AXIS, /* or CLUTTER_Y_AXIS */
+ 0.0, /* set the rotation to this angle */
+ 0.0,
+ 0.0,
+ 0.0);
+
+ data->cb2 (data->data2);
+
+}
+
+static void
+rotate_ystage1 (ClutterAnimation *amim, struct _anim_data *data)
+{
+ data->cb1 (data->data1);
+
+ clutter_actor_set_rotation (data->item,
+ CLUTTER_Y_AXIS, /* or CLUTTER_Y_AXIS */
+ 270.0, /* set the rotation to this angle */
+ 0.0,
+ 0.0,
+ 0.0);
+
+ clutter_actor_animate (data->item, CLUTTER_EASE_IN_SINE,
+ 200,
+ "rotation-angle-y", 360.0,
+ "signal-after::completed", rotate_ystage2, data,
+ NULL);
+
+
+}
+
+static void
+wvce_animate_rotate_y (ClutterActor *item,
+ void (*cb1) (gpointer),
+ gpointer data1,
+ void (*cb2) (gpointer),
+ gpointer data2)
+
+{
+ float height=0, width=0;
+ struct _anim_data *data= g_new0 (struct _anim_data, 1);
+
+ data->item = item;
+ data->cb1 = cb1;
+ data->data1 = data1;
+ data->cb2 = cb2;
+ data->data2 = data2;
+
+ clutter_actor_get_size (item, &width, &height);
+
+ clutter_actor_set_anchor_point (item, (float)width/2, 0);
+ clutter_actor_move_by (item, width/2, 0);
+
+ clutter_actor_animate (item, CLUTTER_EASE_OUT_SINE,
+ 200,
+ "rotation-angle-y", 90.0,
+ "signal-after::completed", rotate_ystage1, data,
NULL);
}
@@ -1955,12 +2099,30 @@ wvce_set_view_editing_2 (EDayViewClutterEventItem *item)
void
e_day_view_clutter_event_item_switch_editing_mode (EDayViewClutterEventItem *item)
{
- float height=0, width=0;
+ float height=0, width=0,x,y;
+ gint w=0, h=0;
+
+ clutter_cairo_texture_get_surface_size (item->priv->texture, &w, &h);
clutter_text_set_text (item->priv->text_item, item->priv->text);
+ clutter_grab_keyboard (item->priv->text_item);
+ clutter_actor_grab_key_focus (item->priv->text_item);
+// clutter_actor_hide (item->priv->texture);
+// clutter_actor_show (item->priv->text_item);
+
+// clutter_actor_set_size (item->priv->text_item, w, h);
+// clutter_actor_get_position (item->priv->text_item, &x, &y);
+// clutter_actor_set_clip (item->priv->text_item,
+// x,y,
+// (float)w, (float)h);
+
+ if (!item->priv->long_event && !item->priv->short_event)
+ wvce_animate_rotate_y (item, wvce_set_view_editing_1, item,
+ wvce_set_view_editing_2, item);
+ else
+ wvce_animate_rotate_x (item, wvce_set_view_editing_1, item,
+ wvce_set_view_editing_2, item);
- wvce_animate_rotate (item, wvce_set_view_editing_1, item,
- wvce_set_view_editing_2, item);
}
@@ -1975,11 +2137,14 @@ scale_stage2 (ClutterAnimation *amim, struct _anim_data *data)
static void
scale_stage1 (ClutterAnimation *amim, struct _anim_data *data)
{
- data->cb1 (data->data1);
+ EDayViewClutterEventItem *eitem = (EDayViewClutterEventItem *)data->item;
+ gboolean se = eitem->priv->long_event || eitem->priv->short_event;
+ data->cb1 (data->data1);
+
clutter_actor_animate (data->item, CLUTTER_EASE_IN_SINE,
200,
- "scale-x", 1.0,
+ se ? "scale-y" : "scale-x", 1.0,
"signal-after::completed", scale_stage2, data,
NULL);
@@ -1996,7 +2161,8 @@ wvce_animate_scale (ClutterActor *item,
{
float height=0, width=0;
struct _anim_data *data= g_new0 (struct _anim_data, 1);
-
+ EDayViewClutterEventItem *eitem = (EDayViewClutterEventItem *)item;
+ gboolean se = eitem->priv->long_event || eitem->priv->short_event;
data->item = item;
data->cb1 = cb1;
data->data1 = data1;
@@ -2009,7 +2175,7 @@ wvce_animate_scale (ClutterActor *item,
clutter_actor_animate (item, CLUTTER_EASE_OUT_SINE,
200,
- "scale-x", 0.0,
+ se ? "scale-y" : "scale-x", 0.0,
"signal-after::completed", scale_stage1, data,
NULL);
}
@@ -2029,6 +2195,8 @@ wvce_set_view_normal_2 (EDayViewClutterEventItem *item)
void
e_day_view_clutter_event_item_switch_normal_mode (EDayViewClutterEventItem *item)
{
+ //clutter_actor_hide (item->priv->text_item);
+ //clutter_actor_show (item->priv->texture);
wvce_animate_scale (item, wvce_set_view_normal_1, item,
wvce_set_view_normal_2, item);
diff --git a/calendar/gui/e-day-view.c b/calendar/gui/e-day-view.c
index 736e1ca..5a7773a 100644
--- a/calendar/gui/e-day-view.c
+++ b/calendar/gui/e-day-view.c
@@ -184,9 +184,6 @@ static void e_day_view_update_top_scroll (EDayView *day_view, gboolean scroll_to
static void e_day_view_on_canvas_realized (GtkWidget *widget,
EDayView *day_view);
-static gboolean e_day_view_on_top_canvas_button_press (GtkWidget *widget,
- GdkEventButton *event,
- EDayView *day_view);
static gboolean e_day_view_on_top_canvas_button_release (GtkWidget *widget,
GdkEventButton *event,
EDayView *day_view);
@@ -194,13 +191,6 @@ static gboolean e_day_view_on_top_canvas_motion (GtkWidget *widget,
GdkEventMotion *event,
EDayView *day_view);
-static gboolean e_day_view_on_main_canvas_button_press (GtkWidget *widget,
- GdkEventButton *event,
- EDayView *day_view);
-static gboolean e_day_view_on_main_canvas_button_release (GtkWidget *widget,
- GdkEventButton *event,
- EDayView *day_view);
-
static gboolean e_day_view_on_top_canvas_scroll (GtkWidget *widget,
GdkEventScroll *scroll,
EDayView *day_view);
@@ -326,10 +316,6 @@ static void e_day_view_reshape_main_canvas_resize_bars (EDayView *day_view);
static void e_day_view_ensure_events_sorted (EDayView *day_view);
-static void e_day_view_start_editing_event (EDayView *day_view,
- gint day,
- gint event_num,
- GdkEventKey *key_event);
static void e_day_view_stop_editing_event (EDayView *day_view);
static gboolean e_day_view_on_text_item_event (GnomeCanvasItem *item,
GdkEvent *event,
@@ -341,8 +327,6 @@ static void e_day_view_change_event_end_time_up (EDayView *day_view);
static void e_day_view_change_event_end_time_down (EDayView *day_view);
static void e_day_view_on_editing_started (EDayView *day_view,
GnomeCanvasItem *item);
-static void e_day_view_on_editing_stopped (EDayView *day_view,
- GnomeCanvasItem *item);
static time_t e_day_view_convert_grid_position_to_time (EDayView *day_view,
gint col,
@@ -2335,6 +2319,7 @@ e_day_view_remove_event_cb (EDayView *day_view,
gpointer data)
{
EDayViewEvent *event;
+ gboolean delete_from_cal = data != NULL ? TRUE : FALSE;
#if 0
g_print ("In e_day_view_remove_event_cb day:%i event_num:%i\n",
@@ -2373,8 +2358,12 @@ e_day_view_remove_event_cb (EDayView *day_view,
if (event->canvas_item)
gtk_object_destroy (GTK_OBJECT (event->canvas_item));
- if (event->actor)
- clutter_actor_destroy (event->actor);
+ if (event->actor) {
+ if (delete_from_cal||event->marked_for_delete)
+ e_day_view_clutter_event_item_scale_destroy (event->actor);
+ else
+ e_day_view_clutter_event_item_fade_destroy (event->actor);
+ }
event->actor = NULL;
if (is_comp_data_valid (event))
@@ -2478,12 +2467,18 @@ e_day_view_update_event_label (EDayView *day_view,
} else
short_event = FALSE;
+#if HAVE_CLUTTER
+ if (WITHOUT_CLUTTER) {
+#endif
if (!editing_event) {
if (!short_event) {
text = g_strdup_printf (" \n%s", text);
free_text = TRUE;
}
}
+#if HAVE_CLUTTER
+ }
+#endif
#if HAVE_CLUTTER
if (WITHOUT_CLUTTER) {
@@ -3628,7 +3623,7 @@ e_day_view_convert_time_to_position (EDayView *day_view,
return offset * day_view->row_height / day_view->mins_per_row;
}
-static gboolean
+gboolean
e_day_view_on_top_canvas_button_press (GtkWidget *widget,
GdkEventButton *event,
EDayView *day_view)
@@ -3657,24 +3652,33 @@ e_day_view_on_top_canvas_button_press (GtkWidget *widget,
event_x, event_y,
&day, &event_num);
- if (pos == E_CALENDAR_VIEW_POS_OUTSIDE)
+ if (pos == E_CALENDAR_VIEW_POS_OUTSIDE) {
+#if HAVE_CLUTTER
+ if (!WITHOUT_CLUTTER) {
+ e_day_view_cancel_editing (day_view);
+ if (e_day_view_on_editing_stopped (day_view, NULL, FALSE)) {
+ day_view->editing_event_num = -1;
+ day_view->editing_event_day = -1;
+ }
+ gtk_widget_grab_focus (day_view);
+ }
+#endif
return FALSE;
+ }
-#if HAVE_CLUTTER
- if (WITHOUT_CLUTTER) {
-#endif
if (pos != E_CALENDAR_VIEW_POS_NONE)
return e_day_view_on_long_event_button_press (day_view,
event_num,
event, pos,
event_x,
event_y);
-#if HAVE_CLUTTER
- } else {
- if (pos != E_CALENDAR_VIEW_POS_NONE)
- return FALSE;
+#if HAVE_CLUTTER
+ if (!WITHOUT_CLUTTER) {
+ e_day_view_cancel_editing (day_view);
+ e_day_view_on_editing_stopped (day_view, NULL, TRUE);
+ gtk_widget_grab_focus (day_view);
}
-#endif
+#endif
e_day_view_stop_editing_event (day_view);
if (event->button == 1) {
@@ -3767,13 +3771,21 @@ e_day_view_convert_event_coords (EDayView *day_view,
*x_return = event_x;
*y_return = event_y;
+#if HAVE_CLUTTER
+ if (WITHOUT_CLUTTER) {
+#endif
if (event_window != window)
g_warning ("Couldn't find event window\n");
return (event_window == window) ? TRUE : FALSE;
+#if HAVE_CLUTTER
+ } else {
+ return TRUE;
+ }
+#endif
}
-static gboolean
+gboolean
e_day_view_on_main_canvas_button_press (GtkWidget *widget,
GdkEventButton *event,
EDayView *day_view)
@@ -3808,23 +3820,33 @@ e_day_view_on_main_canvas_button_press (GtkWidget *widget,
&day, &row,
&event_num);
- if (pos == E_CALENDAR_VIEW_POS_OUTSIDE)
- return FALSE;
+ if (pos == E_CALENDAR_VIEW_POS_OUTSIDE) {
+#if HAVE_CLUTTER
+ if (!WITHOUT_CLUTTER) {
+ e_day_view_cancel_editing (day_view);
+ if (e_day_view_on_editing_stopped (day_view, NULL, FALSE)) {
+ day_view->editing_event_num = -1;
+ day_view->editing_event_day = -1;
+ }
+ gtk_widget_grab_focus (day_view);
+ }
+#endif
+ return FALSE;
+ }
if (pos != E_CALENDAR_VIEW_POS_NONE) {
-#if HAVE_CLUTTER
- if (WITHOUT_CLUTTER) {
-#endif
return e_day_view_on_event_button_press (day_view, day,
event_num, event, pos,
event_x, event_y);
-#if HAVE_CLUTTER
- } else {
- return FALSE;
- }
-#endif
}
+#if HAVE_CLUTTER
+ if (!WITHOUT_CLUTTER) {
+ e_day_view_cancel_editing (day_view);
+ e_day_view_on_editing_stopped (day_view, NULL, TRUE);
+ gtk_widget_grab_focus (day_view);
+ }
+#endif
e_day_view_stop_editing_event (day_view);
/* Start the selection drag. */
@@ -4037,7 +4059,7 @@ e_day_view_on_long_event_click (EDayView *day_view,
return;
/* Ignore clicks on the EText while editing. */
- if (pos == E_CALENDAR_VIEW_POS_EVENT
+ if (pos == E_CALENDAR_VIEW_POS_EVENT && event->canvas_item
&& E_TEXT (event->canvas_item)->editing) {
GNOME_CANVAS_ITEM_GET_CLASS (event->canvas_item)->event (event->canvas_item, (GdkEvent*)bevent);
return;
@@ -4118,7 +4140,7 @@ e_day_view_on_event_click (EDayView *day_view,
return;
/* Ignore clicks on the EText while editing. */
- if (pos == E_CALENDAR_VIEW_POS_EVENT
+ if (pos == E_CALENDAR_VIEW_POS_EVENT && event->canvas_item
&& E_TEXT (event->canvas_item)->editing) {
GNOME_CANVAS_ITEM_GET_CLASS (event->canvas_item)->event (event->canvas_item, (GdkEvent*)bevent);
return;
@@ -4344,10 +4366,20 @@ e_day_view_on_top_canvas_button_release (GtkWidget *widget,
gdk_pointer_ungrab (event->time);
e_day_view_finish_long_event_resize (day_view);
} else if (day_view->pressed_event_day != -1) {
+ if (day_view->editing_event_num != -1) {
+ e_day_view_cancel_editing (day_view);
+ e_day_view_on_editing_stopped (day_view, NULL, TRUE);
+ }
e_day_view_start_editing_event (day_view,
day_view->pressed_event_day,
day_view->pressed_event_num,
NULL);
+#if HAVE_CLUTTER
+ if (!WITHOUT_CLUTTER) {
+ day_view->editing_event_num = day_view->pressed_event_num;
+ day_view->editing_event_day = day_view->pressed_event_day;
+ }
+#endif
}
day_view->pressed_event_day = -1;
@@ -4355,7 +4387,7 @@ e_day_view_on_top_canvas_button_release (GtkWidget *widget,
return FALSE;
}
-static gboolean
+gboolean
e_day_view_on_main_canvas_button_release (GtkWidget *widget,
GdkEventButton *event,
EDayView *day_view)
@@ -4373,10 +4405,21 @@ e_day_view_on_main_canvas_button_release (GtkWidget *widget,
e_day_view_finish_resize (day_view);
e_day_view_stop_auto_scroll (day_view);
} else if (day_view->pressed_event_day != -1) {
+ if (day_view->editing_event_num != -1) {
+ e_day_view_cancel_editing (day_view);
+ e_day_view_on_editing_stopped (day_view, NULL, TRUE);
+ }
+
e_day_view_start_editing_event (day_view,
day_view->pressed_event_day,
day_view->pressed_event_num,
NULL);
+#if HAVE_CLUTTER
+ if (!WITHOUT_CLUTTER) {
+ day_view->editing_event_num = day_view->pressed_event_num;
+ day_view->editing_event_day = day_view->pressed_event_day;
+ }
+#endif
}
day_view->pressed_event_day = -1;
@@ -5246,6 +5289,8 @@ e_day_view_add_event (ECalComponent *comp,
event.timeout = -1;
event.end = end;
event.canvas_item = NULL;
+ event.marked_for_delete = FALSE;
+ event.just_added = TRUE;
#if HAVE_CLUTTER
event.actor = NULL;
#endif
@@ -5954,6 +5999,13 @@ e_day_view_do_key_press (GtkWidget *widget, GdkEventKey *event)
day_view = E_DAY_VIEW (widget);
keyval = event->keyval;
+#if HAVE_CLUTTER
+ if (!WITHOUT_CLUTTER && day_view->editing_event_num != -1) {
+
+ return TRUE;
+
+ }
+#endif
/* The Escape key aborts a resize operation. */
if (day_view->resize_drag_pos != E_CALENDAR_VIEW_POS_NONE) {
if (keyval == GDK_Escape) {
@@ -6859,7 +6911,7 @@ e_day_view_ensure_rows_visible (EDayView *day_view,
gtk_adjustment_set_value (adjustment, value);
}
-static void
+void
e_day_view_start_editing_event (EDayView *day_view,
gint day,
gint event_num,
@@ -6899,6 +6951,14 @@ e_day_view_start_editing_event (EDayView *day_view,
if (!e_cal_is_read_only (event->comp_data->client, &read_only, NULL) || read_only)
return;
+#if HAVE_CLUTTER
+ if (!WITHOUT_CLUTTER) {
+ gtk_widget_grab_focus (day_view->main_canvas_embed);
+ e_day_view_clutter_event_item_switch_editing_mode (event->actor);
+ day_view->editing_event_num = event_num;
+ day_view->editing_event_day = day;
+ }
+#endif
/* If the event is not shown, don't try to edit it. */
if (!event->canvas_item)
return;
@@ -6985,14 +7045,27 @@ cancel_editing (EDayView *day_view)
/* Reset the text to what was in the component */
summary = icalcomponent_get_summary (event->comp_data->icalcomp);
+#if HAVE_CLUTTER
+ if (WITHOUT_CLUTTER) {
+#endif
g_object_set (G_OBJECT (event->canvas_item),
"text", summary ? summary : "",
NULL);
-
+#if HAVE_CLUTTER
+ } else {
+ e_day_view_clutter_event_item_switch_normal_mode (event->actor);
+ }
+#endif
/* Stop editing */
e_day_view_stop_editing_event (day_view);
}
+void
+e_day_view_cancel_editing (EDayView *day_view)
+{
+ cancel_editing (day_view);
+}
+
static EDayViewEvent *
tooltip_get_view_event (EDayView *day_view, gint day, gint event_num)
{
@@ -7100,7 +7173,7 @@ e_day_view_on_text_item_event (GnomeCanvasItem *item,
if (event->focus_change.in)
e_day_view_on_editing_started (day_view, item);
else
- e_day_view_on_editing_stopped (day_view, item);
+ e_day_view_on_editing_stopped (day_view, item, TRUE);
return FALSE;
case GDK_ENTER_NOTIFY:
@@ -7513,9 +7586,10 @@ e_day_view_on_editing_started (EDayView *day_view,
g_signal_emit_by_name (day_view, "selection_changed");
}
-static void
+gboolean
e_day_view_on_editing_stopped (EDayView *day_view,
- GnomeCanvasItem *item)
+ GnomeCanvasItem *item,
+ gboolean create)
{
gint day, event_num;
EDayViewEvent *event;
@@ -7524,6 +7598,7 @@ e_day_view_on_editing_stopped (EDayView *day_view,
ECalComponent *comp;
ECal *client;
gboolean on_server;
+ gboolean ret = TRUE;
/* Note: the item we are passed here isn't reliable, so we just stop
the edit of whatever item was being edited. We also receive this
@@ -7538,17 +7613,17 @@ e_day_view_on_editing_stopped (EDayView *day_view,
/* If no item is being edited, just return. */
if (day == -1)
- return;
+ return TRUE;
if (day == E_DAY_VIEW_LONG_EVENT) {
if (!is_array_index_in_bounds (day_view->long_events, event_num))
- return;
+ return TRUE;
event = &g_array_index (day_view->long_events, EDayViewEvent,
event_num);
} else {
if (!is_array_index_in_bounds (day_view->events[day], event_num))
- return;
+ return TRUE;
event = &g_array_index (day_view->events[day], EDayViewEvent,
event_num);
@@ -7556,7 +7631,7 @@ e_day_view_on_editing_stopped (EDayView *day_view,
}
if (!is_comp_data_valid (event))
- return;
+ return TRUE;
/* Reset the edit fields. */
day_view->editing_event_day = -1;
@@ -7565,11 +7640,20 @@ e_day_view_on_editing_stopped (EDayView *day_view,
day_view->resize_bars_event_day = -1;
day_view->resize_bars_event_num = -1;
+#if HAVE_CLUTTER
+ if (WITHOUT_CLUTTER) {
+#endif
g_object_set (event->canvas_item, "handle_popup", FALSE, NULL);
g_object_get (G_OBJECT (event->canvas_item),
"text", &text,
NULL);
- g_return_if_fail (text != NULL);
+#if HAVE_CLUTTER
+ } else {
+ e_day_view_clutter_event_item_switch_normal_mode (event->actor);
+ text = g_strdup(e_day_view_clutter_event_item_get_edit_text (event->actor));
+ }
+#endif
+ g_return_val_if_fail (text != NULL, TRUE);
comp = e_cal_component_new ();
e_cal_component_set_icalcomponent (comp, icalcomponent_new_clone (event->comp_data->icalcomp));
@@ -7583,7 +7667,7 @@ e_day_view_on_editing_stopped (EDayView *day_view,
e_cal_component_get_uid (comp, &uid);
e_day_view_foreach_event_with_uid (day_view, uid,
- e_day_view_remove_event_cb, NULL);
+ e_day_view_remove_event_cb, TRUE);
e_day_view_check_layout (day_view);
#if HAVE_CLUTTER
if (WITHOUT_CLUTTER) {
@@ -7596,6 +7680,7 @@ e_day_view_on_editing_stopped (EDayView *day_view,
e_day_view_clutter_top_item_redraw ((EDayViewClutterTopItem *)day_view->top_canvas_actor);
}
#endif
+ ret = FALSE;
goto out;
}
@@ -7623,7 +7708,7 @@ e_day_view_on_editing_stopped (EDayView *day_view,
E_CALENDAR_VIEW (day_view));
/* we remove the object since we either got the update from the server or failed */
- e_day_view_remove_event_cb (day_view, day, event_num, NULL);
+ e_day_view_remove_event_cb (day_view, day, event_num, TRUE);
} else {
CalObjModType mod = CALOBJ_MOD_ALL;
GtkWindow *toplevel;
@@ -7707,6 +7792,7 @@ e_day_view_on_editing_stopped (EDayView *day_view,
g_free (text);
g_signal_emit_by_name (day_view, "selection_changed");
+ return ret;
}
/* FIXME: It is possible that we may produce an invalid time due to daylight
diff --git a/calendar/gui/e-day-view.h b/calendar/gui/e-day-view.h
index f942172..eb74bfd 100644
--- a/calendar/gui/e-day-view.h
+++ b/calendar/gui/e-day-view.h
@@ -652,6 +652,25 @@ void e_day_view_ensure_rows_visible (EDayView *day_view,
GdkColor e_day_view_get_text_color (EDayView *day_view,
EDayViewEvent *event,
GtkWidget *widget);
+void e_day_view_cancel_editing (EDayView *day_view);
+gboolean e_day_view_on_editing_stopped (EDayView *day_view,
+ GnomeCanvasItem *item,
+ gboolean create);
+void e_day_view_start_editing_event (EDayView *day_view,
+ gint day,
+ gint event_num,
+ GdkEventKey *key_event);
+gboolean
+e_day_view_on_main_canvas_button_press (GtkWidget *widget,
+ GdkEventButton *event,
+ EDayView *day_view);
+gboolean
+e_day_view_on_main_canvas_button_release (GtkWidget *widget,
+ GdkEventButton *event,
+ EDayView *day_view);
+gboolean e_day_view_on_top_canvas_button_press (GtkWidget *widget,
+ GdkEventButton *event,
+ EDayView *day_view);
G_END_DECLS
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]