diff options
Diffstat (limited to 'calendar/gui')
26 files changed, 561 insertions, 400 deletions
diff --git a/calendar/gui/calendar-component.c b/calendar/gui/calendar-component.c index 5b8f40a1b8..f7f91080f8 100644 --- a/calendar/gui/calendar-component.c +++ b/calendar/gui/calendar-component.c @@ -352,6 +352,88 @@ impl_handleURI (PortableServer_Servant servant, const char *uri, CORBA_Environme } static void +<<<<<<< .working +======= +impl_upgradeFromVersion (PortableServer_Servant servant, + CORBA_short major, + CORBA_short minor, + CORBA_short revision, + CORBA_Environment *ev) +{ + GError *err = NULL; + CalendarComponent *calendar_component = CALENDAR_COMPONENT (bonobo_object_from_servant (servant)); + + if (!migrate_calendars (calendar_component, major, minor, revision, &err)) { + GNOME_Evolution_Component_UpgradeFailed *failedex; + + failedex = GNOME_Evolution_Component_UpgradeFailed__alloc(); + failedex->what = CORBA_string_dup(_("Failed upgrading calendars.")); + failedex->why = CORBA_string_dup(err->message); + CORBA_exception_set(ev, CORBA_USER_EXCEPTION, ex_GNOME_Evolution_Component_UpgradeFailed, failedex); + } + + if (err) + g_error_free(err); +} + +static gboolean +selector_tree_data_dropped (ESourceSelector *selector, + GtkSelectionData *data, + ESource *destination, + GdkDragAction action, + guint info, + CalendarComponent *component) +{ + gboolean success = FALSE; + ECal *client; + + client = auth_new_cal_from_source (destination, E_CAL_SOURCE_TYPE_EVENT); + + if (!client || !e_cal_open (client, TRUE, NULL)) { + if (client) + g_object_unref (client); + + return FALSE; + } + + if (data->data) { + icalcomponent *icalcomp = NULL; + char *comp_str; /* do not free this! */ + + /* data->data is "source_uid\ncomponent_string" */ + comp_str = strchr ((char *)data->data, '\n'); + if (comp_str) { + comp_str [0] = 0; + comp_str++; + + icalcomp = icalparser_parse_string (comp_str); + + if (icalcomp) { + success = cal_comp_process_source_list_drop (client, icalcomp, action, (char *)data->data, component->priv->source_list); + icalcomponent_free (icalcomp); + } + } + } + + return success; +} + +static void +control_activate_cb (BonoboControl *control, gboolean activate, gpointer data) +{ + CalendarComponentView *component_view = data; + + if (activate) { + BonoboUIComponent *uic; + uic = bonobo_control_get_ui_component (component_view->view_control); + + e_user_creatable_items_handler_activate (component_view->creatable_items_handler, uic); + } +} + + +static void +>>>>>>> .merge-right.r37199 config_create_ecal_changed_cb (GConfClient *client, guint id, GConfEntry *entry, gpointer data) { CalendarComponent *calendar_component = data; @@ -475,6 +557,16 @@ create_component_view (CalendarComponent *calendar_component) /* Create sidebar selector */ component_view->source_selector = e_source_selector_new (calendar_component->priv->source_list); +<<<<<<< .working +======= + g_signal_connect ( + component_view->source_selector, "data-dropped", + G_CALLBACK (selector_tree_data_dropped), calendar_component); + + gtk_drag_dest_set(component_view->source_selector, GTK_DEST_DEFAULT_ALL, drag_types, + num_drag_types, GDK_ACTION_COPY | GDK_ACTION_MOVE); + +>>>>>>> .merge-right.r37199 gtk_widget_show (component_view->source_selector); /* Set up the "new" item handler */ diff --git a/calendar/gui/comp-util.c b/calendar/gui/comp-util.c index 9504c7bda7..9a58a8cf6b 100644 --- a/calendar/gui/comp-util.c +++ b/calendar/gui/comp-util.c @@ -33,6 +33,7 @@ #include "dialogs/delete-comp.h" #include <libecal/e-cal-component.h> #include "e-util/e-categories-config.h" +#include "common/authentication.h" @@ -607,3 +608,191 @@ cal_comp_set_dtend_with_oldzone (ECal *client, ECalComponent *comp, const ECalCo e_cal_component_free_datetime (&olddate); } + +static gboolean +update_single_object (ECal *client, icalcomponent *icalcomp, gboolean fail_on_modify) +{ + const char *uid; + char *tmp; + icalcomponent *tmp_icalcomp; + gboolean res; + + uid = icalcomponent_get_uid (icalcomp); + + if (e_cal_get_object (client, uid, NULL, &tmp_icalcomp, NULL)) { + if (fail_on_modify) + return FALSE; + + return e_cal_modify_object (client, icalcomp, CALOBJ_MOD_ALL, NULL); + } + + tmp = NULL; + res = e_cal_create_object (client, icalcomp, &tmp, NULL); + + g_free (tmp); + + return res; +} + +static gboolean +update_objects (ECal *client, icalcomponent *icalcomp) +{ + icalcomponent *subcomp; + icalcomponent_kind kind; + + kind = icalcomponent_isa (icalcomp); + if (kind == ICAL_VTODO_COMPONENT || + kind == ICAL_VEVENT_COMPONENT || + kind == ICAL_VJOURNAL_COMPONENT) + return update_single_object (client, icalcomp, kind == ICAL_VJOURNAL_COMPONENT); + else if (kind != ICAL_VCALENDAR_COMPONENT) + return FALSE; + + subcomp = icalcomponent_get_first_component (icalcomp, ICAL_ANY_COMPONENT); + while (subcomp) { + gboolean success; + + kind = icalcomponent_isa (subcomp); + if (kind == ICAL_VTIMEZONE_COMPONENT) { + icaltimezone *zone; + + zone = icaltimezone_new (); + icaltimezone_set_component (zone, subcomp); + + success = e_cal_add_timezone (client, zone, NULL); + icaltimezone_free (zone, 1); + if (!success) + return success; + } else if (kind == ICAL_VTODO_COMPONENT || + kind == ICAL_VEVENT_COMPONENT || + kind == ICAL_VJOURNAL_COMPONENT) { + success = update_single_object (client, subcomp, kind == ICAL_VJOURNAL_COMPONENT); + if (!success) + return success; + } + + subcomp = icalcomponent_get_next_component (icalcomp, ICAL_ANY_COMPONENT); + } + + return TRUE; +} + +/** + * cal_comp_process_source_list_drop: + * Processes the drop signal over the ESourceList. + * @param destination Where to put the component. + * @param comp Component to move/copy. + * @param action What to do. + * @param source_uid Where the component comes from; used when moving. + * @param source_list The ESourceList over which the event was called. + * @return Whether was the operation successful. + **/ +gboolean +cal_comp_process_source_list_drop (ECal *destination, icalcomponent *comp, GdkDragAction action, const char *source_uid, ESourceList *source_list) +{ + const char * uid; + char *old_uid = NULL; + icalcomponent *tmp_icalcomp = NULL; + GError *error = NULL; + gboolean success = FALSE; + + g_return_val_if_fail (destination != NULL, FALSE); + g_return_val_if_fail (comp != NULL, FALSE); + g_return_val_if_fail (source_uid != NULL, FALSE); + g_return_val_if_fail (source_list != NULL, FALSE); + + /* FIXME deal with GDK_ACTION_ASK */ + if (action == GDK_ACTION_COPY) { + char *tmp; + + old_uid = g_strdup (icalcomponent_get_uid (comp)); + tmp = e_cal_component_gen_uid (); + + icalcomponent_set_uid (comp, tmp); + g_free (tmp); + } + + uid = icalcomponent_get_uid (comp); + if (!old_uid) + old_uid = g_strdup (uid); + + if (!e_cal_get_object (destination, uid, NULL, &tmp_icalcomp, &error)) { + if ((error != NULL) && (error->code != E_CALENDAR_STATUS_OBJECT_NOT_FOUND)) { + switch (e_cal_get_source_type (destination)) { + case E_CAL_SOURCE_TYPE_EVENT: + g_message ("Failed to search the object in destination event list: %s", error->message); + break; + case E_CAL_SOURCE_TYPE_TODO: + g_message ("Failed to search the object in destination task list: %s", error->message); + break; + case E_CAL_SOURCE_TYPE_JOURNAL: + g_message ("Failed to search the object in destination memo list: %s", error->message); + break; + default: + break; + } + } else { + /* this will report success by last item, but we don't care */ + success = update_objects (destination, comp); + + if (success && action == GDK_ACTION_MOVE) { + /* remove components rather here, because we know which has been moved */ + ESource *source_source; + ECal *source_client; + + source_source = e_source_list_peek_source_by_uid (source_list, source_uid); + + if (source_source && !E_IS_SOURCE_GROUP (source_source) && !e_source_get_readonly (source_source)) { + source_client = auth_new_cal_from_source (source_source, e_cal_get_source_type (destination)); + + if (source_client) { + gboolean read_only = TRUE; + + e_cal_is_read_only (source_client, &read_only, NULL); + + if (!read_only && e_cal_open (source_client, TRUE, NULL)) + e_cal_remove_object (source_client, old_uid, NULL); + else if (!read_only) { + switch (e_cal_get_source_type (destination)) { + case E_CAL_SOURCE_TYPE_EVENT: + g_message ("Cannot open source client to remove old event"); + break; + case E_CAL_SOURCE_TYPE_TODO: + g_message ("Cannot open source client to remove old task"); + break; + case E_CAL_SOURCE_TYPE_JOURNAL: + g_message ("Cannot open source client to remove old memo"); + break; + default: + break; + } + } + + g_object_unref (source_client); + } else { + switch (e_cal_get_source_type (destination)) { + case E_CAL_SOURCE_TYPE_EVENT: + g_message ("Cannot create source client to remove old event"); + break; + case E_CAL_SOURCE_TYPE_TODO: + g_message ("Cannot create source client to remove old task"); + break; + case E_CAL_SOURCE_TYPE_JOURNAL: + g_message ("Cannot create source client to remove old memo"); + break; + default: + break; + } + } + } + } + } + + g_clear_error (&error); + } else + icalcomponent_free (tmp_icalcomp); + + g_free (old_uid); + + return success; +} diff --git a/calendar/gui/comp-util.h b/calendar/gui/comp-util.h index e4e200217e..3225557a5e 100644 --- a/calendar/gui/comp-util.h +++ b/calendar/gui/comp-util.h @@ -57,4 +57,6 @@ GSList *cal_comp_selection_get_string_list (GtkSelectionData *data); void cal_comp_set_dtstart_with_oldzone (ECal *client, ECalComponent *comp, const ECalComponentDateTime *pdate); void cal_comp_set_dtend_with_oldzone (ECal *client, ECalComponent *comp, const ECalComponentDateTime *pdate); +gboolean cal_comp_process_source_list_drop (ECal *destination, icalcomponent *comp, GdkDragAction action, const char *source_uid, ESourceList *source_list); + #endif diff --git a/calendar/gui/dialogs/e-send-options-utils.c b/calendar/gui/dialogs/e-send-options-utils.c index fde53ca336..52f73aed02 100644 --- a/calendar/gui/dialogs/e-send-options-utils.c +++ b/calendar/gui/dialogs/e-send-options-utils.c @@ -192,7 +192,7 @@ e_sendoptions_utils_fill_component (ESendOptionsDialog *sod, ECalComponent *comp icaltimezone *zone = calendar_config_get_icaltimezone (); temp = icaltime_from_timet_with_zone (gopts->delay_until, FALSE, zone); - str = icaltime_as_ical_string (temp); + str = icaltime_as_ical_string_r (temp); prop = icalproperty_new_x (str); g_free (str); icalproperty_set_x_name (prop, "X-EVOLUTION-OPTIONS-DELAY"); diff --git a/calendar/gui/dialogs/event-editor.c b/calendar/gui/dialogs/event-editor.c index 620600369e..e2ca71c5cb 100644 --- a/calendar/gui/dialogs/event-editor.c +++ b/calendar/gui/dialogs/event-editor.c @@ -568,6 +568,8 @@ event_editor_edit_comp (CompEditor *editor, ECalComponent *comp) } if (!(delegate && e_cal_get_static_capability (client, CAL_STATIC_CAPABILITY_DELEGATE_TO_MANY))) { + event_page_remove_all_attendees (priv->event_page); + for (l = attendees; l != NULL; l = l->next) { ECalComponentAttendee *ca = l->data; EMeetingAttendee *ia; diff --git a/calendar/gui/dialogs/event-page.c b/calendar/gui/dialogs/event-page.c index 53707432d9..2faed38a39 100644 --- a/calendar/gui/dialogs/event-page.c +++ b/calendar/gui/dialogs/event-page.c @@ -1820,27 +1820,28 @@ attendee_added_cb (EMeetingListView *emlv, client = comp_editor_get_client (editor); flags = comp_editor_get_flags (editor); - if (flags & COMP_EDITOR_DELEGATE) { - if (existing_attendee (ia, priv->comp)) - e_meeting_store_remove_attendee (priv->model, ia); - else { - if (!e_cal_get_static_capability (client, - CAL_STATIC_CAPABILITY_DELEGATE_TO_MANY)) { - const char *delegator_id = e_meeting_attendee_get_delfrom (ia); - EMeetingAttendee *delegator; + if (!(flags & COMP_EDITOR_DELEGATE)) + return; + + if (existing_attendee (ia, priv->comp)) { + e_meeting_store_remove_attendee (priv->model, ia); + } else { + if (!e_cal_get_static_capability (client, CAL_STATIC_CAPABILITY_DELEGATE_TO_MANY)) { + const char *delegator_id = e_meeting_attendee_get_delfrom (ia); + EMeetingAttendee *delegator; - delegator = e_meeting_store_find_attendee (priv->model, delegator_id, NULL); - e_meeting_attendee_set_delto (delegator, - g_strdup (e_meeting_attendee_get_address (ia))); + delegator = e_meeting_store_find_attendee (priv->model, delegator_id, NULL); - e_meeting_attendee_set_delfrom (ia, g_strdup_printf ("MAILTO:%s", delegator_id)); - gtk_widget_set_sensitive (priv->invite, FALSE); - gtk_widget_set_sensitive (priv->add, FALSE); - gtk_widget_set_sensitive (priv->edit, FALSE); - } - } -} + g_return_if_fail (delegator != NULL); + e_meeting_attendee_set_delto (delegator, g_strdup (e_meeting_attendee_get_address (ia))); + + e_meeting_attendee_set_delfrom (ia, g_strdup (delegator_id)); + gtk_widget_set_sensitive (priv->invite, FALSE); + gtk_widget_set_sensitive (priv->add, FALSE); + gtk_widget_set_sensitive (priv->edit, FALSE); + } + } } /* Callbacks for list view*/ @@ -3250,3 +3251,23 @@ event_page_add_attendee (EventPage *epage, EMeetingAttendee *attendee) e_meeting_store_add_attendee (priv->model, attendee); e_meeting_list_view_add_attendee_to_name_selector (E_MEETING_LIST_VIEW (priv->list_view), attendee); } + +/** + * event_page_remove_all_attendees + * Removes all attendees from the meeting store and name selector. + * @param epage EventPage. + **/ +void +event_page_remove_all_attendees (EventPage *epage) +{ + EventPagePrivate *priv; + + g_return_if_fail (epage != NULL); + g_return_if_fail (IS_EVENT_PAGE (epage)); + + priv = epage->priv; + + e_meeting_store_remove_all_attendees (priv->model); + e_meeting_list_view_remove_all_attendees_from_name_selector (E_MEETING_LIST_VIEW (priv->list_view)); +} + diff --git a/calendar/gui/dialogs/event-page.h b/calendar/gui/dialogs/event-page.h index 7c868f1d3d..63c0bd2306 100644 --- a/calendar/gui/dialogs/event-page.h +++ b/calendar/gui/dialogs/event-page.h @@ -108,6 +108,7 @@ void event_page_set_view_rvsp (EventPage *epage, ENameSelector * event_page_get_name_selector (EventPage *epage); void event_page_add_attendee (EventPage *epage, EMeetingAttendee *attendee); +void event_page_remove_all_attendees (EventPage *epage); G_END_DECLS diff --git a/calendar/gui/dialogs/task-page.c b/calendar/gui/dialogs/task-page.c index 7d674d20a0..b81119c5cf 100644 --- a/calendar/gui/dialogs/task-page.c +++ b/calendar/gui/dialogs/task-page.c @@ -1155,8 +1155,11 @@ attendee_added_cb (EMeetingListView *emlv, EMeetingAttendee *delegator; delegator = e_meeting_store_find_attendee (priv->model, delegator_id, NULL); + + g_return_if_fail (delegator != NULL); + e_meeting_attendee_set_delto (delegator, - g_strdup (e_meeting_attendee_get_address (ia))); + g_strdup (e_meeting_attendee_get_address (ia))); gtk_widget_set_sensitive (priv->invite, FALSE); gtk_widget_set_sensitive (priv->add, FALSE); diff --git a/calendar/gui/e-cal-model.c b/calendar/gui/e-cal-model.c index 850807ed05..7ead19cc06 100644 --- a/calendar/gui/e-cal-model.c +++ b/calendar/gui/e-cal-model.c @@ -1338,7 +1338,7 @@ search_by_id_and_client (ECalModelPrivate *priv, ECal *client, const ECalCompone gboolean has_rid = (id->rid && *id->rid); uid = icalcomponent_get_uid (comp_data->icalcomp); - rid = icaltime_as_ical_string (icalcomponent_get_recurrenceid (comp_data->icalcomp)); + rid = icaltime_as_ical_string_r (icalcomponent_get_recurrenceid (comp_data->icalcomp)); if (uid && *uid) { if ((!client || comp_data->client == client) && !strcmp (id->uid, uid)) { @@ -1677,10 +1677,10 @@ update_e_cal_view_for_client (ECalModel *model, ECalModelClient *client_data) try_again: if (!e_cal_get_query (client_data->client, priv->full_sexp, &client_data->query, &error)) { - if (error->code == E_CALENDAR_STATUS_BUSY && tries != 3) { + if (error->code == E_CALENDAR_STATUS_BUSY && tries != 10) { tries++; /*TODO chose an optimal value */ - g_usleep (50); + g_usleep (500); g_clear_error (&error); goto try_again; } diff --git a/calendar/gui/e-calendar-table.c b/calendar/gui/e-calendar-table.c index e82a62216e..74d22efe29 100644 --- a/calendar/gui/e-calendar-table.c +++ b/calendar/gui/e-calendar-table.c @@ -1298,7 +1298,7 @@ copy_row_cb (int model_row, gpointer data) e_cal_util_add_timezones_from_component (cal_table->tmp_vcal, comp_data->icalcomp); /* add the new component to the VCALENDAR component */ - comp_str = icalcomponent_as_ical_string (comp_data->icalcomp); + comp_str = icalcomponent_as_ical_string_r (comp_data->icalcomp); child = icalparser_parse_string (comp_str); if (child) { icalcomponent_add_component (cal_table->tmp_vcal, @@ -1328,13 +1328,12 @@ e_calendar_table_copy_clipboard (ECalendarTable *cal_table) etable = e_calendar_table_get_table (cal_table); e_table_selected_row_foreach (etable, copy_row_cb, cal_table); - comp_str = icalcomponent_as_ical_string (cal_table->tmp_vcal); + comp_str = icalcomponent_as_ical_string_r (cal_table->tmp_vcal); clipboard = gtk_widget_get_clipboard (GTK_WIDGET (cal_table), clipboard_atom); if (!gtk_clipboard_set_with_data(clipboard, target_types, n_target_types, clipboard_get_calendar_cb, NULL, comp_str)) { - /* do not free this pointer, it owns libical */ - /* g_free (comp_str); */ + /* no-op */ } else { gtk_clipboard_set_can_store (clipboard, target_types + 1, n_target_types - 1); } diff --git a/calendar/gui/e-calendar-view.c b/calendar/gui/e-calendar-view.c index e24cb6230a..938593a9a6 100644 --- a/calendar/gui/e-calendar-view.c +++ b/calendar/gui/e-calendar-view.c @@ -742,7 +742,7 @@ e_calendar_view_copy_clipboard (ECalendarView *cal_view) /* copy the VCALENDAR to the clipboard */ clipboard = gtk_widget_get_clipboard (GTK_WIDGET (cal_view), GDK_SELECTION_CLIPBOARD); - comp_str = icalcomponent_as_ical_string (vcal_comp); + comp_str = icalcomponent_as_ical_string_r (vcal_comp); if (!gtk_clipboard_set_with_data (clipboard, target_types, n_target_types, clipboard_get_calendar_cb, @@ -1367,7 +1367,7 @@ transfer_item_to (ECalendarViewEvent *event, ECal *dest_client, gboolean remove_ struct icaltimetype recur_id = icalcomponent_get_recurrenceid (event->comp_data->icalcomp); if (!icaltime_is_null_time (recur_id)) - rid = icaltime_as_ical_string (recur_id); + rid = icaltime_as_ical_string_r (recur_id); e_cal_remove_object_with_mod (event->comp_data->client, uid, rid, CALOBJ_MOD_ALL, NULL); g_free (rid); @@ -1922,7 +1922,7 @@ e_calendar_view_new_appointment_full (ECalendarView *cal_view, gboolean all_day, /* We either need rounding or don't want to set all_day for this, we will rather use actual */ /* time in this cases; dtstart should be a midnight in this case */ - if (do_rounding || (!all_day && (dtend - dtstart) % (60 * 60 * 24) == 0)) { + if (do_rounding || (!all_day && (dtend - dtstart) == (60 * 60 * 24))) { struct tm local = *localtime (&now); int time_div = calendar_config_get_time_divisions (); int hours, mins; @@ -2168,7 +2168,7 @@ e_calendar_view_get_attendees_status_info (ECalComponent *comp, ECal *client) char *res = NULL; int i; - if (!comp || !e_cal_component_has_attendees (comp) || !itip_organizer_is_user (comp, client)) + if (!comp || !e_cal_component_has_attendees (comp) || !itip_organizer_is_user_ex (comp, client, TRUE)) return NULL; e_cal_component_get_attendee_list (comp, &attendees); @@ -2409,7 +2409,7 @@ icalcomp_contains_category (icalcomponent *icalcomp, const gchar *category) for (property = icalcomponent_get_first_property (icalcomp, ICAL_CATEGORIES_PROPERTY); property != NULL; property = icalcomponent_get_next_property (icalcomp, ICAL_CATEGORIES_PROPERTY)) { - char *value = icalproperty_get_value_as_string (property); + char *value = icalproperty_get_value_as_string_r (property); if (value && strcmp (category, value) == 0){ g_free (value); diff --git a/calendar/gui/e-day-view-main-item.c b/calendar/gui/e-day-view-main-item.c index 76529d9533..f96e6cc5ed 100644 --- a/calendar/gui/e-day-view-main-item.c +++ b/calendar/gui/e-day-view-main-item.c @@ -602,7 +602,7 @@ e_day_view_main_item_draw_day_event (EDayViewMainItem *dvmitem, GdkGC *gc; GdkColor bg_color; ECalComponent *comp; - gint num_icons, icon_x, icon_y, icon_x_inc, icon_y_inc; + gint num_icons, icon_x, icon_y, icon_x_inc = 0, icon_y_inc = 0; gint max_icon_w, max_icon_h; gboolean draw_reminder_icon, draw_recurrence_icon, draw_timezone_icon, draw_meeting_icon; gboolean draw_attach_icon; @@ -995,92 +995,6 @@ e_day_view_main_item_draw_day_event (EDayViewMainItem *dvmitem, else if (bar_y2 < scroll_flag) event->end_minute -= day_view->mins_per_row; - if (!short_event) - { - if (event->start_minute % day_view->mins_per_row != 0 - || (day_view->show_event_end_times - && event->end_minute % day_view->mins_per_row != 0)) { - offset = day_view->first_hour_shown * 60 - + day_view->first_minute_shown; - show_span = TRUE; - } else { - offset = 0; - } - start_minute = offset + event->start_minute; - end_minute = offset + event->end_minute; - - format_time = (((end_minute - start_minute)/day_view->mins_per_row) >= 2) ? TRUE : FALSE; - - start_hour = start_minute / 60; - start_minute = start_minute % 60; - - end_hour = end_minute / 60; - end_minute = end_minute % 60; - - e_day_view_convert_time_to_display (day_view, start_hour, - &start_display_hour, - &start_suffix, - &start_suffix_width); - e_day_view_convert_time_to_display (day_view, end_hour, - &end_display_hour, - &end_suffix, - &end_suffix_width); - - if (e_calendar_view_get_use_24_hour_format (E_CALENDAR_VIEW (day_view))) { - if (day_view->show_event_end_times && show_span) { - /* 24 hour format with end time. */ - text = g_strdup_printf - ("%2i:%02i-%2i:%02i", - start_display_hour, start_minute, - end_display_hour, end_minute); - } else { - if (format_time) { - /* 24 hour format without end time. */ - text = g_strdup_printf - ("%2i:%02i", - start_display_hour, start_minute); - } - } - } else { - if (day_view->show_event_end_times && show_span) { - /* 12 hour format with end time. */ - text = g_strdup_printf - ("%2i:%02i%s-%2i:%02i%s", - start_display_hour, start_minute, - start_suffix, - end_display_hour, end_minute, end_suffix); - } else { - /* 12 hour format without end time. */ - text = g_strdup_printf - ("%2i:%02i%s", - start_display_hour, start_minute, - start_suffix); - } - } - - cairo_save (cr); - cairo_rectangle (cr, item_x + E_DAY_VIEW_BAR_WIDTH + 1.75, item_y + 2.75, - item_w - E_DAY_VIEW_BAR_WIDTH - 4.5, - 14); - cairo_clip (cr); - cairo_new_path (cr); - if (resize_flag) - cairo_move_to (cr, item_x + E_DAY_VIEW_BAR_WIDTH + 10, item_y + 13); - else - cairo_move_to (cr, item_x + E_DAY_VIEW_BAR_WIDTH + 14, item_y + 13); - if ((red/cc > 0.7) || (green/cc > 0.7) || (blue/cc > 0.7 )) - cairo_set_source_rgb (cr, 0, 0, 0); - else - cairo_set_source_rgb (cr, 1, 1, 1); - cairo_set_font_size (cr, 14.0); - cairo_set_font_options (cr, font_options); - cairo_show_text (cr, text); - cairo_close_path (cr); - cairo_restore (cr); - } - - if (font_options) - cairo_font_options_destroy (font_options); comp = e_cal_component_new (); e_cal_component_set_icalcomponent (comp, icalcomponent_new_clone (event->comp_data->icalcomp)); @@ -1298,6 +1212,98 @@ e_day_view_main_item_draw_day_event (EDayViewMainItem *dvmitem, e_cal_component_free_categories_list (categories_list); } + if (!short_event) + { + if (event->start_minute % day_view->mins_per_row != 0 + || (day_view->show_event_end_times + && event->end_minute % day_view->mins_per_row != 0)) { + offset = day_view->first_hour_shown * 60 + + day_view->first_minute_shown; + show_span = TRUE; + } else { + offset = 0; + } + start_minute = offset + event->start_minute; + end_minute = offset + event->end_minute; + + format_time = (((end_minute - start_minute)/day_view->mins_per_row) >= 2) ? TRUE : FALSE; + + start_hour = start_minute / 60; + start_minute = start_minute % 60; + + end_hour = end_minute / 60; + end_minute = end_minute % 60; + + e_day_view_convert_time_to_display (day_view, start_hour, + &start_display_hour, + &start_suffix, + &start_suffix_width); + e_day_view_convert_time_to_display (day_view, end_hour, + &end_display_hour, + &end_suffix, + &end_suffix_width); + + if (e_calendar_view_get_use_24_hour_format (E_CALENDAR_VIEW (day_view))) { + if (day_view->show_event_end_times && show_span) { + /* 24 hour format with end time. */ + text = g_strdup_printf + ("%2i:%02i-%2i:%02i", + start_display_hour, start_minute, + end_display_hour, end_minute); + } else { + if (format_time) { + /* 24 hour format without end time. */ + text = g_strdup_printf + ("%2i:%02i", + start_display_hour, start_minute); + } + } + } else { + if (day_view->show_event_end_times && show_span) { + /* 12 hour format with end time. */ + text = g_strdup_printf + ("%2i:%02i%s-%2i:%02i%s", + start_display_hour, start_minute, + start_suffix, + end_display_hour, end_minute, end_suffix); + } else { + /* 12 hour format without end time. */ + text = g_strdup_printf + ("%2i:%02i%s", + start_display_hour, start_minute, + start_suffix); + } + } + + cairo_save (cr); + cairo_rectangle (cr, item_x + E_DAY_VIEW_BAR_WIDTH + 1.75, item_y + 2.75, + item_w - E_DAY_VIEW_BAR_WIDTH - 4.5, + 14); + + cairo_clip (cr); + cairo_new_path (cr); + + if (icon_x_inc == 0) + icon_x += 14; + + if (resize_flag) + cairo_move_to (cr, item_x + E_DAY_VIEW_BAR_WIDTH + 10, item_y + 13); + else + cairo_move_to (cr, icon_x, item_y + 13); + if ((red/cc > 0.7) || (green/cc > 0.7) || (blue/cc > 0.7 )) + cairo_set_source_rgb (cr, 0, 0, 0); + else + cairo_set_source_rgb (cr, 1, 1, 1); + cairo_set_font_size (cr, 14.0); + cairo_set_font_options (cr, font_options); + cairo_show_text (cr, text); + cairo_close_path (cr); + cairo_restore (cr); + } + + if (font_options) + cairo_font_options_destroy (font_options); + g_free (text); g_object_unref (comp); cairo_destroy (cr); diff --git a/calendar/gui/e-day-view.c b/calendar/gui/e-day-view.c index 9391f48ced..5bb7850020 100644 --- a/calendar/gui/e-day-view.c +++ b/calendar/gui/e-day-view.c @@ -565,7 +565,7 @@ update_row (EDayView *day_view, int row) prop = icalcomponent_get_first_property (comp_data->icalcomp, ICAL_RECURRENCEID_PROPERTY); if (prop) - rid = icaltime_as_ical_string (icalcomponent_get_recurrenceid (comp_data->icalcomp)); + rid = icaltime_as_ical_string_r (icalcomponent_get_recurrenceid (comp_data->icalcomp)); } if (e_day_view_find_event_from_uid (day_view, comp_data->client, uid, rid, &day, &event_num)) @@ -659,7 +659,7 @@ model_comps_deleted_cb (ETableModel *etm, gpointer data, gpointer user_data) prop = icalcomponent_get_first_property (comp_data->icalcomp, ICAL_RECURRENCEID_PROPERTY); if (prop) - rid = icaltime_as_ical_string (icalcomponent_get_recurrenceid (comp_data->icalcomp)); + rid = icaltime_as_ical_string_r (icalcomponent_get_recurrenceid (comp_data->icalcomp)); } if (e_day_view_find_event_from_uid (day_view, comp_data->client, uid, rid, &day, &event_num)) @@ -1994,7 +1994,7 @@ e_day_view_find_event_from_uid (EDayView *day_view, u = icalcomponent_get_uid (event->comp_data->icalcomp); if (u && !strcmp (uid, u)) { if (rid && *rid) { - r = icaltime_as_ical_string (icalcomponent_get_recurrenceid (event->comp_data->icalcomp)); + r = icaltime_as_ical_string_r (icalcomponent_get_recurrenceid (event->comp_data->icalcomp)); if (!r || !*r) continue; if (strcmp (rid, r) != 0) { @@ -4589,7 +4589,7 @@ e_day_view_reshape_day_events (EDayView *day_view, e_day_view_reshape_day_event (day_view, day, event_num); event = &g_array_index (day_view->events[day], EDayViewEvent, event_num); - current_comp_string = icalcomponent_as_ical_string (event->comp_data->icalcomp); + current_comp_string = icalcomponent_as_ical_string_r (event->comp_data->icalcomp); if (day_view->last_edited_comp_string == NULL) { g_free (current_comp_string); continue; @@ -7373,10 +7373,20 @@ e_day_view_on_drag_data_get (GtkWidget *widget, e_cal_util_add_timezones_from_component (vcal, event->comp_data->icalcomp); icalcomponent_add_component (vcal, icalcomponent_new_clone (event->comp_data->icalcomp)); - comp_str = icalcomponent_as_ical_string (vcal); + comp_str = icalcomponent_as_ical_string_r (vcal); if (comp_str) { + ESource *source = e_cal_get_source (event->comp_data->client); + const char *source_uid = e_source_peek_uid (source); + char *tmp; + + if (!source_uid) + source_uid = ""; + + tmp = g_strconcat (source_uid, "\n", comp_str, NULL); gtk_selection_data_set (selection_data, selection_data->target, - 8, (unsigned char *)comp_str, strlen (comp_str)); + 8, (unsigned char *)tmp, strlen (tmp)); + + g_free (tmp); } icalcomponent_free (vcal); diff --git a/calendar/gui/e-itip-control.c b/calendar/gui/e-itip-control.c index ff6aeb92ba..03001cc3d9 100644 --- a/calendar/gui/e-itip-control.c +++ b/calendar/gui/e-itip-control.c @@ -1950,7 +1950,7 @@ update_item (EItipControl *itip) * and you then look at it in Outlook). */ stamp = icaltime_current_time_with_zone (icaltimezone_get_utc_timezone ()); - str = icaltime_as_ical_string (stamp); + str = icaltime_as_ical_string_r (stamp); prop = icalproperty_new_x (str); g_free (str); icalproperty_set_x_name (prop, "X-MICROSOFT-CDO-REPLYTIME"); diff --git a/calendar/gui/e-meeting-list-view.c b/calendar/gui/e-meeting-list-view.c index 95bdcdff19..78f87c23f5 100644 --- a/calendar/gui/e-meeting-list-view.c +++ b/calendar/gui/e-meeting-list-view.c @@ -296,10 +296,8 @@ e_meeting_list_view_remove_attendee_from_name_selector (EMeetingListView *view, } } else { attendee = e_destination_get_email (des); - if (madd && attendee && g_str_equal (madd, attendee)) { - attendee = e_destination_get_email (des); - e_destination_store_remove_destination (destination_store, des); + e_destination_store_remove_destination (destination_store, des); } } } @@ -307,6 +305,49 @@ e_meeting_list_view_remove_attendee_from_name_selector (EMeetingListView *view, g_list_free (destinations); } +void +e_meeting_list_view_remove_all_attendees_from_name_selector (EMeetingListView *view) +{ + ENameSelectorModel *name_selector_model; + EMeetingListViewPrivate *priv; + guint i; + + priv = view->priv; + + name_selector_model = e_name_selector_peek_model (priv->name_selector); + + for (i = 0; sections[i] != NULL; i++) { + EDestinationStore *destination_store = NULL; + GList *destinations = NULL, *l = NULL; + + e_name_selector_model_peek_section (name_selector_model, sections[i], + NULL, &destination_store); + if (!destination_store) { + g_warning ("destination store is NULL\n"); + continue; + } + + destinations = e_destination_store_list_destinations (destination_store); + for (l = destinations; l; l = g_list_next (l)) { + EDestination *des = l->data; + + if (e_destination_is_evolution_list (des)) { + GList *m, *dl; + + dl = (GList *)e_destination_list_get_dests (des); + + for (m = dl; m; m = m->next) { + g_object_unref (m->data); + m = g_list_remove (m, l->data); + } + } else { + e_destination_store_remove_destination (destination_store, des); + } + } + g_list_free (destinations); + } +} + static void attendee_edited_cb (GtkCellRenderer *renderer, const gchar *path, GList *addresses, GList *names, GtkTreeView *view) { @@ -898,8 +939,12 @@ name_selector_dialog_close_cb (ENameSelectorDialog *dialog, gint response, gpoin ma = e_meeting_store_find_attendee (store, email, &i); - if (ma) - e_meeting_store_remove_attendee (store, ma); + if (ma) { + if (e_meeting_attendee_get_edit_level (ma) != E_MEETING_ATTENDEE_EDIT_FULL) + g_warning ("Not enough rights to delete attendee: %s\n", e_meeting_attendee_get_address (ma)); + else + e_meeting_store_remove_attendee (store, ma); + } } g_slist_free (la); diff --git a/calendar/gui/e-meeting-list-view.h b/calendar/gui/e-meeting-list-view.h index b1ed367257..12deb8a25d 100644 --- a/calendar/gui/e-meeting-list-view.h +++ b/calendar/gui/e-meeting-list-view.h @@ -64,6 +64,8 @@ void e_meeting_list_view_edit (EMeetingListView *emlv, EMeetingAttendee *a void e_meeting_list_view_invite_others_dialog (EMeetingListView *emlv); void e_meeting_list_view_remove_attendee_from_name_selector (EMeetingListView *view, EMeetingAttendee *ma); +void e_meeting_list_view_remove_all_attendees_from_name_selector (EMeetingListView *view); + void e_meeting_list_view_add_attendee_to_name_selector (EMeetingListView *view, EMeetingAttendee *ma); void e_meeting_list_view_set_editable (EMeetingListView *lview, gboolean set); ENameSelector * e_meeting_list_view_get_name_selector (EMeetingListView *lview); diff --git a/calendar/gui/e-meeting-store.c b/calendar/gui/e-meeting-store.c index 663de70ba8..d320198ec3 100644 --- a/calendar/gui/e-meeting-store.c +++ b/calendar/gui/e-meeting-store.c @@ -780,7 +780,7 @@ e_meeting_store_remove_attendee (EMeetingStore *store, EMeetingAttendee *attende gtk_tree_model_row_deleted (GTK_TREE_MODEL (store), path); gtk_tree_path_free (path); - g_ptr_array_remove_index (store->priv->attendees, row); + g_ptr_array_remove_index (store->priv->attendees, row); g_object_unref (attendee); } } @@ -788,22 +788,20 @@ e_meeting_store_remove_attendee (EMeetingStore *store, EMeetingAttendee *attende void e_meeting_store_remove_all_attendees (EMeetingStore *store) { - gint i; - GtkTreePath *path = gtk_tree_path_new (); - - gtk_tree_path_append_index (path, 0); - - for (i = 0; i < store->priv->attendees->len; i++) { - EMeetingAttendee *attendee = g_ptr_array_index (store->priv->attendees, i); - + gint i, j, k; + + for (i = 0, j = e_meeting_store_count_actual_attendees (store), k = 0; i < j; i++) { + /* Always try to remove the attendee at index 0 since it is the only one that will + * continue to exist until all attendees are removed. */ + EMeetingAttendee *attendee = g_ptr_array_index (store->priv->attendees, k); + GtkTreePath *path = gtk_tree_path_new (); + gtk_tree_path_append_index (path, k); gtk_tree_model_row_deleted (GTK_TREE_MODEL (store), path); - gtk_tree_path_next (path); + gtk_tree_path_free (path); + g_ptr_array_remove_index (store->priv->attendees, k); g_object_unref (attendee); } - - g_ptr_array_set_size (store->priv->attendees, 0); - gtk_tree_path_free (path); } EMeetingAttendee * diff --git a/calendar/gui/e-memo-table.c b/calendar/gui/e-memo-table.c index 1fc947b7ea..490de9f919 100644 --- a/calendar/gui/e-memo-table.c +++ b/calendar/gui/e-memo-table.c @@ -1009,7 +1009,7 @@ copy_row_cb (int model_row, gpointer data) e_cal_util_add_timezones_from_component (memo_table->tmp_vcal, comp_data->icalcomp); /* add the new component to the VCALENDAR component */ - comp_str = icalcomponent_as_ical_string (comp_data->icalcomp); + comp_str = icalcomponent_as_ical_string_r (comp_data->icalcomp); child = icalparser_parse_string (comp_str); if (child) { icalcomponent_add_component (memo_table->tmp_vcal, @@ -1039,13 +1039,12 @@ e_memo_table_copy_clipboard (EMemoTable *memo_table) etable = e_memo_table_get_table (memo_table); e_table_selected_row_foreach (etable, copy_row_cb, memo_table); - comp_str = icalcomponent_as_ical_string (memo_table->tmp_vcal); + comp_str = icalcomponent_as_ical_string_r (memo_table->tmp_vcal); clipboard = gtk_widget_get_clipboard (GTK_WIDGET (memo_table), clipboard_atom); if (!gtk_clipboard_set_with_data(clipboard, target_types, n_target_types, clipboard_get_calendar_cb, NULL, comp_str)) { - /* do not free this pointer, it owns libical */ - /* g_free (comp_str); */ + /* no-op */ } else { gtk_clipboard_set_can_store (clipboard, target_types + 1, n_target_types - 1); } diff --git a/calendar/gui/e-tasks.c b/calendar/gui/e-tasks.c index ebf8c91df6..997eaee4da 100644 --- a/calendar/gui/e-tasks.c +++ b/calendar/gui/e-tasks.c @@ -189,7 +189,7 @@ obtain_list_of_components (gpointer data, gpointer user_data) e_cal_util_add_timezones_from_component (vcal, comp_data->icalcomp); icalcomponent_add_component (vcal, icalcomponent_new_clone (comp_data->icalcomp)); - comp_str = icalcomponent_as_ical_string (vcal); + comp_str = icalcomponent_as_ical_string_r (vcal); if (comp_str) { ESource *source = e_cal_get_source (comp_data->client); const char *source_uid = e_source_peek_uid (source); diff --git a/calendar/gui/e-week-view.c b/calendar/gui/e-week-view.c index 7683f7a687..8614141b6e 100644 --- a/calendar/gui/e-week-view.c +++ b/calendar/gui/e-week-view.c @@ -351,7 +351,7 @@ update_row (EWeekView *week_view, int row) prop = icalcomponent_get_first_property (comp_data->icalcomp, ICAL_RECURRENCEID_PROPERTY); if (prop) - rid = icaltime_as_ical_string (icalcomponent_get_recurrenceid (comp_data->icalcomp)); + rid = icaltime_as_ical_string_r (icalcomponent_get_recurrenceid (comp_data->icalcomp)); } if (e_week_view_find_event_from_uid (week_view, comp_data->client, uid, rid, &event_num)) @@ -441,7 +441,7 @@ model_comps_deleted_cb (ETableModel *etm, gpointer data, gpointer user_data) prop = icalcomponent_get_first_property (comp_data->icalcomp, ICAL_RECURRENCEID_PROPERTY); if (prop) - rid = icaltime_as_ical_string (icalcomponent_get_recurrenceid (comp_data->icalcomp)); + rid = icaltime_as_ical_string_r (icalcomponent_get_recurrenceid (comp_data->icalcomp)); } if (e_week_view_find_event_from_uid (week_view, comp_data->client, uid, rid, &event_num)) @@ -2566,7 +2566,7 @@ e_week_view_reshape_events (EWeekView *week_view) span_num); if (week_view->last_edited_comp_string == NULL) continue; - current_comp_string = icalcomponent_as_ical_string (event->comp_data->icalcomp); + current_comp_string = icalcomponent_as_ical_string_r (event->comp_data->icalcomp); if (strncmp (current_comp_string, week_view->last_edited_comp_string,50) == 0) { EWeekViewEventSpan *span; span = &g_array_index (week_view->spans, EWeekViewEventSpan, event->spans_index + span_num); @@ -3718,7 +3718,7 @@ e_week_view_find_event_from_uid (EWeekView *week_view, u = icalcomponent_get_uid (event->comp_data->icalcomp); if (u && !strcmp (uid, u)) { if (rid && *rid) { - r = icaltime_as_ical_string (icalcomponent_get_recurrenceid (event->comp_data->icalcomp)); + r = icaltime_as_ical_string_r (icalcomponent_get_recurrenceid (event->comp_data->icalcomp)); if (!r || !*r) continue; if (strcmp (rid, r) != 0) { diff --git a/calendar/gui/gnome-cal.c b/calendar/gui/gnome-cal.c index 40b36aa154..d918c18a11 100644 --- a/calendar/gui/gnome-cal.c +++ b/calendar/gui/gnome-cal.c @@ -756,10 +756,10 @@ try_again: old_query = NULL; if (!e_cal_get_query ((ECal *) l->data, real_sexp, &old_query, &error)) { /* If calendar is busy try again for 3 times. */ - if (error->code == E_CALENDAR_STATUS_BUSY && tries != 3) { + if (error->code == E_CALENDAR_STATUS_BUSY && tries != 10) { tries++; /*TODO chose an optimal value */ - g_usleep (50); + g_usleep (500); g_clear_error (&error); goto try_again; @@ -3162,7 +3162,7 @@ gnome_calendar_purge (GnomeCalendar *gcal, time_t older_than) struct icaltimetype recur_id = icalcomponent_get_recurrenceid (m->data); if (!icaltime_is_null_time (recur_id) ) - rid = icaltime_as_ical_string (recur_id); + rid = icaltime_as_ical_string_r (recur_id); e_cal_remove_object_with_mod (client, uid, rid, CALOBJ_MOD_ALL, &error); g_free (rid); diff --git a/calendar/gui/itip-utils.c b/calendar/gui/itip-utils.c index 17a5d97fb5..6b481d4a49 100644 --- a/calendar/gui/itip-utils.c +++ b/calendar/gui/itip-utils.c @@ -82,13 +82,13 @@ itip_addresses_get_default (void) } gboolean -itip_organizer_is_user (ECalComponent *comp, ECal *client) +itip_organizer_is_user_ex (ECalComponent *comp, ECal *client, gboolean skip_cap_test) { ECalComponentOrganizer organizer; const char *strip; gboolean user_org = FALSE; - if (!e_cal_component_has_organizer (comp) || e_cal_get_static_capability (client, CAL_STATIC_CAPABILITY_NO_ORGANIZER)) + if (!e_cal_component_has_organizer (comp) || (!skip_cap_test && e_cal_get_static_capability (client, CAL_STATIC_CAPABILITY_NO_ORGANIZER))) return FALSE; e_cal_component_get_organizer (comp, &organizer); @@ -116,6 +116,12 @@ itip_organizer_is_user (ECalComponent *comp, ECal *client) } gboolean +itip_organizer_is_user (ECalComponent *comp, ECal *client) +{ + return itip_organizer_is_user_ex (comp, client, FALSE); +} + +gboolean itip_sentby_is_user (ECalComponent *comp) { ECalComponentOrganizer organizer; @@ -858,7 +864,7 @@ comp_limit_attendees (ECalComponent *comp) continue; } - attendee = icalproperty_get_value_as_string (prop); + attendee = icalproperty_get_value_as_string_r (prop); if (!attendee) continue; @@ -1254,7 +1260,7 @@ itip_send_comp (ECalComponentItipMethod method, ECalComponent *send_comp, content_type = comp_content_type (comp, method); top_level = comp_toplevel_with_zones (method, comp, client, zones); - ical_string = icalcomponent_as_ical_string (top_level); + ical_string = icalcomponent_as_ical_string_r (top_level); if (e_cal_component_get_vtype (comp) == E_CAL_COMPONENT_EVENT) { e_msg_composer_set_body (composer, ical_string, content_type); @@ -1358,7 +1364,7 @@ reply_to_calendar_comp (ECalComponentItipMethod method, e_destination_freev (destinations); top_level = comp_toplevel_with_zones (method, comp, client, zones); - ical_string = icalcomponent_as_ical_string (top_level); + ical_string = icalcomponent_as_ical_string_r (top_level); if (e_cal_component_get_vtype (comp) == E_CAL_COMPONENT_EVENT){ @@ -1668,7 +1674,7 @@ itip_publish_comp (ECal *client, gchar *uri, gchar *username, } soup_message_set_flags (msg, SOUP_MESSAGE_NO_REDIRECT); - ical_string = icalcomponent_as_ical_string (toplevel); + ical_string = icalcomponent_as_ical_string_r (toplevel); soup_message_set_request (msg, "text/calendar", SOUP_MEMORY_TEMPORARY, ical_string, strlen (ical_string)); diff --git a/calendar/gui/itip-utils.h b/calendar/gui/itip-utils.h index 3c84af929f..631c0a3430 100644 --- a/calendar/gui/itip-utils.h +++ b/calendar/gui/itip-utils.h @@ -51,6 +51,7 @@ EAccountList *itip_addresses_get (void); EAccount *itip_addresses_get_default (void); gboolean itip_organizer_is_user (ECalComponent *comp, ECal *client); +gboolean itip_organizer_is_user_ex (ECalComponent *comp, ECal *client, gboolean skip_cap_test); gboolean itip_sentby_is_user (ECalComponent *comp); const gchar *itip_strip_mailto (const gchar *address); diff --git a/calendar/gui/memos-component.c b/calendar/gui/memos-component.c index ec9dc18571..803a784453 100644 --- a/calendar/gui/memos-component.c +++ b/calendar/gui/memos-component.c @@ -158,67 +158,6 @@ source_selection_changed_cb (ESourceSelector *selector, MemosComponentView *comp /* Evolution::Component CORBA methods */ static gboolean -update_single_object (ECal *client, icalcomponent *icalcomp, gboolean fail_on_modify) -{ - char *uid; - icalcomponent *tmp_icalcomp; - - d(g_message("memos-component.c: update_single_object called");) - - uid = (char *) icalcomponent_get_uid (icalcomp); - - if (e_cal_get_object (client, uid, NULL, &tmp_icalcomp, NULL)) { - if (fail_on_modify) - return FALSE; - else - return e_cal_modify_object (client, icalcomp, CALOBJ_MOD_ALL, NULL); - } - - return e_cal_create_object (client, icalcomp, &uid, NULL); -} - -static gboolean -update_objects (ECal *client, icalcomponent *icalcomp) -{ - icalcomponent *subcomp; - icalcomponent_kind kind; - - d(g_message("memos-component.c: update_objects called");) - - kind = icalcomponent_isa (icalcomp); - if (kind == ICAL_VJOURNAL_COMPONENT) - return update_single_object (client, icalcomp, TRUE); - else if (kind != ICAL_VCALENDAR_COMPONENT) - return FALSE; - - subcomp = icalcomponent_get_first_component (icalcomp, ICAL_ANY_COMPONENT); - while (subcomp) { - gboolean success; - - kind = icalcomponent_isa (subcomp); - if (kind == ICAL_VTIMEZONE_COMPONENT) { - icaltimezone *zone; - - zone = icaltimezone_new (); - icaltimezone_set_component (zone, subcomp); - - success = e_cal_add_timezone (client, zone, NULL); - icaltimezone_free (zone, 1); - if (!success) - return success; - } else if (kind == ICAL_VJOURNAL_COMPONENT) { - success = update_single_object (client, subcomp, TRUE); - if (!success) - return success; - } - - subcomp = icalcomponent_get_next_component (icalcomp, ICAL_ANY_COMPONENT); - } - - return TRUE; -} - -static gboolean selector_tree_data_dropped (ESourceSelector *selector, GtkSelectionData *data, ESource *destination, @@ -238,11 +177,8 @@ selector_tree_data_dropped (ESourceSelector *selector, goto finish; components = cal_comp_selection_get_string_list (data); - for (p = components; p; p = p->next) { - const char * uid; - char *old_uid = NULL; - icalcomponent *tmp_icalcomp = NULL; - GError *error = NULL; + success = components != NULL; + for (p = components; p && success; p = p->next) { char *comp_str; /* do not free this! */ /* p->data is "source_uid\ncomponent_string" */ @@ -257,58 +193,10 @@ selector_tree_data_dropped (ESourceSelector *selector, if (!icalcomp) continue; - /* FIXME deal with GDK_ACTION_ASK */ - if (action == GDK_ACTION_COPY) { - old_uid = g_strdup (icalcomponent_get_uid (icalcomp)); - uid = e_cal_component_gen_uid (); - icalcomponent_set_uid (icalcomp, uid); - } - - uid = icalcomponent_get_uid (icalcomp); - if (!old_uid) - old_uid = g_strdup (uid); - - if (!e_cal_get_object (client, uid, NULL, &tmp_icalcomp, &error)) { - if ((error != NULL) && (error->code != E_CALENDAR_STATUS_OBJECT_NOT_FOUND)) - g_message ("Failed to search the object in destination task list: %s",error->message); - else { - /* this will report success by last item, but we don't care */ - success = update_objects (client, icalcomp); - - if (success && action == GDK_ACTION_MOVE) { - /* remove components rather here, because we know which has been moved */ - ESource *source_source; - ECal *source_client; - - source_source = e_source_list_peek_source_by_uid (component->priv->source_list, p->data); - - if (source_source && !E_IS_SOURCE_GROUP (source_source) && !e_source_get_readonly (source_source)) { - source_client = auth_new_cal_from_source (source_source, E_CAL_SOURCE_TYPE_JOURNAL); - - if (source_client) { - gboolean read_only = TRUE; - - e_cal_is_read_only (source_client, &read_only, NULL); - - if (!read_only && e_cal_open (source_client, TRUE, NULL)) - e_cal_remove_object (source_client, old_uid, NULL); - else if (!read_only) - g_message ("Cannot open source client to remove old memo"); - - g_object_unref (source_client); - } else - g_message ("Cannot create source client to remove old memo"); - } - } - } - - g_clear_error (&error); - } else - icalcomponent_free (tmp_icalcomp); - - g_free (old_uid); + success = cal_comp_process_source_list_drop (client, icalcomp, action, p->data, component->priv->source_list); icalcomponent_free (icalcomp); } + g_slist_foreach (components, (GFunc)g_free, NULL); g_slist_free (components); diff --git a/calendar/gui/print.c b/calendar/gui/print.c index f448b4704d..c4f42fe4bd 100644 --- a/calendar/gui/print.c +++ b/calendar/gui/print.c @@ -125,9 +125,9 @@ get_font_size (PangoFontDescription *font) /* The width of the small calendar months, the space from the right edge of the header rectangle, and the space between the months. */ -#define SMALL_MONTH_WIDTH 80 -#define SMALL_MONTH_PAD 4 -#define SMALL_MONTH_SPACING 12 +#define SMALL_MONTH_WIDTH 100 +#define SMALL_MONTH_PAD 5 +#define SMALL_MONTH_SPACING 20 /* The minimum number of rows we leave space for for the long events in the day view. */ @@ -498,7 +498,7 @@ titled_box (GtkPrintContext *context, const char *text, *x1 += 2; *x2 -= 2; *y2 += 2; - print_text (context, font, text, alignment, *x1, *x2, *y1, *y1 + size * 1.4); + print_text (context, font, text, alignment, *x1, *x2, *y1 + 1.0, *y1 + size * 1.4); *y1 += size * 1.4; } @@ -839,10 +839,10 @@ print_day_background (GtkPrintContext *context, GnomeCalendar *gcal, sprintf (buf, "%d", hour); print_text (context, font_hour, buf, PANGO_ALIGN_RIGHT, left, hour_minute_x, - y - yinc + yinc / 2, y - yinc + yinc / 2 + hour_font_size); + y - yinc, y - yinc + hour_font_size); print_text (context, font_minute, minute, PANGO_ALIGN_LEFT, hour_minute_x, left + width - 3, - y - yinc + yinc / 2, y - yinc + yinc / 2 + minute_font_size); + y - yinc, y - yinc + minute_font_size); /* Draw the horizontal line between hours, across the entire width of the day view. */ @@ -2093,7 +2093,7 @@ print_day_view (GtkPrintContext *context, GnomeCalendar *gcal, time_t date) /* Print the filled border around the header. */ print_border (context, 0.0, width, - 0.0, HEADER_HEIGHT + 2.0, 1.0, 0.9); + 0.0, HEADER_HEIGHT + 3.5, 1.0, 0.9); /* Print the 2 mini calendar-months. */ l = width - SMALL_MONTH_PAD - SMALL_MONTH_WIDTH * 2 - SMALL_MONTH_SPACING; @@ -2178,14 +2178,14 @@ print_week_view (GtkPrintContext *context, GnomeCalendar *gcal, time_t date) l = width - SMALL_MONTH_PAD - SMALL_MONTH_WIDTH * 2 - SMALL_MONTH_SPACING; print_month_small (context, gcal, when, - l, 4, l + SMALL_MONTH_WIDTH, HEADER_HEIGHT + 30, + l, 4, l + SMALL_MONTH_WIDTH, HEADER_HEIGHT + 10, DATE_MONTH | DATE_YEAR, when, time_add_week_with_zone (when, 1, zone), FALSE); l += SMALL_MONTH_SPACING + SMALL_MONTH_WIDTH; print_month_small (context, gcal, time_add_month_with_zone (when, 1, zone), - l, 4, l + SMALL_MONTH_WIDTH, HEADER_HEIGHT + 30, + l, 4, l + SMALL_MONTH_WIDTH, HEADER_HEIGHT + 10, DATE_MONTH | DATE_YEAR, when, time_add_week_with_zone (when, 1, zone), FALSE); @@ -2211,6 +2211,7 @@ print_month_view (GtkPrintContext *context, GnomeCalendar *gcal, time_t date) icaltimezone *zone = calendar_config_get_icaltimezone (); char buf[100]; gdouble width, height; + double l; setup = gtk_print_context_get_page_setup (context); @@ -2221,17 +2222,19 @@ print_month_view (GtkPrintContext *context, GnomeCalendar *gcal, time_t date) print_month_summary (context, gcal, date, 0.0, width, HEADER_HEIGHT, height); /* Print the border around the header. */ - print_border (context, 0.0, width, 0.0, HEADER_HEIGHT, 1.0, 0.9); + print_border (context, 0.0, width, 0.0, HEADER_HEIGHT + 10, 1.0, 0.9); + + l = width - SMALL_MONTH_PAD - SMALL_MONTH_WIDTH; /* Print the 2 mini calendar-months. */ print_month_small (context, gcal, time_add_month_with_zone (date, 1, zone), - width - width / 7 + 2, 4, - width - 8, HEADER_HEIGHT, + l, 4, l + SMALL_MONTH_WIDTH, HEADER_HEIGHT + 4, DATE_MONTH | DATE_YEAR, 0, 0, FALSE); + print_month_small (context, gcal, time_add_month_with_zone (date, -1, zone), - 8, 4, width / 7 - 2, HEADER_HEIGHT, + 8, 4, width / 7 + 20, HEADER_HEIGHT + 4, DATE_MONTH | DATE_YEAR, 0, 0, FALSE); /* Print the month, e.g. 'May 2001'. */ diff --git a/calendar/gui/tasks-component.c b/calendar/gui/tasks-component.c index f61100c34f..cb7326e7d6 100644 --- a/calendar/gui/tasks-component.c +++ b/calendar/gui/tasks-component.c @@ -355,60 +355,6 @@ source_removed_cb (ETasks *tasks, ESource *source, TasksComponentView *component } static gboolean -update_single_object (ECal *client, icalcomponent *icalcomp) -{ - char *uid; - icalcomponent *tmp_icalcomp; - - uid = (char *) icalcomponent_get_uid (icalcomp); - - if (e_cal_get_object (client, uid, NULL, &tmp_icalcomp, NULL)) - return e_cal_modify_object (client, icalcomp, CALOBJ_MOD_ALL, NULL); - - return e_cal_create_object (client, icalcomp, &uid, NULL); -} - -static gboolean -update_objects (ECal *client, icalcomponent *icalcomp) -{ - icalcomponent *subcomp; - icalcomponent_kind kind; - - kind = icalcomponent_isa (icalcomp); - if (kind == ICAL_VTODO_COMPONENT || kind == ICAL_VEVENT_COMPONENT) - return update_single_object (client, icalcomp); - else if (kind != ICAL_VCALENDAR_COMPONENT) - return FALSE; - - subcomp = icalcomponent_get_first_component (icalcomp, ICAL_ANY_COMPONENT); - while (subcomp) { - gboolean success; - - kind = icalcomponent_isa (subcomp); - if (kind == ICAL_VTIMEZONE_COMPONENT) { - icaltimezone *zone; - - zone = icaltimezone_new (); - icaltimezone_set_component (zone, subcomp); - - success = e_cal_add_timezone (client, zone, NULL); - icaltimezone_free (zone, 1); - if (!success) - return success; - } else if (kind == ICAL_VTODO_COMPONENT || - kind == ICAL_VEVENT_COMPONENT) { - success = update_single_object (client, subcomp); - if (!success) - return success; - } - - subcomp = icalcomponent_get_next_component (icalcomp, ICAL_ANY_COMPONENT); - } - - return TRUE; -} - -static gboolean selector_tree_data_dropped (ESourceSelector *selector, GtkSelectionData *data, ESource *destination, @@ -428,11 +374,8 @@ selector_tree_data_dropped (ESourceSelector *selector, goto finish; components = cal_comp_selection_get_string_list (data); - for (p = components; p; p = p->next) { - const char * uid; - char *old_uid = NULL; - icalcomponent *tmp_icalcomp = NULL; - GError *error = NULL; + success = components != NULL; + for (p = components; p && success; p = p->next) { char *comp_str; /* do not free this! */ /* p->data is "source_uid\ncomponent_string" */ @@ -447,56 +390,7 @@ selector_tree_data_dropped (ESourceSelector *selector, if (!icalcomp) continue; - /* FIXME deal with GDK_ACTION_ASK */ - if (action == GDK_ACTION_COPY) { - old_uid = g_strdup (icalcomponent_get_uid (icalcomp)); - uid = e_cal_component_gen_uid (); - icalcomponent_set_uid (icalcomp, uid); - } - - uid = icalcomponent_get_uid (icalcomp); - if (!old_uid) - old_uid = g_strdup (uid); - - if (!e_cal_get_object (client, uid, NULL, &tmp_icalcomp, &error)) { - if ((error != NULL) && (error->code != E_CALENDAR_STATUS_OBJECT_NOT_FOUND)) - g_message ("Failed to search the object in destination task list: %s",error->message); - else { - /* this will report success by last item, but we don't care */ - success = update_objects (client, icalcomp); - - if (success && action == GDK_ACTION_MOVE) { - /* remove components rather here, because we know which has been moved */ - ESource *source_source; - ECal *source_client; - - source_source = e_source_list_peek_source_by_uid (component->priv->source_list, p->data); - - if (source_source && !E_IS_SOURCE_GROUP (source_source) && !e_source_get_readonly (source_source)) { - source_client = auth_new_cal_from_source (source_source, E_CAL_SOURCE_TYPE_TODO); - - if (source_client) { - gboolean read_only = TRUE; - - e_cal_is_read_only (source_client, &read_only, NULL); - - if (!read_only && e_cal_open (source_client, TRUE, NULL)) - e_cal_remove_object (source_client, old_uid, NULL); - else if (!read_only) - g_message ("Cannot open source client to remove old task"); - - g_object_unref (source_client); - } else - g_message ("Cannot create source client to remove old task"); - } - } - } - - g_clear_error (&error); - } else - icalcomponent_free (tmp_icalcomp); - - g_free (old_uid); + success = cal_comp_process_source_list_drop (client, icalcomp, action, p->data, component->priv->source_list); icalcomponent_free (icalcomp); } g_slist_foreach (components, (GFunc)g_free, NULL); |