aboutsummaryrefslogtreecommitdiffstats
path: root/calendar/gui/e-day-view.c
diff options
context:
space:
mode:
authorRodrigo Moya <rodrigo@src.gnome.org>2003-08-20 18:17:18 +0800
committerRodrigo Moya <rodrigo@src.gnome.org>2003-08-20 18:17:18 +0800
commit4ad72d24ee36553c85c1bbf21b22c46f77c2ac82 (patch)
tree048f40b08f5a0e42df0f2a5567158174b228bdea /calendar/gui/e-day-view.c
parentba861603f446ca0fd9b4cf72f0f8357c306ce953 (diff)
downloadgsoc2013-evolution-4ad72d24ee36553c85c1bbf21b22c46f77c2ac82.tar.gz
gsoc2013-evolution-4ad72d24ee36553c85c1bbf21b22c46f77c2ac82.tar.zst
gsoc2013-evolution-4ad72d24ee36553c85c1bbf21b22c46f77c2ac82.zip
Merged from calendar-views-with-model branch
svn path=/trunk/; revision=22308
Diffstat (limited to 'calendar/gui/e-day-view.c')
-rw-r--r--calendar/gui/e-day-view.c701
1 files changed, 280 insertions, 421 deletions
diff --git a/calendar/gui/e-day-view.c b/calendar/gui/e-day-view.c
index 307a0324bb..1511709881 100644
--- a/calendar/gui/e-day-view.c
+++ b/calendar/gui/e-day-view.c
@@ -107,6 +107,11 @@
we get from the server. */
#define E_DAY_VIEW_LAYOUT_TIMEOUT 100
+typedef struct {
+ EDayView *day_view;
+ ECalModelComponent *comp_data;
+} AddEventData;
+
/* Drag and Drop stuff. */
enum {
TARGET_CALENDAR_EVENT,
@@ -153,10 +158,10 @@ static gboolean e_day_view_do_key_press (GtkWidget *widget,
GdkEventKey *event);
static gboolean e_day_view_popup_menu (GtkWidget *widget);
static GList *e_day_view_get_selected_events (ECalView *cal_view);
-static void e_day_view_get_selected_time_range (EDayView *day_view, time_t *start_time, time_t *end_time);
-static void e_day_view_set_selected_time_range (EDayView *day_view, time_t start_time, time_t end_time);
-static gboolean e_day_view_get_visible_time_range (EDayView *day_view, time_t *start_time, time_t *end_time);
-static void e_day_view_update_query (EDayView *day_view);
+static void e_day_view_get_selected_time_range (ECalView *cal_view, time_t *start_time, time_t *end_time);
+static void e_day_view_set_selected_time_range (ECalView *cal_view, time_t start_time, time_t end_time);
+static gboolean e_day_view_get_visible_time_range (ECalView *cal_view, time_t *start_time, time_t *end_time);
+static void e_day_view_update_query (ECalView *cal_view);
static void e_day_view_goto_start_of_work_day (EDayView *day_view);
static void e_day_view_goto_end_of_work_day (EDayView *day_view);
static void e_day_view_change_duration_to_start_of_work_day (EDayView *day_view);
@@ -498,7 +503,7 @@ timezone_changed_cb (ECalView *cal_view, icaltimezone *old_zone,
lower = icaltime_as_timet_with_zone (tt, new_zone);
e_day_view_recalc_day_starts (day_view, lower);
- e_day_view_update_query (day_view);
+ e_day_view_update_query ((ECalView *) day_view);
}
static void
@@ -861,11 +866,6 @@ e_day_view_destroy (GtkObject *object)
e_day_view_stop_auto_scroll (day_view);
- if (e_cal_view_get_cal_client (E_CAL_VIEW (day_view))) {
- g_signal_handlers_disconnect_matched (e_cal_view_get_cal_client (E_CAL_VIEW (day_view)),
- G_SIGNAL_MATCH_DATA, 0, 0, NULL, NULL, day_view);
- }
-
if (day_view->query) {
g_signal_handlers_disconnect_matched (day_view->query, G_SIGNAL_MATCH_DATA,
0, 0, NULL, NULL, day_view);
@@ -1426,176 +1426,6 @@ e_day_view_focus_out (GtkWidget *widget, GdkEventFocus *event)
return FALSE;
}
-/* Callback used when a component is updated in the live query */
-static void
-query_obj_updated_cb (CalQuery *query, const char *uid,
- gboolean query_in_progress, int n_scanned, int total,
- gpointer data)
-{
- EDayView *day_view;
- EDayViewEvent *event;
- CalComponent *comp;
- icalcomponent *icalcomp;
- CalClientGetStatus status;
- gint day, event_num;
-
- day_view = E_DAY_VIEW (data);
-
- /* If our time hasn't been set yet, just return. */
- if (day_view->lower == 0 && day_view->upper == 0)
- return;
-
- /* Get the event from the server. */
- status = cal_client_get_object (e_cal_view_get_cal_client (E_CAL_VIEW (day_view)), uid, &icalcomp);
-
- switch (status) {
- case CAL_CLIENT_GET_SUCCESS:
- comp = cal_component_new ();
- if (!cal_component_set_icalcomponent (comp, icalcomp)) {
- g_object_unref (comp);
- icalcomponent_free (icalcomp);
-
- g_message ("query_obj_updated_cb(): Invalid object %s", uid);
- return;
- }
- break;
-
- case CAL_CLIENT_GET_SYNTAX_ERROR:
- g_message ("query_obj_updated_cb(): Syntax error when getting object `%s'", uid);
- return;
-
- case CAL_CLIENT_GET_NOT_FOUND:
- /* The object is no longer in the server, so do nothing */
- return;
-
- default:
- g_assert_not_reached ();
- return;
- }
-
- /* If the event already exists and the dates didn't change, we can
- update the event fairly easily without changing the events arrays
- or computing a new layout. */
- if (e_day_view_find_event_from_uid (day_view, uid, &day, &event_num)) {
- if (day == E_DAY_VIEW_LONG_EVENT)
- event = &g_array_index (day_view->long_events,
- EDayViewEvent, event_num);
- else
- event = &g_array_index (day_view->events[day],
- EDayViewEvent, event_num);
-
- if (!cal_component_has_recurrences (comp)
- && !cal_component_has_recurrences (event->comp)
- && cal_component_event_dates_match (comp, event->comp)) {
-#if 0
- g_print ("updated object's dates unchanged\n");
-#endif
- e_day_view_foreach_event_with_uid (day_view, uid, e_day_view_update_event_cb, comp);
- g_object_unref (comp);
- gtk_widget_queue_draw (day_view->top_canvas);
- gtk_widget_queue_draw (day_view->main_canvas);
- return;
- }
-
- /* The dates have changed, so we need to remove the
- old occurrrences before adding the new ones. */
-#if 0
- g_print ("dates changed - removing occurrences\n");
-#endif
- e_day_view_foreach_event_with_uid (day_view, uid,
- e_day_view_remove_event_cb,
- NULL);
- }
-
- /* Add the occurrences of the event. */
- cal_recur_generate_instances (comp, day_view->lower,
- day_view->upper,
- e_day_view_add_event, day_view,
- cal_client_resolve_tzid_cb,
- e_cal_view_get_cal_client (E_CAL_VIEW (day_view)),
- e_cal_view_get_timezone (E_CAL_VIEW (day_view)));
- g_object_unref (comp);
-
- e_day_view_queue_layout (day_view);
-}
-
-/* Callback used when a component is removed from the live query */
-static void
-query_obj_removed_cb (CalQuery *query, const char *uid, gpointer data)
-{
- EDayView *day_view;
-
- day_view = E_DAY_VIEW (data);
-
- e_day_view_foreach_event_with_uid (day_view, uid,
- e_day_view_remove_event_cb, NULL);
-
- e_day_view_check_layout (day_view);
- gtk_widget_queue_draw (day_view->top_canvas);
- gtk_widget_queue_draw (day_view->main_canvas);
-}
-
-/* Callback used when a query ends */
-static void
-query_query_done_cb (CalQuery *query, CalQueryDoneStatus status, const char *error_str, gpointer data)
-{
- EDayView *day_view;
-
- day_view = E_DAY_VIEW (data);
-
- /* FIXME */
-
- e_cal_view_set_status_message (E_CAL_VIEW (day_view), NULL);
-
- if (status != CAL_QUERY_DONE_SUCCESS)
- fprintf (stderr, "query done: %s\n", error_str);
-}
-
-/* Callback used when an evaluation error occurs when running a query */
-static void
-query_eval_error_cb (CalQuery *query, const char *error_str, gpointer data)
-{
- EDayView *day_view;
-
- day_view = E_DAY_VIEW (data);
-
- /* FIXME */
-
- e_cal_view_set_status_message (E_CAL_VIEW (day_view), NULL);
-
- fprintf (stderr, "eval error: %s\n", error_str);
-}
-
-
-/* Builds a complete query sexp for the day view by adding the predicates to
- * filter only for VEVENTS that fit in the day view's time range.
- */
-static char *
-adjust_query_sexp (EDayView *day_view, const char *sexp)
-{
- char *start, *end;
- char *new_sexp;
-
- /* If the dates have not been set yet, we just want an empty query. */
- if (day_view->lower == 0 || day_view->upper == 0)
- return NULL;
-
- start = isodate_from_time_t (day_view->lower);
- end = isodate_from_time_t (day_view->upper);
-
- new_sexp = g_strdup_printf ("(and (= (get-vtype) \"VEVENT\")"
- " (occur-in-time-range? (make-time \"%s\")"
- " (make-time \"%s\"))"
- " %s)",
- start, end,
- sexp);
-
- g_free (start);
- g_free (end);
-
- return new_sexp;
-}
-
/**
* e_day_view_set_default_category:
* @day_view: A day view.
@@ -1623,9 +1453,9 @@ e_day_view_update_event_cb (EDayView *day_view,
gpointer data)
{
EDayViewEvent *event;
- CalComponent *comp;
+ ECalModelComponent *comp_data;
- comp = data;
+ comp_data = data;
#if 0
g_print ("In e_day_view_update_event_cb day:%i event_num:%i\n",
day, event_num);
@@ -1638,9 +1468,10 @@ e_day_view_update_event_cb (EDayView *day_view,
event_num);
}
- g_object_unref (event->comp);
- event->comp = comp;
- g_object_ref (comp);
+ if (event->allocated_comp_data)
+ e_cal_model_free_component_data (event->comp_data);
+ event->comp_data = comp_data;
+ event->allocated_comp_data = FALSE;
if (day == E_DAY_VIEW_LONG_EVENT) {
e_day_view_update_long_event_label (day_view, event_num);
@@ -1715,10 +1546,9 @@ e_day_view_foreach_event_with_uid (EDayView *day_view,
event = &g_array_index (day_view->events[day],
EDayViewEvent, event_num);
- cal_component_get_uid (event->comp, &u);
+ u = icalcomponent_get_uid (event->comp_data->icalcomp);
if (uid && !strcmp (uid, u)) {
- if (!(*callback) (day_view, day, event_num,
- data))
+ if (!(*callback) (day_view, day, event_num, data))
return;
}
}
@@ -1730,10 +1560,9 @@ e_day_view_foreach_event_with_uid (EDayView *day_view,
event = &g_array_index (day_view->long_events,
EDayViewEvent, event_num);
- cal_component_get_uid (event->comp, &u);
+ u = icalcomponent_get_uid (event->comp_data->icalcomp);
if (u && !strcmp (uid, u)) {
- if (!(*callback) (day_view, E_DAY_VIEW_LONG_EVENT,
- event_num, data))
+ if (!(*callback) (day_view, E_DAY_VIEW_LONG_EVENT, event_num, data))
return;
}
}
@@ -1768,7 +1597,11 @@ e_day_view_remove_event_cb (EDayView *day_view,
if (event->canvas_item)
gtk_object_destroy (GTK_OBJECT (event->canvas_item));
- g_object_unref (event->comp);
+
+ if (event->allocated_comp_data) {
+ e_cal_model_free_component_data (event->comp_data);
+ event->allocated_comp_data = FALSE;
+ }
if (day == E_DAY_VIEW_LONG_EVENT) {
g_array_remove_index (day_view->long_events, event_num);
@@ -1794,17 +1627,16 @@ e_day_view_update_event_label (EDayView *day_view,
gint offset;
gint start_hour, start_display_hour, start_minute, start_suffix_width;
gint end_hour, end_display_hour, end_minute, end_suffix_width;
- CalComponentText summary;
+ const gchar *summary;
- event = &g_array_index (day_view->events[day], EDayViewEvent,
- event_num);
+ event = &g_array_index (day_view->events[day], EDayViewEvent, event_num);
/* If the event isn't visible just return. */
if (!event->canvas_item)
return;
- cal_component_get_summary (event->comp, &summary);
- text = summary.value ? (char*) summary.value : "";
+ summary = icalcomponent_get_summary (event->comp_data->icalcomp);
+ text = summary ? (char *) summary : "";
if (day_view->editing_event_day == day
&& day_view->editing_event_num == event_num)
@@ -1886,7 +1718,7 @@ e_day_view_update_long_event_label (EDayView *day_view,
gint event_num)
{
EDayViewEvent *event;
- CalComponentText summary;
+ const gchar *summary;
event = &g_array_index (day_view->long_events, EDayViewEvent,
event_num);
@@ -1895,9 +1727,9 @@ e_day_view_update_long_event_label (EDayView *day_view,
if (!event->canvas_item)
return;
- cal_component_get_summary (event->comp, &summary);
+ summary = icalcomponent_get_summary (event->comp_data->icalcomp);
gnome_canvas_item_set (event->canvas_item,
- "text", summary.value ? summary.value : "",
+ "text", summary ? summary : "",
NULL);
}
@@ -1965,7 +1797,7 @@ e_day_view_find_event_from_uid (EDayView *day_view,
event = &g_array_index (day_view->events[day],
EDayViewEvent, event_num);
- cal_component_get_uid (event->comp, &u);
+ u = icalcomponent_get_uid (event->comp_data->icalcomp);
if (u && !strcmp (uid, u)) {
*day_return = day;
*event_num_return = event_num;
@@ -1979,7 +1811,7 @@ e_day_view_find_event_from_uid (EDayView *day_view,
event = &g_array_index (day_view->long_events,
EDayViewEvent, event_num);
- cal_component_get_uid (event->comp, &u);
+ u = icalcomponent_get_uid (event->comp_data->icalcomp);
if (u && !strcmp (uid, u)) {
*day_return = E_DAY_VIEW_LONG_EVENT;
*event_num_return = event_num;
@@ -1996,13 +1828,14 @@ e_day_view_find_event_from_uid (EDayView *day_view,
and are both visible in the view, then the selection is set to those times,
otherwise it is set to 1 hour from the start of the working day. */
static void
-e_day_view_set_selected_time_range (EDayView *day_view,
+e_day_view_set_selected_time_range (ECalView *cal_view,
time_t start_time,
time_t end_time)
{
time_t lower;
gint start_row, start_col, end_row, end_col;
gboolean need_redraw = FALSE, start_in_grid, end_in_grid;
+ EDayView *day_view = E_DAY_VIEW (cal_view);
g_return_if_fail (E_IS_DAY_VIEW (day_view));
@@ -2019,7 +1852,7 @@ e_day_view_set_selected_time_range (EDayView *day_view,
/* See if we need to change the days shown. */
if (lower != day_view->lower) {
e_day_view_recalc_day_starts (day_view, lower);
- e_day_view_update_query (day_view);
+ e_day_view_update_query ((ECalView *) day_view);
}
/* Set the selection. */
@@ -2215,12 +2048,11 @@ e_day_view_find_work_week_start (EDayView *day_view,
/* Returns the selected time range. */
static void
-e_day_view_get_selected_time_range (EDayView *day_view,
- time_t *start_time,
- time_t *end_time)
+e_day_view_get_selected_time_range (ECalView *cal_view, time_t *start_time, time_t *end_time)
{
gint start_col, start_row, end_col, end_row;
time_t start, end;
+ EDayView *day_view = E_DAY_VIEW (cal_view);
start_col = day_view->selection_start_day;
start_row = day_view->selection_start_row;
@@ -2254,10 +2086,12 @@ e_day_view_get_selected_time_range (EDayView *day_view,
/* Gets the visible time range. Returns FALSE if no time range has been set. */
static gboolean
-e_day_view_get_visible_time_range (EDayView *day_view,
+e_day_view_get_visible_time_range (ECalView *cal_view,
time_t *start_time,
time_t *end_time)
{
+ EDayView *day_view = E_DAY_VIEW (cal_view);
+
/* If the date isn't set, return FALSE. */
if (day_view->lower == 0 && day_view->upper == 0)
return FALSE;
@@ -2345,7 +2179,7 @@ e_day_view_set_days_shown (EDayView *day_view,
e_day_view_recalc_day_starts (day_view, day_view->lower);
e_day_view_recalc_cell_sizes (day_view);
- e_day_view_update_query (day_view);
+ e_day_view_update_query ((ECalView *) day_view);
}
@@ -2622,7 +2456,7 @@ e_day_view_recalc_work_week (EDayView *day_view)
day_view->selection_start_day = -1;
e_day_view_recalc_day_starts (day_view, lower);
- e_day_view_update_query (day_view);
+ e_day_view_update_query ((ECalView *) day_view);
/* This updates the date navigator. */
e_day_view_update_calendar_selection_time (day_view);
@@ -2750,8 +2584,7 @@ e_day_view_on_top_canvas_button_press (GtkWidget *widget,
if (event->type == GDK_2BUTTON_PRESS) {
time_t dtstart, dtend;
- e_day_view_get_selected_time_range (day_view, &dtstart,
- &dtend);
+ e_day_view_get_selected_time_range ((ECalView *) day_view, &dtstart, &dtend);
gnome_calendar_new_appointment_for (e_cal_view_get_calendar (E_CAL_VIEW (day_view)),
dtstart, dtend,
TRUE, FALSE);
@@ -2872,8 +2705,7 @@ e_day_view_on_main_canvas_button_press (GtkWidget *widget,
if (event->type == GDK_2BUTTON_PRESS) {
time_t dtstart, dtend;
- e_day_view_get_selected_time_range (day_view, &dtstart,
- &dtend);
+ e_day_view_get_selected_time_range ((ECalView *) day_view, &dtstart, &dtend);
gnome_calendar_new_appointment_for (e_cal_view_get_calendar (E_CAL_VIEW (day_view)),
dtstart, dtend,
FALSE, FALSE);
@@ -2920,6 +2752,7 @@ e_day_view_on_main_canvas_scroll (GtkWidget *widget,
e_day_view_scroll (day_view, -E_DAY_VIEW_WHEEL_MOUSE_STEP_SIZE);
return TRUE;
default:
+ break;
}
return FALSE;
@@ -2940,25 +2773,12 @@ e_day_view_on_time_canvas_scroll (GtkWidget *widget,
e_day_view_scroll (day_view, -E_DAY_VIEW_WHEEL_MOUSE_STEP_SIZE);
return TRUE;
default:
+ break;
}
return FALSE;
}
-
-/* Callback used when a component is destroyed. Expects the closure data to be
- * a pointer to a boolean; will set it to TRUE.
- */
-static void
-comp_destroy_cb (gpointer data, GObject *deadbeef)
-{
- gboolean *destroyed;
-
- destroyed = data;
- *destroyed = TRUE;
-}
-
-
static gboolean
e_day_view_on_long_event_button_press (EDayView *day_view,
gint event_num,
@@ -2982,24 +2802,17 @@ e_day_view_on_long_event_button_press (EDayView *day_view,
}
} else if (event->button == 3) {
EDayViewEvent *e;
- gboolean destroyed;
e = &g_array_index (day_view->long_events, EDayViewEvent, event_num);
- destroyed = FALSE;
- g_object_weak_ref ((GObject *) e->comp, comp_destroy_cb, &destroyed);
if (!GTK_WIDGET_HAS_FOCUS (day_view))
gtk_widget_grab_focus (GTK_WIDGET (day_view));
- if (!destroyed) {
- g_object_weak_unref ((GObject *) e->comp, comp_destroy_cb, &destroyed);
-
- e_day_view_set_selected_time_range_in_top_visible (day_view, e->start, e->end);
+ e_day_view_set_selected_time_range_in_top_visible (day_view, e->start, e->end);
- e_day_view_on_event_right_click (day_view, event,
- E_DAY_VIEW_LONG_EVENT,
- event_num);
- }
+ e_day_view_on_event_right_click (day_view, event,
+ E_DAY_VIEW_LONG_EVENT,
+ event_num);
return TRUE;
}
@@ -3031,24 +2844,16 @@ e_day_view_on_event_button_press (EDayView *day_view,
}
} else if (event->button == 3) {
EDayViewEvent *e;
- gboolean destroyed;
e = &g_array_index (day_view->events[day], EDayViewEvent, event_num);
- destroyed = FALSE;
- g_object_weak_ref ((GObject *) e->comp, comp_destroy_cb, &destroyed);
-
if (!GTK_WIDGET_HAS_FOCUS (day_view))
gtk_widget_grab_focus (GTK_WIDGET (day_view));
- if (!destroyed) {
- g_object_weak_unref ((GObject *) e->comp, comp_destroy_cb, &destroyed);
-
- e_day_view_set_selected_time_range_visible (day_view, e->start, e->end);
+ e_day_view_set_selected_time_range_visible (day_view, e->start, e->end);
- e_day_view_on_event_right_click (day_view, event,
- day, event_num);
- }
+ e_day_view_on_event_right_click (day_view, event,
+ day, event_num);
return TRUE;
}
@@ -3076,30 +2881,21 @@ e_day_view_on_long_event_click (EDayView *day_view,
&& E_TEXT (event->canvas_item)->editing)
return;
- if ((cal_component_is_instance (event->comp) || !cal_component_has_recurrences (event->comp))
+ if ((cal_util_component_is_instance (event->comp_data->icalcomp) ||
+ !cal_util_component_has_recurrences (event->comp_data->icalcomp))
&& (pos == E_CAL_VIEW_POS_LEFT_EDGE
|| pos == E_CAL_VIEW_POS_RIGHT_EDGE)) {
- gboolean destroyed;
-
if (!e_day_view_find_long_event_days (event,
day_view->days_shown,
day_view->day_starts,
&start_day, &end_day))
return;
- destroyed = FALSE;
- g_object_weak_ref ((GObject *) event->comp, comp_destroy_cb, &destroyed);
-
/* Grab the keyboard focus, so the event being edited is saved
and we can use the Escape key to abort the resize. */
if (!GTK_WIDGET_HAS_FOCUS (day_view))
gtk_widget_grab_focus (GTK_WIDGET (day_view));
- if (destroyed)
- return;
-
- g_object_weak_unref ((GObject *) event->comp, comp_destroy_cb, &destroyed);
-
if (gdk_pointer_grab (GTK_LAYOUT (day_view->top_canvas)->bin_window, FALSE,
GDK_POINTER_MOTION_MASK
| GDK_BUTTON_RELEASE_MASK,
@@ -3160,24 +2956,15 @@ e_day_view_on_event_click (EDayView *day_view,
&& E_TEXT (event->canvas_item)->editing)
return;
- if ((cal_component_is_instance (event->comp) || !cal_component_has_recurrences (event->comp))
+ if ((cal_util_component_is_instance (event->comp_data->icalcomp) ||
+ !cal_util_component_has_recurrences (event->comp_data->icalcomp))
&& (pos == E_CAL_VIEW_POS_TOP_EDGE
|| pos == E_CAL_VIEW_POS_BOTTOM_EDGE)) {
- gboolean destroyed;
-
- destroyed = FALSE;
- g_object_weak_ref ((GObject *) event->comp, comp_destroy_cb, &destroyed);
-
/* Grab the keyboard focus, so the event being edited is saved
and we can use the Escape key to abort the resize. */
if (!GTK_WIDGET_HAS_FOCUS (day_view))
gtk_widget_grab_focus (GTK_WIDGET (day_view));
- if (destroyed)
- return;
-
- g_object_weak_unref ((GObject *) event->comp, comp_destroy_cb, &destroyed);
-
if (gdk_pointer_grab (GTK_LAYOUT (day_view->main_canvas)->bin_window, FALSE,
GDK_POINTER_MOTION_MASK
| GDK_BUTTON_RELEASE_MASK,
@@ -3311,7 +3098,7 @@ e_day_view_on_event_double_click (EDayView *day_view,
gint event_num)
{
EDayViewEvent *event;
- gboolean destroyed;
+ GnomeCalendar *calendar;
if (day == -1)
event = &g_array_index (day_view->long_events, EDayViewEvent,
@@ -3320,22 +3107,13 @@ e_day_view_on_event_double_click (EDayView *day_view,
event = &g_array_index (day_view->events[day], EDayViewEvent,
event_num);
- destroyed = FALSE;
- g_object_weak_ref ((GObject *) event->comp, comp_destroy_cb, &destroyed);
-
e_day_view_stop_editing_event (day_view);
- if (!destroyed) {
- GnomeCalendar *calendar;
-
- g_object_weak_unref ((GObject *) event->comp, comp_destroy_cb, &destroyed);
-
- calendar = e_cal_view_get_calendar (E_CAL_VIEW (day_view));
- if (calendar)
- gnome_calendar_edit_object (calendar, event->comp, FALSE);
- else
- g_warning ("Calendar not set");
- }
+ calendar = e_cal_view_get_calendar (E_CAL_VIEW (day_view));
+ if (calendar)
+ gnome_calendar_edit_object (calendar, event->comp_data->client, event->comp_data->icalcomp, FALSE);
+ else
+ g_warning ("Calendar not set");
}
static void
@@ -3344,7 +3122,6 @@ e_day_view_show_popup_menu (EDayView *day_view,
gint day,
gint event_num)
{
- EDayViewEvent *event;
GtkMenu *popup;
day_view->popup_event_day = day;
@@ -3400,12 +3177,76 @@ e_day_view_get_selected_events (ECalView *cal_view)
return list;
}
+static void
+process_component (EDayView *day_view, ECalModelComponent *comp_data)
+{
+ EDayViewEvent *event;
+ gint day, event_num;
+ const char *uid;
+ CalComponent *comp;
+ AddEventData add_event_data;
+
+ /* If our time hasn't been set yet, just return. */
+ if (day_view->lower == 0 && day_view->upper == 0)
+ return;
+
+ /* If the event already exists and the dates didn't change, we can
+ update the event fairly easily without changing the events arrays
+ or computing a new layout. */
+ uid = icalcomponent_get_uid (comp_data->icalcomp);
+
+ if (e_day_view_find_event_from_uid (day_view, uid, &day, &event_num)) {
+ if (day == E_DAY_VIEW_LONG_EVENT)
+ event = &g_array_index (day_view->long_events,
+ EDayViewEvent, event_num);
+ else
+ event = &g_array_index (day_view->events[day],
+ EDayViewEvent, event_num);
+
+ if (!cal_util_component_has_recurrences (comp_data->icalcomp)
+ && !cal_component_has_recurrences (event->comp_data->icalcomp)
+ && cal_util_event_dates_match (event->comp_data->icalcomp, comp_data->icalcomp)) {
+#if 0
+ g_print ("updated object's dates unchanged\n");
+#endif
+ e_day_view_foreach_event_with_uid (day_view, uid, e_day_view_update_event_cb, comp_data);
+ gtk_widget_queue_draw (day_view->top_canvas);
+ gtk_widget_queue_draw (day_view->main_canvas);
+ return;
+ }
+
+ /* The dates have changed, so we need to remove the
+ old occurrrences before adding the new ones. */
+#if 0
+ g_print ("dates changed - removing occurrences\n");
+#endif
+ e_day_view_foreach_event_with_uid (day_view, uid,
+ e_day_view_remove_event_cb,
+ NULL);
+ }
+
+ /* Add the occurrences of the event. */
+ comp = cal_component_new ();
+ cal_component_set_icalcomponent (comp, icalcomponent_new_clone (comp_data->icalcomp));
+ add_event_data.day_view = day_view;
+ add_event_data.comp_data = comp_data;
+ cal_recur_generate_instances (comp, day_view->lower,
+ day_view->upper,
+ e_day_view_add_event, &add_event_data,
+ cal_client_resolve_tzid_cb,
+ comp_data->client,
+ e_cal_view_get_timezone (E_CAL_VIEW (day_view)));
+ g_object_unref (comp);
+
+ e_day_view_queue_layout (day_view);
+}
+
/* Restarts a query for the day view */
static void
-e_day_view_update_query (EDayView *day_view)
+e_day_view_update_query (ECalView *cal_view)
{
- CalQuery *old_query;
- char *real_sexp;
+ gint rows, r;
+ EDayView *day_view = E_DAY_VIEW (cal_view);
e_day_view_stop_editing_event (day_view);
@@ -3414,36 +3255,18 @@ e_day_view_update_query (EDayView *day_view)
e_day_view_free_events (day_view);
e_day_view_queue_layout (day_view);
- old_query = day_view->query;
- day_view->query = NULL;
-
- if (old_query) {
- g_signal_handlers_disconnect_matched (old_query, G_SIGNAL_MATCH_DATA,
- 0, 0, NULL, NULL, day_view);
- g_object_unref (old_query);
- }
-
- real_sexp = adjust_query_sexp (day_view, e_cal_view_get_query (E_CAL_VIEW (day_view)));
- if (!real_sexp)
- return; /* No time range is set, so don't start a query */
-
e_cal_view_set_status_message (E_CAL_VIEW (day_view), _("Searching"));
- day_view->query = cal_client_get_query (e_cal_view_get_cal_client (E_CAL_VIEW (day_view)), real_sexp);
- g_free (real_sexp);
- if (!day_view->query) {
- g_message ("e_day_view_update_query(): Could not create the query");
- return;
+ rows = e_table_model_row_count (E_TABLE_MODEL (e_cal_view_get_model (E_CAL_VIEW (day_view))));
+ for (r = 0; r < rows; r++) {
+ ECalModelComponent *comp_data;
+
+ comp_data = e_cal_model_get_component_at (e_cal_view_get_model (E_CAL_VIEW (day_view)), r);
+ g_assert (comp_data != NULL);
+ process_component (day_view, comp_data);
}
- g_signal_connect (day_view->query, "obj_updated",
- G_CALLBACK (query_obj_updated_cb), day_view);
- g_signal_connect (day_view->query, "obj_removed",
- G_CALLBACK (query_obj_removed_cb), day_view);
- g_signal_connect (day_view->query, "query_done",
- G_CALLBACK (query_query_done_cb), day_view);
- g_signal_connect (day_view->query, "eval_error",
- G_CALLBACK (query_eval_error_cb), day_view);
+ e_cal_view_set_status_message (E_CAL_VIEW (day_view), NULL);
}
static void
@@ -3474,13 +3297,15 @@ e_day_view_unrecur_appointment (EDayView *day_view)
/* For the recurring object, we add an exception to get rid of the
instance. */
- comp = cal_component_clone (event->comp);
+ comp = cal_component_new ();
+ cal_component_set_icalcomponent (comp, icalcomponent_new_clone (event->comp_data->icalcomp));
cal_comp_util_add_exdate (comp, event->start, e_cal_view_get_timezone (E_CAL_VIEW (day_view)));
/* For the unrecurred instance we duplicate the original object,
create a new uid for it, get rid of the recurrence rules, and set
the start & end times to the instances times. */
- new_comp = cal_component_clone (event->comp);
+ new_comp = cal_component_new ();
+ cal_component_set_icalcomponent (comp, icalcomponent_new_clone (event->comp_data->icalcomp));
cal_component_set_uid (new_comp, cal_component_gen_uid ());
cal_component_set_rdate_list (new_comp, NULL);
cal_component_set_rrule_list (new_comp, NULL);
@@ -3501,13 +3326,13 @@ e_day_view_unrecur_appointment (EDayView *day_view)
/* Now update both CalComponents. Note that we do this last since at
* present the updates happen synchronously so our event may disappear.
*/
- if (cal_client_update_object (e_cal_view_get_cal_client (E_CAL_VIEW (day_view)), comp)
+ if (cal_client_update_object (event->comp_data->client, comp)
!= CAL_CLIENT_RESULT_SUCCESS)
g_message ("e_day_view_on_unrecur_appointment(): Could not update the object!");
g_object_unref (comp);
- if (cal_client_update_object (e_cal_view_get_cal_client (E_CAL_VIEW (day_view)), new_comp)
+ if (cal_client_update_object (event->comp_data->client, new_comp)
!= CAL_CLIENT_RESULT_SUCCESS)
g_message ("e_day_view_on_unrecur_appointment(): Could not update the object!");
@@ -3592,7 +3417,7 @@ e_day_view_update_calendar_selection_time (EDayView *day_view)
time_t start, end;
GnomeCalendar *calendar;
- e_day_view_get_selected_time_range (day_view, &start, &end);
+ e_day_view_get_selected_time_range ((ECalView *) day_view, &start, &end);
#if 0
g_print ("Start: %s", ctime (&start));
@@ -3652,7 +3477,8 @@ e_day_view_on_top_canvas_motion (GtkWidget *widget,
event = &g_array_index (day_view->long_events, EDayViewEvent,
day_view->pressed_event_num);
- if ((cal_component_is_instance (event->comp) || !cal_component_has_recurrences (event->comp))
+ if ((cal_util_component_is_instance (event->comp_data->icalcomp) ||
+ !cal_util_component_has_recurrences (event->comp_data->icalcomp))
&& (abs (canvas_x - day_view->drag_event_x)
> E_DAY_VIEW_DRAG_START_OFFSET
|| abs (canvas_y - day_view->drag_event_y)
@@ -3680,7 +3506,8 @@ e_day_view_on_top_canvas_motion (GtkWidget *widget,
cursor = day_view->normal_cursor;
/* Recurring events can't be resized. */
- if (event && (cal_component_is_instance (event->comp) || !cal_component_has_recurrences (event->comp))) {
+ if (event && (cal_util_component_is_instance (event->comp_data->icalcomp) ||
+ !cal_util_component_has_recurrences (event->comp_data->icalcomp))) {
switch (pos) {
case E_CAL_VIEW_POS_LEFT_EDGE:
case E_CAL_VIEW_POS_RIGHT_EDGE:
@@ -3756,7 +3583,8 @@ e_day_view_on_main_canvas_motion (GtkWidget *widget,
event = &g_array_index (day_view->events[day_view->pressed_event_day], EDayViewEvent, day_view->pressed_event_num);
- if ((cal_component_is_instance (event->comp) || !cal_component_has_recurrences (event->comp))
+ if ((cal_util_component_is_instance (event->comp_data->icalcomp) ||
+ !cal_util_component_has_recurrences (event->comp_data->icalcomp))
&& (abs (canvas_x - day_view->drag_event_x)
> E_DAY_VIEW_DRAG_START_OFFSET
|| abs (canvas_y - day_view->drag_event_y)
@@ -3784,7 +3612,8 @@ e_day_view_on_main_canvas_motion (GtkWidget *widget,
cursor = day_view->normal_cursor;
/* Recurring events can't be resized. */
- if (event && (cal_component_is_instance (event->comp) || !cal_component_has_recurrences (event->comp))) {
+ if (event && (cal_util_component_is_instance (event->comp_data->icalcomp) ||
+ !cal_util_component_has_recurrences (event->comp_data->icalcomp))) {
switch (pos) {
case E_CAL_VIEW_POS_LEFT_EDGE:
cursor = day_view->move_cursor;
@@ -4010,16 +3839,17 @@ e_day_view_finish_long_event_resize (EDayView *day_view)
time_t dt;
CalClient *client;
- client = e_cal_view_get_cal_client (E_CAL_VIEW (day_view));
-
event_num = day_view->resize_event_num;
event = &g_array_index (day_view->long_events, EDayViewEvent,
event_num);
+ client = event->comp_data->client;
+
/* We use a temporary copy of the comp since we don't want to
change the original comp here. Otherwise we would not detect that
the event's time had changed in the "update_event" callback. */
- comp = cal_component_clone (event->comp);
+ comp = cal_component_new ();
+ cal_component_set_icalcomponent (comp, icalcomponent_new_clone (event->comp_data->icalcomp));
date.value = &itt;
/* FIXME: Should probably keep the timezone of the original start
@@ -4044,7 +3874,7 @@ e_day_view_finish_long_event_resize (EDayView *day_view)
if (recur_component_dialog (comp, &mod, NULL)) {
if (cal_client_update_object_with_mod (client, comp, mod) == CAL_CLIENT_RESULT_SUCCESS) {
if (itip_organizer_is_user (comp, client) &&
- send_component_dialog (gtk_widget_get_toplevel (day_view),
+ send_component_dialog ((GtkWindow *) gtk_widget_get_toplevel (GTK_WIDGET (day_view)),
client, comp, FALSE))
itip_send_comp (CAL_COMPONENT_METHOD_REQUEST, comp, client, NULL);
} else {
@@ -4055,7 +3885,7 @@ e_day_view_finish_long_event_resize (EDayView *day_view)
}
} else if (cal_client_update_object (client, comp) == CAL_CLIENT_RESULT_SUCCESS) {
if (itip_organizer_is_user (comp, client) &&
- send_component_dialog (gtk_widget_get_toplevel (day_view),
+ send_component_dialog ((GtkWindow *) gtk_widget_get_toplevel (GTK_WIDGET (day_view)),
client, comp, TRUE))
itip_send_comp (CAL_COMPONENT_METHOD_REQUEST, comp, client, NULL);
} else {
@@ -4083,17 +3913,18 @@ e_day_view_finish_resize (EDayView *day_view)
time_t dt;
CalClient *client;
- client = e_cal_view_get_cal_client (E_CAL_VIEW (day_view));
-
day = day_view->resize_event_day;
event_num = day_view->resize_event_num;
event = &g_array_index (day_view->events[day], EDayViewEvent,
event_num);
+ client = event->comp_data->client;
+
/* We use a temporary shallow copy of the ico since we don't want to
change the original ico here. Otherwise we would not detect that
the event's time had changed in the "update_event" callback. */
- comp = cal_component_clone (event->comp);
+ comp = cal_component_new ();
+ cal_component_set_icalcomponent (comp, icalcomponent_new_clone (event->comp_data->icalcomp));
date.value = &itt;
/* FIXME: Should probably keep the timezone of the original start
@@ -4129,7 +3960,7 @@ e_day_view_finish_resize (EDayView *day_view)
if (recur_component_dialog (comp, &mod, NULL)) {
if (cal_client_update_object_with_mod (client, comp, mod) == CAL_CLIENT_RESULT_SUCCESS) {
if (itip_organizer_is_user (comp, client) &&
- send_component_dialog (gtk_widget_get_toplevel (day_view),
+ send_component_dialog ((GtkWindow *) gtk_widget_get_toplevel (GTK_WIDGET (day_view)),
client, comp, FALSE))
itip_send_comp (CAL_COMPONENT_METHOD_REQUEST, comp, client, NULL);
} else {
@@ -4140,7 +3971,7 @@ e_day_view_finish_resize (EDayView *day_view)
}
} else if (cal_client_update_object (client, comp) == CAL_CLIENT_RESULT_SUCCESS) {
if (itip_organizer_is_user (comp, client) &&
- send_component_dialog (gtk_widget_get_toplevel (day_view), client, comp, FALSE))
+ send_component_dialog ((GtkWindow *) gtk_widget_get_toplevel (GTK_WIDGET (day_view)), client, comp, FALSE))
itip_send_comp (CAL_COMPONENT_METHOD_REQUEST, comp, client, NULL);
} else {
g_message ("e_day_view_finish_resize(): Could not update the object!");
@@ -4218,7 +4049,11 @@ e_day_view_free_event_array (EDayView *day_view,
event = &g_array_index (array, EDayViewEvent, event_num);
if (event->canvas_item)
gtk_object_destroy (GTK_OBJECT (event->canvas_item));
- g_object_unref (event->comp);
+
+ if (event->allocated_comp_data) {
+ e_cal_model_free_component_data (event->comp_data);
+ event->allocated_comp_data = FALSE;
+ }
}
g_array_set_size (array, 0);
@@ -4233,40 +4068,50 @@ e_day_view_add_event (CalComponent *comp,
gpointer data)
{
- EDayView *day_view;
EDayViewEvent event;
gint day, offset;
struct icaltimetype start_tt, end_tt;
+ AddEventData *add_event_data;
- day_view = E_DAY_VIEW (data);
+ add_event_data = data;
#if 0
- g_print ("Day view lower: %s", ctime (&day_view->lower));
- g_print ("Day view upper: %s", ctime (&day_view->upper));
+ g_print ("Day view lower: %s", ctime (&add_event_data->day_view->lower));
+ g_print ("Day view upper: %s", ctime (&add_event_data->day_view->upper));
g_print ("Event start: %s", ctime (&start));
g_print ("Event end : %s\n", ctime (&end));
#endif
/* Check that the event times are valid. */
g_return_val_if_fail (start <= end, TRUE);
- g_return_val_if_fail (start < day_view->upper, TRUE);
- g_return_val_if_fail (end > day_view->lower, TRUE);
+ g_return_val_if_fail (start < add_event_data->day_view->upper, TRUE);
+ g_return_val_if_fail (end > add_event_data->day_view->lower, TRUE);
start_tt = icaltime_from_timet_with_zone (start, FALSE,
- e_cal_view_get_timezone (E_CAL_VIEW (day_view)));
+ e_cal_view_get_timezone (E_CAL_VIEW (add_event_data->day_view)));
end_tt = icaltime_from_timet_with_zone (end, FALSE,
- e_cal_view_get_timezone (E_CAL_VIEW (day_view)));
+ e_cal_view_get_timezone (E_CAL_VIEW (add_event_data->day_view)));
+
+ if (add_event_data->comp_data) {
+ event.comp_data = add_event_data->comp_data;
+ event.allocated_comp_data = FALSE;
+ } else {
+ event.comp_data = g_new0 (ECalModelComponent, 1);
+ event.allocated_comp_data = TRUE;
+
+ event.comp_data->client = e_cal_model_get_default_client (e_cal_view_get_model (E_CAL_VIEW (add_event_data->day_view)));
+ cal_component_commit_sequence (comp);
+ event.comp_data->icalcomp = icalcomponent_new_clone (cal_component_get_icalcomponent (comp));
+ }
- event.comp = comp;
- g_object_ref (comp);
event.start = start;
event.end = end;
event.canvas_item = NULL;
/* Calculate the start & end minute, relative to the top of the
display. */
- offset = day_view->first_hour_shown * 60
- + day_view->first_minute_shown;
+ offset = add_event_data->day_view->first_hour_shown * 60
+ + add_event_data->day_view->first_minute_shown;
event.start_minute = start_tt.hour * 60 + start_tt.minute - offset;
event.end_minute = end_tt.hour * 60 + end_tt.minute - offset;
@@ -4274,40 +4119,41 @@ e_day_view_add_event (CalComponent *comp,
event.num_columns = 0;
event.different_timezone = FALSE;
- if (!cal_comp_util_compare_event_timezones (comp, e_cal_view_get_cal_client (E_CAL_VIEW (day_view)),
- e_cal_view_get_timezone (E_CAL_VIEW (day_view))))
+ if (!cal_comp_util_compare_event_timezones (comp,
+ event.comp_data->client,
+ e_cal_view_get_timezone (E_CAL_VIEW (add_event_data->day_view))))
event.different_timezone = TRUE;
/* Find out which array to add the event to. */
- for (day = 0; day < day_view->days_shown; day++) {
- if (start >= day_view->day_starts[day]
- && end <= day_view->day_starts[day + 1]) {
+ for (day = 0; day < add_event_data->day_view->days_shown; day++) {
+ if (start >= add_event_data->day_view->day_starts[day]
+ && end <= add_event_data->day_view->day_starts[day + 1]) {
/* Special case for when the appointment ends at
midnight, i.e. the start of the next day. */
- if (end == day_view->day_starts[day + 1]) {
+ if (end == add_event_data->day_view->day_starts[day + 1]) {
/* If the event last the entire day, then we
skip it here so it gets added to the top
canvas. */
- if (start == day_view->day_starts[day])
- break;
+ if (start == add_event_data->day_view->day_starts[day])
+ break;
event.end_minute = 24 * 60;
}
- g_array_append_val (day_view->events[day], event);
- day_view->events_sorted[day] = FALSE;
- day_view->need_layout[day] = TRUE;
+ g_array_append_val (add_event_data->day_view->events[day], event);
+ add_event_data->day_view->events_sorted[day] = FALSE;
+ add_event_data->day_view->need_layout[day] = TRUE;
return TRUE;
}
}
/* The event wasn't within one day so it must be a long event,
i.e. shown in the top canvas. */
- g_array_append_val (day_view->long_events, event);
- day_view->long_events_sorted = FALSE;
- day_view->long_events_need_layout = TRUE;
+ g_array_append_val (add_event_data->day_view->long_events, event);
+ add_event_data->day_view->long_events_sorted = FALSE;
+ add_event_data->day_view->long_events_need_layout = TRUE;
return TRUE;
}
@@ -4435,7 +4281,8 @@ e_day_view_reshape_long_event (EDayView *day_view,
/* We don't show the icons while resizing, since we'd have to
draw them on top of the resize rect. Nor when editing. */
num_icons = 0;
- comp = event->comp;
+ comp = cal_component_new ();
+ cal_component_set_icalcomponent (comp, icalcomponent_new_clone (event->comp_data->icalcomp));
/* Set up Pango prerequisites */
font_desc = gtk_widget_get_style (GTK_WIDGET (day_view))->font_desc;
@@ -4488,7 +4335,7 @@ e_day_view_reshape_long_event (EDayView *day_view,
"editable", TRUE,
"use_ellipsis", TRUE,
"draw_background", FALSE,
- "fill_color_rgba", GNOME_CANVAS_COLOR(0, 0, 0),
+ "fill_color_rgba", GNOME_CANVAS_COLOR (0, 0, 0),
"im_context", E_CANVAS (day_view->top_canvas)->im_context,
NULL);
g_signal_connect (event->canvas_item, "event",
@@ -4580,11 +4427,9 @@ e_day_view_reshape_day_event (EDayView *day_view,
EDayViewEvent *event;
gint item_x, item_y, item_w, item_h;
gint num_icons, icons_offset;
- CalComponent *comp;
event = &g_array_index (day_view->events[day], EDayViewEvent,
event_num);
- comp = event->comp;
if (!e_day_view_get_event_position (day_view, day, event_num,
&item_x, &item_y,
@@ -4607,6 +4452,10 @@ e_day_view_reshape_day_event (EDayView *day_view,
|| day_view->resize_event_day != day
|| day_view->resize_event_num != event_num) {
GSList *categories_list, *elem;
+ CalComponent *comp;
+
+ comp = cal_component_new ();
+ cal_component_set_icalcomponent (comp, icalcomponent_new_clone (event->comp_data->icalcomp));
if (cal_component_has_alarms (comp))
num_icons++;
@@ -4781,6 +4630,7 @@ static gboolean
e_day_view_do_key_press (GtkWidget *widget, GdkEventKey *event)
{
EDayView *day_view;
+ icalcomponent *icalcomp;
CalComponent *comp;
gint day, event_num;
gchar *initial_text;
@@ -4789,7 +4639,8 @@ e_day_view_do_key_press (GtkWidget *widget, GdkEventKey *event)
time_t dtstart, dtend;
CalComponentDateTime start_dt, end_dt;
struct icaltimetype start_tt, end_tt;
- const char *uid;
+ const char *uid;
+ AddEventData add_event_data;
g_return_val_if_fail (widget != NULL, FALSE);
g_return_val_if_fail (E_IS_DAY_VIEW (widget), FALSE);
@@ -4797,11 +4648,6 @@ e_day_view_do_key_press (GtkWidget *widget, GdkEventKey *event)
day_view = E_DAY_VIEW (widget);
keyval = event->keyval;
-
- if (!(e_cal_view_get_cal_client (E_CAL_VIEW (day_view))
- && cal_client_get_load_state (e_cal_view_get_cal_client (E_CAL_VIEW (day_view)))
- == CAL_CLIENT_LOAD_LOADED))
- return TRUE;
/* The Escape key aborts a resize operation. */
if (day_view->resize_drag_pos != E_CAL_VIEW_POS_NONE) {
@@ -4918,9 +4764,13 @@ e_day_view_do_key_press (GtkWidget *widget, GdkEventKey *event)
/* Add a new event covering the selected range */
- comp = cal_comp_event_new_with_defaults (e_cal_view_get_cal_client (E_CAL_VIEW (day_view)));
+ icalcomp = e_cal_model_create_component_with_defaults (e_cal_view_get_model (E_CAL_VIEW (day_view)));
+ uid = icalcomponent_get_uid (icalcomp);
- e_day_view_get_selected_time_range (day_view, &dtstart, &dtend);
+ comp = cal_component_new ();
+ cal_component_set_icalcomponent (comp, icalcomp);
+
+ e_day_view_get_selected_time_range ((ECalView *) day_view, &dtstart, &dtend);
start_tt = icaltime_from_timet_with_zone (dtstart, FALSE,
e_cal_view_get_timezone (E_CAL_VIEW (day_view)));
@@ -4946,12 +4796,13 @@ e_day_view_do_key_press (GtkWidget *widget, GdkEventKey *event)
/* We add the event locally and start editing it. We don't send it
to the server until the user finishes editing it. */
- e_day_view_add_event (comp, dtstart, dtend, day_view);
+ add_event_data.day_view = day_view;
+ add_event_data.comp_data = NULL;
+ e_day_view_add_event (comp, dtstart, dtend, &add_event_data);
e_day_view_check_layout (day_view);
gtk_widget_queue_draw (day_view->top_canvas);
gtk_widget_queue_draw (day_view->main_canvas);
- cal_component_get_uid (comp, &uid);
if (e_day_view_find_event_from_uid (day_view, uid, &day, &event_num)) {
e_day_view_start_editing_event (day_view, day, event_num,
initial_text);
@@ -5715,7 +5566,7 @@ cancel_editing (EDayView *day_view)
{
int day, event_num;
EDayViewEvent *event;
- CalComponentText summary;
+ const gchar *summary;
day = day_view->editing_event_day;
event_num = day_view->editing_event_num;
@@ -5729,9 +5580,9 @@ cancel_editing (EDayView *day_view)
/* Reset the text to what was in the component */
- cal_component_get_summary (event->comp, &summary);
+ summary = icalcomponent_get_summary (event->comp_data->icalcomp);
g_object_set (G_OBJECT (event->canvas_item),
- "text", summary.value ? summary.value : "",
+ "text", summary ? summary : "",
NULL);
/* Stop editing */
@@ -5841,6 +5692,7 @@ e_day_view_on_editing_stopped (EDayView *day_view,
EDayViewEvent *event;
gchar *text = NULL;
CalComponentText summary;
+ CalComponent *comp;
/* 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
@@ -5883,11 +5735,14 @@ e_day_view_on_editing_stopped (EDayView *day_view,
NULL);
g_assert (text != NULL);
+ comp = cal_component_new ();
+ cal_component_set_icalcomponent (comp, icalcomponent_new_clone (event->comp_data->icalcomp));
+
if (string_is_empty (text) &&
- !cal_comp_is_on_server (event->comp, e_cal_view_get_cal_client (E_CAL_VIEW (day_view)))) {
+ !cal_comp_is_on_server (comp, event->comp_data->client)) {
const char *uid;
- cal_component_get_uid (event->comp, &uid);
+ cal_component_get_uid (comp, &uid);
e_day_view_foreach_event_with_uid (day_view, uid,
e_day_view_remove_event_cb, NULL);
@@ -5898,7 +5753,7 @@ e_day_view_on_editing_stopped (EDayView *day_view,
}
/* Only update the summary if necessary. */
- cal_component_get_summary (event->comp, &summary);
+ cal_component_get_summary (comp, &summary);
if (summary.value && !strcmp (text, summary.value)) {
if (day == E_DAY_VIEW_LONG_EVENT)
e_day_view_reshape_long_event (day_view, event_num);
@@ -5906,34 +5761,31 @@ e_day_view_on_editing_stopped (EDayView *day_view,
e_day_view_update_event_label (day_view, day,
event_num);
} else if (summary.value || !string_is_empty (text)) {
- CalClient *client;
-
- client = e_cal_view_get_cal_client (E_CAL_VIEW (day_view));
-
summary.value = text;
summary.altrep = NULL;
- cal_component_set_summary (event->comp, &summary);
+ cal_component_set_summary (comp, &summary);
- if (cal_component_is_instance (event->comp)) {
+ if (cal_component_is_instance (comp)) {
CalObjModType mod;
- if (recur_component_dialog (event->comp, &mod, NULL)) {
- if (cal_client_update_object_with_mod (client, event->comp, mod) == CAL_CLIENT_RESULT_SUCCESS) {
- if (itip_organizer_is_user (event->comp, client)
- && send_component_dialog (gtk_widget_get_toplevel (day_view),
- client, event->comp, FALSE))
- itip_send_comp (CAL_COMPONENT_METHOD_REQUEST, event->comp,
- client, NULL);
+ if (recur_component_dialog (comp, &mod, NULL)) {
+ if (cal_client_update_object_with_mod (event->comp_data->client, comp, mod)
+ == CAL_CLIENT_RESULT_SUCCESS) {
+ if (itip_organizer_is_user (comp, event->comp_data->client)
+ && send_component_dialog ((GtkWindow *) gtk_widget_get_toplevel (GTK_WIDGET (day_view)),
+ event->comp_data->client, comp, FALSE))
+ itip_send_comp (CAL_COMPONENT_METHOD_REQUEST, comp,
+ event->comp_data->client, NULL);
} else {
g_message ("e_day_view_on_editing_stopped(): Could not update the object!");
}
}
- } else if (cal_client_update_object (client, event->comp) == CAL_CLIENT_RESULT_SUCCESS) {
- if (itip_organizer_is_user (event->comp, client) &&
- send_component_dialog (gtk_widget_get_toplevel (day_view),
- client, event->comp, FALSE))
- itip_send_comp (CAL_COMPONENT_METHOD_REQUEST, event->comp,
- client, NULL);
+ } else if (cal_client_update_object (event->comp_data->client, comp) == CAL_CLIENT_RESULT_SUCCESS) {
+ if (itip_organizer_is_user (comp, event->comp_data->client) &&
+ send_component_dialog ((GtkWindow *) gtk_widget_get_toplevel (GTK_WIDGET (day_view)),
+ event->comp_data->client, comp, FALSE))
+ itip_send_comp (CAL_COMPONENT_METHOD_REQUEST, comp,
+ event->comp_data->client, NULL);
} else {
g_message ("e_day_view_on_editing_stopped(): Could not update the object!");
}
@@ -5941,6 +5793,7 @@ e_day_view_on_editing_stopped (EDayView *day_view,
out:
+ g_object_unref (comp);
g_free (text);
g_signal_emit_by_name (day_view, "selection_changed");
@@ -6579,11 +6432,11 @@ e_day_view_update_top_canvas_drag (EDayView *day_view,
set the text then. */
if (!(day_view->drag_long_event_item->object.flags
& GNOME_CANVAS_ITEM_VISIBLE)) {
- CalComponentText summary;
+ const gchar *summary;
if (event) {
- cal_component_get_summary (event->comp, &summary);
- text = g_strdup (summary.value);
+ summary = icalcomponent_get_summary (event->comp_data->icalcomp);
+ text = g_strdup (summary);
} else {
text = NULL;
}
@@ -6741,11 +6594,11 @@ e_day_view_update_main_canvas_drag (EDayView *day_view,
time it moves, so we check if it is currently invisible and only
set the text then. */
if (!(day_view->drag_item->object.flags & GNOME_CANVAS_ITEM_VISIBLE)) {
- CalComponentText summary;
+ const gchar *summary;
if (event) {
- cal_component_get_summary (event->comp, &summary);
- text = g_strdup (summary.value);
+ summary = icalcomponent_get_summary (event->comp_data->icalcomp);
+ text = g_strdup (summary);
} else {
text = NULL;
}
@@ -6887,7 +6740,7 @@ e_day_view_on_drag_data_get (GtkWidget *widget,
if (info == TARGET_CALENDAR_EVENT) {
const char *event_uid;
- cal_component_get_uid (event->comp, &event_uid);
+ event_uid = icalcomponent_get_uid (event->comp_data->icalcomp);
g_return_if_fail (event_uid != NULL);
gtk_selection_data_set (selection_data, selection_data->target,
@@ -6897,10 +6750,10 @@ e_day_view_on_drag_data_get (GtkWidget *widget,
icalcomponent *vcal;
vcal = cal_util_new_top_level ();
- cal_util_add_timezones_from_component (vcal, cal_component_get_icalcomponent (event->comp));
+ cal_util_add_timezones_from_component (vcal, event->comp_data->icalcomp);
icalcomponent_add_component (
vcal,
- icalcomponent_new_clone (cal_component_get_icalcomponent (event->comp)));
+ icalcomponent_new_clone (event->comp_data->icalcomp));
comp_str = icalcomponent_as_ical_string (vcal);
if (comp_str) {
@@ -6935,7 +6788,7 @@ e_day_view_on_top_canvas_drag_data_received (GtkWidget *widget,
gboolean all_day_event;
CalClient *client;
- client = e_cal_view_get_cal_client (E_CAL_VIEW (day_view));
+ client = e_cal_model_get_default_client (e_cal_view_get_model (E_CAL_VIEW (day_view)));
/* Note that we only support DnD within the EDayView at present. */
if ((data->length >= 0) && (data->format == 8)
@@ -6972,9 +6825,11 @@ e_day_view_on_top_canvas_drag_data_received (GtkWidget *widget,
day_view->drag_event_num);
}
+ client = event->comp_data->client;
+
event_uid = data->data;
- cal_component_get_uid (event->comp, &uid);
+ uid = icalcomponent_get_uid (event->comp_data->icalcomp);
if (!event_uid || !uid || strcmp (event_uid, uid))
g_warning ("Unexpected event UID");
@@ -6984,7 +6839,8 @@ e_day_view_on_top_canvas_drag_data_received (GtkWidget *widget,
Otherwise we would not detect that the event's time
had changed in the "update_event" callback. */
- comp = cal_component_clone (event->comp);
+ comp = cal_component_new ();
+ cal_component_set_icalcomponent (comp, icalcomponent_new_clone (event->comp_data->icalcomp));
if (start_offset == 0 && end_offset == 0)
all_day_event = TRUE;
@@ -7038,7 +6894,7 @@ e_day_view_on_top_canvas_drag_data_received (GtkWidget *widget,
if (recur_component_dialog (comp, &mod, NULL)) {
if (cal_client_update_object_with_mod (client, comp, mod) == CAL_CLIENT_RESULT_SUCCESS) {
if (itip_organizer_is_user (comp, client)
- && send_component_dialog (gtk_widget_get_toplevel (day_view),
+ && send_component_dialog ((GtkWindow *) gtk_widget_get_toplevel (GTK_WIDGET (day_view)),
client, comp, FALSE))
itip_send_comp (CAL_COMPONENT_METHOD_REQUEST, comp,
client, NULL);
@@ -7050,7 +6906,7 @@ e_day_view_on_top_canvas_drag_data_received (GtkWidget *widget,
} else if (cal_client_update_object (client, comp)
== CAL_CLIENT_RESULT_SUCCESS) {
if (itip_organizer_is_user (comp, client) &&
- send_component_dialog (gtk_widget_get_toplevel (day_view),
+ send_component_dialog ((GtkWindow *) gtk_widget_get_toplevel (GTK_WIDGET (day_view)),
client, comp, FALSE))
itip_send_comp (CAL_COMPONENT_METHOD_REQUEST, comp,
client, NULL);
@@ -7090,7 +6946,7 @@ e_day_view_on_main_canvas_drag_data_received (GtkWidget *widget,
time_t dt;
CalClient *client;
- client = e_cal_view_get_cal_client (E_CAL_VIEW (day_view));
+ client = e_cal_model_get_default_client (e_cal_view_get_model (E_CAL_VIEW (day_view)));
gnome_canvas_get_scroll_offsets (GNOME_CANVAS (widget),
&scroll_x, &scroll_y);
@@ -7132,9 +6988,11 @@ e_day_view_on_main_canvas_drag_data_received (GtkWidget *widget,
end_offset = day_view->mins_per_row - end_offset;
}
+ client = event->comp_data->client;
+
event_uid = data->data;
- cal_component_get_uid (event->comp, &uid);
+ uid = icalcomponent_get_uid (event->comp_data->icalcomp);
if (!event_uid || !uid || strcmp (event_uid, uid))
g_warning ("Unexpected event UID");
@@ -7142,7 +7000,8 @@ e_day_view_on_main_canvas_drag_data_received (GtkWidget *widget,
don't want to change the original comp here.
Otherwise we would not detect that the event's time
had changed in the "update_event" callback. */
- comp = cal_component_clone (event->comp);
+ comp = cal_component_new ();
+ cal_component_set_icalcomponent (comp, icalcomponent_new_clone (event->comp_data->icalcomp));
date.value = &itt;
date.tzid = icaltimezone_get_tzid (e_cal_view_get_timezone (E_CAL_VIEW (day_view)));
@@ -7172,7 +7031,7 @@ e_day_view_on_main_canvas_drag_data_received (GtkWidget *widget,
if (recur_component_dialog (comp, &mod, NULL)) {
if (cal_client_update_object_with_mod (client, comp, mod) == CAL_CLIENT_RESULT_SUCCESS) {
if (itip_organizer_is_user (comp, client)
- && send_component_dialog (gtk_widget_get_toplevel (day_view),
+ && send_component_dialog ((GtkWindow *) gtk_widget_get_toplevel (GTK_WIDGET (day_view)),
client, comp, FALSE))
itip_send_comp (CAL_COMPONENT_METHOD_REQUEST, comp,
client, NULL);
@@ -7183,7 +7042,7 @@ e_day_view_on_main_canvas_drag_data_received (GtkWidget *widget,
}
} else if (cal_client_update_object (client, comp) == CAL_CLIENT_RESULT_SUCCESS) {
if (itip_organizer_is_user (comp, client) &&
- send_component_dialog (gtk_widget_get_toplevel (day_view),
+ send_component_dialog ((GtkWindow *) gtk_widget_get_toplevel (GTK_WIDGET (day_view)),
client, comp, FALSE))
itip_send_comp (CAL_COMPONENT_METHOD_REQUEST, comp,
client, NULL);