aboutsummaryrefslogtreecommitdiffstats
path: root/widgets/misc/e-calendar-item.c
diff options
context:
space:
mode:
authorDamon Chaplin <damon@ximian.com>2001-01-25 11:48:56 +0800
committerDamon Chaplin <damon@src.gnome.org>2001-01-25 11:48:56 +0800
commit9e60ca1bb2c10e5f299714b1fde83d1d8da73a04 (patch)
tree141281cdc3cf28809fd00e3f1c030fd2de8e3cb9 /widgets/misc/e-calendar-item.c
parent00044b17d710a88a708ae498581e2bdbd4a76207 (diff)
downloadgsoc2013-evolution-9e60ca1bb2c10e5f299714b1fde83d1d8da73a04.tar
gsoc2013-evolution-9e60ca1bb2c10e5f299714b1fde83d1d8da73a04.tar.gz
gsoc2013-evolution-9e60ca1bb2c10e5f299714b1fde83d1d8da73a04.tar.bz2
gsoc2013-evolution-9e60ca1bb2c10e5f299714b1fde83d1d8da73a04.tar.lz
gsoc2013-evolution-9e60ca1bb2c10e5f299714b1fde83d1d8da73a04.tar.xz
gsoc2013-evolution-9e60ca1bb2c10e5f299714b1fde83d1d8da73a04.tar.zst
gsoc2013-evolution-9e60ca1bb2c10e5f299714b1fde83d1d8da73a04.zip
e_calendar_item_get_date_range() now returns a boolean, which is FALSE if
2001-01-25 Damon Chaplin <damon@ximian.com> * e-calendar-item.[hc]: e_calendar_item_get_date_range() now returns a boolean, which is FALSE if no dates are currently shown. Plus a couple of minor sanity checks. svn path=/trunk/; revision=7799
Diffstat (limited to 'widgets/misc/e-calendar-item.c')
-rw-r--r--widgets/misc/e-calendar-item.c29
1 files changed, 24 insertions, 5 deletions
diff --git a/widgets/misc/e-calendar-item.c b/widgets/misc/e-calendar-item.c
index a13cbb259d..32b2c62d33 100644
--- a/widgets/misc/e-calendar-item.c
+++ b/widgets/misc/e-calendar-item.c
@@ -792,11 +792,18 @@ e_calendar_item_update (GnomeCanvasItem *item,
width -= xthickness * 2;
height -= ythickness * 2;
- rows = height / calitem->min_month_height;
+ if (calitem->min_month_height == 0)
+ rows = 1;
+ else
+ rows = height / calitem->min_month_height;
rows = MAX (rows, calitem->min_rows);
if (calitem->max_rows > 0)
rows = MIN (rows, calitem->max_rows);
- cols = width / calitem->min_month_width;
+
+ if (calitem->min_month_width == 0)
+ cols = 1;
+ else
+ cols = width / calitem->min_month_width;
cols = MAX (cols, calitem->min_cols);
if (calitem->max_cols > 0)
cols = MIN (cols, calitem->max_cols);
@@ -1504,17 +1511,21 @@ e_calendar_item_recalc_sizes (ECalendarItem *calitem)
canvas_item = GNOME_CANVAS_ITEM (calitem);
style = GTK_WIDGET (canvas_item->canvas)->style;
+ if (!style)
+ return;
+
font = calitem->font;
if (!font)
font = style->font;
wkfont = calitem->week_number_font;
if (!wkfont)
wkfont = font;
- char_height = font->ascent + font->descent;
g_return_if_fail (font != NULL);
g_return_if_fail (wkfont != NULL);
+ char_height = font->ascent + font->descent;
+
/* If both fonts are the same, just return. */
if (font != calitem->old_font
|| wkfont != calitem->old_week_number_font) {
@@ -2261,8 +2272,11 @@ e_calendar_item_add_days_to_selection (ECalendarItem *calitem,
}
-/* Returns the range of dates actually shown. Months are 0 to 11. */
-void
+/* Gets the range of dates actually shown. Months are 0 to 11.
+ This also includes the last days of the previous month and the first days
+ of the following month, which are normally shown in gray.
+ It returns FALSE if no dates are currently shown. */
+gboolean
e_calendar_item_get_date_range (ECalendarItem *calitem,
gint *start_year,
gint *start_month,
@@ -2273,6 +2287,9 @@ e_calendar_item_get_date_range (ECalendarItem *calitem,
{
gint first_day_offset, days_in_month, days_in_prev_month;
+ if (calitem->rows == 0 || calitem->cols == 0)
+ return FALSE;
+
/* Calculate the first day shown. This will be one of the greyed-out
days before the first full month begins. */
e_calendar_item_get_month_info (calitem, 0, 0, &first_day_offset,
@@ -2296,6 +2313,8 @@ e_calendar_item_get_date_range (ECalendarItem *calitem,
*end_month %= 12;
*end_day = E_CALENDAR_ROWS_PER_MONTH * E_CALENDAR_COLS_PER_MONTH
- first_day_offset - days_in_month;
+
+ return TRUE;
}