From 186370e3a44a90b6761c373e4290213d1e51d1e7 Mon Sep 17 00:00:00 2001 From: Milan Crha Date: Fri, 19 Jun 2009 16:26:57 +0200 Subject: Bug #513451 - Select Today for calendar views on the first showing --- calendar/gui/gnome-cal.c | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) (limited to 'calendar/gui/gnome-cal.c') diff --git a/calendar/gui/gnome-cal.c b/calendar/gui/gnome-cal.c index 458a5c1dc9..1e943eeb14 100644 --- a/calendar/gui/gnome-cal.c +++ b/calendar/gui/gnome-cal.c @@ -628,7 +628,7 @@ gnome_calendar_get_current_view_widget (GnomeCalendar *gcal) } static void -get_times_for_views (GnomeCalendar *gcal, GnomeCalendarViewType view_type, time_t *start_time, time_t *end_time) +get_times_for_views (GnomeCalendar *gcal, GnomeCalendarViewType view_type, time_t *start_time, time_t *end_time, time_t *select_time) { GnomeCalendarPrivate *priv; gint shown, display_start; @@ -697,6 +697,9 @@ get_times_for_views (GnomeCalendar *gcal, GnomeCalendarViewType view_type, time_ *start_time = icaltime_as_timet_with_zone (tt, priv->zone); *end_time = time_add_day_with_zone (*start_time, days_shown, priv->zone); + + if (select_time && E_DAY_VIEW (priv->views[view_type])->selection_start_day == -1) + time (select_time); break; case GNOME_CAL_WEEK_VIEW: /* FIXME We should be using the same day of the week enum every where */ @@ -704,6 +707,9 @@ get_times_for_views (GnomeCalendar *gcal, GnomeCalendarViewType view_type, time_ *start_time = time_week_begin_with_zone (*start_time, display_start, priv->zone); *end_time = time_add_week_with_zone (*start_time, 1, priv->zone); + + if (select_time && E_WEEK_VIEW (priv->views[view_type])->selection_start_day == -1) + time (select_time); break; case GNOME_CAL_MONTH_VIEW: shown = e_week_view_get_weeks_shown (E_WEEK_VIEW (priv->views[view_type])); @@ -714,6 +720,9 @@ get_times_for_views (GnomeCalendar *gcal, GnomeCalendarViewType view_type, time_ *start_time = time_month_begin_with_zone (*start_time, priv->zone); *start_time = time_week_begin_with_zone (*start_time, display_start, priv->zone); *end_time = time_add_week_with_zone (*start_time, shown, priv->zone); + + if (select_time && E_WEEK_VIEW (priv->views[view_type])->selection_start_day == -1) + time (select_time); break; case GNOME_CAL_LIST_VIEW: /* FIXME What to do here? */ @@ -988,7 +997,7 @@ set_search_query (GnomeCalendar *gcal, const gchar *sexp) e_cal_model_set_search_query_with_time_range (e_calendar_view_get_model (priv->views [i]), sexp, start, end); } else { start = priv->base_view_time; - get_times_for_views (gcal, GNOME_CAL_LIST_VIEW, &start, &end); + get_times_for_views (gcal, GNOME_CAL_LIST_VIEW, &start, &end, NULL); e_cal_model_set_search_query_with_time_range (e_calendar_view_get_model (priv->views [i]), sexp, start, end); @@ -2183,19 +2192,22 @@ update_view_times (GnomeCalendar *gcal, time_t start_time) GnomeCalendarPrivate *priv; ECalModel *model; time_t real_start_time = start_time; - time_t end_time; + time_t end_time, select_time = 0; priv = gcal->priv; priv->base_view_time = start_time; model = e_calendar_view_get_model (priv->views [priv->current_view_type]); - get_times_for_views (gcal, priv->current_view_type, &real_start_time, &end_time); + get_times_for_views (gcal, priv->current_view_type, &real_start_time, &end_time, &select_time); if (priv->current_view_type == GNOME_CAL_LIST_VIEW && !priv->lview_select_daten_range) return; e_cal_model_set_time_range (model, real_start_time, end_time); + + if (select_time != 0 && select_time >= real_start_time && select_time <= end_time) + e_calendar_view_set_selected_time_range (priv->views [priv->current_view_type], select_time, select_time); } static void -- cgit