diff options
author | Milan Crha <mcrha@redhat.com> | 2009-01-20 00:41:40 +0800 |
---|---|---|
committer | Milan Crha <mcrha@src.gnome.org> | 2009-01-20 00:41:40 +0800 |
commit | fa2e93cedc1396a3e323c3a4a1bfdfee8ac3bf53 (patch) | |
tree | 2d817af9437b0f47477aee12947446d1fbce191c /calendar/gui/e-cal-model.c | |
parent | 324f78272ffa32c943600918a90a032ba94272dc (diff) | |
download | gsoc2013-evolution-fa2e93cedc1396a3e323c3a4a1bfdfee8ac3bf53.tar.gz gsoc2013-evolution-fa2e93cedc1396a3e323c3a4a1bfdfee8ac3bf53.tar.zst gsoc2013-evolution-fa2e93cedc1396a3e323c3a4a1bfdfee8ac3bf53.zip |
** Fix for bug #567850
2009-01-19 Milan Crha <mcrha@redhat.com>
** Fix for bug #567850
* gui/e-cal-model.h: (e_cal_model_set_default_time_func):
* gui/e-cal-model.c: (struct _ECalModelPrivate), (ecm_append_row),
(e_cal_model_set_default_time_func):
New functionality to retrieve a default time for a model's new
event created from a "click-to-add" row.
* gui/gnome-cal.c: (gc_get_default_time), (setup_widgets):
Set the new time callback for the memo table.
svn path=/trunk/; revision=37100
Diffstat (limited to 'calendar/gui/e-cal-model.c')
-rw-r--r-- | calendar/gui/e-cal-model.c | 37 |
1 files changed, 36 insertions, 1 deletions
diff --git a/calendar/gui/e-cal-model.c b/calendar/gui/e-cal-model.c index 7f7fe2db02..f834007003 100644 --- a/calendar/gui/e-cal-model.c +++ b/calendar/gui/e-cal-model.c @@ -77,6 +77,10 @@ struct _ECalModelPrivate { /* Whether we display dates in 24-hour format. */ gboolean use_24_hour_format; + + /* callback, to retrieve start time for newly added rows by click-to-add */ + ECalModelDefaultTimeFunc get_default_time; + gpointer get_default_time_user_data; }; #define E_CAL_MODEL_COMPONENT_GET_PRIVATE(obj) \ @@ -816,9 +820,26 @@ ecm_append_row (ETableModel *etm, ETableModel *source, int row) set_categories (&comp_data, e_table_model_value_at (source, E_CAL_MODEL_FIELD_CATEGORIES, row)); set_classification (&comp_data, e_table_model_value_at (source, E_CAL_MODEL_FIELD_CLASSIFICATION, row)); set_description (&comp_data, e_table_model_value_at (source, E_CAL_MODEL_FIELD_DESCRIPTION, row)); - set_dtstart (model, &comp_data, e_table_model_value_at (source, E_CAL_MODEL_FIELD_DTSTART, row)); set_summary (&comp_data, e_table_model_value_at (source, E_CAL_MODEL_FIELD_SUMMARY, row)); + if (e_table_model_value_at (source, E_CAL_MODEL_FIELD_DTSTART, row)) { + set_dtstart (model, &comp_data, e_table_model_value_at (source, E_CAL_MODEL_FIELD_DTSTART, row)); + } else if (model->priv->get_default_time) { + time_t tt = model->priv->get_default_time (model, model->priv->get_default_time_user_data); + + if (tt > 0) { + struct icaltimetype itt = icaltime_from_timet_with_zone (tt, FALSE, e_cal_model_get_timezone (model)); + icalproperty *prop = icalcomponent_get_first_property (comp_data.icalcomp, ICAL_DTSTART_PROPERTY); + + if (prop) { + icalproperty_set_dtstart (prop, itt); + } else { + prop = icalproperty_new_dtstart (itt); + icalcomponent_add_property (comp_data.icalcomp, prop); + } + } + } + /* call the class' method for filling the component */ model_class = (ECalModelClass *) G_OBJECT_GET_CLASS (model); if (model_class->fill_component_from_model != NULL) { @@ -2460,3 +2481,17 @@ e_cal_model_set_instance_times (ECalModelComponent *comp_data, const icaltimezon } comp_data->instance_end = icaltime_as_timet_with_zone (end_time, zone); } + +/** + * e_cal_model_set_default_time_func: + * This function will be used when creating new item from the "click-to-add", + * when user didn't fill a start date there. + **/ +void +e_cal_model_set_default_time_func (ECalModel *model, ECalModelDefaultTimeFunc func, gpointer user_data) +{ + g_return_if_fail (E_IS_CAL_MODEL (model)); + + model->priv->get_default_time = func; + model->priv->get_default_time_user_data = user_data; +} |