[evolution/gnome-3-16] Bug 675671 - Update event numbers after event deletion
- From: Milan Crha <mcrha src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [evolution/gnome-3-16] Bug 675671 - Update event numbers after event deletion
- Date: Thu, 28 May 2015 14:04:06 +0000 (UTC)
commit 65d8891d34a752f46b3fa53217dcdae3b4629e2b
Author: Milan Crha <mcrha redhat com>
Date: Thu May 28 16:03:34 2015 +0200
Bug 675671 - Update event numbers after event deletion
calendar/gui/e-day-view.c | 90 +++++++++++++++++++++++++++++++++++++++----
calendar/gui/e-week-view.c | 21 ++++++++--
2 files changed, 98 insertions(+), 13 deletions(-)
---
diff --git a/calendar/gui/e-day-view.c b/calendar/gui/e-day-view.c
index bfbccdb..a0294d5 100644
--- a/calendar/gui/e-day-view.c
+++ b/calendar/gui/e-day-view.c
@@ -158,6 +158,8 @@ struct _EDayViewPrivate {
gboolean marcus_bains_show_line;
gchar *marcus_bains_day_view_color;
gchar *marcus_bains_time_bar_color;
+
+ GdkDragContext *drag_context;
};
typedef struct {
@@ -368,6 +370,7 @@ static void e_day_view_start_editing_event (EDayView *day_view,
gint event_num,
GdkEventKey *key_event);
static void e_day_view_stop_editing_event (EDayView *day_view);
+static void cancel_editing (EDayView *day_view);
static gboolean e_day_view_on_text_item_event (GnomeCanvasItem *item,
GdkEvent *event,
EDayView *day_view);
@@ -1213,6 +1216,7 @@ day_view_dispose (GObject *object)
g_clear_object (&day_view->main_canvas);
g_clear_object (&day_view->time_canvas);
g_clear_object (&day_view->priv->model);
+ g_clear_object (&day_view->priv->drag_context);
g_free (day_view->priv->marcus_bains_day_view_color);
day_view->priv->marcus_bains_day_view_color = NULL;
@@ -2045,15 +2049,14 @@ e_day_view_init (EDayView *day_view)
day_view->selection_is_being_dragged = FALSE;
day_view->selection_drag_pos = E_DAY_VIEW_DRAG_END;
day_view->selection_in_top_canvas = FALSE;
+ day_view->drag_last_day = -1;
day_view->drag_event_day = -1;
day_view->drag_event_num = -1;
day_view->resize_drag_pos = E_CALENDAR_VIEW_POS_NONE;
+ day_view->priv->drag_context = NULL;
day_view->pressed_event_day = -1;
- day_view->drag_event_day = -1;
- day_view->drag_last_day = -1;
-
day_view->auto_scroll_timeout_id = 0;
day_view->large_font_desc = NULL;
@@ -3070,14 +3073,19 @@ e_day_view_remove_event_cb (EDayView *day_view,
/* If we were editing this event, set editing_event_day to -1 so
* on_editing_stopped doesn't try to update the event. */
if (day_view->editing_event_num == event_num && day_view->editing_event_day == day) {
+ cancel_editing (day_view);
day_view->editing_event_num = -1;
day_view->editing_event_day = -1;
g_object_notify (G_OBJECT (day_view), "is-editing");
+ } else if (day_view->editing_event_num > event_num && day_view->editing_event_day == day) {
+ day_view->editing_event_num--;
}
if (day_view->popup_event_num == event_num && day_view->popup_event_day == day) {
day_view->popup_event_num = -1;
day_view->popup_event_day = -1;
+ } else if (day_view->popup_event_num > event_num && day_view->popup_event_day == day) {
+ day_view->popup_event_num--;
}
if (event->timeout > 0) {
@@ -3085,6 +3093,45 @@ e_day_view_remove_event_cb (EDayView *day_view,
event->timeout = -1;
}
+ if (day_view->resize_bars_event_num >= event_num && day_view->resize_bars_event_day == day) {
+ if (day_view->resize_bars_event_num == event_num) {
+ day_view->resize_bars_event_num = -1;
+ day_view->resize_bars_event_day = -1;
+ } else {
+ day_view->resize_bars_event_num--;
+ }
+ }
+
+ if (day_view->resize_event_num >= event_num && day_view->resize_event_day == day) {
+ if (day_view->resize_event_num == event_num) {
+ e_day_view_abort_resize (day_view);
+ day_view->resize_event_num = -1;
+ day_view->resize_event_day = -1;
+ } else {
+ day_view->resize_event_num--;
+ }
+ }
+
+ if (day_view->pressed_event_num >= event_num && day_view->pressed_event_day == day) {
+ if (day_view->pressed_event_num == event_num) {
+ day_view->pressed_event_num = -1;
+ day_view->pressed_event_day = -1;
+ } else {
+ day_view->pressed_event_num--;
+ }
+ }
+
+ if (day_view->drag_event_num >= event_num && day_view->drag_event_day == day) {
+ if (day_view->drag_event_num == event_num) {
+ day_view->drag_event_num = -1;
+ day_view->drag_event_day = -1;
+ if (day_view->priv->drag_context)
+ gtk_drag_cancel (day_view->priv->drag_context);
+ } else {
+ day_view->drag_event_num--;
+ }
+ }
+
if (event->canvas_item)
g_object_run_dispose (G_OBJECT (event->canvas_item));
@@ -3101,6 +3148,7 @@ e_day_view_remove_event_cb (EDayView *day_view,
day_view->need_layout[day] = TRUE;
gtk_widget_grab_focus (GTK_WIDGET (day_view->main_canvas));
}
+
return TRUE;
}
@@ -4820,11 +4868,15 @@ e_day_view_on_top_canvas_motion (GtkWidget *widget,
target_list = gtk_target_list_new (
target_table, G_N_ELEMENTS (target_table));
e_target_list_add_calendar_targets (target_list, 0);
- gtk_drag_begin (
+ g_clear_object (&day_view->priv->drag_context);
+ day_view->priv->drag_context = gtk_drag_begin (
widget, target_list,
GDK_ACTION_COPY | GDK_ACTION_MOVE,
1, (GdkEvent *) mevent);
gtk_target_list_unref (target_list);
+
+ if (day_view->priv->drag_context)
+ g_object_ref (day_view->priv->drag_context);
}
} else {
cursor = day_view->normal_cursor;
@@ -4929,11 +4981,15 @@ e_day_view_on_main_canvas_motion (GtkWidget *widget,
target_list = gtk_target_list_new (
target_table, G_N_ELEMENTS (target_table));
e_target_list_add_calendar_targets (target_list, 0);
- gtk_drag_begin (
+ g_clear_object (&day_view->priv->drag_context);
+ day_view->priv->drag_context = gtk_drag_begin (
widget, target_list,
GDK_ACTION_COPY | GDK_ACTION_MOVE,
1, (GdkEvent *) mevent);
gtk_target_list_unref (target_list);
+
+ if (day_view->priv->drag_context)
+ g_object_ref (day_view->priv->drag_context);
}
} else {
cursor = day_view->normal_cursor;
@@ -5449,6 +5505,8 @@ e_day_view_free_events (EDayView *day_view)
day_view->editing_event_num = -1;
day_view->popup_event_num = -1;
+ g_clear_object (&day_view->priv->drag_context);
+
e_day_view_free_event_array (day_view, day_view->long_events);
for (day = 0; day < E_DAY_VIEW_MAX_DAYS; day++)
@@ -5795,6 +5853,8 @@ e_day_view_reshape_long_event (EDayView *day_view,
g_signal_emit_by_name (day_view, "event_added", event);
e_day_view_update_long_event_label (day_view, event_num);
+ } else if (GPOINTER_TO_INT (g_object_get_data (G_OBJECT (event->canvas_item), "event-num")) !=
event_num) {
+ g_object_set_data (G_OBJECT (event->canvas_item), "event-num", GINT_TO_POINTER (event_num));
}
/* Calculate its position. We first calculate the ideal position which
@@ -5979,6 +6039,8 @@ e_day_view_reshape_day_event (EDayView *day_view,
g_signal_emit_by_name (day_view, "event_added", event);
e_day_view_update_event_label (day_view, day, event_num);
+ } else if (GPOINTER_TO_INT (g_object_get_data (G_OBJECT (event->canvas_item), "event-num"))
!= event_num) {
+ g_object_set_data (G_OBJECT (event->canvas_item), "event-num", GINT_TO_POINTER
(event_num));
}
item_w = MAX (item_w, 0);
@@ -7082,9 +7144,12 @@ tooltip_destroy (EDayView *day_view,
if (item) {
EDayViewEvent *pevent;
- gint event_num = GPOINTER_TO_INT (g_object_get_data ((GObject *) item, "event-num"));
- gint day = GPOINTER_TO_INT (g_object_get_data ((GObject *) item, "event-day"));
+ gint event_num, day;
+ e_day_view_check_layout (day_view);
+
+ event_num = GPOINTER_TO_INT (g_object_get_data ((GObject *) item, "event-num"));
+ day = GPOINTER_TO_INT (g_object_get_data ((GObject *) item, "event-day"));
pevent = tooltip_get_view_event (day_view, day, event_num);
if (pevent) {
pevent->tooltip = NULL;
@@ -7254,8 +7319,12 @@ e_day_view_on_text_item_event (GnomeCanvasItem *item,
case GDK_MOTION_NOTIFY:
{
EDayViewEvent *pevent;
- gint event_num = GPOINTER_TO_INT (g_object_get_data ((GObject *) item, "event-num"));
- gint day = GPOINTER_TO_INT (g_object_get_data ((GObject *) item, "event-day"));
+ gint event_num, day;
+
+ e_day_view_check_layout (day_view);
+
+ event_num = GPOINTER_TO_INT (g_object_get_data ((GObject *) item, "event-num"));
+ day = GPOINTER_TO_INT (g_object_get_data ((GObject *) item, "event-day"));
pevent = tooltip_get_view_event (day_view, day, event_num);
if (!pevent)
@@ -8732,6 +8801,7 @@ e_day_view_on_drag_end (GtkWidget *widget,
day_view->drag_event_day = -1;
day_view->drag_event_num = -1;
+ g_clear_object (&day_view->priv->drag_context);
}
static void
@@ -8975,6 +9045,7 @@ e_day_view_on_top_canvas_drag_data_received (GtkWidget *widget,
/* Reset this since it will be invalid. */
day_view->drag_event_day = -1;
+ g_clear_object (&day_view->priv->drag_context);
/* Show the text item again, just in case it hasn't
* moved. If we don't do this it may not appear. */
@@ -9192,6 +9263,7 @@ e_day_view_on_main_canvas_drag_data_received (GtkWidget *widget,
/* Reset this since it will be invalid. */
day_view->drag_event_day = -1;
+ g_clear_object (&day_view->priv->drag_context);
/* Show the text item again, just in case it hasn't
* moved. If we don't do this it may not appear. */
diff --git a/calendar/gui/e-week-view.c b/calendar/gui/e-week-view.c
index c0723b0..a9432a5 100644
--- a/calendar/gui/e-week-view.c
+++ b/calendar/gui/e-week-view.c
@@ -956,6 +956,8 @@ week_view_update_style_settings (EWeekView *week_view)
EWeekViewEventSpan *span;
e_week_view_set_colors (week_view);
+ e_week_view_check_layout (week_view);
+
if (week_view->spans) {
for (span_num = 0; span_num < week_view->spans->len; span_num++) {
span = &g_array_index (week_view->spans, EWeekViewEventSpan, span_num);
@@ -3372,10 +3374,14 @@ static void
tooltip_destroy (EWeekView *week_view,
GnomeCanvasItem *item)
{
- gint event_num = GPOINTER_TO_INT (g_object_get_data (G_OBJECT (item), "event-num"));
+ gint event_num;
EWeekViewEvent *pevent;
guint timeout;
+ e_week_view_check_layout (week_view);
+
+ event_num = GPOINTER_TO_INT (g_object_get_data (G_OBJECT (item), "event-num"));
+
timeout = GPOINTER_TO_UINT (g_object_get_data (G_OBJECT (week_view), "tooltip-timeout"));
if (timeout) {
g_source_remove (timeout);
@@ -3420,9 +3426,12 @@ tooltip_event_cb (GnomeCanvasItem *item,
GdkEvent *event,
EWeekView *view)
{
- gint event_num = GPOINTER_TO_INT (g_object_get_data (G_OBJECT (item), "event-num"));
+ gint event_num;
EWeekViewEvent *pevent;
+ e_week_view_check_layout (view);
+
+ event_num = GPOINTER_TO_INT (g_object_get_data (G_OBJECT (item), "event-num"));
pevent = tooltip_get_view_event (view, -1, event_num);
switch (event->type) {
@@ -3640,7 +3649,6 @@ e_week_view_reshape_event_span (EWeekView *week_view,
&& e_cal_util_component_has_attendee (event->comp_data->icalcomp)) {
set_text_as_bold (event, span, registry);
}
- g_object_set_data (G_OBJECT (span->text_item), "event-num", GINT_TO_POINTER (event_num));
g_signal_connect (
span->text_item, "event",
G_CALLBACK (e_week_view_on_text_item_event), week_view);
@@ -3650,6 +3658,8 @@ e_week_view_reshape_event_span (EWeekView *week_view,
}
+ g_object_set_data (G_OBJECT (span->text_item), "event-num", GINT_TO_POINTER (event_num));
+
/* Calculate the position of the text item.
* For events < 1 day it starts after the times & icons and ends at the
* right edge of the span.
@@ -3949,13 +3959,16 @@ e_week_view_on_text_item_event (GnomeCanvasItem *item,
{
EWeekViewEvent *event;
gint event_num, span_num;
- gint nevent = GPOINTER_TO_INT (g_object_get_data (G_OBJECT (item), "event-num"));
+ gint nevent;
EWeekViewEvent *pevent;
guint event_button = 0;
guint event_keyval = 0;
gdouble event_x_root = 0;
gdouble event_y_root = 0;
+ e_week_view_check_layout (week_view);
+
+ nevent = GPOINTER_TO_INT (g_object_get_data (G_OBJECT (item), "event-num"));
pevent = tooltip_get_view_event (week_view, -1, nevent);
switch (gdk_event->type) {
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]