aboutsummaryrefslogtreecommitdiffstats
path: root/calendar
diff options
context:
space:
mode:
authorJP Rosevear <jpr@ximian.com>2004-05-07 23:10:46 +0800
committerJP Rosevear <jpr@src.gnome.org>2004-05-07 23:10:46 +0800
commit6b70641a976fd56ca4df9b49e620da0fd1b3e2df (patch)
treeac57b214d411f296578863ac6535603a328fe179 /calendar
parent7aa2882d38e0cf537c53e2eca23c1a748d288bd7 (diff)
downloadgsoc2013-evolution-6b70641a976fd56ca4df9b49e620da0fd1b3e2df.tar.gz
gsoc2013-evolution-6b70641a976fd56ca4df9b49e620da0fd1b3e2df.tar.zst
gsoc2013-evolution-6b70641a976fd56ca4df9b49e620da0fd1b3e2df.zip
Fixes #52294
2004-05-07 JP Rosevear <jpr@ximian.com> 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
Diffstat (limited to 'calendar')
-rw-r--r--calendar/ChangeLog13
-rw-r--r--calendar/gui/e-cal-model-calendar.c48
-rw-r--r--calendar/gui/e-cal-model-tasks.c47
-rw-r--r--calendar/gui/e-cal-model.c52
4 files changed, 136 insertions, 24 deletions
diff --git a/calendar/ChangeLog b/calendar/ChangeLog
index 29ddca2cea..914da1c7a8 100644
--- a/calendar/ChangeLog
+++ b/calendar/ChangeLog
@@ -1,5 +1,18 @@
2004-05-07 JP Rosevear <jpr@ximian.com>
+ 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
+
+2004-05-07 JP Rosevear <jpr@ximian.com>
+
* gui/e-cal-model.c (ecm_is_cell_editable): fix comment and check
* gui/e-cal-model-tasks.c (ecmt_set_value_at): set a parent field
diff --git a/calendar/gui/e-cal-model-calendar.c b/calendar/gui/e-cal-model-calendar.c
index e03a5c5f52..e6aba158da 100644
--- a/calendar/gui/e-cal-model-calendar.c
+++ b/calendar/gui/e-cal-model-calendar.c
@@ -205,17 +205,53 @@ ecmc_value_at (ETableModel *etm, int col, int row)
static void
set_dtend (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_DTEND_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_dtend (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_dtend (prop, dv->tt);
+ } else {
+ prop = icalproperty_new_dtend (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
@@ -323,9 +359,7 @@ ecmc_is_cell_editable (ETableModel *etm, int col, int row)
g_return_val_if_fail (E_IS_CAL_MODEL_CALENDAR (model), FALSE);
g_return_val_if_fail (col >= 0 && col < E_CAL_MODEL_CALENDAR_FIELD_LAST, FALSE);
-
- /* FIXME: We can't check this as 'click-to-add' passes row 0. */
- /* g_return_val_if_fail (row >= 0 && row < e_table_model_get_row_count (etm), FALSE); */
+ g_return_val_if_fail (row >= -1 || (row >= 0 && row < e_table_model_row_count (etm)), FALSE);
if (col < E_CAL_MODEL_FIELD_LAST)
return E_TABLE_MODEL_CLASS (parent_class)->is_cell_editable (etm, col, row);
diff --git a/calendar/gui/e-cal-model-tasks.c b/calendar/gui/e-cal-model-tasks.c
index 5067e2557d..fb958cbe89 100644
--- a/calendar/gui/e-cal-model-tasks.c
+++ b/calendar/gui/e-cal-model-tasks.c
@@ -540,23 +540,52 @@ set_complete (ECalModelComponent *comp_data, const void *value)
static void
set_due (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_DTEND_PROPERTY);
+ if (prop)
+ param = icalproperty_get_first_parameter (prop, ICAL_TZID_PARAMETER);
+ else
+ param = NULL;
- prop = icalcomponent_get_first_property (comp_data->icalcomp, ICAL_DUE_PROPERTY);
-
+ /* 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);
}
+
+ 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_dtend (prop, dv->tt);
} else {
- if (prop)
- icalproperty_set_due (prop, dv->tt);
- else {
- prop = icalproperty_new_due (dv->tt);
- icalcomponent_add_property (comp_data->icalcomp, prop);
+ prop = icalproperty_new_dtend (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);
}
}
@@ -813,7 +842,7 @@ ecmt_is_cell_editable (ETableModel *etm, int col, int row)
priv = model->priv;
g_return_val_if_fail (col >= 0 && col < E_CAL_MODEL_TASKS_FIELD_LAST, FALSE);
- g_return_val_if_fail (row >= -1 && row < e_table_model_get_row_count (etm), FALSE);
+ g_return_val_if_fail (row >= -1 || (row >= 0 && row < e_table_model_row_count (etm)), FALSE);
if (col < E_CAL_MODEL_FIELD_LAST)
return E_TABLE_MODEL_CLASS (parent_class)->is_cell_editable (etm, col, row);
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)