aboutsummaryrefslogtreecommitdiffstats
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
parent00044b17d710a88a708ae498581e2bdbd4a76207 (diff)
downloadgsoc2013-evolution-9e60ca1bb2c10e5f299714b1fde83d1d8da73a04.tar.gz
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
-rw-r--r--widgets/misc/ChangeLog6
-rw-r--r--widgets/misc/e-calendar-item.c29
-rw-r--r--widgets/misc/e-calendar-item.h7
3 files changed, 34 insertions, 8 deletions
diff --git a/widgets/misc/ChangeLog b/widgets/misc/ChangeLog
index 14121734fa..aa78dd809a 100644
--- a/widgets/misc/ChangeLog
+++ b/widgets/misc/ChangeLog
@@ -1,3 +1,9 @@
+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.
+
2001-01-19 Federico Mena Quintero <federico@ximian.com>
* e-calendar.c (e_calendar_init): Unset the GTK_CAN_FOCUS flag on
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;
}
diff --git a/widgets/misc/e-calendar-item.h b/widgets/misc/e-calendar-item.h
index f638b16573..0e655cf355 100644
--- a/widgets/misc/e-calendar-item.h
+++ b/widgets/misc/e-calendar-item.h
@@ -261,10 +261,11 @@ gint e_calendar_item_get_days_start_week_sel(ECalendarItem *calitem);
void e_calendar_item_set_days_start_week_sel(ECalendarItem *calitem,
gint days);
-/* Returns the range of dates actually shown. Months are 0 to 11.
+/* 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. */
-void e_calendar_item_get_date_range (ECalendarItem *calitem,
+ 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,
gint *start_day,