aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--widgets/misc/ChangeLog5
-rw-r--r--widgets/misc/e-calendar-item.c27
2 files changed, 28 insertions, 4 deletions
diff --git a/widgets/misc/ChangeLog b/widgets/misc/ChangeLog
index 88fcdff23c..a88854c6bc 100644
--- a/widgets/misc/ChangeLog
+++ b/widgets/misc/ChangeLog
@@ -1,3 +1,8 @@
+2002-10-11 JP Rosevear <jpr@ximian.com>
+
+ * e-calendar-item.c (e_calendar_item_ensure_days_visible): check
+ if the selection fits in the leftover days
+
2002-09-30 Ettore Perazzoli <ettore@ximian.com>
[Add a small delay to the switching of pages in the multi-config
diff --git a/widgets/misc/e-calendar-item.c b/widgets/misc/e-calendar-item.c
index f6d7c03820..4a53b10e96 100644
--- a/widgets/misc/e-calendar-item.c
+++ b/widgets/misc/e-calendar-item.c
@@ -2149,7 +2149,7 @@ e_calendar_item_set_first_month(ECalendarItem *calitem,
calitem->month = new_month;
} else {
old_days_in_selection = e_calendar_item_get_inclusive_days (calitem, calitem->selection_start_month_offset, calitem->selection_start_day, calitem->selection_end_month_offset, calitem->selection_end_day);
-
+
/* Make sure the selection will be displayed. */
if (calitem->selection_start_month_offset < 0
|| calitem->selection_start_month_offset >= num_months) {
@@ -2705,9 +2705,28 @@ e_calendar_item_ensure_days_visible (ECalendarItem *calitem,
if (end_year > current_end_year
|| (end_year == current_end_year
&& end_month > current_end_month)) {
- need_update = TRUE;
- calitem->year = end_year;
- calitem->month = end_month - months_shown + 1;
+
+ /* First we see if the end of the selection will fit in the
+ leftover days of the month after the last one shown. */
+ calitem->month += (months_shown - 1);
+ e_calendar_item_normalize_date (calitem, &calitem->year,
+ &calitem->month);
+
+ e_calendar_item_get_month_info (calitem, 0, 0,
+ &first_day_offset,
+ &days_in_month,
+ &days_in_prev_month);
+
+ if (end_day >= E_CALENDAR_ROWS_PER_MONTH * E_CALENDAR_COLS_PER_MONTH -
+ first_day_offset - days_in_month) {
+ need_update = TRUE;
+
+ calitem->year = end_year;
+ calitem->month = end_month - months_shown + 1;
+ } else {
+ calitem->month -= (months_shown - 1);
+ }
+
e_calendar_item_normalize_date (calitem, &calitem->year,
&calitem->month);
}