From d1769d5646e9fef3c6de607f9f884b02dd954844 Mon Sep 17 00:00:00 2001 From: Federico Mena Quintero Date: Wed, 30 Sep 1998 20:37:06 +0000 Subject: New function to mark the current day in the year view. 1998-09-30 Federico Mena Quintero * year-view.c (mark_current_day): New function to mark the current day in the year view. * mark.c: Removed mark_current_day from here. svn path=/trunk/; revision=418 --- calendar/ChangeLog | 7 +++++++ calendar/gui/mark.c | 21 ------------------- calendar/gui/year-view.c | 52 +++++++++++++++++++++++++++++++++++++++++++++++- calendar/gui/year-view.h | 2 ++ calendar/mark.c | 21 ------------------- calendar/year-view.c | 52 +++++++++++++++++++++++++++++++++++++++++++++++- calendar/year-view.h | 2 ++ 7 files changed, 113 insertions(+), 44 deletions(-) (limited to 'calendar') diff --git a/calendar/ChangeLog b/calendar/ChangeLog index ae18d44bc5..38e85e9a8d 100644 --- a/calendar/ChangeLog +++ b/calendar/ChangeLog @@ -1,3 +1,10 @@ +1998-09-30 Federico Mena Quintero + + * year-view.c (mark_current_day): New function to mark the current + day in the year view. + + * mark.c: Removed mark_current_day from here. + 1998-09-29 Federico Mena Quintero * prop.c (fetch_color_spec): Changed name from fetch_prelight_spec diff --git a/calendar/gui/mark.c b/calendar/gui/mark.c index 274c9efe30..2de8e2b880 100644 --- a/calendar/gui/mark.c +++ b/calendar/gui/mark.c @@ -100,27 +100,6 @@ mark_event_in_month (GnomeMonthItem *mitem, time_t start, time_t end) } } -static void -mark_current_day (GnomeMonthItem *mitem) -{ - struct tm *tm; - time_t t; - int day_index; - GnomeCanvasItem *item; - - t = time (NULL); - tm = localtime (&t); - - if (((tm->tm_year + 1900) == mitem->year) && (tm->tm_mon == mitem->month)) { - day_index = gnome_month_item_day2index (mitem, tm->tm_mday); - item = gnome_month_item_num2child (mitem, GNOME_MONTH_ITEM_DAY_LABEL + day_index); - gnome_canvas_item_set (item, - "fill_color", color_spec_from_prop (COLOR_PROP_CURRENT_DAY_FG), - "font", CURRENT_DAY_FONT, - NULL); - } -} - void mark_month_item (GnomeMonthItem *mitem, Calendar *cal) { diff --git a/calendar/gui/year-view.c b/calendar/gui/year-view.c index da39318ecd..96b43c264b 100644 --- a/calendar/gui/year-view.c +++ b/calendar/gui/year-view.c @@ -479,6 +479,7 @@ year_view_init (YearView *yv) /* We will need to resize the items when we paint for the first time */ + yv->old_marked_day = -1; yv->idle_id = -1; need_resize (yv); } @@ -568,6 +569,52 @@ year_view_update (YearView *yv, iCalObject *object, int flags) year_view_set (yv, time_year_begin (time_from_day (yv->year, 0, 1))); } +/* Unmarks the old day that was marked as current and marks the current day */ +static void +mark_current_day (YearView *yv) +{ + time_t t; + struct tm *tm; + int month_index, day_index; + GnomeCanvasItem *item; + + /* Unmark the old day */ + + if (yv->old_marked_day != -1) { + month_index = yv->old_marked_day / 42; + day_index = yv->old_marked_day % 42; + + item = gnome_month_item_num2child (GNOME_MONTH_ITEM (yv->mitems[month_index]), + GNOME_MONTH_ITEM_DAY_LABEL + day_index); + gnome_canvas_item_set (item, + "fill_color", color_spec_from_prop (COLOR_PROP_DAY_FG), + "font", NORMAL_DAY_FONT, + NULL); + + yv->old_marked_day = -1; + } + + /* Mark the new day */ + + t = time (NULL); + tm = localtime (&t); + + if ((tm->tm_year + 1900) == yv->year) { + month_index = tm->tm_mon; + day_index = gnome_month_item_day2index (GNOME_MONTH_ITEM (yv->mitems[month_index]), tm->tm_mday); + g_assert (day_index != -1); + + item = gnome_month_item_num2child (GNOME_MONTH_ITEM (yv->mitems[month_index]), + GNOME_MONTH_ITEM_DAY_LABEL + day_index); + gnome_canvas_item_set (item, + "fill_color", color_spec_from_prop (COLOR_PROP_CURRENT_DAY_FG), + "font", CURRENT_DAY_FONT, + NULL); + + yv->old_marked_day = month_index * 42 + day_index; + } +} + void year_view_set (YearView *yv, time_t year) { @@ -602,6 +649,8 @@ year_view_set (YearView *yv, time_t year) unmark_month_item (GNOME_MONTH_ITEM (yv->mitems[i])); mark_month_item (GNOME_MONTH_ITEM (yv->mitems[i]), yv->calendar->cal); } + + mark_current_day (yv); } void @@ -628,9 +677,10 @@ year_view_colors_changed (YearView *yv) g_return_if_fail (yv != NULL); g_return_if_fail (IS_YEAR_VIEW (yv)); - for (i = 0; i < 12; i++) { colorify_month_item (GNOME_MONTH_ITEM (yv->mitems[i]), default_color_func, NULL); mark_month_item (GNOME_MONTH_ITEM (yv->mitems[i]), yv->calendar->cal); } + + mark_current_day (yv); } diff --git a/calendar/gui/year-view.h b/calendar/gui/year-view.h index 705f99ffd7..a59be73f46 100644 --- a/calendar/gui/year-view.h +++ b/calendar/gui/year-view.h @@ -38,6 +38,8 @@ struct _YearView { GnomeCanvasItem *titles[12]; /* Titles for months */ GnomeCanvasItem *mitems[12]; /* Month items */ + int old_marked_day; /* The day that is marked as the current day */ + guint idle_id; /* ID of idle handler for resize */ int need_resize : 1; /* Specifies whether we need to resize the canvas items or not */ diff --git a/calendar/mark.c b/calendar/mark.c index 274c9efe30..2de8e2b880 100644 --- a/calendar/mark.c +++ b/calendar/mark.c @@ -100,27 +100,6 @@ mark_event_in_month (GnomeMonthItem *mitem, time_t start, time_t end) } } -static void -mark_current_day (GnomeMonthItem *mitem) -{ - struct tm *tm; - time_t t; - int day_index; - GnomeCanvasItem *item; - - t = time (NULL); - tm = localtime (&t); - - if (((tm->tm_year + 1900) == mitem->year) && (tm->tm_mon == mitem->month)) { - day_index = gnome_month_item_day2index (mitem, tm->tm_mday); - item = gnome_month_item_num2child (mitem, GNOME_MONTH_ITEM_DAY_LABEL + day_index); - gnome_canvas_item_set (item, - "fill_color", color_spec_from_prop (COLOR_PROP_CURRENT_DAY_FG), - "font", CURRENT_DAY_FONT, - NULL); - } -} - void mark_month_item (GnomeMonthItem *mitem, Calendar *cal) { diff --git a/calendar/year-view.c b/calendar/year-view.c index da39318ecd..96b43c264b 100644 --- a/calendar/year-view.c +++ b/calendar/year-view.c @@ -479,6 +479,7 @@ year_view_init (YearView *yv) /* We will need to resize the items when we paint for the first time */ + yv->old_marked_day = -1; yv->idle_id = -1; need_resize (yv); } @@ -568,6 +569,52 @@ year_view_update (YearView *yv, iCalObject *object, int flags) year_view_set (yv, time_year_begin (time_from_day (yv->year, 0, 1))); } +/* Unmarks the old day that was marked as current and marks the current day */ +static void +mark_current_day (YearView *yv) +{ + time_t t; + struct tm *tm; + int month_index, day_index; + GnomeCanvasItem *item; + + /* Unmark the old day */ + + if (yv->old_marked_day != -1) { + month_index = yv->old_marked_day / 42; + day_index = yv->old_marked_day % 42; + + item = gnome_month_item_num2child (GNOME_MONTH_ITEM (yv->mitems[month_index]), + GNOME_MONTH_ITEM_DAY_LABEL + day_index); + gnome_canvas_item_set (item, + "fill_color", color_spec_from_prop (COLOR_PROP_DAY_FG), + "font", NORMAL_DAY_FONT, + NULL); + + yv->old_marked_day = -1; + } + + /* Mark the new day */ + + t = time (NULL); + tm = localtime (&t); + + if ((tm->tm_year + 1900) == yv->year) { + month_index = tm->tm_mon; + day_index = gnome_month_item_day2index (GNOME_MONTH_ITEM (yv->mitems[month_index]), tm->tm_mday); + g_assert (day_index != -1); + + item = gnome_month_item_num2child (GNOME_MONTH_ITEM (yv->mitems[month_index]), + GNOME_MONTH_ITEM_DAY_LABEL + day_index); + gnome_canvas_item_set (item, + "fill_color", color_spec_from_prop (COLOR_PROP_CURRENT_DAY_FG), + "font", CURRENT_DAY_FONT, + NULL); + + yv->old_marked_day = month_index * 42 + day_index; + } +} + void year_view_set (YearView *yv, time_t year) { @@ -602,6 +649,8 @@ year_view_set (YearView *yv, time_t year) unmark_month_item (GNOME_MONTH_ITEM (yv->mitems[i])); mark_month_item (GNOME_MONTH_ITEM (yv->mitems[i]), yv->calendar->cal); } + + mark_current_day (yv); } void @@ -628,9 +677,10 @@ year_view_colors_changed (YearView *yv) g_return_if_fail (yv != NULL); g_return_if_fail (IS_YEAR_VIEW (yv)); - for (i = 0; i < 12; i++) { colorify_month_item (GNOME_MONTH_ITEM (yv->mitems[i]), default_color_func, NULL); mark_month_item (GNOME_MONTH_ITEM (yv->mitems[i]), yv->calendar->cal); } + + mark_current_day (yv); } diff --git a/calendar/year-view.h b/calendar/year-view.h index 705f99ffd7..a59be73f46 100644 --- a/calendar/year-view.h +++ b/calendar/year-view.h @@ -38,6 +38,8 @@ struct _YearView { GnomeCanvasItem *titles[12]; /* Titles for months */ GnomeCanvasItem *mitems[12]; /* Month items */ + int old_marked_day; /* The day that is marked as the current day */ + guint idle_id; /* ID of idle handler for resize */ int need_resize : 1; /* Specifies whether we need to resize the canvas items or not */ -- cgit v1.2.3