From bde55a8d92780b10706dd0d942eab532fcb2ba91 Mon Sep 17 00:00:00 2001 From: JP Rosevear Date: Mon, 14 Jan 2002 20:21:20 +0000 Subject: figure out when today is and highlight if it is not selected 2002-01-14 JP Rosevear * gui/e-week-view-main-item.c (e_week_view_main_item_draw_day): figure out when today is and highlight if it is not selected * gui/e-week-view.h: enum the "today" color * gui/e-week-view.c (e_week_view_realize): init the "today" color svn path=/trunk/; revision=15319 --- calendar/ChangeLog | 9 +++++++++ calendar/gui/e-week-view-main-item.c | 19 ++++++++++++++++--- calendar/gui/e-week-view.c | 4 ++++ calendar/gui/e-week-view.h | 1 + 4 files changed, 30 insertions(+), 3 deletions(-) diff --git a/calendar/ChangeLog b/calendar/ChangeLog index a7e8e9c633..fb48b0c8f8 100644 --- a/calendar/ChangeLog +++ b/calendar/ChangeLog @@ -1,3 +1,12 @@ +2002-01-14 JP Rosevear + + * gui/e-week-view-main-item.c (e_week_view_main_item_draw_day): + figure out when today is and highlight if it is not selected + + * gui/e-week-view.h: enum the "today" color + + * gui/e-week-view.c (e_week_view_realize): init the "today" color + 2002-01-13 JP Rosevear * gui/alarm-notify/save.h: add protos diff --git a/calendar/gui/e-week-view-main-item.c b/calendar/gui/e-week-view-main-item.c index 007960c826..60d71f0631 100644 --- a/calendar/gui/e-week-view-main-item.c +++ b/calendar/gui/e-week-view-main-item.c @@ -295,7 +295,7 @@ e_week_view_main_item_draw_day (EWeekViewMainItem *wvmitem, width - 5, line_y - y); } } - + /* Display the date in the top of the cell. In the week view, display the long format "10 January" in all cells, or abbreviate it to "10 Jan" or "10" if that doesn't fit. @@ -353,10 +353,23 @@ e_week_view_main_item_draw_day (EWeekViewMainItem *wvmitem, date_x = x + width - date_width - E_WEEK_VIEW_DATE_R_PAD; date_x = MAX (date_x, x + 1); - if (selected) + if (selected) { gdk_gc_set_foreground (gc, &week_view->colors[E_WEEK_VIEW_COLOR_DATES_SELECTED]); - else + } else if (week_view->multi_week_view) { + struct icaltimetype tt; + + /* Check if we are drawing today */ + tt = icaltime_from_timet_with_zone (time (NULL), FALSE, week_view->zone); + if (g_date_year (date) == tt.year + && g_date_month (date) == tt.month + && g_date_day (date) == tt.day) + gdk_gc_set_foreground (gc, &week_view->colors[E_WEEK_VIEW_COLOR_TODAY]); + else + gdk_gc_set_foreground (gc, &week_view->colors[E_WEEK_VIEW_COLOR_DATES]); + } else { gdk_gc_set_foreground (gc, &week_view->colors[E_WEEK_VIEW_COLOR_DATES]); + } + gdk_draw_string (drawable, font, gc, date_x, y + E_WEEK_VIEW_DATE_T_PAD + font->ascent, buffer); diff --git a/calendar/gui/e-week-view.c b/calendar/gui/e-week-view.c index c9c4b4077e..7dd9d83cc3 100644 --- a/calendar/gui/e-week-view.c +++ b/calendar/gui/e-week-view.c @@ -593,6 +593,10 @@ e_week_view_realize (GtkWidget *widget) week_view->colors[E_WEEK_VIEW_COLOR_DATES_SELECTED].green = 65535; week_view->colors[E_WEEK_VIEW_COLOR_DATES_SELECTED].blue = 65535; + week_view->colors[E_WEEK_VIEW_COLOR_TODAY].red = 65535; + week_view->colors[E_WEEK_VIEW_COLOR_TODAY].green = 0; + week_view->colors[E_WEEK_VIEW_COLOR_TODAY].blue = 0; + nfailed = gdk_colormap_alloc_colors (colormap, week_view->colors, E_WEEK_VIEW_COLOR_LAST, FALSE, TRUE, success); diff --git a/calendar/gui/e-week-view.h b/calendar/gui/e-week-view.h index e10954b9bd..ed14796414 100644 --- a/calendar/gui/e-week-view.h +++ b/calendar/gui/e-week-view.h @@ -106,6 +106,7 @@ typedef enum E_WEEK_VIEW_COLOR_SELECTED, E_WEEK_VIEW_COLOR_DATES, E_WEEK_VIEW_COLOR_DATES_SELECTED, + E_WEEK_VIEW_COLOR_TODAY, E_WEEK_VIEW_COLOR_LAST } EWeekViewColors; -- cgit v1.2.3