From 6b70641a976fd56ca4df9b49e620da0fd1b3e2df Mon Sep 17 00:00:00 2001 From: JP Rosevear Date: Fri, 7 May 2004 15:10:46 +0000 Subject: Fixes #52294 2004-05-07 JP Rosevear Fixes #52294 * gui/e-cal-model.c (set_dtstart): set the tzid properly (ecm_is_cell_editable): set check properly * gui/e-cal-model-tasks.c (set_due): set the tzid properly (ecmt_is_cell_editable): set check properly * gui/e-cal-model-calendar.c (set_dtend): set the tzid properly (ecmc_is_cell_editable): kill fixme and set check properly svn path=/trunk/; revision=25825 --- calendar/gui/e-cal-model.c | 52 +++++++++++++++++++++++++++++++++++++++------- 1 file changed, 44 insertions(+), 8 deletions(-) (limited to 'calendar/gui/e-cal-model.c') diff --git a/calendar/gui/e-cal-model.c b/calendar/gui/e-cal-model.c index ca3ca1e863..8de47998f3 100644 --- a/calendar/gui/e-cal-model.c +++ b/calendar/gui/e-cal-model.c @@ -582,17 +582,53 @@ set_description (ECalModelComponent *comp_data, const char *value) static void set_dtstart (ECalModel *model, ECalModelComponent *comp_data, const void *value) { - icalproperty *prop; ECellDateEditValue *dv = (ECellDateEditValue *) value; - + icalproperty *prop; + icalparameter *param; + const char *tzid; + prop = icalcomponent_get_first_property (comp_data->icalcomp, ICAL_DTSTART_PROPERTY); + if (prop) + param = icalproperty_get_first_parameter (prop, ICAL_TZID_PARAMETER); + else + param = NULL; + + /* If we are setting the property to NULL (i.e. removing it), then + we remove it if it exists. */ if (!dv) { if (prop) { icalcomponent_remove_property (comp_data->icalcomp, prop); icalproperty_free (prop); } - } else - icalcomponent_set_dtstart (comp_data->icalcomp, dv->tt); + + return; + } + + /* If the TZID is set to "UTC", we set the is_utc flag. */ + tzid = dv->zone ? icaltimezone_get_tzid (dv->zone) : "UTC"; + if (tzid && !strcmp (tzid, "UTC")) + dv->tt.is_utc = 1; + else + dv->tt.is_utc = 0; + + if (prop) { + icalproperty_set_dtstart (prop, dv->tt); + } else { + prop = icalproperty_new_dtstart (dv->tt); + icalcomponent_add_property (comp_data->icalcomp, prop); + } + + /* If the TZID is set to "UTC", we don't want to save the TZID. */ + if (tzid && strcmp (tzid, "UTC")) { + if (param) { + icalparameter_set_tzid (param, (char *) tzid); + } else { + param = icalparameter_new_tzid ((char *) tzid); + icalproperty_add_parameter (prop, param); + } + } else if (param) { + icalproperty_remove_parameter (prop, ICAL_TZID_PARAMETER); + } } static void @@ -671,7 +707,7 @@ ecm_is_cell_editable (ETableModel *etm, int col, int row) priv = model->priv; g_return_val_if_fail (col >= 0 && col <= E_CAL_MODEL_FIELD_LAST, FALSE); - g_return_val_if_fail (row >= -1 && row < priv->objects->len, FALSE); + g_return_val_if_fail (row >= -1 || (row >= 0 && row < priv->objects->len), FALSE); switch (col) { case E_CAL_MODEL_FIELD_CATEGORIES : @@ -1206,7 +1242,7 @@ e_cal_view_objects_added_cb (ECalView *query, GList *objects, gpointer user_data comp_data = g_new0 (ECalModelComponent, 1); comp_data->client = g_object_ref (e_cal_view_get_client (query)); comp_data->icalcomp = icalcomponent_new_clone (l->data); - + g_ptr_array_add (priv->objects, comp_data); e_table_model_row_inserted (E_TABLE_MODEL (model), priv->objects->len - 1); @@ -1803,8 +1839,8 @@ e_cal_model_copy_component_data (ECalModelComponent *comp_data) new_data = g_new0 (ECalModelComponent, 1); - if (comp_data->icalcomp) - new_data->icalcomp = icalcomponent_new_clone (comp_data->icalcomp); + if (comp_data->icalcomp) + new_data->icalcomp = icalcomponent_new_clone (comp_data->icalcomp); if (comp_data->client) new_data->client = g_object_ref (comp_data->client); if (comp_data->dtstart) -- cgit v1.2.3