"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "src/calendar/gui/e-day-view.c" between
evolution-3.32.4.tar.xz and evolution-3.34.0.tar.xz

About: Evolution is a personal information management application that provides integrated mail, calendaring and address book functionality (GNOME desktop).

e-day-view.c  (evolution-3.32.4.tar.xz):e-day-view.c  (evolution-3.34.0.tar.xz)
skipping to change at line 578 skipping to change at line 578
g_return_if_fail (E_IS_DAY_VIEW (day_view)); g_return_if_fail (E_IS_DAY_VIEW (day_view));
g_return_if_fail (start_hour != NULL); g_return_if_fail (start_hour != NULL);
g_return_if_fail (start_minute != NULL); g_return_if_fail (start_minute != NULL);
g_return_if_fail (end_hour != NULL); g_return_if_fail (end_hour != NULL);
g_return_if_fail (end_minute != NULL); g_return_if_fail (end_minute != NULL);
model = e_calendar_view_get_model (E_CALENDAR_VIEW (day_view)); model = e_calendar_view_get_model (E_CALENDAR_VIEW (day_view));
if (day >= 0 && day < e_day_view_get_days_shown (day_view)) { if (day >= 0 && day < e_day_view_get_days_shown (day_view)) {
GDateWeekday weekday; GDateWeekday weekday;
struct icaltimetype tt; ICalTime *tt;
tt = icaltime_from_timet_with_zone (day_view->day_starts[day], FA LSE, tt = i_cal_time_new_from_timet_with_zone (day_view->day_starts[da y], FALSE,
e_calendar_view_get_timezone (E_CALENDAR_VIEW (day_view)) ); e_calendar_view_get_timezone (E_CALENDAR_VIEW (day_view)) );
switch (icaltime_day_of_week (tt)) { switch (i_cal_time_day_of_week (tt)) {
case 1: case 1:
weekday = G_DATE_SUNDAY; weekday = G_DATE_SUNDAY;
break; break;
case 2: case 2:
weekday = G_DATE_MONDAY; weekday = G_DATE_MONDAY;
break; break;
case 3: case 3:
weekday = G_DATE_TUESDAY; weekday = G_DATE_TUESDAY;
break; break;
case 4: case 4:
skipping to change at line 610 skipping to change at line 610
weekday = G_DATE_FRIDAY; weekday = G_DATE_FRIDAY;
break; break;
case 7: case 7:
weekday = G_DATE_SATURDAY; weekday = G_DATE_SATURDAY;
break; break;
default: default:
weekday = G_DATE_BAD_WEEKDAY; weekday = G_DATE_BAD_WEEKDAY;
break; break;
} }
g_clear_object (&tt);
e_cal_model_get_work_day_range_for (model, weekday, e_cal_model_get_work_day_range_for (model, weekday,
start_hour, start_minute, start_hour, start_minute,
end_hour, end_minute); end_hour, end_minute);
} else { } else {
*start_hour = e_cal_model_get_work_day_start_hour (model); *start_hour = e_cal_model_get_work_day_start_hour (model);
*start_minute = e_cal_model_get_work_day_start_minute (model); *start_minute = e_cal_model_get_work_day_start_minute (model);
*end_hour = e_cal_model_get_work_day_end_hour (model); *end_hour = e_cal_model_get_work_day_end_hour (model);
*end_minute = e_cal_model_get_work_day_end_minute (model); *end_minute = e_cal_model_get_work_day_end_minute (model);
} }
} }
skipping to change at line 753 skipping to change at line 755
if (ned) { if (ned) {
g_clear_object (&ned->day_view); g_clear_object (&ned->day_view);
g_free (ned->key_event); g_free (ned->key_event);
g_free (ned); g_free (ned);
} }
} }
static void static void
day_view_new_event_in_selected_range_cb (ECalModel *model, day_view_new_event_in_selected_range_cb (ECalModel *model,
ECalClient *client, ECalClient *client,
icalcomponent *default_component, ICalComponent *default_component,
gpointer user_data) gpointer user_data)
{ {
NewEventInRangeData *ned = user_data; NewEventInRangeData *ned = user_data;
ECalComponent *comp = NULL; ECalComponent *comp = NULL;
gint day, event_num; gint day, event_num;
ECalComponentDateTime start_dt, end_dt; ECalComponentDateTime *start_dt, *end_dt;
struct icaltimetype start_tt, end_tt; ICalTime *start_tt, *end_tt;
const gchar *uid; const gchar *uid, *use_tzid;
AddEventData add_event_data; AddEventData add_event_data;
ESourceRegistry *registry; ESourceRegistry *registry;
icaltimezone *zone; ICalTimezone *zone;
g_return_if_fail (ned != NULL); g_return_if_fail (ned != NULL);
g_return_if_fail (E_IS_CAL_MODEL (model)); g_return_if_fail (E_IS_CAL_MODEL (model));
g_return_if_fail (E_IS_CAL_CLIENT (client)); g_return_if_fail (E_IS_CAL_CLIENT (client));
g_return_if_fail (default_component != NULL); g_return_if_fail (default_component != NULL);
/* Check if the client is read only */ /* Check if the client is read only */
if (e_client_is_readonly (E_CLIENT (client))) if (e_client_is_readonly (E_CLIENT (client)))
return; return;
registry = e_cal_model_get_registry (model); registry = e_cal_model_get_registry (model);
zone = e_cal_model_get_timezone (model); zone = e_cal_model_get_timezone (model);
uid = icalcomponent_get_uid (default_component); uid = i_cal_component_get_uid (default_component);
comp = e_cal_component_new_from_icalcomponent (icalcomponent_new_clone (d efault_component)); comp = e_cal_component_new_from_icalcomponent (i_cal_component_clone (def ault_component));
g_return_if_fail (comp != NULL); g_return_if_fail (comp != NULL);
start_tt = icaltime_from_timet_with_zone (ned->dtstart, FALSE, zone); start_tt = i_cal_time_new_from_timet_with_zone (ned->dtstart, FALSE, zone
end_tt = icaltime_from_timet_with_zone (ned->dtend, FALSE, zone); );
end_tt = i_cal_time_new_from_timet_with_zone (ned->dtend, FALSE, zone);
if (ned->in_top_canvas) { if (ned->in_top_canvas) {
start_dt.tzid = NULL; use_tzid = NULL;
start_tt.is_date = 1; i_cal_time_set_is_date (start_tt, 1);
end_tt.is_date = 1; i_cal_time_set_is_date (end_tt, 1);
/* Editor default in day/work-week view - top canvas */ /* Editor default in day/work-week view - top canvas */
e_cal_component_set_transparency (comp, E_CAL_COMPONENT_TRANSP_TR ANSPARENT); e_cal_component_set_transparency (comp, E_CAL_COMPONENT_TRANSP_TR ANSPARENT);
} else { } else {
start_dt.tzid = icaltimezone_get_tzid (zone); use_tzid = i_cal_timezone_get_tzid (zone);
/* Editor default in day/work-week view - main canvas */ /* Editor default in day/work-week view - main canvas */
e_cal_component_set_transparency (comp, E_CAL_COMPONENT_TRANSP_OP AQUE); e_cal_component_set_transparency (comp, E_CAL_COMPONENT_TRANSP_OP AQUE);
} }
start_dt.value = &start_tt; start_dt = e_cal_component_datetime_new_take (start_tt, g_strdup (use_tzi
end_dt.value = &end_tt; d));
end_dt.tzid = start_dt.tzid; end_dt = e_cal_component_datetime_new_take (end_tt, g_strdup (use_tzid));
e_cal_component_set_dtstart (comp, &start_dt);
e_cal_component_set_dtend (comp, &end_dt); e_cal_component_set_dtstart (comp, start_dt);
e_cal_component_set_dtend (comp, end_dt);
e_cal_component_datetime_free (start_dt);
e_cal_component_datetime_free (end_dt);
/* We add the event locally and start editing it. We don't send it /* We add the event locally and start editing it. We don't send it
* to the server until the user finishes editing it. */ * to the server until the user finishes editing it. */
add_event_data.day_view = ned->day_view; add_event_data.day_view = ned->day_view;
add_event_data.comp_data = NULL; add_event_data.comp_data = NULL;
e_day_view_add_event (registry, client, comp, ned->dtstart, ned->dtend, & add_event_data); e_day_view_add_event (registry, client, comp, ned->dtstart, ned->dtend, & add_event_data);
e_day_view_check_layout (ned->day_view); e_day_view_check_layout (ned->day_view);
gtk_widget_queue_draw (ned->day_view->top_canvas); gtk_widget_queue_draw (ned->day_view->top_canvas);
gtk_widget_queue_draw (ned->day_view->main_canvas); gtk_widget_queue_draw (ned->day_view->main_canvas);
skipping to change at line 2537 skipping to change at line 2542
static void static void
e_day_view_precalc_visible_time_range (ECalendarView *cal_view, e_day_view_precalc_visible_time_range (ECalendarView *cal_view,
time_t in_start_time, time_t in_start_time,
time_t in_end_time, time_t in_end_time,
time_t *out_start_time, time_t *out_start_time,
time_t *out_end_time) time_t *out_end_time)
{ {
EDayView *day_view; EDayView *day_view;
gint days_shown; gint days_shown;
time_t lower; time_t lower;
icaltimezone *zone; ICalTimezone *zone;
g_return_if_fail (E_IS_DAY_VIEW (cal_view)); g_return_if_fail (E_IS_DAY_VIEW (cal_view));
g_return_if_fail (out_start_time != NULL); g_return_if_fail (out_start_time != NULL);
g_return_if_fail (out_end_time != NULL); g_return_if_fail (out_end_time != NULL);
day_view = E_DAY_VIEW (cal_view); day_view = E_DAY_VIEW (cal_view);
days_shown = e_day_view_get_days_shown (day_view); days_shown = e_day_view_get_days_shown (day_view);
zone = e_calendar_view_get_timezone (cal_view); zone = e_calendar_view_get_timezone (cal_view);
/* Calculate the first day that should be shown, based on start_time /* Calculate the first day that should be shown, based on start_time
skipping to change at line 2625 skipping to change at line 2630
/* update the time canvas to show proper date in it */ /* update the time canvas to show proper date in it */
eti = E_DAY_VIEW_TIME_ITEM (day_view->time_canvas_item); eti = E_DAY_VIEW_TIME_ITEM (day_view->time_canvas_item);
if (eti && e_day_view_time_item_get_second_zone (eti)) if (eti && e_day_view_time_item_get_second_zone (eti))
gtk_widget_queue_draw (day_view->time_canvas); gtk_widget_queue_draw (day_view->time_canvas);
} }
static void static void
process_component (EDayView *day_view, process_component (EDayView *day_view,
ECalModelComponent *comp_data) ECalModelComponent *comp_data)
{ {
const gchar *uid;
gchar *rid = NULL;
ECalModel *model; ECalModel *model;
ECalComponent *comp; ECalComponent *comp;
ESourceRegistry *registry; ESourceRegistry *registry;
AddEventData add_event_data; AddEventData add_event_data;
model = e_calendar_view_get_model (E_CALENDAR_VIEW (day_view)); model = e_calendar_view_get_model (E_CALENDAR_VIEW (day_view));
registry = e_cal_model_get_registry (model); registry = e_cal_model_get_registry (model);
/* If our time hasn't been set yet, just return. */ /* If our time hasn't been set yet, just return. */
if (day_view->lower == 0 && day_view->upper == 0) if (day_view->lower == 0 && day_view->upper == 0)
return; return;
comp = e_cal_component_new (); comp = e_cal_component_new_from_icalcomponent (i_cal_component_clone (com
if (!e_cal_component_set_icalcomponent (comp, icalcomponent_new_clone (co p_data->icalcomp));
mp_data->icalcomp))) { if (!comp) {
g_object_unref (comp); g_message (G_STRLOC ": Could not set ICalComponent on ECalCompone
nt");
g_message (G_STRLOC ": Could not set icalcomponent on ECalCompone
nt");
return; return;
} }
e_cal_component_get_uid (comp, &uid);
if (e_cal_component_is_instance (comp))
rid = e_cal_component_get_recurid_as_string (comp);
else
rid = NULL;
/* rid is never used below here, why? */
/* Add the object */ /* Add the object */
add_event_data.day_view = day_view; add_event_data.day_view = day_view;
add_event_data.comp_data = comp_data; add_event_data.comp_data = comp_data;
e_day_view_add_event ( e_day_view_add_event (
registry, comp_data->client, comp, comp_data->instance_start, registry, comp_data->client, comp, comp_data->instance_start,
comp_data->instance_end, &add_event_data); comp_data->instance_end, &add_event_data);
g_object_unref (comp); g_object_unref (comp);
g_free (rid);
} }
static void static void
update_row (EDayView *day_view, update_row (EDayView *day_view,
gint row, gint row,
gboolean do_cancel_editing) gboolean do_cancel_editing)
{ {
ECalModelComponent *comp_data; ECalModelComponent *comp_data;
ECalModel *model; ECalModel *model;
gint day, event_num; gint day, event_num;
const gchar *uid = NULL; const gchar *uid;
gchar *rid = NULL; gchar *rid;
if (do_cancel_editing) if (do_cancel_editing)
cancel_editing (day_view); cancel_editing (day_view);
else else
e_day_view_stop_editing_event (day_view); e_day_view_stop_editing_event (day_view);
model = e_calendar_view_get_model (E_CALENDAR_VIEW (day_view)); model = e_calendar_view_get_model (E_CALENDAR_VIEW (day_view));
comp_data = e_cal_model_get_component_at (model, row); comp_data = e_cal_model_get_component_at (model, row);
g_return_if_fail (comp_data != NULL); g_return_if_fail (comp_data != NULL);
uid = icalcomponent_get_uid (comp_data->icalcomp); uid = i_cal_component_get_uid (comp_data->icalcomp);
if (e_cal_util_component_is_instance (comp_data->icalcomp)) { rid = e_cal_util_component_get_recurid_as_string (comp_data->icalcomp);
icalproperty *prop;
prop = icalcomponent_get_first_property (comp_data->icalcomp, ICA
L_RECURRENCEID_PROPERTY);
if (prop)
rid = icaltime_as_ical_string_r (icalcomponent_get_recurr
enceid (comp_data->icalcomp));
}
if (e_day_view_find_event_from_uid (day_view, comp_data->client, uid, rid , &day, &event_num)) if (e_day_view_find_event_from_uid (day_view, comp_data->client, uid, rid , &day, &event_num))
e_day_view_remove_event_cb (day_view, day, event_num, NULL); e_day_view_remove_event_cb (day_view, day, event_num, NULL);
g_free (rid); g_free (rid);
process_component (day_view, comp_data); process_component (day_view, comp_data);
gtk_widget_queue_draw (day_view->top_canvas); gtk_widget_queue_draw (day_view->top_canvas);
gtk_widget_queue_draw (day_view->main_canvas); gtk_widget_queue_draw (day_view->main_canvas);
skipping to change at line 2794 skipping to change at line 2781
e_day_view_free_events (day_view); e_day_view_free_events (day_view);
day_view->requires_update = TRUE; day_view->requires_update = TRUE;
return; return;
} }
e_day_view_stop_editing_event (day_view); e_day_view_stop_editing_event (day_view);
for (l = list; l != NULL; l = g_slist_next (l)) { for (l = list; l != NULL; l = g_slist_next (l)) {
ECalModelComponent *comp_data = l->data; ECalModelComponent *comp_data = l->data;
gint day, event_num; gint day, event_num;
const gchar *uid = NULL; const gchar *uid;
gchar *rid = NULL; gchar *rid;
uid = icalcomponent_get_uid (comp_data->icalcomp); uid = i_cal_component_get_uid (comp_data->icalcomp);
if (e_cal_util_component_is_instance (comp_data->icalcomp)) { rid = e_cal_util_component_get_recurid_as_string (comp_data->ical
icalproperty *prop; comp);
prop = icalcomponent_get_first_property (comp_data->icalc
omp, ICAL_RECURRENCEID_PROPERTY);
if (prop)
rid = icaltime_as_ical_string_r (icalcomponent_ge
t_recurrenceid (comp_data->icalcomp));
}
if (e_day_view_find_event_from_uid (day_view, comp_data->client, uid, rid, &day, &event_num)) if (e_day_view_find_event_from_uid (day_view, comp_data->client, uid, rid, &day, &event_num))
e_day_view_remove_event_cb (day_view, day, event_num, NUL L); e_day_view_remove_event_cb (day_view, day, event_num, NUL L);
g_free (rid); g_free (rid);
} }
gtk_widget_queue_draw (day_view->top_canvas); gtk_widget_queue_draw (day_view->top_canvas);
gtk_widget_queue_draw (day_view->main_canvas); gtk_widget_queue_draw (day_view->main_canvas);
e_day_view_queue_layout (day_view); e_day_view_queue_layout (day_view);
} }
static void static void
timezone_changed_cb (ECalModel *cal_model, timezone_changed_cb (ECalModel *cal_model,
icaltimezone *old_zone, ICalTimezone *old_zone,
icaltimezone *new_zone, ICalTimezone *new_zone,
gpointer user_data) gpointer user_data)
{ {
struct icaltimetype tt; ICalTime *tt;
time_t lower; time_t lower;
EDayView *day_view = (EDayView *) user_data; EDayView *day_view = (EDayView *) user_data;
ECalendarView *cal_view = (ECalendarView *) day_view; ECalendarView *cal_view = (ECalendarView *) day_view;
g_return_if_fail (E_IS_DAY_VIEW (day_view)); g_return_if_fail (E_IS_DAY_VIEW (day_view));
e_day_view_update_timezone_name_labels (day_view);
if (!cal_view->in_focus) { if (!cal_view->in_focus) {
e_day_view_free_events (day_view); e_day_view_free_events (day_view);
day_view->requires_update = TRUE; day_view->requires_update = TRUE;
return; return;
} }
/* If our time hasn't been set yet, just return. */ /* If our time hasn't been set yet, just return. */
if (day_view->lower == 0 && day_view->upper == 0) if (day_view->lower == 0 && day_view->upper == 0)
return; return;
/* Recalculate the new start of the first day. We just use exactly /* Recalculate the new start of the first day. We just use exactly
* the same time, but with the new timezone. */ * the same time, but with the new timezone. */
tt = icaltime_from_timet_with_zone ( tt = i_cal_time_new_from_timet_with_zone (
day_view->lower, FALSE, day_view->lower, FALSE,
old_zone); old_zone);
lower = icaltime_as_timet_with_zone (tt, new_zone); lower = i_cal_time_as_timet_with_zone (tt, new_zone);
g_clear_object (&tt);
e_day_view_recalc_day_starts (day_view, lower); e_day_view_recalc_day_starts (day_view, lower);
e_day_view_update_query (day_view); e_day_view_update_query (day_view);
e_day_view_update_timezone_name_labels (day_view);
} }
static void static void
init_model (EDayView *day_view, init_model (EDayView *day_view,
ECalModel *model) ECalModel *model)
{ {
gulong handler_id; gulong handler_id;
handler_id = g_signal_connect ( handler_id = g_signal_connect (
model, "time_range_changed", model, "time_range_changed",
skipping to change at line 3170 skipping to change at line 3154
for (day = 0; day < days_shown; day++) { for (day = 0; day < days_shown; day++) {
for (event_num = day_view->events[day]->len - 1; for (event_num = day_view->events[day]->len - 1;
event_num >= 0; event_num >= 0;
event_num--) { event_num--) {
event = &g_array_index (day_view->events[day], event = &g_array_index (day_view->events[day],
EDayViewEvent, event_num); EDayViewEvent, event_num);
if (!is_comp_data_valid (event)) if (!is_comp_data_valid (event))
continue; continue;
u = icalcomponent_get_uid (event->comp_data->icalcomp); u = i_cal_component_get_uid (event->comp_data->icalcomp);
if (u && !strcmp (uid, u)) { if (u && !strcmp (uid, u)) {
if (!(*callback) (day_view, day, event_num, data) ) if (!(*callback) (day_view, day, event_num, data) )
return; return;
} }
} }
} }
for (event_num = day_view->long_events->len - 1; for (event_num = day_view->long_events->len - 1;
event_num >= 0; event_num >= 0;
event_num--) { event_num--) {
event = &g_array_index (day_view->long_events, event = &g_array_index (day_view->long_events,
EDayViewEvent, event_num); EDayViewEvent, event_num);
if (!is_comp_data_valid (event)) if (!is_comp_data_valid (event))
continue; continue;
u = icalcomponent_get_uid (event->comp_data->icalcomp); u = i_cal_component_get_uid (event->comp_data->icalcomp);
if (u && !strcmp (uid, u)) { 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; return;
} }
} }
} }
static gboolean static gboolean
e_day_view_remove_event_cb (EDayView *day_view, e_day_view_remove_event_cb (EDayView *day_view,
gint day, gint day,
skipping to change at line 3217 skipping to change at line 3201
event = &g_array_index (day_view->long_events, event = &g_array_index (day_view->long_events,
EDayViewEvent, event_num); EDayViewEvent, event_num);
} else { } else {
if (!is_array_index_in_bounds (day_view->events[day], event_num)) if (!is_array_index_in_bounds (day_view->events[day], event_num))
return TRUE; return TRUE;
event = &g_array_index (day_view->events[day], event = &g_array_index (day_view->events[day],
EDayViewEvent, event_num); EDayViewEvent, event_num);
} }
if (!event)
return TRUE;
/* If we were editing this event, set editing_event_day to -1 so /* If we were editing this event, set editing_event_day to -1 so
* on_editing_stopped doesn't try to update the event. */ * on_editing_stopped doesn't try to update the event. */
if (day_view->editing_event_num == event_num && day_view->editing_event_d ay == day) { if (day_view->editing_event_num == event_num && day_view->editing_event_d ay == day) {
cancel_editing (day_view); cancel_editing (day_view);
day_view->editing_event_num = -1; day_view->editing_event_num = -1;
day_view->editing_event_day = -1; day_view->editing_event_day = -1;
g_object_notify (G_OBJECT (day_view), "is-editing"); g_object_notify (G_OBJECT (day_view), "is-editing");
} else if (day_view->editing_event_num > event_num && day_view->editing_e vent_day == day) { } else if (day_view->editing_event_num > event_num && day_view->editing_e vent_day == day) {
day_view->editing_event_num--; day_view->editing_event_num--;
} }
skipping to change at line 3311 skipping to change at line 3292
} }
/* Checks if the users participation status is NEEDS-ACTION and shows the summar y as bold text */ /* Checks if the users participation status is NEEDS-ACTION and shows the summar y as bold text */
static void static void
set_style_from_attendee (EDayViewEvent *event, set_style_from_attendee (EDayViewEvent *event,
ESourceRegistry *registry) ESourceRegistry *registry)
{ {
ECalComponent *comp; ECalComponent *comp;
GSList *attendees = NULL, *l; GSList *attendees = NULL, *l;
gchar *address; gchar *address;
ECalComponentAttendee *at = NULL; ICalParameterPartstat partstat = I_CAL_PARTSTAT_NONE;
if (!is_comp_data_valid (event)) if (!is_comp_data_valid (event))
return; return;
comp = e_cal_component_new (); comp = e_cal_component_new_from_icalcomponent (i_cal_component_clone (eve
e_cal_component_set_icalcomponent (comp, icalcomponent_new_clone (event-> nt->comp_data->icalcomp));
comp_data->icalcomp)); if (!comp)
address = itip_get_comp_attendee ( return;
registry, comp, event->comp_data->client);
e_cal_component_get_attendee_list (comp, &attendees); address = itip_get_comp_attendee (registry, comp, event->comp_data->clien
for (l = attendees; l; l = l->next) { t);
attendees = e_cal_component_get_attendees (comp);
for (l = attendees; l && address; l = l->next) {
ECalComponentAttendee *attendee = l->data; ECalComponentAttendee *attendee = l->data;
const gchar *value, *sentby;
if ((attendee->value && g_strcmp0 (itip_strip_mailto (attendee->v value = e_cal_component_attendee_get_value (attendee);
alue), address) == 0) if (value)
|| (attendee->sentby && g_strcmp0 (itip_strip_mailto (attendee-> value = itip_strip_mailto (value);
sentby), address) == 0)) {
at = attendee; sentby = e_cal_component_attendee_get_sentby (attendee);
if (sentby)
value = itip_strip_mailto (sentby);
if ((value && g_ascii_strcasecmp (value, address) == 0) ||
(sentby && g_ascii_strcasecmp (sentby, address) == 0)) {
partstat = e_cal_component_attendee_get_partstat (attende
e);
break; break;
} }
} }
if (icalcomponent_get_status (event->comp_data->icalcomp) == ICAL_STATUS_ CANCELLED) if (i_cal_component_get_status (event->comp_data->icalcomp) == I_CAL_STAT US_CANCELLED)
gnome_canvas_item_set (event->canvas_item, "strikeout", TRUE, NUL L); gnome_canvas_item_set (event->canvas_item, "strikeout", TRUE, NUL L);
/* The attendee has not yet accepted the meeting, display the summary as bolded. /* The attendee has not yet accepted the meeting, display the summary as bolded.
* If the attendee is not present, it might have come through a mailing l ist. * If the attendee is not present, it might have come through a mailing l ist.
* In that case, we never show the meeting as bold even if it is unaccept ed. */ * In that case, we never show the meeting as bold even if it is unaccept ed. */
if (at && (at->status == ICAL_PARTSTAT_NEEDSACTION)) if (partstat == I_CAL_PARTSTAT_NEEDSACTION)
gnome_canvas_item_set (event->canvas_item, "bold", TRUE, NULL); gnome_canvas_item_set (event->canvas_item, "bold", TRUE, NULL);
else if (at && at->status == ICAL_PARTSTAT_DECLINED) else if (partstat == I_CAL_PARTSTAT_DECLINED)
gnome_canvas_item_set (event->canvas_item, "strikeout", TRUE, NUL L); gnome_canvas_item_set (event->canvas_item, "strikeout", TRUE, NUL L);
else if (at && at->status == ICAL_PARTSTAT_TENTATIVE) else if (partstat == I_CAL_PARTSTAT_TENTATIVE)
gnome_canvas_item_set (event->canvas_item, "italic", TRUE, NULL); gnome_canvas_item_set (event->canvas_item, "italic", TRUE, NULL);
else if (at && at->status == ICAL_PARTSTAT_DELEGATED) else if (partstat == I_CAL_PARTSTAT_DELEGATED)
gnome_canvas_item_set (event->canvas_item, "italic", TRUE, "strik eout", TRUE, NULL); gnome_canvas_item_set (event->canvas_item, "italic", TRUE, "strik eout", TRUE, NULL);
e_cal_component_free_attendee_list (attendees); g_slist_free_full (attendees, e_cal_component_attendee_free);
g_free (address); g_free (address);
g_object_unref (comp); g_object_unref (comp);
} }
/* This updates the text shown for an event. If the event start or end do not /* This updates the text shown for an event. If the event start or end do not
* lie on a row boundary, the time is displayed before the summary. */ * lie on a row boundary, the time is displayed before the summary. */
static void static void
e_day_view_update_event_label (EDayView *day_view, e_day_view_update_event_label (EDayView *day_view,
gint day, gint day,
gint event_num) gint event_num)
skipping to change at line 3377 skipping to change at line 3368
if (!is_array_index_in_bounds (day_view->events[day], event_num)) if (!is_array_index_in_bounds (day_view->events[day], event_num))
return; return;
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 the event isn't visible just return. */
if (!event->canvas_item || !is_comp_data_valid (event)) if (!event->canvas_item || !is_comp_data_valid (event))
return; return;
summary = icalcomponent_get_summary (event->comp_data->icalcomp); summary = i_cal_component_get_summary (event->comp_data->icalcomp);
text = summary ? (gchar *) summary : (gchar *) ""; text = summary ? (gchar *) summary : (gchar *) "";
if (day_view->editing_event_day == day if (day_view->editing_event_day == day
&& day_view->editing_event_num == event_num) && day_view->editing_event_num == event_num)
editing_event = TRUE; editing_event = TRUE;
interval = event->end_minute - event->start_minute; interval = event->end_minute - event->start_minute;
cal_view = E_CALENDAR_VIEW (day_view); cal_view = E_CALENDAR_VIEW (day_view);
model = e_calendar_view_get_model (cal_view); model = e_calendar_view_get_model (cal_view);
skipping to change at line 3408 skipping to change at line 3399
} }
} else } else
short_event = FALSE; short_event = FALSE;
if (!editing_event) { if (!editing_event) {
if (!short_event) { if (!short_event) {
const gchar *description, *location; const gchar *description, *location;
gint days_shown; gint days_shown;
days_shown = e_day_view_get_days_shown (day_view); days_shown = e_day_view_get_days_shown (day_view);
description = icalcomponent_get_description (event->comp_ description = i_cal_component_get_description (event->com
data->icalcomp); p_data->icalcomp);
location = icalcomponent_get_location (event->comp_data-> location = i_cal_component_get_location (event->comp_data
icalcomp); ->icalcomp);
if (description && *description) { if (description && *description) {
if (location && *location) if (location && *location)
text = g_strdup_printf (" \n%s%c(%s)\n\n% s", text, days_shown == 1 ? ' ' : '\n', location, description); text = g_strdup_printf (" \n%s%c(%s)\n\n% s", text, days_shown == 1 ? ' ' : '\n', location, description);
else else
text = g_strdup_printf (" \n%s\n\n%s", te xt, description); text = g_strdup_printf (" \n%s\n\n%s", te xt, description);
} else if (location && *location) } else if (location && *location)
text = g_strdup_printf (" \n%s%c(%s)", text, days _shown == 1 ? ' ' : '\n', location); text = g_strdup_printf (" \n%s%c(%s)", text, days _shown == 1 ? ' ' : '\n', location);
else else
text = g_strdup_printf (" \n%s", text); text = g_strdup_printf (" \n%s", text);
skipping to change at line 3432 skipping to change at line 3423
} }
} }
gnome_canvas_item_set ( gnome_canvas_item_set (
event->canvas_item, event->canvas_item,
"text", text, "text", text,
NULL); NULL);
if (e_cal_util_component_has_attendee (event->comp_data->icalcomp)) if (e_cal_util_component_has_attendee (event->comp_data->icalcomp))
set_style_from_attendee (event, registry); set_style_from_attendee (event, registry);
else if (icalcomponent_get_status (event->comp_data->icalcomp) == ICAL_ST ATUS_CANCELLED) else if (i_cal_component_get_status (event->comp_data->icalcomp) == I_CAL _STATUS_CANCELLED)
gnome_canvas_item_set (event->canvas_item, "strikeout", TRUE, NUL L); gnome_canvas_item_set (event->canvas_item, "strikeout", TRUE, NUL L);
if (free_text) if (free_text)
g_free (text); g_free (text);
} }
static void static void
e_day_view_update_long_event_label (EDayView *day_view, e_day_view_update_long_event_label (EDayView *day_view,
gint event_num) gint event_num)
{ {
EDayViewEvent *event; EDayViewEvent *event;
ECalendarView *cal_view; ECalendarView *cal_view;
ECalModel *model; ECalModel *model;
ESourceRegistry *registry; ESourceRegistry *registry;
const gchar *summary; gchar *summary;
gboolean free_text = FALSE;
cal_view = E_CALENDAR_VIEW (day_view); cal_view = E_CALENDAR_VIEW (day_view);
model = e_calendar_view_get_model (cal_view); model = e_calendar_view_get_model (cal_view);
registry = e_cal_model_get_registry (model); registry = e_cal_model_get_registry (model);
if (!is_array_index_in_bounds (day_view->long_events, event_num)) if (!is_array_index_in_bounds (day_view->long_events, event_num))
return; return;
event = &g_array_index (day_view->long_events, EDayViewEvent, event = &g_array_index (day_view->long_events, EDayViewEvent,
event_num); event_num);
/* If the event isn't visible just return. */ /* If the event isn't visible just return. */
if (!event->canvas_item || !is_comp_data_valid (event)) if (!event->canvas_item || !is_comp_data_valid (event))
return; return;
summary = e_calendar_view_get_icalcomponent_summary (event->comp_data->cl ient, event->comp_data->icalcomp, &free_text); summary = e_calendar_view_dup_component_summary (event->comp_data->icalco mp);
gnome_canvas_item_set ( gnome_canvas_item_set (
event->canvas_item, event->canvas_item,
"text", summary ? summary : "", "text", summary ? summary : "",
NULL); NULL);
if (free_text) g_free (summary);
g_free ((gchar *) summary);
if (e_cal_util_component_has_attendee (event->comp_data->icalcomp)) if (e_cal_util_component_has_attendee (event->comp_data->icalcomp))
set_style_from_attendee (event, registry); set_style_from_attendee (event, registry);
else if (icalcomponent_get_status (event->comp_data->icalcomp) == ICAL_ST ATUS_CANCELLED) else if (i_cal_component_get_status (event->comp_data->icalcomp) == I_CAL _STATUS_CANCELLED)
gnome_canvas_item_set (event->canvas_item, "strikeout", TRUE, NUL L); gnome_canvas_item_set (event->canvas_item, "strikeout", TRUE, NUL L);
} }
/* Finds the day and index of the event with the given canvas item. /* Finds the day and index of the event with the given canvas item.
* If is is a long event, -1 is returned as the day. * If is is a long event, -1 is returned as the day.
* Returns TRUE if the event was found. */ * Returns TRUE if the event was found. */
gboolean gboolean
e_day_view_find_event_from_item (EDayView *day_view, e_day_view_find_event_from_item (EDayView *day_view,
GnomeCanvasItem *item, GnomeCanvasItem *item,
gint *day_return, gint *day_return,
skipping to change at line 3561 skipping to change at line 3550
event_num++) { event_num++) {
event = &g_array_index (day_view->events[day], event = &g_array_index (day_view->events[day],
EDayViewEvent, event_num); EDayViewEvent, event_num);
if (!is_comp_data_valid (event)) if (!is_comp_data_valid (event))
continue; continue;
if (event->comp_data->client != client) if (event->comp_data->client != client)
continue; continue;
u = icalcomponent_get_uid (event->comp_data->icalcomp); u = i_cal_component_get_uid (event->comp_data->icalcomp);
if (u && !strcmp (uid, u)) { if (u && !strcmp (uid, u)) {
if (rid && *rid) { if (rid && *rid) {
r = icaltime_as_ical_string_r (icalcompon r = e_cal_util_component_get_recurid_as_s
ent_get_recurrenceid (event->comp_data->icalcomp)); tring (event->comp_data->icalcomp);
if (!r || !*r)
continue; if (!r || !*r || strcmp (rid, r) != 0) {
if (strcmp (rid, r) != 0) {
g_free (r); g_free (r);
continue; continue;
} }
g_free (r); g_free (r);
} }
*day_return = day; *day_return = day;
*event_num_return = event_num; *event_num_return = event_num;
return TRUE; return TRUE;
} }
} }
} }
skipping to change at line 3592 skipping to change at line 3581
event_num++) { event_num++) {
event = &g_array_index (day_view->long_events, event = &g_array_index (day_view->long_events,
EDayViewEvent, event_num); EDayViewEvent, event_num);
if (!is_comp_data_valid (event)) if (!is_comp_data_valid (event))
continue; continue;
if (event->comp_data->client != client) if (event->comp_data->client != client)
continue; continue;
u = icalcomponent_get_uid (event->comp_data->icalcomp); u = i_cal_component_get_uid (event->comp_data->icalcomp);
if (u && !strcmp (uid, u)) { if (u && !strcmp (uid, u)) {
*day_return = E_DAY_VIEW_LONG_EVENT; *day_return = E_DAY_VIEW_LONG_EVENT;
*event_num_return = event_num; *event_num_return = event_num;
return TRUE; return TRUE;
} }
} }
return FALSE; return FALSE;
} }
skipping to change at line 3729 skipping to change at line 3718
/* Finds the start of the working week which includes the given time. */ /* Finds the start of the working week which includes the given time. */
static time_t static time_t
e_day_view_find_work_week_start (EDayView *day_view, e_day_view_find_work_week_start (EDayView *day_view,
time_t start_time) time_t start_time)
{ {
GDate date; GDate date;
ECalModel *model; ECalModel *model;
guint offset; guint offset;
GDateWeekday weekday; GDateWeekday weekday;
GDateWeekday first_work_day; GDateWeekday first_work_day;
struct icaltimetype tt = icaltime_null_time (); ICalTime *tt = NULL;
icaltimezone *zone; ICalTimezone *zone;
time_t res;
model = e_calendar_view_get_model (E_CALENDAR_VIEW (day_view)); model = e_calendar_view_get_model (E_CALENDAR_VIEW (day_view));
zone = e_cal_model_get_timezone (model); zone = e_cal_model_get_timezone (model);
time_to_gdate_with_zone (&date, start_time, zone); time_to_gdate_with_zone (&date, start_time, zone);
/* The start of the work-week is the first working day after the /* The start of the work-week is the first working day after the
* week start day. */ * week start day. */
/* Get the weekday corresponding to start_time. */ /* Get the weekday corresponding to start_time. */
skipping to change at line 3757 skipping to change at line 3747
/* Calculate how many days we need to go back to the first workday. */ /* Calculate how many days we need to go back to the first workday. */
if (weekday < first_work_day) if (weekday < first_work_day)
offset = (weekday + 7) - first_work_day; offset = (weekday + 7) - first_work_day;
else else
offset = weekday - first_work_day; offset = weekday - first_work_day;
if (offset > 0) if (offset > 0)
g_date_subtract_days (&date, offset); g_date_subtract_days (&date, offset);
tt.year = g_date_get_year (&date); tt = i_cal_time_new_null_time ();
tt.month = g_date_get_month (&date);
tt.day = g_date_get_day (&date); i_cal_time_set_date (tt,
g_date_get_year (&date),
g_date_get_month (&date),
g_date_get_day (&date));
res = i_cal_time_as_timet_with_zone (tt, zone);
g_clear_object (&tt);
return icaltime_as_timet_with_zone (tt, zone); return res;
} }
static void static void
e_day_view_recalc_day_starts (EDayView *day_view, e_day_view_recalc_day_starts (EDayView *day_view,
time_t start_time) time_t start_time)
{ {
gint day; gint day;
gchar *str; gchar *str;
gint days_shown; gint days_shown;
struct icaltimetype tt; ICalTime *tt;
GDate dt; GDate dt;
days_shown = e_day_view_get_days_shown (day_view); days_shown = e_day_view_get_days_shown (day_view);
if (days_shown <= 0) if (days_shown <= 0)
return; return;
day_view->day_starts[0] = start_time; day_view->day_starts[0] = start_time;
for (day = 1; day <= days_shown; day++) { for (day = 1; day <= days_shown; day++) {
day_view->day_starts[day] = time_add_day_with_zone (day_view->day _starts[day - 1], 1, e_calendar_view_get_timezone (E_CALENDAR_VIEW (day_view))); day_view->day_starts[day] = time_add_day_with_zone (day_view->day _starts[day - 1], 1, e_calendar_view_get_timezone (E_CALENDAR_VIEW (day_view)));
} }
day_view->lower = start_time; day_view->lower = start_time;
day_view->upper = day_view->day_starts[days_shown]; day_view->upper = day_view->day_starts[days_shown];
tt = icaltime_from_timet_with_zone (day_view->day_starts[0], FALSE, e_cal endar_view_get_timezone (E_CALENDAR_VIEW (day_view))); tt = i_cal_time_new_from_timet_with_zone (day_view->day_starts[0], FALSE, e_calendar_view_get_timezone (E_CALENDAR_VIEW (day_view)));
g_date_clear (&dt, 1); g_date_clear (&dt, 1);
g_date_set_dmy (&dt, tt.day, tt.month, tt.year); g_date_set_dmy (&dt, i_cal_time_get_day (tt), i_cal_time_get_month (tt), i_cal_time_get_year (tt));
/* To Translators: the %d stands for a week number, it's value between 1 and 52/53 */ /* To Translators: the %d stands for a week number, it's value between 1 and 52/53 */
str = g_strdup_printf (_("Week %d"), g_date_get_iso8601_week_of_year (&dt )); str = g_strdup_printf (_("Week %d"), g_date_get_iso8601_week_of_year (&dt ));
gtk_label_set_text (GTK_LABEL (day_view->week_number_label), str); gtk_label_set_text (GTK_LABEL (day_view->week_number_label), str);
g_free (str); g_free (str);
e_day_view_recalc_work_week (day_view); e_day_view_recalc_work_week (day_view);
g_clear_object (&tt);
} }
/* Whether we are displaying a work-week, in which case the display always /* Whether we are displaying a work-week, in which case the display always
* starts on the first day of the working week. */ * starts on the first day of the working week. */
gboolean gboolean
e_day_view_get_work_week_view (EDayView *day_view) e_day_view_get_work_week_view (EDayView *day_view)
{ {
g_return_val_if_fail (E_IS_DAY_VIEW (day_view), FALSE); g_return_val_if_fail (E_IS_DAY_VIEW (day_view), FALSE);
return day_view->priv->work_week_view; return day_view->priv->work_week_view;
skipping to change at line 5411 skipping to change at line 5410
} }
/* This converts the resize start or end row back to a time and updates the /* This converts the resize start or end row back to a time and updates the
* event. */ * event. */
static void static void
e_day_view_finish_long_event_resize (EDayView *day_view) e_day_view_finish_long_event_resize (EDayView *day_view)
{ {
EDayViewEvent *event; EDayViewEvent *event;
gint event_num; gint event_num;
ECalComponent *comp; ECalComponent *comp;
ECalComponentDateTime date; ECalComponentDateTime *date = NULL;
struct icaltimetype itt;
time_t dt; time_t dt;
ECalModel *model; ECalModel *model;
ECalClient *client; ECalClient *client;
ESourceRegistry *registry; ESourceRegistry *registry;
ECalObjModType mod = E_CAL_OBJ_MOD_ALL; ECalObjModType mod = E_CAL_OBJ_MOD_ALL;
ICalTimezone *zone;
gint is_date; gint is_date;
model = e_calendar_view_get_model (E_CALENDAR_VIEW (day_view)); model = e_calendar_view_get_model (E_CALENDAR_VIEW (day_view));
registry = e_cal_model_get_registry (model); registry = e_cal_model_get_registry (model);
event_num = day_view->resize_event_num; event_num = day_view->resize_event_num;
if (!is_array_index_in_bounds (day_view->long_events, event_num)) if (!is_array_index_in_bounds (day_view->long_events, event_num))
return; return;
skipping to change at line 5439 skipping to change at line 5438
event_num); event_num);
if (!is_comp_data_valid (event)) if (!is_comp_data_valid (event))
return; return;
client = event->comp_data->client; client = event->comp_data->client;
/* We use a temporary copy of the comp since we don't want to /* 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 * change the original comp here. Otherwise we would not detect that
* the event's time had changed in the "update_event" callback. */ * the event's time had changed in the "update_event" callback. */
comp = e_cal_component_new (); comp = e_cal_component_new_from_icalcomponent (i_cal_component_clone (eve
e_cal_component_set_icalcomponent (comp, icalcomponent_new_clone (event-> nt->comp_data->icalcomp));
comp_data->icalcomp)); if (!comp)
return;
if (e_cal_component_has_attendees (comp) && if (e_cal_component_has_attendees (comp) &&
!itip_organizer_is_user (registry, comp, client)) { !itip_organizer_is_user (registry, comp, client)) {
g_object_unref (comp); g_object_unref (comp);
e_day_view_abort_resize (day_view); e_day_view_abort_resize (day_view);
return; return;
} }
date.value = &itt; zone = e_calendar_view_get_timezone (E_CALENDAR_VIEW (day_view));
date.tzid = NULL;
if (day_view->resize_drag_pos == E_CALENDAR_VIEW_POS_LEFT_EDGE) { if (day_view->resize_drag_pos == E_CALENDAR_VIEW_POS_LEFT_EDGE) {
ECalComponentDateTime ecdt; ECalComponentDateTime *ecdt;
ecdt = e_cal_component_get_dtstart (comp);
is_date = ecdt && e_cal_component_datetime_get_value (ecdt) &&
i_cal_time_is_date (e_cal_component_datetime_get_value
(ecdt));
e_cal_component_get_dtstart (comp, &ecdt);
is_date = ecdt.value && ecdt.value->is_date;
if (!is_date)
date.tzid = icaltimezone_get_tzid (e_calendar_view_get_ti
mezone (E_CALENDAR_VIEW (day_view)));
dt = day_view->day_starts[day_view->resize_start_row]; dt = day_view->day_starts[day_view->resize_start_row];
*date.value = icaltime_from_timet_with_zone (dt, is_date, date = e_cal_component_datetime_new_take (
e_calendar_view_get_ i_cal_time_new_from_timet_with_zone (dt, is_date, zone),
timezone (E_CALENDAR_VIEW (day_view))); (zone && !is_date) ? g_strdup (i_cal_timezone_get_tzid (z
cal_comp_set_dtstart_with_oldzone (client, comp, &date); one)) : NULL);
e_cal_component_free_datetime (&ecdt); cal_comp_set_dtstart_with_oldzone (client, comp, date);
date.tzid = NULL; /* do not reuse it later */
} else { e_cal_component_datetime_free (ecdt);
ECalComponentDateTime ecdt;
/* do not reuse it later */
e_cal_component_get_dtend (comp, &ecdt); e_cal_component_datetime_set_tzid (date, NULL);
is_date = ecdt.value && ecdt.value->is_date; } else {
if (!is_date) ECalComponentDateTime *ecdt;
date.tzid = icaltimezone_get_tzid (e_calendar_view_get_ti
mezone (E_CALENDAR_VIEW (day_view))); ecdt = e_cal_component_get_dtend (comp);
is_date = ecdt && e_cal_component_datetime_get_value (ecdt) &&
i_cal_time_is_date (e_cal_component_datetime_get_value
(ecdt));
dt = day_view->day_starts[day_view->resize_end_row + 1]; dt = day_view->day_starts[day_view->resize_end_row + 1];
*date.value = icaltime_from_timet_with_zone (dt, is_date, date = e_cal_component_datetime_new_take (
e_calendar_view_get_ i_cal_time_new_from_timet_with_zone (dt, is_date, zone),
timezone (E_CALENDAR_VIEW (day_view))); (zone && !is_date) ? g_strdup (i_cal_timezone_get_tzid (z
cal_comp_set_dtend_with_oldzone (client, comp, &date); one)) : NULL);
e_cal_component_free_datetime (&ecdt); cal_comp_set_dtend_with_oldzone (client, comp, date);
date.tzid = NULL; /* do not reuse it later */
e_cal_component_datetime_free (ecdt);
/* do not reuse it later */
e_cal_component_datetime_set_tzid (date, NULL);
} }
e_cal_component_commit_sequence (comp); e_cal_component_commit_sequence (comp);
if (e_cal_component_has_recurrences (comp)) { if (e_cal_component_has_recurrences (comp)) {
if (!e_cal_dialogs_recur_component (client, comp, &mod, NULL, FAL SE)) { if (!e_cal_dialogs_recur_component (client, comp, &mod, NULL, FAL SE)) {
gtk_widget_queue_draw (day_view->top_canvas); gtk_widget_queue_draw (day_view->top_canvas);
goto out; goto out;
} }
if (mod == E_CAL_OBJ_MOD_THIS) { if (mod == E_CAL_OBJ_MOD_THIS) {
/* set the correct DTSTART/DTEND on the individual recurr ence */ /* set the correct DTSTART/DTEND on the individual recurr ence */
if (day_view->resize_drag_pos == E_CALENDAR_VIEW_POS_TOP_ EDGE) { if (day_view->resize_drag_pos == E_CALENDAR_VIEW_POS_TOP_ EDGE) {
*date.value = icaltime_from_timet_with_zone ( e_cal_component_datetime_take_value (date,
event->comp_data->instance_end, FALSE, i_cal_time_new_from_timet_with_zone (even
e_calendar_view_get_timezone (E_CALENDAR_ t->comp_data->instance_end, FALSE, zone));
VIEW (day_view))); cal_comp_set_dtend_with_oldzone (client, comp, da
cal_comp_set_dtend_with_oldzone (client, comp, &d te);
ate);
} else { } else {
*date.value = icaltime_from_timet_with_zone ( e_cal_component_datetime_take_value (date,
event->comp_data->instance_start, FALSE, i_cal_time_new_from_timet_with_zone (even
e_calendar_view_get_timezone (E_CALENDAR_ t->comp_data->instance_start, FALSE, zone));
VIEW (day_view))); cal_comp_set_dtstart_with_oldzone (client, comp,
cal_comp_set_dtstart_with_oldzone (client, comp, date);
&date);
} }
e_cal_component_set_rdate_list (comp, NULL); e_cal_component_set_rdates (comp, NULL);
e_cal_component_set_rrule_list (comp, NULL); e_cal_component_set_rrules (comp, NULL);
e_cal_component_set_exdate_list (comp, NULL); e_cal_component_set_exdates (comp, NULL);
e_cal_component_set_exrule_list (comp, NULL); e_cal_component_set_exrules (comp, NULL);
} }
} else if (e_cal_component_is_instance (comp)) } else if (e_cal_component_is_instance (comp)) {
mod = E_CAL_OBJ_MOD_THIS; mod = E_CAL_OBJ_MOD_THIS;
}
e_cal_component_commit_sequence (comp); e_cal_component_commit_sequence (comp);
e_cal_ops_modify_component (model, client, e_cal_component_get_icalcompon ent (comp), e_cal_ops_modify_component (model, client, e_cal_component_get_icalcompon ent (comp),
mod, E_CAL_OPS_SEND_FLAG_ASK | E_CAL_OPS_SEND_FLAG_IS_NEW_COMPONE NT); mod, E_CAL_OPS_SEND_FLAG_ASK | E_CAL_OPS_SEND_FLAG_IS_NEW_COMPONE NT);
out: out:
day_view->resize_drag_pos = E_CALENDAR_VIEW_POS_NONE; day_view->resize_drag_pos = E_CALENDAR_VIEW_POS_NONE;
e_cal_component_datetime_free (date);
g_object_unref (comp); g_object_unref (comp);
} }
/* This converts the resize start or end row back to a time and updates the /* This converts the resize start or end row back to a time and updates the
* event. */ * event. */
static void static void
e_day_view_finish_resize (EDayView *day_view) e_day_view_finish_resize (EDayView *day_view)
{ {
EDayViewEvent *event; EDayViewEvent *event;
gint day, event_num; gint day, event_num;
ECalComponent *comp; ECalComponent *comp;
ECalComponentDateTime date; ECalComponentDateTime *date = NULL;
struct icaltimetype itt; ICalTimezone *zone;
time_t dt; time_t dt;
ECalModel *model; ECalModel *model;
ECalClient *client; ECalClient *client;
ESourceRegistry *registry; ESourceRegistry *registry;
ECalObjModType mod = E_CAL_OBJ_MOD_ALL; ECalObjModType mod = E_CAL_OBJ_MOD_ALL;
GtkWindow *toplevel; GtkWindow *toplevel;
GtkResponseType send = GTK_RESPONSE_NO; GtkResponseType send = GTK_RESPONSE_NO;
gboolean only_new_attendees = FALSE; gboolean only_new_attendees = FALSE;
gboolean strip_alarms = TRUE; gboolean strip_alarms = TRUE;
skipping to change at line 5563 skipping to change at line 5570
event_num); event_num);
if (!is_comp_data_valid (event)) if (!is_comp_data_valid (event))
return; return;
client = event->comp_data->client; client = event->comp_data->client;
/* We use a temporary shallow copy of the ico since we don't want to /* 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 * change the original ico here. Otherwise we would not detect that
* the event's time had changed in the "update_event" callback. */ * the event's time had changed in the "update_event" callback. */
comp = e_cal_component_new (); comp = e_cal_component_new_from_icalcomponent (i_cal_component_clone (eve
e_cal_component_set_icalcomponent (comp, icalcomponent_new_clone (event-> nt->comp_data->icalcomp));
comp_data->icalcomp)); if (!comp)
return;
if (e_cal_component_has_attendees (comp) && if (e_cal_component_has_attendees (comp) &&
!itip_organizer_is_user (registry, comp, client)) { !itip_organizer_is_user (registry, comp, client)) {
g_object_unref (comp); g_object_unref (comp);
e_day_view_abort_resize (day_view); e_day_view_abort_resize (day_view);
return; return;
} }
toplevel = GTK_WINDOW (gtk_widget_get_toplevel (GTK_WIDGET (day_view))); toplevel = GTK_WINDOW (gtk_widget_get_toplevel (GTK_WIDGET (day_view)));
skipping to change at line 5586 skipping to change at line 5594
(itip_organizer_is_user (registry, comp, client) || (itip_organizer_is_user (registry, comp, client) ||
itip_sentby_is_user (registry, comp, client))) itip_sentby_is_user (registry, comp, client)))
send = e_cal_dialogs_send_dragged_or_resized_component ( send = e_cal_dialogs_send_dragged_or_resized_component (
toplevel, client, comp, &strip_alarms, &only_new_ attendees); toplevel, client, comp, &strip_alarms, &only_new_ attendees);
if (send == GTK_RESPONSE_CANCEL) { if (send == GTK_RESPONSE_CANCEL) {
e_day_view_abort_resize (day_view); e_day_view_abort_resize (day_view);
goto out; goto out;
} }
date.value = &itt; zone = e_calendar_view_get_timezone (E_CALENDAR_VIEW (day_view));
date.tzid = icaltimezone_get_tzid (e_calendar_view_get_timezone (E_CALEND
AR_VIEW (day_view)));
if (day_view->resize_drag_pos == E_CALENDAR_VIEW_POS_TOP_EDGE) { if (day_view->resize_drag_pos == E_CALENDAR_VIEW_POS_TOP_EDGE) {
dt = e_day_view_convert_grid_position_to_time (day_view, day, day _view->resize_start_row); dt = e_day_view_convert_grid_position_to_time (day_view, day, day _view->resize_start_row);
*date.value = icaltime_from_timet_with_zone (dt, FALSE, date = e_cal_component_datetime_new_take (
e_calendar_view_get_ i_cal_time_new_from_timet_with_zone (dt, FALSE, zone),
timezone (E_CALENDAR_VIEW (day_view))); zone ? g_strdup (i_cal_timezone_get_tzid (zone)) : NULL);
cal_comp_set_dtstart_with_oldzone (client, comp, &date); cal_comp_set_dtstart_with_oldzone (client, comp, date);
} else { } else {
dt = e_day_view_convert_grid_position_to_time (day_view, day, day _view->resize_end_row + 1); dt = e_day_view_convert_grid_position_to_time (day_view, day, day _view->resize_end_row + 1);
*date.value = icaltime_from_timet_with_zone (dt, FALSE, date = e_cal_component_datetime_new_take (
e_calendar_view_get_ i_cal_time_new_from_timet_with_zone (dt, FALSE, zone),
timezone (E_CALENDAR_VIEW (day_view))); zone ? g_strdup (i_cal_timezone_get_tzid (zone)) : NULL);
cal_comp_set_dtend_with_oldzone (client, comp, &date); cal_comp_set_dtend_with_oldzone (client, comp, date);
} }
e_cal_component_commit_sequence (comp); e_cal_component_commit_sequence (comp);
if (day_view->last_edited_comp_string != NULL) { if (day_view->last_edited_comp_string != NULL) {
g_free (day_view->last_edited_comp_string); g_free (day_view->last_edited_comp_string);
day_view->last_edited_comp_string = NULL; day_view->last_edited_comp_string = NULL;
} }
day_view->last_edited_comp_string = e_cal_component_get_as_string (comp); day_view->last_edited_comp_string = e_cal_component_get_as_string (comp);
skipping to change at line 5625 skipping to change at line 5634
if (e_cal_component_has_recurrences (comp)) { if (e_cal_component_has_recurrences (comp)) {
if (!e_cal_dialogs_recur_component (client, comp, &mod, NULL, FAL SE)) { if (!e_cal_dialogs_recur_component (client, comp, &mod, NULL, FAL SE)) {
gtk_widget_queue_draw (day_view->main_canvas); gtk_widget_queue_draw (day_view->main_canvas);
goto out; goto out;
} }
if (mod == E_CAL_OBJ_MOD_THIS) { if (mod == E_CAL_OBJ_MOD_THIS) {
/* set the correct DTSTART/DTEND on the individual recurr ence */ /* set the correct DTSTART/DTEND on the individual recurr ence */
if (day_view->resize_drag_pos == E_CALENDAR_VIEW_POS_TOP_ EDGE) { if (day_view->resize_drag_pos == E_CALENDAR_VIEW_POS_TOP_ EDGE) {
*date.value = icaltime_from_timet_with_zone ( e_cal_component_datetime_take_value (date,
event->comp_data->instance_end, FALSE, i_cal_time_new_from_timet_with_zone (even
e_calendar_view_get_timezone (E_CALENDAR_ t->comp_data->instance_end, FALSE, zone));
VIEW (day_view))); cal_comp_set_dtend_with_oldzone (client, comp, da
cal_comp_set_dtend_with_oldzone (client, comp, &d te);
ate);
} else { } else {
*date.value = icaltime_from_timet_with_zone ( e_cal_component_datetime_take_value (date,
event->comp_data->instance_start, FALSE, i_cal_time_new_from_timet_with_zone (even
e_calendar_view_get_timezone (E_CALENDAR_ t->comp_data->instance_start, FALSE, zone));
VIEW (day_view))); cal_comp_set_dtstart_with_oldzone (client, comp,
cal_comp_set_dtstart_with_oldzone (client, comp, date);
&date);
} }
e_cal_component_set_rdate_list (comp, NULL); e_cal_component_set_rdates (comp, NULL);
e_cal_component_set_rrule_list (comp, NULL); e_cal_component_set_rrules (comp, NULL);
e_cal_component_set_exdate_list (comp, NULL); e_cal_component_set_exdates (comp, NULL);
e_cal_component_set_exrule_list (comp, NULL); e_cal_component_set_exrules (comp, NULL);
} }
} else if (e_cal_component_is_instance (comp)) } else if (e_cal_component_is_instance (comp)) {
mod = E_CAL_OBJ_MOD_THIS; mod = E_CAL_OBJ_MOD_THIS;
}
e_cal_component_commit_sequence (comp); e_cal_component_commit_sequence (comp);
e_cal_ops_modify_component (model, client, e_cal_component_get_icalcompon ent (comp), mod, e_cal_ops_modify_component (model, client, e_cal_component_get_icalcompon ent (comp), mod,
(send == GTK_RESPONSE_YES ? E_CAL_OPS_SEND_FLAG_SEND : E_CAL_OPS_ SEND_FLAG_DONT_SEND) | (send == GTK_RESPONSE_YES ? E_CAL_OPS_SEND_FLAG_SEND : E_CAL_OPS_ SEND_FLAG_DONT_SEND) |
(strip_alarms ? E_CAL_OPS_SEND_FLAG_STRIP_ALARMS : 0) | (strip_alarms ? E_CAL_OPS_SEND_FLAG_STRIP_ALARMS : 0) |
(only_new_attendees ? E_CAL_OPS_SEND_FLAG_ONLY_NEW_ATTENDEES : 0) ); (only_new_attendees ? E_CAL_OPS_SEND_FLAG_ONLY_NEW_ATTENDEES : 0) );
out: out:
g_object_unref (comp); g_object_unref (comp);
g_clear_object (&date);
} }
static void static void
e_day_view_abort_resize (EDayView *day_view) e_day_view_abort_resize (EDayView *day_view)
{ {
GdkWindow *window; GdkWindow *window;
gint day, event_num; gint day, event_num;
if (day_view->resize_drag_pos == E_CALENDAR_VIEW_POS_NONE) if (day_view->resize_drag_pos == E_CALENDAR_VIEW_POS_NONE)
return; return;
skipping to change at line 5751 skipping to change at line 5760
ECalClient *client, ECalClient *client,
ECalComponent *comp, ECalComponent *comp,
time_t start, time_t start,
time_t end, time_t end,
gpointer data) gpointer data)
{ {
EDayViewEvent event; EDayViewEvent event;
gint day, offset; gint day, offset;
gint days_shown; gint days_shown;
struct icaltimetype start_tt, end_tt; ICalTime *start_tt, *end_tt;
ICalTimezone *zone;
AddEventData *add_event_data; AddEventData *add_event_data;
icaltimezone *zone;
add_event_data = data; add_event_data = data;
/*if (end < start || start >= add_event_data->day_view->upper || end < ad d_event_data->day_view->lower) { /*if (end < start || start >= add_event_data->day_view->upper || end < ad d_event_data->day_view->lower) {
g_print ("%s: day_view: %p\n", G_STRFUNC, add_event_data->day_vie w); g_print ("%s: day_view: %p\n", G_STRFUNC, add_event_data->day_vie w);
g_print ("\tDay view lower: %s", ctime (&add_event_data->day_view ->lower)); g_print ("\tDay view lower: %s", ctime (&add_event_data->day_view ->lower));
g_print ("\tDay view upper: %s", ctime (&add_event_data->day_view ->upper)); g_print ("\tDay view upper: %s", ctime (&add_event_data->day_view ->upper));
g_print ("\tEvent start: %s", ctime (&start)); g_print ("\tEvent start: %s", ctime (&start));
g_print ("\tEvent end : %s\n", ctime (&end)); g_print ("\tEvent end : %s\n", ctime (&end));
}*/ }*/
/* Check that the event times are valid. */ /* Check that the event times are valid. */
g_return_if_fail (start <= end); g_return_if_fail (start <= end);
g_return_if_fail (start < add_event_data->day_view->upper); g_return_if_fail (start < add_event_data->day_view->upper);
if (end != start || end < add_event_data->day_view->lower) if (end != start || end < add_event_data->day_view->lower)
g_return_if_fail (end > add_event_data->day_view->lower); g_return_if_fail (end > add_event_data->day_view->lower);
zone = e_calendar_view_get_timezone (E_CALENDAR_VIEW (add_event_data->day _view)); zone = e_calendar_view_get_timezone (E_CALENDAR_VIEW (add_event_data->day _view));
start_tt = icaltime_from_timet_with_zone (start, FALSE, zone); start_tt = i_cal_time_new_from_timet_with_zone (start, FALSE, zone);
end_tt = icaltime_from_timet_with_zone (end, FALSE, zone); end_tt = i_cal_time_new_from_timet_with_zone (end, FALSE, zone);
if (add_event_data->comp_data) { if (add_event_data->comp_data) {
event.comp_data = g_object_ref (add_event_data->comp_data); event.comp_data = g_object_ref (add_event_data->comp_data);
} else { } else {
event.comp_data = g_object_new (E_TYPE_CAL_MODEL_COMPONENT, NULL) ; event.comp_data = g_object_new (E_TYPE_CAL_MODEL_COMPONENT, NULL) ;
event.comp_data->is_new_component = TRUE; event.comp_data->is_new_component = TRUE;
event.comp_data->client = g_object_ref (client); event.comp_data->client = g_object_ref (client);
e_cal_component_abort_sequence (comp); e_cal_component_abort_sequence (comp);
event.comp_data->icalcomp = icalcomponent_new_clone (e_cal_compon ent_get_icalcomponent (comp)); event.comp_data->icalcomp = i_cal_component_clone (e_cal_componen t_get_icalcomponent (comp));
} }
event.start = start; event.start = start;
event.tooltip = NULL; event.tooltip = NULL;
event.color = NULL; event.color = NULL;
event.timeout = -1; event.timeout = -1;
event.end = end; event.end = end;
event.canvas_item = NULL; event.canvas_item = NULL;
event.comp_data->instance_start = start; event.comp_data->instance_start = start;
event.comp_data->instance_end = end; event.comp_data->instance_end = end;
/* Calculate the start & end minute, relative to the top of the /* Calculate the start & end minute, relative to the top of the
* display. */ * display. */
offset = add_event_data->day_view->first_hour_shown * 60 offset = add_event_data->day_view->first_hour_shown * 60
+ add_event_data->day_view->first_minute_shown; + add_event_data->day_view->first_minute_shown;
event.start_minute = start_tt.hour * 60 + start_tt.minute - offset; event.start_minute = i_cal_time_get_hour (start_tt) * 60 + i_cal_time_get
event.end_minute = end_tt.hour * 60 + end_tt.minute - offset; _minute (start_tt) - offset;
event.end_minute = i_cal_time_get_hour (end_tt) * 60 + i_cal_time_get_min
ute (end_tt) - offset;
g_clear_object (&start_tt);
g_clear_object (&end_tt);
event.start_row_or_col = 0; event.start_row_or_col = 0;
event.num_columns = 0; event.num_columns = 0;
event.different_timezone = FALSE; event.different_timezone = FALSE;
if (!cal_comp_util_compare_event_timezones (comp, event.comp_data->client , zone)) if (!cal_comp_util_compare_event_timezones (comp, event.comp_data->client , zone))
event.different_timezone = TRUE; event.different_timezone = TRUE;
if (!e_cal_component_has_attendees (comp) || if (!e_cal_component_has_attendees (comp) ||
itip_organizer_is_user (registry, comp, event.comp_data->client) || itip_organizer_is_user (registry, comp, event.comp_data->client) ||
skipping to change at line 6018 skipping to change at line 6030
/* Take off the border and padding. */ /* Take off the border and padding. */
item_x += E_DAY_VIEW_LONG_EVENT_BORDER_WIDTH + E_DAY_VIEW_LONG_EVENT_X_PA D; item_x += E_DAY_VIEW_LONG_EVENT_BORDER_WIDTH + E_DAY_VIEW_LONG_EVENT_X_PA D;
item_w -= (E_DAY_VIEW_LONG_EVENT_BORDER_WIDTH + E_DAY_VIEW_LONG_EVENT_X_P AD) * 2; item_w -= (E_DAY_VIEW_LONG_EVENT_BORDER_WIDTH + E_DAY_VIEW_LONG_EVENT_X_P AD) * 2;
item_y += E_DAY_VIEW_LONG_EVENT_BORDER_HEIGHT + E_DAY_VIEW_LONG_EVENT_Y_P AD; item_y += E_DAY_VIEW_LONG_EVENT_BORDER_HEIGHT + E_DAY_VIEW_LONG_EVENT_Y_P AD;
item_h -= (E_DAY_VIEW_LONG_EVENT_BORDER_HEIGHT + E_DAY_VIEW_LONG_EVENT_Y_ PAD) * 2; item_h -= (E_DAY_VIEW_LONG_EVENT_BORDER_HEIGHT + E_DAY_VIEW_LONG_EVENT_Y_ PAD) * 2;
/* We don't show the icons while resizing, since we'd have to /* We don't show the icons while resizing, since we'd have to
* draw them on top of the resize rect. Nor when editing. */ * draw them on top of the resize rect. Nor when editing. */
num_icons = 0; num_icons = 0;
comp = e_cal_component_new (); comp = e_cal_component_new_from_icalcomponent (i_cal_component_clone (eve
e_cal_component_set_icalcomponent (comp, icalcomponent_new_clone (event-> nt->comp_data->icalcomp));
comp_data->icalcomp)); if (!comp)
return;
/* Set up Pango prerequisites */ /* Set up Pango prerequisites */
pango_context = gtk_widget_get_pango_context (GTK_WIDGET (day_view)); pango_context = gtk_widget_get_pango_context (GTK_WIDGET (day_view));
layout = pango_layout_new (pango_context); layout = pango_layout_new (pango_context);
if (day_view->resize_drag_pos != E_CALENDAR_VIEW_POS_NONE if (day_view->resize_drag_pos != E_CALENDAR_VIEW_POS_NONE
&& day_view->resize_event_day == E_DAY_VIEW_LONG_EVENT && day_view->resize_event_day == E_DAY_VIEW_LONG_EVENT
&& day_view->resize_event_num == event_num) && day_view->resize_event_num == event_num)
show_icons = FALSE; show_icons = FALSE;
skipping to change at line 6169 skipping to change at line 6182
event_num++) { event_num++) {
EDayViewEvent *event; EDayViewEvent *event;
gchar *current_comp_string; gchar *current_comp_string;
e_day_view_reshape_day_event (day_view, day, event_num); e_day_view_reshape_day_event (day_view, day, event_num);
event = &g_array_index (day_view->events[day], EDayViewEvent, eve nt_num); event = &g_array_index (day_view->events[day], EDayViewEvent, eve nt_num);
if (!is_comp_data_valid (event)) if (!is_comp_data_valid (event))
continue; continue;
current_comp_string = icalcomponent_as_ical_string_r (event->comp _data->icalcomp); current_comp_string = i_cal_component_as_ical_string (event->comp _data->icalcomp);
if (day_view->last_edited_comp_string == NULL) { if (day_view->last_edited_comp_string == NULL) {
g_free (current_comp_string); g_free (current_comp_string);
continue; continue;
} }
if (strncmp (current_comp_string, day_view->last_edited_comp_stri ng, 50) == 0) { if (strncmp (current_comp_string, day_view->last_edited_comp_stri ng, 50) == 0) {
if (e_calendar_view_get_allow_direct_summary_edit (E_CALE NDAR_VIEW (day_view))) if (e_calendar_view_get_allow_direct_summary_edit (E_CALE NDAR_VIEW (day_view)))
e_canvas_item_grab_focus (event->canvas_item, TRU E); e_canvas_item_grab_focus (event->canvas_item, TRU E);
g_free (day_view->last_edited_comp_string); g_free (day_view->last_edited_comp_string);
skipping to change at line 6224 skipping to change at line 6237
/* We don't show the icons while resizing, since we'd have to /* We don't show the icons while resizing, since we'd have to
* draw them on top of the resize rect. */ * draw them on top of the resize rect. */
icons_offset = 0; icons_offset = 0;
num_icons = 0; num_icons = 0;
if (is_comp_data_valid (event) && (day_view->resize_drag_pos == E _CALENDAR_VIEW_POS_NONE if (is_comp_data_valid (event) && (day_view->resize_drag_pos == E _CALENDAR_VIEW_POS_NONE
|| day_view->resize_event_day != day || day_view->resize_event_day != day
|| day_view->resize_event_num != event_num)) { || day_view->resize_event_num != event_num)) {
ECalComponent *comp; ECalComponent *comp;
comp = e_cal_component_new (); comp = e_cal_component_new_from_icalcomponent (i_cal_comp
e_cal_component_set_icalcomponent (comp, icalcomponent_ne onent_clone (event->comp_data->icalcomp));
w_clone (event->comp_data->icalcomp)); if (comp) {
if (e_cal_component_has_alarms (comp))
num_icons++;
if (e_cal_component_has_recurrences (comp) || e_c
al_component_is_instance (comp))
num_icons++;
if (e_cal_component_has_attachments (comp))
num_icons++;
if (event->different_timezone)
num_icons++;
if (e_cal_component_has_attendees (comp))
num_icons++;
if (e_cal_component_has_alarms (comp)) num_icons += cal_comp_util_get_n_icons (comp, NUL
num_icons++; L);
if (e_cal_component_has_recurrences (comp) || e_cal_compo g_object_unref (comp);
nent_is_instance (comp)) }
num_icons++;
if (e_cal_component_has_attachments (comp))
num_icons++;
if (event->different_timezone)
num_icons++;
if (e_cal_component_has_attendees (comp))
num_icons++;
num_icons += cal_comp_util_get_n_icons (comp, NULL);
g_object_unref (comp);
} }
if (num_icons > 0) { if (num_icons > 0) {
if (item_h >= (E_DAY_VIEW_ICON_HEIGHT + E_DAY_VIEW_ICON_Y _PAD) * num_icons) if (item_h >= (E_DAY_VIEW_ICON_HEIGHT + E_DAY_VIEW_ICON_Y _PAD) * num_icons)
icons_offset = E_DAY_VIEW_ICON_WIDTH + E_DAY_VIEW _ICON_X_PAD * 2; icons_offset = E_DAY_VIEW_ICON_WIDTH + E_DAY_VIEW _ICON_X_PAD * 2;
else if (item_h <= (E_DAY_VIEW_ICON_HEIGHT + E_DAY_VIEW_I CON_Y_PAD) * 2 || num_icons == 1) else if (item_h <= (E_DAY_VIEW_ICON_HEIGHT + E_DAY_VIEW_I CON_Y_PAD) * 2 || num_icons == 1)
icons_offset = (E_DAY_VIEW_ICON_WIDTH + E_DAY_VIE W_ICON_X_PAD) * num_icons + E_DAY_VIEW_ICON_X_PAD; icons_offset = (E_DAY_VIEW_ICON_WIDTH + E_DAY_VIE W_ICON_X_PAD) * num_icons + E_DAY_VIEW_ICON_X_PAD;
else else
icons_offset = E_DAY_VIEW_ICON_X_PAD; icons_offset = E_DAY_VIEW_ICON_X_PAD;
} }
skipping to change at line 7335 skipping to change at line 7348
return; return;
event = &g_array_index (day_view->events[day], EDayViewEvent, eve nt_num); event = &g_array_index (day_view->events[day], EDayViewEvent, eve nt_num);
} }
if (!is_comp_data_valid (event)) if (!is_comp_data_valid (event))
return; return;
/* Reset the text to what was in the component */ /* Reset the text to what was in the component */
summary = icalcomponent_get_summary (event->comp_data->icalcomp); summary = i_cal_component_get_summary (event->comp_data->icalcomp);
g_object_set ( g_object_set (
event->canvas_item, event->canvas_item,
"text", summary ? summary : "", "text", summary ? summary : "",
NULL); NULL);
/* Stop editing */ /* Stop editing */
e_day_view_stop_editing_event (day_view); e_day_view_stop_editing_event (day_view);
} }
static EDayViewEvent * static EDayViewEvent *
skipping to change at line 7596 skipping to change at line 7609
static gboolean static gboolean
e_day_view_event_move (ECalendarView *cal_view, e_day_view_event_move (ECalendarView *cal_view,
ECalViewMoveDirection direction) ECalViewMoveDirection direction)
{ {
EDayViewEvent *event; EDayViewEvent *event;
EDayView *day_view; EDayView *day_view;
gint time_divisions; gint time_divisions;
gint day, event_num, resize_start_row, resize_end_row; gint day, event_num, resize_start_row, resize_end_row;
time_t start_dt, end_dt; time_t start_dt, end_dt;
struct icaltimetype start_time, end_time; ICalTime *start_time, *end_time;
day_view = E_DAY_VIEW (cal_view); day_view = E_DAY_VIEW (cal_view);
day = day_view->editing_event_day; day = day_view->editing_event_day;
event_num = day_view->editing_event_num; event_num = day_view->editing_event_num;
time_divisions = e_calendar_view_get_time_divisions (cal_view); time_divisions = e_calendar_view_get_time_divisions (cal_view);
if ((day == -1) || (day == E_DAY_VIEW_LONG_EVENT)) if ((day == -1) || (day == E_DAY_VIEW_LONG_EVENT))
return FALSE; return FALSE;
skipping to change at line 7643 skipping to change at line 7656
resize_start_row++; resize_start_row++;
resize_end_row++; resize_end_row++;
start_dt = e_day_view_convert_grid_position_to_time (day_view, da y, resize_start_row); start_dt = e_day_view_convert_grid_position_to_time (day_view, da y, resize_start_row);
end_dt = e_day_view_convert_grid_position_to_time (day_view, day, resize_end_row + 1); end_dt = e_day_view_convert_grid_position_to_time (day_view, day, resize_end_row + 1);
break; break;
case E_CAL_VIEW_MOVE_LEFT: case E_CAL_VIEW_MOVE_LEFT:
if (day <= 0) if (day <= 0)
return TRUE; return TRUE;
start_dt = e_day_view_convert_grid_position_to_time (day_view, da y, resize_start_row); start_dt = e_day_view_convert_grid_position_to_time (day_view, da y, resize_start_row);
end_dt = e_day_view_convert_grid_position_to_time (day_view, day, resize_end_row + 1); end_dt = e_day_view_convert_grid_position_to_time (day_view, day, resize_end_row + 1);
start_time = icaltime_from_timet_with_zone (start_dt, 0, NULL); start_time = i_cal_time_new_from_timet_with_zone (start_dt, 0, NU
end_time = icaltime_from_timet_with_zone (end_dt, 0, NULL); LL);
icaltime_adjust (&start_time ,-1,0,0,0); end_time = i_cal_time_new_from_timet_with_zone (end_dt, 0, NULL);
icaltime_adjust (&end_time ,-1,0,0,0); i_cal_time_adjust (start_time, -1, 0, 0, 0);
start_dt = icaltime_as_timet (start_time); i_cal_time_adjust (end_time, -1, 0, 0, 0);
end_dt = icaltime_as_timet (end_time); start_dt = i_cal_time_as_timet (start_time);
end_dt = i_cal_time_as_timet (end_time);
g_clear_object (&start_time);
g_clear_object (&end_time);
break; break;
case E_CAL_VIEW_MOVE_RIGHT: case E_CAL_VIEW_MOVE_RIGHT:
if (day + 1 >= e_day_view_get_days_shown (day_view)) if (day + 1 >= e_day_view_get_days_shown (day_view))
return TRUE; return TRUE;
start_dt = e_day_view_convert_grid_position_to_time (day_view, da y, resize_start_row); start_dt = e_day_view_convert_grid_position_to_time (day_view, da y, resize_start_row);
end_dt = e_day_view_convert_grid_position_to_time (day_view, day, resize_end_row + 1); end_dt = e_day_view_convert_grid_position_to_time (day_view, day, resize_end_row + 1);
start_time = icaltime_from_timet_with_zone (start_dt, 0, NULL); start_time = i_cal_time_new_from_timet_with_zone (start_dt, 0, NU
end_time = icaltime_from_timet_with_zone (end_dt, 0, NULL); LL);
icaltime_adjust (&start_time ,1,0,0,0); end_time = i_cal_time_new_from_timet_with_zone (end_dt, 0, NULL);
icaltime_adjust (&end_time ,1,0,0,0); i_cal_time_adjust (start_time ,1,0,0,0);
start_dt = icaltime_as_timet (start_time); i_cal_time_adjust (end_time ,1,0,0,0);
end_dt = icaltime_as_timet (end_time); start_dt = i_cal_time_as_timet (start_time);
end_dt = i_cal_time_as_timet (end_time);
g_clear_object (&start_time);
g_clear_object (&end_time);
break; break;
default: default:
return FALSE; return FALSE;
} }
e_day_view_change_event_time (day_view, start_dt, end_dt); e_day_view_change_event_time (day_view, start_dt, end_dt);
e_day_view_ensure_rows_visible (day_view, resize_start_row, resize_end_ro w); e_day_view_ensure_rows_visible (day_view, resize_start_row, resize_end_ro w);
return TRUE; return TRUE;
} }
static void static void
e_day_view_change_event_time (EDayView *day_view, e_day_view_change_event_time (EDayView *day_view,
time_t start_dt, time_t start_dt,
time_t end_dt) time_t end_dt)
{ {
EDayViewEvent *event; EDayViewEvent *event;
gint day, event_num; gint day, event_num;
ECalComponent *comp; ECalComponent *comp;
ECalComponentDateTime date; ECalComponentDateTime *date;
struct icaltimetype itt; ICalTimezone *zone;
ECalModel *model; ECalModel *model;
ECalClient *client; ECalClient *client;
ESourceRegistry *registry; ESourceRegistry *registry;
ECalObjModType mod = E_CAL_OBJ_MOD_ALL; ECalObjModType mod = E_CAL_OBJ_MOD_ALL;
day = day_view->editing_event_day; day = day_view->editing_event_day;
event_num = day_view->editing_event_num; event_num = day_view->editing_event_num;
model = e_calendar_view_get_model (E_CALENDAR_VIEW (day_view)); model = e_calendar_view_get_model (E_CALENDAR_VIEW (day_view));
registry = e_cal_model_get_registry (model); registry = e_cal_model_get_registry (model);
skipping to change at line 7707 skipping to change at line 7724
event_num); event_num);
if (!is_comp_data_valid (event)) if (!is_comp_data_valid (event))
return; return;
client = event->comp_data->client; client = event->comp_data->client;
/* We use a temporary shallow copy of the ico since we don't want to /* 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 * change the original ico here. Otherwise we would not detect that
* the event's time had changed in the "update_event" callback. */ * the event's time had changed in the "update_event" callback. */
comp = e_cal_component_new (); comp = e_cal_component_new_from_icalcomponent (i_cal_component_clone (eve
e_cal_component_set_icalcomponent (comp, icalcomponent_new_clone (event-> nt->comp_data->icalcomp));
comp_data->icalcomp));
if (e_cal_component_has_attendees (comp) && if (e_cal_component_has_attendees (comp) &&
!itip_organizer_is_user (registry, comp, client)) { !itip_organizer_is_user (registry, comp, client)) {
g_object_unref (comp); g_object_unref (comp);
return; return;
} }
date.value = &itt; zone = e_calendar_view_get_timezone (E_CALENDAR_VIEW (day_view));
/* FIXME: Should probably keep the timezone of the original start
* and end times. */ date = e_cal_component_datetime_new_take (
date.tzid = icaltimezone_get_tzid (e_calendar_view_get_timezone (E_CALEND i_cal_time_new_from_timet_with_zone (start_dt, FALSE, zone),
AR_VIEW (day_view))); zone ? g_strdup (i_cal_timezone_get_tzid (zone)) : NULL);
cal_comp_set_dtstart_with_oldzone (client, comp, date);
*date.value = icaltime_from_timet_with_zone (start_dt, FALSE,
e_calendar_view_get_timezone e_cal_component_datetime_take_value (date,
(E_CALENDAR_VIEW (day_view))); i_cal_time_new_from_timet_with_zone (end_dt, FALSE, zone));
cal_comp_set_dtstart_with_oldzone (client, comp, &date); cal_comp_set_dtend_with_oldzone (client, comp, date);
*date.value = icaltime_from_timet_with_zone (end_dt, FALSE,
e_calendar_view_get_timezone e_cal_component_datetime_free (date);
(E_CALENDAR_VIEW (day_view)));
cal_comp_set_dtend_with_oldzone (client, comp, &date);
e_cal_component_commit_sequence (comp); e_cal_component_commit_sequence (comp);
if (day_view->last_edited_comp_string != NULL) { if (day_view->last_edited_comp_string != NULL) {
g_free (day_view->last_edited_comp_string); g_free (day_view->last_edited_comp_string);
day_view->last_edited_comp_string = NULL; day_view->last_edited_comp_string = NULL;
} }
day_view->last_edited_comp_string = e_cal_component_get_as_string (comp); day_view->last_edited_comp_string = e_cal_component_get_as_string (comp);
day_view->resize_drag_pos = E_CALENDAR_VIEW_POS_NONE; day_view->resize_drag_pos = E_CALENDAR_VIEW_POS_NONE;
if (e_cal_component_has_recurrences (comp)) { if (e_cal_component_has_recurrences (comp)) {
if (!e_cal_dialogs_recur_component (client, comp, &mod, NULL, FAL SE)) { if (!e_cal_dialogs_recur_component (client, comp, &mod, NULL, FAL SE)) {
gtk_widget_queue_draw (day_view->top_canvas); gtk_widget_queue_draw (day_view->top_canvas);
goto out; goto out;
} }
if (mod == E_CAL_OBJ_MOD_THIS) { if (mod == E_CAL_OBJ_MOD_THIS) {
e_cal_component_set_rdate_list (comp, NULL); e_cal_component_set_rdates (comp, NULL);
e_cal_component_set_rrule_list (comp, NULL); e_cal_component_set_rrules (comp, NULL);
e_cal_component_set_exdate_list (comp, NULL); e_cal_component_set_exdates (comp, NULL);
e_cal_component_set_exrule_list (comp, NULL); e_cal_component_set_exrules (comp, NULL);
} }
} else if (e_cal_component_is_instance (comp)) } else if (e_cal_component_is_instance (comp))
mod = E_CAL_OBJ_MOD_THIS; mod = E_CAL_OBJ_MOD_THIS;
e_cal_component_commit_sequence (comp); e_cal_component_commit_sequence (comp);
e_cal_ops_modify_component (model, client, e_cal_component_get_icalcompon ent (comp), e_cal_ops_modify_component (model, client, e_cal_component_get_icalcompon ent (comp),
mod, E_CAL_OPS_SEND_FLAG_ASK | E_CAL_OPS_SEND_FLAG_IS_NEW_COMPONE NT); mod, E_CAL_OPS_SEND_FLAG_ASK | E_CAL_OPS_SEND_FLAG_IS_NEW_COMPONE NT);
out: out:
skipping to change at line 7906 skipping to change at line 7923
g_object_notify (G_OBJECT (day_view), "is-editing"); g_object_notify (G_OBJECT (day_view), "is-editing");
} }
static void static void
e_day_view_on_editing_stopped (EDayView *day_view, e_day_view_on_editing_stopped (EDayView *day_view,
GnomeCanvasItem *item) GnomeCanvasItem *item)
{ {
gint day, event_num; gint day, event_num;
EDayViewEvent *event; EDayViewEvent *event;
gchar *text = NULL; gchar *text = NULL;
ECalComponentText summary; ECalComponentText *summary = NULL;
ECalComponent *comp; ECalComponent *comp;
ECalClient *client; ECalClient *client;
gboolean on_server; gboolean on_server;
/* Note: the item we are passed here isn't reliable, so we just stop /* 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 * the edit of whatever item was being edited. We also receive this
* event twice for some reason. */ * event twice for some reason. */
day = day_view->editing_event_day; day = day_view->editing_event_day;
event_num = day_view->editing_event_num; event_num = day_view->editing_event_num;
skipping to change at line 7953 skipping to change at line 7970
day_view->resize_bars_event_day = -1; day_view->resize_bars_event_day = -1;
day_view->resize_bars_event_num = -1; day_view->resize_bars_event_num = -1;
g_object_set (event->canvas_item, "handle_popup", FALSE, NULL); g_object_set (event->canvas_item, "handle_popup", FALSE, NULL);
g_object_get ( g_object_get (
event->canvas_item, event->canvas_item,
"text", &text, "text", &text,
NULL); NULL);
g_return_if_fail (text != NULL); g_return_if_fail (text != NULL);
comp = e_cal_component_new (); comp = e_cal_component_new_from_icalcomponent (i_cal_component_clone (eve
e_cal_component_set_icalcomponent (comp, icalcomponent_new_clone (event-> nt->comp_data->icalcomp));
comp_data->icalcomp)); if (!comp) {
g_free (text);
return;
}
client = event->comp_data->client; client = event->comp_data->client;
on_server = !event->comp_data->is_new_component; on_server = !event->comp_data->is_new_component;
if (string_is_empty (text) && !on_server) { if (string_is_empty (text) && !on_server) {
const gchar *uid; const gchar *uid;
e_cal_component_get_uid (comp, &uid); uid = e_cal_component_get_uid (comp);
e_day_view_foreach_event_with_uid (day_view, uid, e_day_view_foreach_event_with_uid (day_view, uid,
e_day_view_remove_event_cb, NU LL); e_day_view_remove_event_cb, NU LL);
e_day_view_check_layout (day_view); e_day_view_check_layout (day_view);
gtk_widget_queue_draw (day_view->top_canvas); gtk_widget_queue_draw (day_view->top_canvas);
gtk_widget_queue_draw (day_view->main_canvas); gtk_widget_queue_draw (day_view->main_canvas);
goto out; goto out;
} }
/* Only update the summary if necessary. */ /* Only update the summary if necessary. */
e_cal_component_get_summary (comp, &summary); summary = e_cal_component_get_summary (comp);
if (summary.value && !strcmp (text, summary.value)) { if (summary && !g_strcmp0 (text, e_cal_component_text_get_value (summary)
)) {
if (day == E_DAY_VIEW_LONG_EVENT) if (day == E_DAY_VIEW_LONG_EVENT)
e_day_view_reshape_long_event (day_view, event_num); e_day_view_reshape_long_event (day_view, event_num);
else else
e_day_view_update_event_label ( e_day_view_update_event_label (
day_view, day, day_view, day,
event_num); event_num);
} else if (summary.value || !string_is_empty (text)) { } else if ((summary && e_cal_component_text_get_value (summary)) || !stri
icalcomponent *icalcomp = e_cal_component_get_icalcomponent (comp ng_is_empty (text)) {
); ICalComponent *icomp = e_cal_component_get_icalcomponent (comp);
summary.value = text; if (summary)
summary.altrep = NULL; e_cal_component_text_free (summary);
e_cal_component_set_summary (comp, &summary); summary = e_cal_component_text_new (text, NULL);
e_cal_component_set_summary (comp, summary);
e_cal_component_commit_sequence (comp); e_cal_component_commit_sequence (comp);
if (!on_server) { if (!on_server) {
e_cal_ops_create_component (e_calendar_view_get_model (E_ CALENDAR_VIEW (day_view)), client, icalcomp, e_cal_ops_create_component (e_calendar_view_get_model (E_ CALENDAR_VIEW (day_view)), client, icomp,
e_calendar_view_component_created_cb, g_object_re f (day_view), g_object_unref); e_calendar_view_component_created_cb, g_object_re f (day_view), g_object_unref);
/* we remove the object since we either got the update fr om the server or failed */ /* we remove the object since we either got the update fr om the server or failed */
e_day_view_remove_event_cb (day_view, day, event_num, NUL L); e_day_view_remove_event_cb (day_view, day, event_num, NUL L);
} else { } else {
ECalObjModType mod = E_CAL_OBJ_MOD_ALL; ECalObjModType mod = E_CAL_OBJ_MOD_ALL;
if (e_cal_component_has_recurrences (comp)) { if (e_cal_component_has_recurrences (comp)) {
if (!e_cal_dialogs_recur_component (client, comp, &mod, NULL, FALSE)) { if (!e_cal_dialogs_recur_component (client, comp, &mod, NULL, FALSE)) {
goto out; goto out;
} }
if (mod == E_CAL_OBJ_MOD_THIS) { if (mod == E_CAL_OBJ_MOD_THIS) {
ECalComponentDateTime olddt, dt; ECalComponentDateTime *olddt, *dt;
icaltimetype itt;
olddt = e_cal_component_get_dtstart (comp
);
if (olddt && e_cal_component_datetime_get
_value (olddt) &&
i_cal_time_get_timezone (e_cal_compon
ent_datetime_get_value (olddt))) {
ICalTime *itt;
dt.value = &itt; itt = e_cal_component_datetime_ge t_value (olddt);
e_cal_component_get_dtstart (comp, &olddt dt = e_cal_component_datetime_new
); _take (
if (olddt.value->zone) { i_cal_time_new_from_timet
*dt.value = icaltime_from_timet_w _with_zone (event->comp_data->instance_start,
ith_zone ( i_cal_time_is_dat
event->comp_data->instanc e (itt), i_cal_time_get_timezone (itt)),
e_start, g_strdup (e_cal_component
olddt.value->is_date, _datetime_get_tzid (olddt)));
olddt.value->zone);
} else { } else {
*dt.value = icaltime_from_timet_w ICalTime *itt;
ith_zone ( ICalTimezone *zone;
event->comp_data->instanc
e_start, zone = e_calendar_view_get_timezo
olddt.value->is_date, ne (E_CALENDAR_VIEW (day_view));
e_calendar_view_get_timez itt = olddt ? e_cal_component_dat
one (E_CALENDAR_VIEW (day_view))); etime_get_value (olddt) : NULL;
dt = e_cal_component_datetime_new
_take (
i_cal_time_new_from_timet
_with_zone (event->comp_data->instance_start,
itt ? i_cal_time_
is_date (itt) : FALSE, zone),
zone ? g_strdup (i_cal_ti
mezone_get_tzid (zone)) : NULL);
} }
dt.tzid = olddt.tzid; e_cal_component_set_dtstart (comp, dt);
e_cal_component_set_dtstart (comp, &dt);
dt.tzid = NULL; e_cal_component_datetime_free (olddt);
e_cal_component_free_datetime (&olddt); e_cal_component_datetime_free (dt);
e_cal_component_get_dtend (comp, &olddt); olddt = e_cal_component_get_dtend (comp);
if (olddt.value->zone) {
*dt.value = icaltime_from_timet_w if (olddt && e_cal_component_datetime_get
ith_zone ( _value (olddt) &&
event->comp_data->instanc i_cal_time_get_timezone (e_cal_compon
e_end, ent_datetime_get_value (olddt))) {
olddt.value->is_date, ICalTime *itt;
olddt.value->zone);
itt = e_cal_component_datetime_ge
t_value (olddt);
dt = e_cal_component_datetime_new
_take (
i_cal_time_new_from_timet
_with_zone (event->comp_data->instance_end,
i_cal_time_is_dat
e (itt), i_cal_time_get_timezone (itt)),
g_strdup (e_cal_component
_datetime_get_tzid (olddt)));
} else { } else {
*dt.value = icaltime_from_timet_w ICalTime *itt;
ith_zone ( ICalTimezone *zone;
event->comp_data->instanc
e_end, zone = e_calendar_view_get_timezo
olddt.value->is_date, ne (E_CALENDAR_VIEW (day_view));
e_calendar_view_get_timez itt = olddt ? e_cal_component_dat
one (E_CALENDAR_VIEW (day_view))); etime_get_value (olddt) : NULL;
dt = e_cal_component_datetime_new
_take (
i_cal_time_new_from_timet
_with_zone (event->comp_data->instance_end,
itt ? i_cal_time_
is_date (itt) : FALSE, zone),
zone ? g_strdup (i_cal_ti
mezone_get_tzid (zone)) : NULL);
} }
dt.tzid = olddt.tzid; e_cal_component_set_dtend (comp, dt);
e_cal_component_set_dtend (comp, &dt);
dt.tzid = NULL; e_cal_component_datetime_free (olddt);
e_cal_component_free_datetime (&olddt); e_cal_component_datetime_free (dt);
e_cal_component_set_rdate_list (comp, NUL e_cal_component_set_rdates (comp, NULL);
L); e_cal_component_set_rrules (comp, NULL);
e_cal_component_set_rrule_list (comp, NUL e_cal_component_set_exdates (comp, NULL);
L); e_cal_component_set_exrules (comp, NULL);
e_cal_component_set_exdate_list (comp, NU
LL);
e_cal_component_set_exrule_list (comp, NU
LL);
e_cal_component_commit_sequence (comp); e_cal_component_commit_sequence (comp);
} }
} else if (e_cal_component_is_instance (comp)) } else if (e_cal_component_is_instance (comp))
mod = E_CAL_OBJ_MOD_THIS; mod = E_CAL_OBJ_MOD_THIS;
e_cal_ops_modify_component (e_calendar_view_get_model (E_ CALENDAR_VIEW (day_view)), e_cal_ops_modify_component (e_calendar_view_get_model (E_ CALENDAR_VIEW (day_view)),
client, e_cal_component_get_icalcomponent (comp), mod, E_CAL_OPS_SEND_FLAG_ASK); client, e_cal_component_get_icalcomponent (comp), mod, E_CAL_OPS_SEND_FLAG_ASK);
} }
} }
gtk_widget_queue_draw (day_view->main_canvas); gtk_widget_queue_draw (day_view->main_canvas);
out: out:
e_cal_component_text_free (summary);
g_object_unref (comp); g_object_unref (comp);
g_free (text); g_free (text);
g_signal_emit_by_name (day_view, "selection_changed"); g_signal_emit_by_name (day_view, "selection_changed");
g_object_notify (G_OBJECT (day_view), "is-editing"); g_object_notify (G_OBJECT (day_view), "is-editing");
} }
/* FIXME: It is possible that we may produce an invalid time due to daylight /* FIXME: It is possible that we may produce an invalid time due to daylight
* saving times (i.e. when clocks go forward there is a range of time which * saving times (i.e. when clocks go forward there is a range of time which
* is not valid). I don't know the best way to handle daylight saving time. */ * is not valid). I don't know the best way to handle daylight saving time. */
static time_t static time_t
e_day_view_convert_grid_position_to_time (EDayView *day_view, e_day_view_convert_grid_position_to_time (EDayView *day_view,
gint col, gint col,
gint row) gint row)
{ {
ECalendarView *cal_view; ECalendarView *cal_view;
gint time_divisions; gint time_divisions;
struct icaltimetype tt; ICalTime *tt;
time_t val; time_t val;
gint minutes; gint minutes;
cal_view = E_CALENDAR_VIEW (day_view); cal_view = E_CALENDAR_VIEW (day_view);
time_divisions = e_calendar_view_get_time_divisions (cal_view); time_divisions = e_calendar_view_get_time_divisions (cal_view);
/* Calulate the number of minutes since the start of the day. */ /* Calulate the number of minutes since the start of the day. */
minutes = day_view->first_hour_shown * 60 minutes = day_view->first_hour_shown * 60
+ day_view->first_minute_shown + day_view->first_minute_shown
+ row * time_divisions; + row * time_divisions;
/* A special case for midnight, where we can use the start of the /* A special case for midnight, where we can use the start of the
* next day. */ * next day. */
if (minutes == 60 * 24) if (minutes == 60 * 24)
return day_view->day_starts[col + 1]; return day_view->day_starts[col + 1];
/* Create an icaltimetype and convert to a time_t. */ /* Create an ICalTime and convert to a time_t. */
tt = icaltime_from_timet_with_zone ( tt = i_cal_time_new_from_timet_with_zone (
day_view->day_starts[col], day_view->day_starts[col],
FALSE, e_calendar_view_get_timezone (E_CALENDAR_VIEW (day_view))) ; FALSE, e_calendar_view_get_timezone (E_CALENDAR_VIEW (day_view))) ;
tt.hour = minutes / 60; i_cal_time_set_hour (tt, minutes / 60);
tt.minute = minutes % 60; i_cal_time_set_minute (tt, minutes % 60);
tt.second = 0; i_cal_time_set_second (tt, 0);
val = i_cal_time_as_timet_with_zone (tt, e_calendar_view_get_timezone (E_
CALENDAR_VIEW (day_view)));
g_clear_object (&tt);
val = icaltime_as_timet_with_zone (tt, e_calendar_view_get_timezone (E_CA LENDAR_VIEW (day_view)));
return val; return val;
} }
static gboolean static gboolean
e_day_view_convert_time_to_grid_position (EDayView *day_view, e_day_view_convert_time_to_grid_position (EDayView *day_view,
time_t time, time_t time,
gint *col, gint *col,
gint *row) gint *row)
{ {
ECalendarView *cal_view; ECalendarView *cal_view;
struct icaltimetype tt; ICalTime *tt;
gint time_divisions; gint time_divisions;
gint day, minutes; gint day, minutes;
gint days_shown; gint days_shown;
*col = *row = 0; *col = *row = 0;
cal_view = E_CALENDAR_VIEW (day_view); cal_view = E_CALENDAR_VIEW (day_view);
time_divisions = e_calendar_view_get_time_divisions (cal_view); time_divisions = e_calendar_view_get_time_divisions (cal_view);
if (time < day_view->lower || time >= day_view->upper) if (time < day_view->lower || time >= day_view->upper)
skipping to change at line 8139 skipping to change at line 8185
days_shown = e_day_view_get_days_shown (day_view); days_shown = e_day_view_get_days_shown (day_view);
/* We can find the column easily using the day_starts array. */ /* We can find the column easily using the day_starts array. */
for (day = 1; day <= days_shown; day++) { for (day = 1; day <= days_shown; day++) {
if (time < day_view->day_starts[day]) { if (time < day_view->day_starts[day]) {
*col = day - 1; *col = day - 1;
break; break;
} }
} }
/* To find the row we need to convert the time to an icaltimetype, /* To find the row we need to convert the time to an ICalTime,
* calculate the offset in minutes from the top of the display and * calculate the offset in minutes from the top of the display and
* divide it by the mins per row setting. */ * divide it by the mins per row setting. */
tt = icaltime_from_timet_with_zone (time, FALSE, e_calendar_view_get_time zone (E_CALENDAR_VIEW (day_view))); tt = i_cal_time_new_from_timet_with_zone (time, FALSE, e_calendar_view_ge t_timezone (E_CALENDAR_VIEW (day_view)));
minutes = tt.hour * 60 + tt.minute; minutes = i_cal_time_get_hour (tt) * 60 + i_cal_time_get_minute (tt);
minutes -= day_view->first_hour_shown * 60 + day_view->first_minute_shown ; minutes -= day_view->first_hour_shown * 60 + day_view->first_minute_shown ;
g_clear_object (&tt);
*row = minutes / time_divisions; *row = minutes / time_divisions;
if (*row < 0 || *row >= day_view->rows) if (*row < 0 || *row >= day_view->rows)
return FALSE; return FALSE;
return TRUE; return TRUE;
} }
/* This starts or stops auto-scrolling when dragging a selection or resizing /* This starts or stops auto-scrolling when dragging a selection or resizing
* an event. */ * an event. */
skipping to change at line 8740 skipping to change at line 8788
gnome_canvas_item_show (day_view->drag_long_event_rect_item); gnome_canvas_item_show (day_view->drag_long_event_rect_item);
} }
/* Set the text, if necessary. We don't want to set the text every /* Set the text, if necessary. We don't want to set the text every
* time it moves, so we check if it is currently invisible and only * time it moves, so we check if it is currently invisible and only
* set the text then. */ * set the text then. */
if (!(day_view->drag_long_event_item->flags & GNOME_CANVAS_ITEM_VISIBLE)) { if (!(day_view->drag_long_event_item->flags & GNOME_CANVAS_ITEM_VISIBLE)) {
const gchar *summary; const gchar *summary;
if (event && is_comp_data_valid (event)) { if (event && is_comp_data_valid (event)) {
summary = icalcomponent_get_summary (event->comp_data->ic alcomp); summary = i_cal_component_get_summary (event->comp_data-> icalcomp);
text = g_strdup (summary); text = g_strdup (summary);
} else { } else {
text = NULL; text = NULL;
} }
gnome_canvas_item_set ( gnome_canvas_item_set (
day_view->drag_long_event_item, day_view->drag_long_event_item,
"text", text ? text : "", "text", text ? text : "",
NULL); NULL);
gnome_canvas_item_raise_to_top (day_view->drag_long_event_item); gnome_canvas_item_raise_to_top (day_view->drag_long_event_item);
skipping to change at line 8917 skipping to change at line 8965
gnome_canvas_item_show (day_view->drag_rect_item); gnome_canvas_item_show (day_view->drag_rect_item);
} }
/* Set the text, if necessary. We don't want to set the text every /* Set the text, if necessary. We don't want to set the text every
* time it moves, so we check if it is currently invisible and only * time it moves, so we check if it is currently invisible and only
* set the text then. */ * set the text then. */
if (!(day_view->drag_item->flags & GNOME_CANVAS_ITEM_VISIBLE)) { if (!(day_view->drag_item->flags & GNOME_CANVAS_ITEM_VISIBLE)) {
const gchar *summary; const gchar *summary;
if (event && is_comp_data_valid (event)) { if (event && is_comp_data_valid (event)) {
summary = icalcomponent_get_summary (event->comp_data->ic alcomp); summary = i_cal_component_get_summary (event->comp_data-> icalcomp);
text = g_strdup (summary); text = g_strdup (summary);
} else { } else {
text = NULL; text = NULL;
} }
gnome_canvas_item_set ( gnome_canvas_item_set (
day_view->drag_item, day_view->drag_item,
"text", text ? text : "", "text", text ? text : "",
NULL); NULL);
gnome_canvas_item_raise_to_top (day_view->drag_item); gnome_canvas_item_raise_to_top (day_view->drag_item);
skipping to change at line 9053 skipping to change at line 9101
static void static void
e_day_view_on_drag_data_get (GtkWidget *widget, e_day_view_on_drag_data_get (GtkWidget *widget,
GdkDragContext *context, GdkDragContext *context,
GtkSelectionData *selection_data, GtkSelectionData *selection_data,
guint info, guint info,
guint time, guint time,
EDayView *day_view) EDayView *day_view)
{ {
EDayViewEvent *event; EDayViewEvent *event;
icalcomponent *vcal; ICalComponent *vcal;
gint day, event_num; gint day, event_num;
gchar *comp_str; gchar *comp_str;
day = day_view->drag_event_day; day = day_view->drag_event_day;
event_num = day_view->drag_event_num; event_num = day_view->drag_event_num;
/* These should both be set. */ /* These should both be set. */
if (day == -1) { if (day == -1) {
g_warn_if_reached (); g_warn_if_reached ();
return; return;
skipping to change at line 9088 skipping to change at line 9136
event = &g_array_index (day_view->events[day], event = &g_array_index (day_view->events[day],
EDayViewEvent, event_num); EDayViewEvent, event_num);
} }
if (!is_comp_data_valid (event)) if (!is_comp_data_valid (event))
return; return;
vcal = e_cal_util_new_top_level (); vcal = e_cal_util_new_top_level ();
e_cal_util_add_timezones_from_component ( e_cal_util_add_timezones_from_component (
vcal, event->comp_data->icalcomp); vcal, event->comp_data->icalcomp);
icalcomponent_add_component ( i_cal_component_take_component (
vcal, icalcomponent_new_clone (event->comp_data->icalcomp)); vcal, i_cal_component_clone (event->comp_data->icalcomp));
comp_str = icalcomponent_as_ical_string_r (vcal); comp_str = i_cal_component_as_ical_string (vcal);
if (comp_str) { if (comp_str) {
ESource *source; ESource *source;
const gchar *source_uid; const gchar *source_uid;
GdkAtom target; GdkAtom target;
gchar *tmp; gchar *tmp;
source = e_client_get_source (E_CLIENT (event->comp_data->client) ); source = e_client_get_source (E_CLIENT (event->comp_data->client) );
source_uid = e_source_get_uid (source); source_uid = e_source_get_uid (source);
tmp = g_strconcat (source_uid, "\n", comp_str, NULL); tmp = g_strconcat (source_uid, "\n", comp_str, NULL);
target = gtk_selection_data_get_target (selection_data); target = gtk_selection_data_get_target (selection_data);
gtk_selection_data_set ( gtk_selection_data_set (
selection_data, target, 8, selection_data, target, 8,
(guchar *) tmp, strlen (tmp)); (guchar *) tmp, strlen (tmp));
g_free (tmp); g_free (tmp);
} }
icalcomponent_free (vcal); g_clear_object (&vcal);
g_free (comp_str); g_free (comp_str);
} }
static void static void
e_day_view_on_top_canvas_drag_data_received (GtkWidget *widget, e_day_view_on_top_canvas_drag_data_received (GtkWidget *widget,
GdkDragContext *context, GdkDragContext *context,
gint x, gint x,
gint y, gint y,
GtkSelectionData *selection_data, GtkSelectionData *selection_data,
guint info, guint info,
guint time, guint time,
EDayView *day_view) EDayView *day_view)
{ {
EDayViewEvent *event = NULL; EDayViewEvent *event = NULL;
ECalendarViewPosition pos; ECalendarViewPosition pos;
gint day, start_day, end_day, num_days; gint day, start_day, end_day, num_days;
gint start_offset, end_offset; gint start_offset, end_offset;
ECalComponent *comp; ECalComponent *comp;
ECalComponentDateTime date;
ESourceRegistry *registry; ESourceRegistry *registry;
struct icaltimetype itt;
time_t dt; time_t dt;
gboolean all_day_event; gboolean all_day_event;
ECalModel *model; ECalModel *model;
ECalendarView *cal_view; ECalendarView *cal_view;
gboolean drag_from_same_window; gboolean drag_from_same_window;
const guchar *data; const guchar *data;
gint format, length; gint format, length;
gint days_shown; gint days_shown;
GtkResponseType send = GTK_RESPONSE_NO; GtkResponseType send = GTK_RESPONSE_NO;
gboolean only_new_attendees = FALSE; gboolean only_new_attendees = FALSE;
skipping to change at line 9169 skipping to change at line 9215
/* Note that we only support DnD within the EDayView at present. */ /* Note that we only support DnD within the EDayView at present. */
if (length >= 0 && format == 8 && day_view->drag_event_day != -1) { if (length >= 0 && format == 8 && day_view->drag_event_day != -1) {
/* We are dragging in the same window */ /* We are dragging in the same window */
pos = e_day_view_convert_position_in_top_canvas ( pos = e_day_view_convert_position_in_top_canvas (
day_view, day_view,
x, y, &day, x, y, &day,
NULL); NULL);
if (pos != E_CALENDAR_VIEW_POS_OUTSIDE) { if (pos != E_CALENDAR_VIEW_POS_OUTSIDE) {
ECalComponentDateTime *date;
ECalObjModType mod = E_CAL_OBJ_MOD_ALL; ECalObjModType mod = E_CAL_OBJ_MOD_ALL;
ECalClient *client; ECalClient *client;
GtkWindow *toplevel; GtkWindow *toplevel;
ICalTime *itt;
ICalTimezone *zone;
num_days = 1; num_days = 1;
start_offset = 0; start_offset = 0;
end_offset = 0; end_offset = 0;
if (day_view->drag_event_day == E_DAY_VIEW_LONG_EVENT) { if (day_view->drag_event_day == E_DAY_VIEW_LONG_EVENT) {
if (!is_array_index_in_bounds (day_view->long_eve nts, day_view->drag_event_num)) if (!is_array_index_in_bounds (day_view->long_eve nts, day_view->drag_event_num))
return; return;
event = &g_array_index (day_view->long_events, ED ayViewEvent, event = &g_array_index (day_view->long_events, ED ayViewEvent,
skipping to change at line 9221 skipping to change at line 9270
return; return;
} }
client = event->comp_data->client; client = event->comp_data->client;
/* We clone the event since we don't want to change /* We clone the event since we don't want to change
* the original comp here. * the original comp here.
* Otherwise we would not detect that the event's time * Otherwise we would not detect that the event's time
* had changed in the "update_event" callback. */ * had changed in the "update_event" callback. */
comp = e_cal_component_new (); comp = e_cal_component_new_from_icalcomponent (i_cal_comp
e_cal_component_set_icalcomponent (comp, icalcomponent_ne onent_clone (event->comp_data->icalcomp));
w_clone (event->comp_data->icalcomp)); if (!comp)
return;
if (e_cal_component_has_attendees (comp) && if (e_cal_component_has_attendees (comp) &&
!itip_organizer_is_user (registry, comp, client)) { !itip_organizer_is_user (registry, comp, client)) {
g_object_unref (comp); g_object_unref (comp);
return; return;
} }
toplevel = GTK_WINDOW (gtk_widget_get_toplevel (GTK_WIDGE T (day_view))); toplevel = GTK_WINDOW (gtk_widget_get_toplevel (GTK_WIDGE T (day_view)));
if (itip_has_any_attendees (comp) && if (itip_has_any_attendees (comp) &&
skipping to change at line 9249 skipping to change at line 9299
e_day_view_abort_resize (day_view); e_day_view_abort_resize (day_view);
g_object_unref (comp); g_object_unref (comp);
return; return;
} }
if (start_offset == 0 && end_offset == 0) if (start_offset == 0 && end_offset == 0)
all_day_event = TRUE; all_day_event = TRUE;
else else
all_day_event = FALSE; all_day_event = FALSE;
date.value = &itt; zone = e_calendar_view_get_timezone (E_CALENDAR_VIEW (day
_view));
dt = day_view->day_starts[day] + start_offset * 60; dt = day_view->day_starts[day] + start_offset * 60;
itt = icaltime_from_timet_with_zone ( itt = i_cal_time_new_from_timet_with_zone (dt, FALSE, zon
dt, FALSE, e);
e_calendar_view_get_timezone (E_CALENDAR_VIEW (da
y_view)));
if (all_day_event) { if (all_day_event) {
itt.is_date = TRUE; i_cal_time_set_is_date (itt, TRUE);
date.tzid = NULL; date = e_cal_component_datetime_new_take (itt, NU
LL);
} else { } else {
/* FIXME: Should probably keep the timezone of date = e_cal_component_datetime_new_take (itt,
* the original start and end times. */ zone ? g_strdup (i_cal_timezone_get_tzid
date.tzid = icaltimezone_get_tzid (e_calendar_vie (zone)) : NULL);
w_get_timezone (E_CALENDAR_VIEW (day_view)));
} }
cal_comp_set_dtstart_with_oldzone (client, comp, &date); cal_comp_set_dtstart_with_oldzone (client, comp, date);
e_cal_component_datetime_free (date);
if (end_offset == 0) if (end_offset == 0)
dt = day_view->day_starts[day + num_days]; dt = day_view->day_starts[day + num_days];
else else
dt = day_view->day_starts[day + num_days - 1] + e nd_offset * 60; dt = day_view->day_starts[day + num_days - 1] + e nd_offset * 60;
itt = icaltime_from_timet_with_zone ( itt = i_cal_time_new_from_timet_with_zone (dt, FALSE, zon
dt, FALSE, e);
e_calendar_view_get_timezone (E_CALENDAR_VIEW (da
y_view)));
if (all_day_event) { if (all_day_event) {
itt.is_date = TRUE; i_cal_time_set_is_date (itt, TRUE);
date.tzid = NULL; date = e_cal_component_datetime_new_take (itt, NU
LL);
} else { } else {
/* FIXME: Should probably keep the timezone of date = e_cal_component_datetime_new_take (itt,
* the original start and end times. */ zone ? g_strdup (i_cal_timezone_get_tzid
date.tzid = icaltimezone_get_tzid (e_calendar_vie (zone)) : NULL);
w_get_timezone (E_CALENDAR_VIEW (day_view)));
} }
cal_comp_set_dtend_with_oldzone (client, comp, &date); cal_comp_set_dtend_with_oldzone (client, comp, date);
gtk_drag_finish (context, TRUE, TRUE, time); gtk_drag_finish (context, TRUE, TRUE, time);
/* Reset this since it will be invalid. */ /* Reset this since it will be invalid. */
day_view->drag_event_day = -1; day_view->drag_event_day = -1;
g_clear_object (&day_view->priv->drag_context); g_clear_object (&day_view->priv->drag_context);
/* Show the text item again, just in case it hasn't /* Show the text item again, just in case it hasn't
* moved. If we don't do this it may not appear. */ * moved. If we don't do this it may not appear. */
if (event->canvas_item) if (event->canvas_item)
skipping to change at line 9302 skipping to change at line 9346
e_cal_component_commit_sequence (comp); e_cal_component_commit_sequence (comp);
if (e_cal_component_has_recurrences (comp)) { if (e_cal_component_has_recurrences (comp)) {
if (!e_cal_dialogs_recur_component (client, comp, &mod, NULL, FALSE)) { if (!e_cal_dialogs_recur_component (client, comp, &mod, NULL, FALSE)) {
gtk_widget_queue_draw (day_view->top_canv as); gtk_widget_queue_draw (day_view->top_canv as);
g_object_unref (comp); g_object_unref (comp);
return; return;
} }
if (mod == E_CAL_OBJ_MOD_THIS) { if (mod == E_CAL_OBJ_MOD_THIS) {
e_cal_component_set_rdate_list (comp, NUL e_cal_component_set_rdates (comp, NULL);
L); e_cal_component_set_rrules (comp, NULL);
e_cal_component_set_rrule_list (comp, NUL e_cal_component_set_exdates (comp, NULL);
L); e_cal_component_set_exrules (comp, NULL);
e_cal_component_set_exdate_list (comp, NU
LL);
e_cal_component_set_exrule_list (comp, NU
LL);
} }
} else if (e_cal_component_is_instance (comp)) } else if (e_cal_component_is_instance (comp))
mod = E_CAL_OBJ_MOD_THIS; mod = E_CAL_OBJ_MOD_THIS;
e_cal_component_commit_sequence (comp); e_cal_component_commit_sequence (comp);
e_cal_ops_modify_component (model, client, e_cal_componen t_get_icalcomponent (comp), mod, e_cal_ops_modify_component (model, client, e_cal_componen t_get_icalcomponent (comp), mod,
(send == GTK_RESPONSE_YES ? E_CAL_OPS_SEND_FLAG_S END : E_CAL_OPS_SEND_FLAG_DONT_SEND) | (send == GTK_RESPONSE_YES ? E_CAL_OPS_SEND_FLAG_S END : E_CAL_OPS_SEND_FLAG_DONT_SEND) |
(strip_alarms ? E_CAL_OPS_SEND_FLAG_STRIP_ALARMS : 0) | (strip_alarms ? E_CAL_OPS_SEND_FLAG_STRIP_ALARMS : 0) |
(only_new_attendees ? E_CAL_OPS_SEND_FLAG_ONLY_NE W_ATTENDEES : 0)); (only_new_attendees ? E_CAL_OPS_SEND_FLAG_ONLY_NE W_ATTENDEES : 0));
g_object_unref (comp); g_object_unref (comp);
return; return;
} }
} }
if (length >= 0 && format == 8 && !drag_from_same_window) { if (length >= 0 && format == 8 && !drag_from_same_window) {
/* We are dragging between different window */ /* We are dragging between different window */
icalcomponent *icalcomp; ICalComponent *icomp;
icalcomponent_kind kind; ICalComponentKind kind;
pos = e_day_view_convert_position_in_top_canvas ( pos = e_day_view_convert_position_in_top_canvas (
day_view, day_view,
x, y, &day, x, y, &day,
NULL); NULL);
if (pos == E_CALENDAR_VIEW_POS_OUTSIDE) if (pos == E_CALENDAR_VIEW_POS_OUTSIDE)
goto error; goto error;
icalcomp = icalparser_parse_string ((const gchar *) data); icomp = i_cal_parser_parse_string ((const gchar *) data);
if (!icalcomp) if (!icomp)
goto error; goto error;
/* check the type of the component */ /* check the type of the component */
kind = icalcomponent_isa (icalcomp); kind = i_cal_component_isa (icomp);
icalcomponent_free (icalcomp); g_clear_object (&icomp);
if (kind != ICAL_VCALENDAR_COMPONENT && kind != ICAL_VEVENT_COMPO NENT) if (kind != I_CAL_VCALENDAR_COMPONENT && kind != I_CAL_VEVENT_COM PONENT)
goto error; goto error;
e_cal_ops_paste_components (model, (const gchar *) data); e_cal_ops_paste_components (model, (const gchar *) data);
gtk_drag_finish (context, TRUE, TRUE, time); gtk_drag_finish (context, TRUE, TRUE, time);
return; return;
} }
error: error:
gtk_drag_finish (context, FALSE, FALSE, time); gtk_drag_finish (context, FALSE, FALSE, time);
skipping to change at line 9374 skipping to change at line 9418
EDayView *day_view) EDayView *day_view)
{ {
ECalendarView *cal_view; ECalendarView *cal_view;
EDayViewEvent *event = NULL; EDayViewEvent *event = NULL;
ECalendarViewPosition pos; ECalendarViewPosition pos;
gint time_divisions; gint time_divisions;
gint day, row, start_row, end_row, num_rows, scroll_x, scroll_y; gint day, row, start_row, end_row, num_rows, scroll_x, scroll_y;
gint start_offset, end_offset; gint start_offset, end_offset;
ECalModel *model; ECalModel *model;
ECalComponent *comp; ECalComponent *comp;
ECalComponentDateTime date;
ESourceRegistry *registry; ESourceRegistry *registry;
struct icaltimetype itt;
time_t dt; time_t dt;
gboolean drag_from_same_window; gboolean drag_from_same_window;
const guchar *data; const guchar *data;
gint format, length; gint format, length;
GtkResponseType send = GTK_RESPONSE_NO; GtkResponseType send = GTK_RESPONSE_NO;
gboolean only_new_attendees = FALSE; gboolean only_new_attendees = FALSE;
gboolean strip_alarms = TRUE; gboolean strip_alarms = TRUE;
cal_view = E_CALENDAR_VIEW (day_view); cal_view = E_CALENDAR_VIEW (day_view);
model = e_calendar_view_get_model (cal_view); model = e_calendar_view_get_model (cal_view);
skipping to change at line 9415 skipping to change at line 9457
/* Note that we only support DnD within the EDayView at present. */ /* Note that we only support DnD within the EDayView at present. */
if (length >= 0 && format == 8 && (day_view->drag_event_day != -1)) { if (length >= 0 && format == 8 && (day_view->drag_event_day != -1)) {
/* We are dragging in the same window */ /* We are dragging in the same window */
pos = e_day_view_convert_position_in_main_canvas ( pos = e_day_view_convert_position_in_main_canvas (
day_view, day_view,
x, y, &day, x, y, &day,
&row, NULL); &row, NULL);
if (pos != E_CALENDAR_VIEW_POS_OUTSIDE) { if (pos != E_CALENDAR_VIEW_POS_OUTSIDE) {
ECalComponentDateTime *date;
ECalObjModType mod = E_CAL_OBJ_MOD_ALL; ECalObjModType mod = E_CAL_OBJ_MOD_ALL;
ECalClient *client; ECalClient *client;
GtkWindow *toplevel; GtkWindow *toplevel;
ICalTimezone *zone;
num_rows = 1; num_rows = 1;
start_offset = 0; start_offset = 0;
end_offset = 0; end_offset = 0;
if (day_view->drag_event_day == E_DAY_VIEW_LONG_EVENT) { if (day_view->drag_event_day == E_DAY_VIEW_LONG_EVENT) {
if (!is_array_index_in_bounds (day_view->long_eve nts, day_view->drag_event_num)) if (!is_array_index_in_bounds (day_view->long_eve nts, day_view->drag_event_num))
return; return;
event = &g_array_index (day_view->long_events, ED ayViewEvent, event = &g_array_index (day_view->long_events, ED ayViewEvent,
skipping to change at line 9465 skipping to change at line 9509
if (end_offset != 0) if (end_offset != 0)
end_offset = time_divisions - end_offset; end_offset = time_divisions - end_offset;
} }
client = event->comp_data->client; client = event->comp_data->client;
/* We use a temporary shallow copy of comp since we /* We use a temporary shallow copy of comp since we
* don't want to change the original comp here. * don't want to change the original comp here.
* Otherwise we would not detect that the event's time * Otherwise we would not detect that the event's time
* had changed in the "update_event" callback. */ * had changed in the "update_event" callback. */
comp = e_cal_component_new (); comp = e_cal_component_new_from_icalcomponent (i_cal_comp
e_cal_component_set_icalcomponent (comp, icalcomponent_ne onent_clone (event->comp_data->icalcomp));
w_clone (event->comp_data->icalcomp)); if (!comp)
return;
if (e_cal_component_has_attendees (comp) && if (e_cal_component_has_attendees (comp) &&
!itip_organizer_is_user (registry, comp, client)) { !itip_organizer_is_user (registry, comp, client)) {
g_object_unref (comp); g_object_unref (comp);
return; return;
} }
toplevel = GTK_WINDOW (gtk_widget_get_toplevel (GTK_WIDGE T (day_view))); toplevel = GTK_WINDOW (gtk_widget_get_toplevel (GTK_WIDGE T (day_view)));
if (itip_has_any_attendees (comp) && if (itip_has_any_attendees (comp) &&
skipping to change at line 9488 skipping to change at line 9533
itip_sentby_is_user (registry, comp, client))) itip_sentby_is_user (registry, comp, client)))
send = e_cal_dialogs_send_dragged_or_resized_comp onent ( send = e_cal_dialogs_send_dragged_or_resized_comp onent (
toplevel, client, comp, &strip_al arms, &only_new_attendees); toplevel, client, comp, &strip_al arms, &only_new_attendees);
if (send == GTK_RESPONSE_CANCEL) { if (send == GTK_RESPONSE_CANCEL) {
e_day_view_abort_resize (day_view); e_day_view_abort_resize (day_view);
g_object_unref (comp); g_object_unref (comp);
return; return;
} }
date.value = &itt; zone = e_calendar_view_get_timezone (E_CALENDAR_VIEW (day
date.tzid = icaltimezone_get_tzid (e_calendar_view_get_ti _view));
mezone (E_CALENDAR_VIEW (day_view)));
dt = e_day_view_convert_grid_position_to_time (day_view, day, row) + start_offset * 60; dt = e_day_view_convert_grid_position_to_time (day_view, day, row) + start_offset * 60;
*date.value = icaltime_from_timet_with_zone (dt, FALSE, date = e_cal_component_datetime_new_take (
e_calendar_v i_cal_time_new_from_timet_with_zone (dt, FALSE, z
iew_get_timezone (E_CALENDAR_VIEW (day_view))); one),
cal_comp_set_dtstart_with_oldzone (client, comp, &date); zone ? g_strdup (i_cal_timezone_get_tzid (zone))
: NULL);
cal_comp_set_dtstart_with_oldzone (client, comp, date);
e_cal_component_datetime_free (date);
dt = e_day_view_convert_grid_position_to_time (day_view, day, row + num_rows) - end_offset * 60; dt = e_day_view_convert_grid_position_to_time (day_view, day, row + num_rows) - end_offset * 60;
*date.value = icaltime_from_timet_with_zone (dt, FALSE, date = e_cal_component_datetime_new_take (
e_calendar_v i_cal_time_new_from_timet_with_zone (dt, FALSE, z
iew_get_timezone (E_CALENDAR_VIEW (day_view))); one),
cal_comp_set_dtend_with_oldzone (client, comp, &date); zone ? g_strdup (i_cal_timezone_get_tzid (zone))
: NULL);
cal_comp_set_dtend_with_oldzone (client, comp, date);
e_cal_component_datetime_free (date);
e_cal_component_abort_sequence (comp); e_cal_component_abort_sequence (comp);
gtk_drag_finish (context, TRUE, TRUE, time); gtk_drag_finish (context, TRUE, TRUE, time);
/* Reset this since it will be invalid. */ /* Reset this since it will be invalid. */
day_view->drag_event_day = -1; day_view->drag_event_day = -1;
g_clear_object (&day_view->priv->drag_context); g_clear_object (&day_view->priv->drag_context);
/* Show the text item again, just in case it hasn't /* Show the text item again, just in case it hasn't
* moved. If we don't do this it may not appear. */ * moved. If we don't do this it may not appear. */
skipping to change at line 9521 skipping to change at line 9571
e_cal_component_commit_sequence (comp); e_cal_component_commit_sequence (comp);
if (e_cal_component_has_recurrences (comp)) { if (e_cal_component_has_recurrences (comp)) {
if (!e_cal_dialogs_recur_component (client, comp, &mod, NULL, FALSE)) { if (!e_cal_dialogs_recur_component (client, comp, &mod, NULL, FALSE)) {
gtk_widget_queue_draw (day_view->main_can vas); gtk_widget_queue_draw (day_view->main_can vas);
g_object_unref (comp); g_object_unref (comp);
return; return;
} }
if (mod == E_CAL_OBJ_MOD_THIS) { if (mod == E_CAL_OBJ_MOD_THIS) {
e_cal_component_set_rdate_list (comp, NUL e_cal_component_set_rdates (comp, NULL);
L); e_cal_component_set_rrules (comp, NULL);
e_cal_component_set_rrule_list (comp, NUL e_cal_component_set_exdates (comp, NULL);
L); e_cal_component_set_exrules (comp, NULL);
e_cal_component_set_exdate_list (comp, NU
LL);
e_cal_component_set_exrule_list (comp, NU
LL);
} }
} else if (e_cal_component_is_instance (comp)) } else if (e_cal_component_is_instance (comp))
mod = E_CAL_OBJ_MOD_THIS; mod = E_CAL_OBJ_MOD_THIS;
e_cal_component_commit_sequence (comp); e_cal_component_commit_sequence (comp);
e_cal_ops_modify_component (model, client, e_cal_componen t_get_icalcomponent (comp), mod, e_cal_ops_modify_component (model, client, e_cal_componen t_get_icalcomponent (comp), mod,
(send == GTK_RESPONSE_YES ? E_CAL_OPS_SEND_FLAG_S END : E_CAL_OPS_SEND_FLAG_DONT_SEND) | (send == GTK_RESPONSE_YES ? E_CAL_OPS_SEND_FLAG_S END : E_CAL_OPS_SEND_FLAG_DONT_SEND) |
(strip_alarms ? E_CAL_OPS_SEND_FLAG_STRIP_ALARMS : 0) | (strip_alarms ? E_CAL_OPS_SEND_FLAG_STRIP_ALARMS : 0) |
(only_new_attendees ? E_CAL_OPS_SEND_FLAG_ONLY_NE W_ATTENDEES : 0)); (only_new_attendees ? E_CAL_OPS_SEND_FLAG_ONLY_NE W_ATTENDEES : 0));
g_object_unref (comp); g_object_unref (comp);
return; return;
} }
} }
if (length >= 0 && format == 8 && !drag_from_same_window) { if (length >= 0 && format == 8 && !drag_from_same_window) {
/* We are dragging between different window */ /* We are dragging between different window */
icalcomponent *icalcomp; ICalComponent *icomp;
icalcomponent_kind kind; ICalComponentKind kind;
pos = e_day_view_convert_position_in_main_canvas ( pos = e_day_view_convert_position_in_main_canvas (
day_view, day_view,
x, y, &day, x, y, &day,
&row, NULL); &row, NULL);
if (pos == E_CALENDAR_VIEW_POS_OUTSIDE) if (pos == E_CALENDAR_VIEW_POS_OUTSIDE)
goto error; goto error;
icalcomp = icalparser_parse_string ((const gchar *) data); icomp = i_cal_parser_parse_string ((const gchar *) data);
if (!icalcomp) if (!icomp)
goto error; goto error;
/* check the type of the component */ /* check the type of the component */
kind = icalcomponent_isa (icalcomp); kind = i_cal_component_isa (icomp);
icalcomponent_free (icalcomp); g_object_unref (&icomp);
if (kind != ICAL_VCALENDAR_COMPONENT && kind != ICAL_VEVENT_COMPO NENT) if (kind != I_CAL_VCALENDAR_COMPONENT && kind != I_CAL_VEVENT_COM PONENT)
goto error; goto error;
e_cal_ops_paste_components (model, (const gchar *) data); e_cal_ops_paste_components (model, (const gchar *) data);
gtk_drag_finish (context, TRUE, TRUE, time); gtk_drag_finish (context, TRUE, TRUE, time);
return; return;
} }
error: error:
gtk_drag_finish (context, FALSE, FALSE, time); gtk_drag_finish (context, FALSE, FALSE, time);
skipping to change at line 9680 skipping to change at line 9730
gboolean gboolean
e_day_view_is_editing (EDayView *day_view) e_day_view_is_editing (EDayView *day_view)
{ {
g_return_val_if_fail (E_IS_DAY_VIEW (day_view), FALSE); g_return_val_if_fail (E_IS_DAY_VIEW (day_view), FALSE);
return day_view->editing_event_day != -1; return day_view->editing_event_day != -1;
} }
static void static void
day_view_update_timezone_name_label (GtkWidget *label, day_view_update_timezone_name_label (GtkWidget *label,
icaltimezone *zone) ICalTimezone *zone)
{ {
const gchar *location, *dash; const gchar *location, *dash;
gchar *markup; gchar *markup;
g_return_if_fail (GTK_IS_LABEL (label)); g_return_if_fail (GTK_IS_LABEL (label));
if (!zone) { if (!zone) {
location = NULL; location = NULL;
} else { } else {
location = icaltimezone_get_location (zone); location = i_cal_timezone_get_location (zone);
if (location && *location) if (location && *location)
location = _(location); location = _(location);
if (!location || !*location) if (!location || !*location)
location = icaltimezone_get_tzid (zone); location = i_cal_timezone_get_tzid (zone);
} }
if (!location) if (!location)
location = ""; location = "";
gtk_widget_set_tooltip_text (label, location); gtk_widget_set_tooltip_text (label, location);
dash = strchr (location, '/'); dash = strchr (location, '/');
if (dash && *dash && dash[1]) if (dash && *dash && dash[1])
location = dash + 1; location = dash + 1;
markup = g_markup_printf_escaped ("<small>%s</small>", location); markup = g_markup_printf_escaped ("<small>%s</small>", location);
gtk_label_set_markup (GTK_LABEL (label), markup); gtk_label_set_markup (GTK_LABEL (label), markup);
g_free (markup); g_free (markup);
} }
void void
e_day_view_update_timezone_name_labels (EDayView *day_view) e_day_view_update_timezone_name_labels (EDayView *day_view)
{ {
icaltimezone *zone; ICalTimezone *zone;
g_return_if_fail (E_IS_DAY_VIEW (day_view)); g_return_if_fail (E_IS_DAY_VIEW (day_view));
zone = e_cal_model_get_timezone (day_view->priv->model); zone = e_cal_model_get_timezone (day_view->priv->model);
day_view_update_timezone_name_label (day_view->priv->timezone_name_1_labe l, zone); day_view_update_timezone_name_label (day_view->priv->timezone_name_1_labe l, zone);
zone = e_day_view_time_item_get_second_zone (E_DAY_VIEW_TIME_ITEM (day_vi ew->time_canvas_item)); zone = e_day_view_time_item_get_second_zone (E_DAY_VIEW_TIME_ITEM (day_vi ew->time_canvas_item));
if (!zone) { if (!zone) {
gtk_widget_hide (day_view->priv->timezone_name_2_label); gtk_widget_hide (day_view->priv->timezone_name_2_label);
} else { } else {
 End of changes. 167 change blocks. 
433 lines changed or deleted 491 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)