diff options
author | Milan Crha <mcrha@redhat.com> | 2009-04-27 18:07:09 +0800 |
---|---|---|
committer | Matthew Barnes <mbarnes@redhat.com> | 2009-04-28 20:06:00 +0800 |
commit | 06a883940fcd97c5324fc2cdf3b3ffc50772208e (patch) | |
tree | 12867ebca018c136de40a4d8f08bbc2afc33d320 /calendar/gui/e-cal-model.c | |
parent | e887df9a554e452c7c1bb2bae3739cb43ddf73bc (diff) | |
download | gsoc2013-evolution-06a883940fcd97c5324fc2cdf3b3ffc50772208e.tar.gz gsoc2013-evolution-06a883940fcd97c5324fc2cdf3b3ffc50772208e.tar.zst gsoc2013-evolution-06a883940fcd97c5324fc2cdf3b3ffc50772208e.zip |
Allow Last Modified and Created columns for event table
** Fix for bug #575773
* gui/e-calendar-table.etspec:
* gui/e-cal-list-view.etspec:
* gui/e-memo-table.etspec:
* gui/e-cal-model.h: (ECalModelField), (struct _ECalModelComponent):
* gui/e-cal-model.c: (get_datetime_from_utc), (ecm_value_at),
(ecm_duplicate_value), (ecm_free_value), (ecm_initialize_value),
(ecm_value_is_empty), (ecm_value_to_string),
(e_cal_view_objects_modified_cb), (e_cal_model_component_finalize),
(e_cal_model_component_init):
Allow showing CREATED and LAST-MODIFIED properties in a table.
* gui/print.c: (print_comp_draw_real):
* gui/e-cal-component-preview.c: (write_html):
* conduits/todo/todo-conduit.c: (local_record_from_comp):
Possible leak fix.
Diffstat (limited to 'calendar/gui/e-cal-model.c')
-rw-r--r-- | calendar/gui/e-cal-model.c | 69 |
1 files changed, 69 insertions, 0 deletions
diff --git a/calendar/gui/e-cal-model.c b/calendar/gui/e-cal-model.c index fd26779169..c437b44dd7 100644 --- a/calendar/gui/e-cal-model.c +++ b/calendar/gui/e-cal-model.c @@ -435,6 +435,43 @@ get_dtstart (ECalModel *model, ECalModelComponent *comp_data) return comp_data->dtstart; } +static ECellDateEditValue* +get_datetime_from_utc (ECalModel *model, ECalModelComponent *comp_data, icalproperty_kind propkind, struct icaltimetype (*get_value)(const icalproperty* prop), ECellDateEditValue **buffer) +{ + ECalModelPrivate *priv; + struct icaltimetype tt_value; + icalproperty *prop; + ECellDateEditValue *res; + + g_return_val_if_fail (buffer!= NULL, NULL); + + if (*buffer) + return *buffer; + + priv = model->priv; + + prop = icalcomponent_get_first_property (comp_data->icalcomp, propkind); + if (!prop) + return NULL; + + tt_value = get_value (prop); + + /* these are always in UTC, thus convert to default zone, if any and done */ + if (priv->zone) + icaltimezone_convert_time (&tt_value, icaltimezone_get_utc_timezone (), priv->zone); + + if (!icaltime_is_valid_time (tt_value) || icaltime_is_null_time (tt_value)) + return NULL; + + res = g_new0 (ECellDateEditValue, 1); + res->tt = tt_value; + res->zone = NULL; + + *buffer = res; + + return res; +} + static char * get_summary (ECalModelComponent *comp_data) { @@ -484,6 +521,10 @@ ecm_value_at (ETableModel *etm, int col, int row) return get_description (comp_data); case E_CAL_MODEL_FIELD_DTSTART : return (void *) get_dtstart (model, comp_data); + case E_CAL_MODEL_FIELD_CREATED : + return (void *) get_datetime_from_utc (model, comp_data, ICAL_CREATED_PROPERTY, icalproperty_get_created, &comp_data->created); + case E_CAL_MODEL_FIELD_LASTMODIFIED : + return (void *) get_datetime_from_utc (model, comp_data, ICAL_LASTMODIFIED_PROPERTY, icalproperty_get_lastmodified, &comp_data->lastmodified); case E_CAL_MODEL_FIELD_HAS_ALARMS : return GINT_TO_POINTER ((icalcomponent_get_first_component (comp_data->icalcomp, ICAL_VALARM_COMPONENT) != NULL)); @@ -878,6 +919,8 @@ ecm_duplicate_value (ETableModel *etm, int col, const void *value) case E_CAL_MODEL_FIELD_COMPONENT : return icalcomponent_new_clone ((icalcomponent *) value); case E_CAL_MODEL_FIELD_DTSTART : + case E_CAL_MODEL_FIELD_CREATED : + case E_CAL_MODEL_FIELD_LASTMODIFIED : if (value) { ECellDateEditValue *dv, *orig_dv; @@ -911,6 +954,8 @@ ecm_free_value (ETableModel *etm, int col, void *value) case E_CAL_MODEL_FIELD_COLOR : break; case E_CAL_MODEL_FIELD_DTSTART : + case E_CAL_MODEL_FIELD_CREATED : + case E_CAL_MODEL_FIELD_LASTMODIFIED : if (value) g_free (value); break; @@ -940,6 +985,8 @@ ecm_initialize_value (ETableModel *etm, int col) case E_CAL_MODEL_FIELD_SUMMARY : return g_strdup (""); case E_CAL_MODEL_FIELD_DTSTART : + case E_CAL_MODEL_FIELD_CREATED : + case E_CAL_MODEL_FIELD_LASTMODIFIED : case E_CAL_MODEL_FIELD_HAS_ALARMS : case E_CAL_MODEL_FIELD_ICON : case E_CAL_MODEL_FIELD_COLOR : @@ -978,6 +1025,8 @@ ecm_value_is_empty (ETableModel *etm, int col, const void *value) case E_CAL_MODEL_FIELD_SUMMARY : return string_is_empty (value); case E_CAL_MODEL_FIELD_DTSTART : + case E_CAL_MODEL_FIELD_CREATED : + case E_CAL_MODEL_FIELD_LASTMODIFIED : return value ? FALSE : TRUE; case E_CAL_MODEL_FIELD_HAS_ALARMS : case E_CAL_MODEL_FIELD_ICON : @@ -1001,6 +1050,8 @@ ecm_value_to_string (ETableModel *etm, int col, const void *value) case E_CAL_MODEL_FIELD_SUMMARY : return g_strdup (value); case E_CAL_MODEL_FIELD_DTSTART : + case E_CAL_MODEL_FIELD_CREATED : + case E_CAL_MODEL_FIELD_LASTMODIFIED : return e_cal_model_date_value_to_string (E_CAL_MODEL (etm), value); case E_CAL_MODEL_FIELD_ICON : if (GPOINTER_TO_INT (value) == 0) @@ -1571,6 +1622,14 @@ e_cal_view_objects_modified_cb (ECalView *query, GList *objects, gpointer user_d g_free (comp_data->completed); comp_data->completed = NULL; } + if (comp_data->created) { + g_free (comp_data->created); + comp_data->created = NULL; + } + if (comp_data->lastmodified) { + g_free (comp_data->lastmodified); + comp_data->lastmodified = NULL; + } if (comp_data->color) { g_free (comp_data->color); comp_data->color = NULL; @@ -2311,6 +2370,14 @@ e_cal_model_component_finalize (GObject *object) g_free (comp_data->completed); comp_data->completed = NULL; } + if (comp_data->created) { + g_free (comp_data->created); + comp_data->created = NULL; + } + if (comp_data->lastmodified) { + g_free (comp_data->lastmodified); + comp_data->lastmodified = NULL; + } if (comp_data->color) { g_free (comp_data->color); comp_data->color = NULL; @@ -2328,6 +2395,8 @@ e_cal_model_component_init (ECalModelComponent *comp) comp->dtend = NULL; comp->due = NULL; comp->completed = NULL; + comp->created = NULL; + comp->lastmodified = NULL; comp->color = NULL; } |