From d6fade43cf3eb5fcf722b3a01342705fc312bd79 Mon Sep 17 00:00:00 2001 From: Federico Mena Quintero Date: Wed, 8 Nov 2000 21:45:19 +0000 Subject: These changes fix bugzilla bugs #874 and #875. 2000-11-08 Federico Mena Quintero These changes fix bugzilla bugs #874 and #875. * cal-util/cal-component.c (cal_component_get_exdate_list): Return a list of CalComponentDateTime instead of simple struct icaltimetype objects. Exception date properties *can* contain a timezone parameter, so we need to include those if they are present. (cal_component_set_exdate_list): On the input, handle a list of CalComponentDateTime structures. On the internals, handle a list of struct datetime instead of plain properties. (cal_component_free_exdate_list): Handle a list of CalComponentDateTime structures. (scan_exdate): Create a list of struct datetime structures. (free_icalcomponent): Free the exdate_list properly. * cal-util/cal-recur.c (generate_instances_for_chunk): Use the proper types for exception dates. * gui/comp-util.h: * gui/comp-util.c: New files with utilities for manipulating calendar component objects. (cal_comp_util_add_exdate): New function. * gui/Makefile.am (evolution_calendar_SOURCES): Added comp-util.[ch] to the list of sources. * gui/e-day-view.c (add_exdate): New convenience function to add an exception date to a calendar component. (e_day_view_on_unrecur_appointment): Use cal_comp_util_add_exdate(). (e_day_view_on_delete_occurrence): Likewise. * gui/e-week-view.c (e_week_view_on_delete_occurrence): Likewise. (e_week_view_on_unrecur_appointment): Likewise. * gui/event-editor.c (nth_weekday): Be paranoid about valid position values. (fill_widgets): Use the proper types for exdates. (dialog_to_comp_object): Likewise. svn path=/trunk/; revision=6517 --- calendar/ChangeLog | 41 ++++++++++ calendar/cal-util/cal-component.c | 163 ++++++++++++++++++++++---------------- calendar/cal-util/cal-recur.c | 6 +- calendar/gui/Makefile.am | 2 + calendar/gui/comp-util.c | 57 +++++++++++++ calendar/gui/comp-util.h | 29 +++++++ calendar/gui/e-day-view.c | 42 ++++------ calendar/gui/e-week-view.c | 27 ++----- calendar/gui/event-editor.c | 31 ++++---- 9 files changed, 263 insertions(+), 135 deletions(-) create mode 100644 calendar/gui/comp-util.c create mode 100644 calendar/gui/comp-util.h (limited to 'calendar') diff --git a/calendar/ChangeLog b/calendar/ChangeLog index e80f5945be..9e3ac57452 100644 --- a/calendar/ChangeLog +++ b/calendar/ChangeLog @@ -1,3 +1,44 @@ +2000-11-08 Federico Mena Quintero + + These changes fix bugzilla bugs #874 and #875. + + * cal-util/cal-component.c (cal_component_get_exdate_list): Return + a list of CalComponentDateTime instead of simple struct + icaltimetype objects. Exception date properties *can* contain a + timezone parameter, so we need to include those if they are + present. + (cal_component_set_exdate_list): On the input, handle a list of + CalComponentDateTime structures. On the internals, handle a list + of struct datetime instead of plain properties. + (cal_component_free_exdate_list): Handle a list of + CalComponentDateTime structures. + (scan_exdate): Create a list of struct datetime structures. + (free_icalcomponent): Free the exdate_list properly. + + * cal-util/cal-recur.c (generate_instances_for_chunk): Use the + proper types for exception dates. + + * gui/comp-util.h: + * gui/comp-util.c: New files with utilities for manipulating + calendar component objects. + (cal_comp_util_add_exdate): New function. + + * gui/Makefile.am (evolution_calendar_SOURCES): Added + comp-util.[ch] to the list of sources. + + * gui/e-day-view.c (add_exdate): New convenience function to add + an exception date to a calendar component. + (e_day_view_on_unrecur_appointment): Use cal_comp_util_add_exdate(). + (e_day_view_on_delete_occurrence): Likewise. + + * gui/e-week-view.c (e_week_view_on_delete_occurrence): Likewise. + (e_week_view_on_unrecur_appointment): Likewise. + + * gui/event-editor.c (nth_weekday): Be paranoid about valid + position values. + (fill_widgets): Use the proper types for exdates. + (dialog_to_comp_object): Likewise. + 2000-11-08 Federico Mena Quintero * gui/event-editor.c (adjust_day_index_spin): Adjust the valid diff --git a/calendar/cal-util/cal-component.c b/calendar/cal-util/cal-component.c index 4f813cbdee..a60333589c 100644 --- a/calendar/cal-util/cal-component.c +++ b/calendar/cal-util/cal-component.c @@ -70,7 +70,7 @@ struct _CalComponentPrivate { struct datetime due; - GSList *exdate_list; /* list of icalproperty objects */ + GSList *exdate_list; /* list of struct datetime */ GSList *exrule_list; /* list of icalproperty objects */ icalproperty *geo; @@ -242,8 +242,7 @@ free_icalcomponent (CalComponent *comp) priv->due.prop = NULL; priv->due.tzid_param = NULL; - g_slist_free (priv->exdate_list); - priv->exdate_list = NULL; + priv->exdate_list = free_slist (priv->exdate_list); g_slist_free (priv->exrule_list); priv->exrule_list = NULL; @@ -348,10 +347,10 @@ cal_component_new (void) /** * cal_component_clone: * @comp: A calendar component object. - * + * * Creates a new calendar component object by copying the information from * another one. - * + * * Return value: A newly-created calendar component with the same values as the * original one. **/ @@ -410,9 +409,15 @@ static void scan_exdate (CalComponent *comp, icalproperty *prop) { CalComponentPrivate *priv; + struct datetime *dt; priv = comp->priv; - priv->exdate_list = g_slist_append (priv->exdate_list, prop); + + dt = g_new (struct datetime, 1); + dt->prop = prop; + dt->tzid_param = icalproperty_get_first_parameter (prop, ICAL_TZID_PARAMETER); + + priv->exdate_list = g_slist_append (priv->exdate_list, dt); } /* Scans an icalperiodtype property */ @@ -860,8 +865,8 @@ cal_component_get_as_string (CalComponent *comp) /** * cal_component_commit_sequence: - * @comp: - * + * @comp: + * * Increments the sequence number property in a calendar component object if it * needs it. This needs to be done when any of a number of properties listed in * RFC 2445 change values, such as the start and end dates of a component. @@ -1976,9 +1981,9 @@ set_period_list (CalComponent *comp, * cal_component_get_exdate_list: * @comp: A calendar component object. * @exdate_list: Return value for the list of exception dates, as a list of - * struct #icaltimetype structures. This should be freed using the + * #CalComponentDateTime structures. This should be freed using the * cal_component_free_exdate_list() function. - * + * * Queries the list of exception date properties in a calendar component object. **/ void @@ -1997,15 +2002,22 @@ cal_component_get_exdate_list (CalComponent *comp, GSList **exdate_list) *exdate_list = NULL; for (l = priv->exdate_list; l; l = l->next) { - icalproperty *prop; - struct icaltimetype *t; + struct datetime *dt; + CalComponentDateTime *cdt; - prop = l->data; + dt = l->data; + + cdt = g_new (CalComponentDateTime, 1); + cdt->value = g_new (struct icaltimetype, 1); + + *cdt->value = icalproperty_get_exdate (dt->prop); - t = g_new (struct icaltimetype, 1); - *t = icalproperty_get_exdate (prop); + if (dt->tzid_param) + cdt->tzid = icalparameter_get_tzid (dt->tzid_param); + else + cdt->tzid = NULL; - *exdate_list = g_slist_prepend (*exdate_list, t); + *exdate_list = g_slist_prepend (*exdate_list, cdt); } *exdate_list = g_slist_reverse (*exdate_list); @@ -2014,8 +2026,8 @@ cal_component_get_exdate_list (CalComponent *comp, GSList **exdate_list) /** * cal_component_set_exdate_list: * @comp: A calendar component object. - * @exdate_list: List of struct #icaltimetype structures. - * + * @exdate_list: List of #CalComponentDateTime structures. + * * Sets the list of exception dates in a calendar component object. **/ void @@ -2033,11 +2045,13 @@ cal_component_set_exdate_list (CalComponent *comp, GSList *exdate_list) /* Remove old exception dates */ for (l = priv->exdate_list; l; l = l->next) { - icalproperty *prop; + struct datetime *dt; - prop = l->data; - icalcomponent_remove_property (priv->icalcomp, prop); - icalproperty_free (prop); + dt = l->data; + + icalcomponent_remove_property (priv->icalcomp, dt->prop); + icalproperty_free (dt->prop); + g_free (dt); } g_slist_free (priv->exdate_list); @@ -2046,16 +2060,25 @@ cal_component_set_exdate_list (CalComponent *comp, GSList *exdate_list) /* Add in new exception dates */ for (l = exdate_list; l; l = l->next) { - icalproperty *prop; - struct icaltimetype *t; + CalComponentDateTime *cdt; + struct datetime *dt; g_assert (l->data != NULL); - t = l->data; + cdt = l->data; - prop = icalproperty_new_exdate (*t); - icalcomponent_add_property (priv->icalcomp, prop); + g_assert (cdt->value != NULL); - priv->exdate_list = g_slist_prepend (priv->exdate_list, prop); + dt = g_new (struct datetime, 1); + dt->prop = icalproperty_new_exdate (*cdt->value); + + if (cdt->tzid) { + dt->tzid_param = icalparameter_new_tzid ((char *) cdt->tzid); + icalproperty_add_parameter (dt->prop, dt->tzid_param); + } else + dt->tzid_param = NULL; + + icalcomponent_add_property (priv->icalcomp, dt->prop); + priv->exdate_list = g_slist_prepend (priv->exdate_list, dt); } priv->exdate_list = g_slist_reverse (priv->exdate_list); @@ -2066,10 +2089,10 @@ cal_component_set_exdate_list (CalComponent *comp, GSList *exdate_list) /** * cal_component_has_exdates: * @comp: A calendar component object. - * + * * Queries whether a calendar component object has any exception dates defined * for it. - * + * * Return value: TRUE if the component has exception dates, FALSE otherwise. **/ gboolean @@ -2160,7 +2183,7 @@ set_recur_list (CalComponent *comp, * @recur_list: List of exception rules as struct #icalrecurrencetype * structures. This should be freed using the cal_component_free_recur_list() * function. - * + * * Queries the list of exception rule properties of a calendar component * object. **/ @@ -2183,7 +2206,7 @@ cal_component_get_exrule_list (CalComponent *comp, GSList **recur_list) * cal_component_get_exrule_property_list: * @comp: A calendar component object. * @recur_list: Returns a list of exception rule properties. - * + * * Returns a list of exception rule properties of a calendar component * object. **/ @@ -2206,7 +2229,7 @@ cal_component_get_exrule_property_list (CalComponent *comp, GSList **recur_list) * cal_component_set_exrule_list: * @comp: A calendar component object. * @recur_list: List of struct #icalrecurrencetype structures. - * + * * Sets the list of exception rules in a calendar component object. **/ void @@ -2228,10 +2251,10 @@ cal_component_set_exrule_list (CalComponent *comp, GSList *recur_list) /** * cal_component_has_exrules: * @comp: A calendar component object. - * + * * Queries whether a calendar component object has any exception rules defined * for it. - * + * * Return value: TRUE if the component has exception rules, FALSE otherwise. **/ gboolean @@ -2251,13 +2274,13 @@ cal_component_has_exrules (CalComponent *comp) /** * cal_component_has_exceptions: * @comp: A calendar component object - * + * * Queries whether a calendar component object has any exception dates * or exception rules. - * + * * Return value: TRUE if the component has exceptions, FALSE otherwise. **/ -gboolean +gboolean cal_component_has_exceptions (CalComponent *comp) { return cal_component_has_exdates (comp) || cal_component_has_exrules (comp); @@ -2268,7 +2291,7 @@ cal_component_has_exceptions (CalComponent *comp) * @comp: A calendar component object. * @geo: Return value for the geographic position property. This should be * freed using the cal_component_free_geo() function. - * + * * Sets the geographic position property of a calendar component object. **/ void @@ -2294,7 +2317,7 @@ cal_component_get_geo (CalComponent *comp, struct icalgeotype **geo) * cal_component_set_geo: * @comp: A calendar component object. * @geo: Value for the geographic position property. - * + * * Sets the geographic position property on a calendar component object. **/ void @@ -2379,7 +2402,7 @@ cal_component_set_last_modified (CalComponent *comp, struct icaltimetype *t) * @comp: A calendar component object. * @percent: Return value for the percent-complete property. This should be * freed using the cal_component_free_percent() function. - * + * * Queries the percent-complete property of a calendar component object. **/ void @@ -2405,7 +2428,7 @@ cal_component_get_percent (CalComponent *comp, int **percent) * cal_component_set_percent: * @comp: A calendar component object. * @percent: Value for the percent-complete property. - * + * * Sets the percent-complete property of a calendar component object. **/ void @@ -2444,7 +2467,7 @@ cal_component_set_percent (CalComponent *comp, int *percent) * @comp: A calendar component object. * @priority: Return value for the priority property. This should be freed using * the cal_component_free_priority() function. - * + * * Queries the priority property of a calendar component object. **/ void @@ -2470,7 +2493,7 @@ cal_component_get_priority (CalComponent *comp, int **priority) * cal_component_set_priority: * @comp: A calendar component object. * @priority: Value for the priority property. - * + * * Sets the priority property of a calendar component object. **/ void @@ -2510,7 +2533,7 @@ cal_component_set_priority (CalComponent *comp, int *priority) * @period_list: Return value for the list of recurrence dates, as a list of * #CalComponentPeriod structures. This should be freed using the * cal_component_free_period_list() function. - * + * * Queries the list of recurrence date properties in a calendar component * object. **/ @@ -2533,7 +2556,7 @@ cal_component_get_rdate_list (CalComponent *comp, GSList **period_list) * cal_component_set_rdate_list: * @comp: A calendar component object. * @period_list: List of #CalComponentPeriod structures. - * + * * Sets the list of recurrence dates in a calendar component object. **/ void @@ -2555,10 +2578,10 @@ cal_component_set_rdate_list (CalComponent *comp, GSList *period_list) /** * cal_component_has_rdates: * @comp: A calendar component object. - * + * * Queries whether a calendar component object has any recurrence dates defined * for it. - * + * * Return value: TRUE if the component has recurrence dates, FALSE otherwise. **/ gboolean @@ -2581,7 +2604,7 @@ cal_component_has_rdates (CalComponent *comp) * @recur_list: List of recurrence rules as struct #icalrecurrencetype * structures. This should be freed using the cal_component_free_recur_list() * function. - * + * * Queries the list of recurrence rule properties of a calendar component * object. **/ @@ -2604,7 +2627,7 @@ cal_component_get_rrule_list (CalComponent *comp, GSList **recur_list) * cal_component_get_rrule_property_list: * @comp: A calendar component object. * @recur_list: Returns a list of recurrence rule properties. - * + * * Returns a list of recurrence rule properties of a calendar component * object. **/ @@ -2627,7 +2650,7 @@ cal_component_get_rrule_property_list (CalComponent *comp, GSList **recur_list) * cal_component_set_rrule_list: * @comp: A calendar component object. * @recur_list: List of struct #icalrecurrencetype structures. - * + * * Sets the list of recurrence rules in a calendar component object. **/ void @@ -2649,10 +2672,10 @@ cal_component_set_rrule_list (CalComponent *comp, GSList *recur_list) /** * cal_component_has_rrules: * @comp: A calendar component object. - * + * * Queries whether a calendar component object has any recurrence rules defined * for it. - * + * * Return value: TRUE if the component has recurrence rules, FALSE otherwise. **/ gboolean @@ -2672,13 +2695,13 @@ cal_component_has_rrules (CalComponent *comp) /** * cal_component_has_recurrences: * @comp: A calendar component object - * + * * Queries whether a calendar component object has any recurrence dates or * recurrence rules. - * + * * Return value: TRUE if the component has recurrences, FALSE otherwise. **/ -gboolean +gboolean cal_component_has_recurrences (CalComponent *comp) { return cal_component_has_rdates (comp) || cal_component_has_rrules (comp); @@ -3026,9 +3049,10 @@ cal_component_free_datetime (CalComponentDateTime *dt) /** * cal_component_free_exdate_list: - * @exdate_list: List of struct #icaltimetype structures. - * - * Frees a list of struct #icaltimetype structures. + * @exdate_list: List of #CalComponentDateTime structures. + * + * Frees a list of #CalComponentDateTime structures as returned by the + * cal_component_get_exdate_list() function. **/ void cal_component_free_exdate_list (GSList *exdate_list) @@ -3036,12 +3060,15 @@ cal_component_free_exdate_list (GSList *exdate_list) GSList *l; for (l = exdate_list; l; l = l->next) { - struct icaltimetype *t; + CalComponentDateTime *cdt; g_assert (l->data != NULL); - t = l->data; + cdt = l->data; - g_free (t); + g_assert (cdt->value != NULL); + g_free (cdt->value); + + g_free (cdt); } g_slist_free (exdate_list); @@ -3050,7 +3077,7 @@ cal_component_free_exdate_list (GSList *exdate_list) /** * cal_component_free_geo: * @geo: An #icalgeotype structure. - * + * * Frees a struct #icalgeotype structure as returned by the calendar component * functions. **/ @@ -3080,7 +3107,7 @@ cal_component_free_icaltimetype (struct icaltimetype *t) /** * cal_component_free_percent: * @percent: Percent value. - * + * * Frees a percent value as returned by the cal_component_get_percent() * function. **/ @@ -3095,7 +3122,7 @@ cal_component_free_percent (int *percent) /** * cal_component_free_priority: * @priority: Priority value. - * + * * Frees a priority value as returned by the cal_component_get_priority() * function. **/ @@ -3133,7 +3160,7 @@ cal_component_free_period_list (GSList *period_list) /** * cal_component_free_recur_list: * @recur_list: List of struct #icalrecurrencetype structures. - * + * * Frees a list of struct #icalrecurrencetype structures. **/ void @@ -3325,10 +3352,10 @@ cal_component_get_first_alarm (CalComponent *comp) /** * cal_component_get_next_alarm: * @comp: A calendar component object. - * + * * Gets the next alarm on a calendar component object. This should be used as * an iterator function after calling cal_component_get_first_alarm(). - * + * * Return value: The next alarm in the component, or NULL if the component has * no more alarms. This should be freed using the cal_component_alarm_free() * function. diff --git a/calendar/cal-util/cal-recur.c b/calendar/cal-util/cal-recur.c index 057bde1368..5dbb851cec 100644 --- a/calendar/cal-util/cal-recur.c +++ b/calendar/cal-util/cal-recur.c @@ -1044,7 +1044,7 @@ generate_instances_for_chunk (CalComponent *comp, /* Add on specific exception dates. */ for (elem = exdates; elem; elem = elem->next) { - struct icaltimetype *it; + CalComponentDateTime *cdt; time_t t; /* FIXME we should only be dealing with dates, not times too. @@ -1052,8 +1052,8 @@ generate_instances_for_chunk (CalComponent *comp, No, I think it is supposed to be dates & times - Damon. I'm not sure what the semantics of just a date would be, since the event could recur several times each day. */ - it = elem->data; - t = icaltime_as_timet (*it); + cdt = elem->data; + t = icaltime_as_timet (*cdt->value); cal_object_time_from_time (&cotime, t); g_array_append_val (ex_occs, cotime); diff --git a/calendar/gui/Makefile.am b/calendar/gui/Makefile.am index ebe73826a6..724594780d 100644 --- a/calendar/gui/Makefile.am +++ b/calendar/gui/Makefile.am @@ -67,6 +67,8 @@ evolution_calendar_SOURCES = \ calendar-commands.h \ calendar-model.c \ calendar-model.h \ + comp-util.c \ + comp-util.h \ control-factory.c \ control-factory.h \ component-factory.c \ diff --git a/calendar/gui/comp-util.c b/calendar/gui/comp-util.c new file mode 100644 index 0000000000..d6c26e7751 --- /dev/null +++ b/calendar/gui/comp-util.c @@ -0,0 +1,57 @@ +/* Evolution calendar - Utilities for manipulating CalComponent objects + * + * Copyright (C) 2000 Helix Code, Inc. + * + * Author: Federico Mena-Quintero + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA. + */ + +#ifdef HAVE_CONFIG_H +#include +#endif + +#include "comp-util.h" + + + +/** + * cal_comp_util_add_exdate: + * @comp: A calendar component object. + * @itt: Time for the exception. + * + * Adds an exception date to the current list of EXDATE properties in a calendar + * component object. + **/ +void +cal_comp_util_add_exdate (CalComponent *comp, struct icaltimetype itt) +{ + GSList *list; + CalComponentDateTime *cdt; + + g_return_if_fail (comp != NULL); + g_return_if_fail (IS_CAL_COMPONENT (comp)); + + cal_component_get_exdate_list (comp, &list); + + cdt = g_new (CalComponentDateTime, 1); + cdt->value = g_new (struct icaltimetype, 1); + *cdt->value = itt; + cdt->tzid = NULL; + + list = g_slist_append (list, cdt); + cal_component_set_exdate_list (comp, list); + cal_component_free_exdate_list (list); +} diff --git a/calendar/gui/comp-util.h b/calendar/gui/comp-util.h new file mode 100644 index 0000000000..d08bfe993b --- /dev/null +++ b/calendar/gui/comp-util.h @@ -0,0 +1,29 @@ +/* Evolution calendar - Utilities for manipulating CalComponent objects + * + * Copyright (C) 2000 Helix Code, Inc. + * + * Author: Federico Mena-Quintero + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA. + */ + +#ifndef COMP_UTIL_H +#define COMP_UTIL_H + +#include + +void cal_comp_util_add_exdate (CalComponent *comp, struct icaltimetype itt); + +#endif diff --git a/calendar/gui/e-day-view.c b/calendar/gui/e-day-view.c index 50f6639f58..c1da656ccd 100644 --- a/calendar/gui/e-day-view.c +++ b/calendar/gui/e-day-view.c @@ -32,6 +32,7 @@ #include #include #include +#include "comp-util.h" #include "e-day-view.h" #include "e-day-view-time-item.h" #include "e-day-view-top-item.h" @@ -368,12 +369,12 @@ static void e_day_view_on_main_canvas_drag_data_received (GtkWidget *widget guint info, guint time, EDayView *day_view); -#ifndef NO_WARNINGS + static gboolean e_day_view_update_event_cb (EDayView *day_view, gint day, gint event_num, gpointer data); -#endif + static gboolean e_day_view_remove_event_cb (EDayView *day_view, gint day, gint event_num, @@ -1325,9 +1326,7 @@ obj_updated_cb (CalClient *client, const char *uid, gpointer data) else event = &g_array_index (day_view->events[day], EDayViewEvent, event_num); -#ifndef NO_WARNINGS #warning "FIXME" -#endif /* Do this the long way every time for now */ #if 0 @@ -1423,7 +1422,6 @@ e_day_view_set_cal_client (EDayView *day_view, } -#ifndef NO_WARNINGS static gboolean e_day_view_update_event_cb (EDayView *day_view, gint day, @@ -1459,7 +1457,6 @@ e_day_view_update_event_cb (EDayView *day_view, } return TRUE; } -#endif /* This calls a given function for each event instance that matches the given @@ -2749,8 +2746,6 @@ e_day_view_on_delete_occurrence (GtkWidget *widget, gpointer data) EDayView *day_view; EDayViewEvent *event; CalComponent *comp; - struct icaltimetype *time; - GSList *list; day_view = E_DAY_VIEW (data); @@ -2761,12 +2756,7 @@ e_day_view_on_delete_occurrence (GtkWidget *widget, gpointer data) /* We must duplicate the CalComponent, or we won't know it has changed when we get the "update_event" callback. */ comp = cal_component_clone (event->comp); - cal_component_get_exdate_list (comp, &list); - time = g_new0 (struct icaltimetype, 1); - *time = icaltime_from_timet (event->start, FALSE, FALSE); - list = g_slist_append (list, time); - cal_component_set_exdate_list (comp, list); - cal_component_free_exdate_list (list); + cal_comp_util_add_exdate (comp, icaltime_from_timet (event->start, FALSE, FALSE)); if (!cal_client_update_object (day_view->client, comp)) g_message ("e_day_view_on_delete_occurrence(): Could not update the object!"); @@ -2808,7 +2798,6 @@ e_day_view_on_unrecur_appointment (GtkWidget *widget, gpointer data) CalComponent *comp, *new_comp; CalComponentDateTime date; struct icaltimetype itt; - GSList *list; day_view = E_DAY_VIEW (data); @@ -2816,17 +2805,11 @@ e_day_view_on_unrecur_appointment (GtkWidget *widget, gpointer data) if (event == NULL) return; - date.value = &itt; - date.tzid = NULL; - - /* For the recurring object, we add a exception to get rid of the + /* For the recurring object, we add an exception to get rid of the instance. */ + comp = cal_component_clone (event->comp); - cal_component_get_exdate_list (comp, &list); - *date.value = icaltime_from_timet (event->start, FALSE, FALSE); - list = g_slist_append (list, &date); - cal_component_set_exdate_list (comp, list); - g_slist_free (list); + cal_comp_util_add_exdate (comp, icaltime_from_timet (event->start, FALSE, FALSE)); /* For the unrecurred instance we duplicate the original object, create a new uid for it, get rid of the recurrence rules, and set @@ -2838,6 +2821,9 @@ e_day_view_on_unrecur_appointment (GtkWidget *widget, gpointer data) cal_component_set_exdate_list (new_comp, NULL); cal_component_set_exrule_list (new_comp, NULL); + date.value = &itt; + date.tzid = NULL; + *date.value = icaltime_from_timet (event->start, FALSE, FALSE); cal_component_set_dtstart (new_comp, &date); *date.value = icaltime_from_timet (event->end, FALSE, FALSE); @@ -2986,9 +2972,9 @@ e_day_view_on_top_canvas_motion (GtkWidget *widget, day_view->pressed_event_num); if (!(cal_component_has_recurrences (event->comp)) - && (abs (canvas_x - day_view->drag_event_x) + && (abs (canvas_x - day_view->drag_event_x) > E_DAY_VIEW_DRAG_START_OFFSET - || abs (canvas_y - day_view->drag_event_y) + || abs (canvas_y - day_view->drag_event_y) > E_DAY_VIEW_DRAG_START_OFFSET)) { day_view->drag_event_day = day_view->pressed_event_day; day_view->drag_event_num = day_view->pressed_event_num; @@ -3092,9 +3078,9 @@ e_day_view_on_main_canvas_motion (GtkWidget *widget, event = &g_array_index (day_view->events[day_view->pressed_event_day], EDayViewEvent, day_view->pressed_event_num); if (!cal_component_has_recurrences (event->comp) - && (abs (canvas_x - day_view->drag_event_x) + && (abs (canvas_x - day_view->drag_event_x) > E_DAY_VIEW_DRAG_START_OFFSET - || abs (canvas_y - day_view->drag_event_y) + || abs (canvas_y - day_view->drag_event_y) > E_DAY_VIEW_DRAG_START_OFFSET)) { day_view->drag_event_day = day_view->pressed_event_day; day_view->drag_event_num = day_view->pressed_event_num; diff --git a/calendar/gui/e-week-view.c b/calendar/gui/e-week-view.c index eadc3c9bd3..48c9f147d3 100644 --- a/calendar/gui/e-week-view.c +++ b/calendar/gui/e-week-view.c @@ -32,6 +32,7 @@ #include #include #include "calendar-commands.h" +#include "comp-util.h" #include "e-week-view.h" #include "e-week-view-event-item.h" #include "e-week-view-main-item.h" @@ -873,10 +874,7 @@ obj_updated_cb (CalClient *client, const char *uid, gpointer data) update the event fairly easily without changing the events arrays or computing a new layout. */ if (e_week_view_find_event_from_uid (week_view, uid, &event_num)) { -#ifndef NO_WARNINGS #warning "FIXME" -#endif - event = &g_array_index (week_view->events, EWeekViewEvent, event_num); @@ -3045,8 +3043,6 @@ e_week_view_on_delete_occurrence (GtkWidget *widget, gpointer data) EWeekView *week_view; EWeekViewEvent *event; CalComponent *comp; - CalComponentDateTime *date=NULL; - GSList *list; week_view = E_WEEK_VIEW (data); @@ -3060,13 +3056,7 @@ e_week_view_on_delete_occurrence (GtkWidget *widget, gpointer data) when we get the "update_event" callback. */ comp = cal_component_clone (event->comp); - cal_component_get_exdate_list (comp, &list); - list = g_slist_append (list, date); - date = g_new0 (CalComponentDateTime, 1); - date->value = g_new (struct icaltimetype, 1); - *date->value = icaltime_from_timet (event->start, TRUE, FALSE); - cal_component_set_exdate_list (comp, list); - cal_component_free_exdate_list (list); + cal_comp_util_add_exdate (comp, icaltime_from_timet (event->start, TRUE, FALSE)); if (!cal_client_update_object (week_view->client, comp)) g_message ("e_week_view_on_delete_occurrence(): Could not update the object!"); @@ -3107,7 +3097,6 @@ e_week_view_on_unrecur_appointment (GtkWidget *widget, gpointer data) CalComponent *comp, *new_comp; CalComponentDateTime date; struct icaltimetype itt; - GSList *list; week_view = E_WEEK_VIEW (data); @@ -3117,17 +3106,10 @@ e_week_view_on_unrecur_appointment (GtkWidget *widget, gpointer data) event = &g_array_index (week_view->events, EWeekViewEvent, week_view->popup_event_num); - date.value = &itt; - date.tzid = NULL; - /* For the recurring object, we add a exception to get rid of the instance. */ comp = cal_component_clone (event->comp); - cal_component_get_exdate_list (comp, &list); - *date.value = icaltime_from_timet (event->start, TRUE, FALSE); - list = g_slist_append (list, &date); - cal_component_set_exdate_list (comp, list); - g_slist_free (list); + cal_comp_util_add_exdate (comp, icaltime_from_timet (event->start, TRUE, FALSE)); /* For the unrecurred instance we duplicate the original object, create a new uid for it, get rid of the recurrence rules, and set @@ -3139,6 +3121,9 @@ e_week_view_on_unrecur_appointment (GtkWidget *widget, gpointer data) cal_component_set_exdate_list (new_comp, NULL); cal_component_set_exrule_list (new_comp, NULL); + date.value = &itt; + date.tzid = NULL; + *date.value = icaltime_from_timet (event->start, TRUE, FALSE); cal_component_set_dtstart (new_comp, &date); *date.value = icaltime_from_timet (event->end, TRUE, FALSE); diff --git a/calendar/gui/event-editor.c b/calendar/gui/event-editor.c index 0eca5fdec9..59f08c2267 100644 --- a/calendar/gui/event-editor.c +++ b/calendar/gui/event-editor.c @@ -975,16 +975,12 @@ init_widgets (EventEditor *ee) /* Recurrence units */ menu = gtk_option_menu_get_menu (GTK_OPTION_MENU (priv->recurrence_interval_unit)); - g_assert (menu != NULL); - gtk_signal_connect (GTK_OBJECT (menu), "selection_done", GTK_SIGNAL_FUNC (recur_interval_selection_done_cb), ee); /* Recurrence ending */ menu = gtk_option_menu_get_menu (GTK_OPTION_MENU (priv->recurrence_ending_menu)); - g_assert (menu != NULL); - gtk_signal_connect (GTK_OBJECT (menu), "selection_done", GTK_SIGNAL_FUNC (recur_ending_selection_done_cb), ee); @@ -1528,11 +1524,11 @@ fill_widgets (EventEditor *ee) cal_component_get_exdate_list (priv->comp, &list); for (l = list; l; l = l->next) { - struct icaltimetype *t; + CalComponentDateTime *cdt; time_t ext; - - t = l->data; - ext = icaltime_as_timet (*t); + + cdt = l->data; + ext = icaltime_as_timet (*cdt->value); append_exception (ee, ext); } @@ -1572,6 +1568,8 @@ classification_get (GtkWidget *widget) static short nth_weekday (int pos, icalrecurrencetype_weekday weekday) { + g_assert (pos > 0 && pos <= 5); + return (pos << 3) | (int) weekday; } @@ -1872,18 +1870,21 @@ dialog_to_comp_object (EventEditor *ee, CalComponent *comp) list = NULL; exception_list = GTK_CLIST (priv->recurrence_exception_list); for (i = 0; i < exception_list->rows; i++) { - struct icaltimetype *tt; + CalComponentDateTime *cdt; time_t *tim; - + + cdt = g_new (CalComponentDateTime, 1); + cdt->value = g_new (struct icaltimetype, 1); + cdt->tzid = NULL; + tim = gtk_clist_get_row_data (exception_list, i); - tt = g_new0 (struct icaltimetype, 1); - *tt = icaltime_from_timet (*tim, FALSE, FALSE); + *cdt->value = icaltime_from_timet (*tim, FALSE, FALSE); - list = g_slist_prepend (list, tt); + list = g_slist_prepend (list, cdt); } + cal_component_set_exdate_list (comp, list); - if (list) - cal_component_free_exdate_list (list); + cal_component_free_exdate_list (list); cal_component_commit_sequence (comp); } -- cgit