aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMilan Crha <mcrha@redhat.com>2009-01-20 00:41:40 +0800
committerMilan Crha <mcrha@src.gnome.org>2009-01-20 00:41:40 +0800
commitfa2e93cedc1396a3e323c3a4a1bfdfee8ac3bf53 (patch)
tree2d817af9437b0f47477aee12947446d1fbce191c
parent324f78272ffa32c943600918a90a032ba94272dc (diff)
downloadgsoc2013-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
-rw-r--r--calendar/ChangeLog12
-rw-r--r--calendar/gui/e-cal-model.c37
-rw-r--r--calendar/gui/e-cal-model.h4
-rw-r--r--calendar/gui/gnome-cal.c16
4 files changed, 68 insertions, 1 deletions
diff --git a/calendar/ChangeLog b/calendar/ChangeLog
index 14a2416361..f9ae4f0b26 100644
--- a/calendar/ChangeLog
+++ b/calendar/ChangeLog
@@ -1,5 +1,17 @@
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.
+
+2009-01-19 Milan Crha <mcrha@redhat.com>
+
** Fix for bug #550735
* gui/print.c: (get_summary_with_location), (print_day_long_event),
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;
+}
diff --git a/calendar/gui/e-cal-model.h b/calendar/gui/e-cal-model.h
index ad9bc7d9ae..80ba4d4b5b 100644
--- a/calendar/gui/e-cal-model.h
+++ b/calendar/gui/e-cal-model.h
@@ -121,6 +121,8 @@ typedef struct {
void (* cal_view_done) (ECalModel *model, ECalendarStatus status, ECalSourceType type);
} ECalModelClass;
+typedef time_t (*ECalModelDefaultTimeFunc)(ECalModel *model, gpointer user_data);
+
GType e_cal_model_get_type (void);
GType e_cal_model_component_get_type (void);
icalcomponent_kind e_cal_model_get_component_kind (ECalModel *model);
@@ -184,6 +186,8 @@ void e_cal_model_set_search_query_with_time_range (ECalModel *model, const char
gboolean e_cal_model_test_row_editable (ECalModel *model, int row);
+void e_cal_model_set_default_time_func (ECalModel *model, ECalModelDefaultTimeFunc func, gpointer user_data);
+
G_END_DECLS
#endif
diff --git a/calendar/gui/gnome-cal.c b/calendar/gui/gnome-cal.c
index c2b1cb3d6c..782d1b76cb 100644
--- a/calendar/gui/gnome-cal.c
+++ b/calendar/gui/gnome-cal.c
@@ -1595,6 +1595,20 @@ gnome_calendar_get_tag (GnomeCalendar *gcal)
return GTK_WIDGET (gcal->priv->date_navigator);
}
+static time_t
+gc_get_default_time (ECalModel *model, gpointer user_data)
+{
+ GnomeCalendar *gcal = user_data;
+ time_t res = 0, end;
+
+ g_return_val_if_fail (model != NULL, 0);
+ g_return_val_if_fail (GNOME_IS_CALENDAR (user_data), 0);
+
+ gnome_calendar_get_current_time_range (gcal, &res, &end);
+
+ return res;
+}
+
static void
setup_widgets (GnomeCalendar *gcal)
{
@@ -1821,6 +1835,8 @@ setup_widgets (GnomeCalendar *gcal)
"MemoPad", NULL);
e_memo_table_load_state (E_MEMO_TABLE (priv->memo), filename);
+ e_cal_model_set_default_time_func (e_memo_table_get_model (E_MEMO_TABLE (priv->memo)), gc_get_default_time, gcal);
+
update_memo_view (gcal);
g_free (filename);