diff options
author | Federico Mena Quintero <federico@nuclecu.unam.mx> | 1998-08-30 09:29:19 +0800 |
---|---|---|
committer | Arturo Espinosa <unammx@src.gnome.org> | 1998-08-30 09:29:19 +0800 |
commit | e0d99122ab17d9bf356cf793b41aec6b6d6016b1 (patch) | |
tree | b2f202ce6ea0b927a8fa4929034c84af223ef782 /calendar/year-view.c | |
parent | 9b6991077bd564348e9dd229ca523bdaa8239ed1 (diff) | |
download | gsoc2013-evolution-e0d99122ab17d9bf356cf793b41aec6b6d6016b1.tar.gz gsoc2013-evolution-e0d99122ab17d9bf356cf793b41aec6b6d6016b1.tar.zst gsoc2013-evolution-e0d99122ab17d9bf356cf793b41aec6b6d6016b1.zip |
Centralized marking of month items. We now have a little utility function
Centralized marking of month items. We now have a little utility
function to colorify the days in a month item that have events
scheduled for them. This is currently used by the year view and
the go-to dialog. Fixed buglets here and there.
1998-08-29 Federico Mena Quintero <federico@nuclecu.unam.mx>
* mark.[ch]: New files with utility functions to mark calendars
with their events.
* mark.c (mark_month_item): New public function to mark a month
item with events.
(unmark_month_item): New public function to unmark all the days in
a month item to their default appearance.
* year-view.c (year_view_set): Use the new unmark_month_item() and
mark_month_item() to mark the months with events.
* goto.c (update): New function that updates the calendar in the
Go-to dialog by marking the days.
* timeutil.c (time_year_begin): Modified to take a time_t value.
(time_year_end): Likewise.
(time_month_begin): Actually implemented this function, which was
in the header file but not here.
(time_days_in_month): New public function that returns the number
of days in a month.
* Makefile.am (gnomecal_SOURCES): Added mark.[ch] to the sources.
* year-view.c (unmark_days): Use unmark_month_item().
* gncal-full-day.c (gncal_full_day_destroy): Fixed crash when
destroying the full day view. The full day's destroy method is
unusual in that it destroys the list of child widgets itself, as
it does not have a remove method, so it needs to reset the list to
NULL.
svn path=/trunk/; revision=351
Diffstat (limited to 'calendar/year-view.c')
-rw-r--r-- | calendar/year-view.c | 113 |
1 files changed, 9 insertions, 104 deletions
diff --git a/calendar/year-view.c b/calendar/year-view.c index bb3a38ecab..a09862f5f0 100644 --- a/calendar/year-view.c +++ b/calendar/year-view.c @@ -10,6 +10,7 @@ #include <libgnomeui/gnome-canvas-text.h> #include "year-view.h" #include "main.h" +#include "mark.h" #include "timeutil.h" @@ -284,107 +285,7 @@ year_view_update (YearView *yv, iCalObject *object, int flags) if (object && ((flags & CHANGE_SUMMARY) == flags)) return; - year_view_set (yv, time_year_begin (yv->year)); -} - -/* Unmarks all the days in the year view by setting their boxes and labels to the default colors */ -static void -unmark_days (YearView *yv) -{ - GnomeCanvasItem *item; - int i, j; - - for (i = 0; i < 12; i++) - for (j = 0; j < 42; j++) { - /* Box */ - - item = gnome_month_item_num2child (GNOME_MONTH_ITEM (yv->mitems[i]), - GNOME_MONTH_ITEM_DAY_BOX + j); - gnome_canvas_item_set (item, - "fill_color", "#d6d6d6d6d6d6", - NULL); - - /* Label */ - - item = gnome_month_item_num2child (GNOME_MONTH_ITEM (yv->mitems[i]), - GNOME_MONTH_ITEM_DAY_LABEL + j); - gnome_canvas_item_set (item, - "fill_color", "black", - NULL); - } -} - -/* Marks all the days that fall into the specified time span */ -static void -mark_event (YearView *yv, time_t start, time_t end) -{ - time_t t; - struct tm tm; - int day_index; - GnomeCanvasItem *mitem, *item; - - tm = *localtime (&start); - end = time_end_of_day (end); - - for (t = start; t < end; t += 60 * 60 * 24) { - mktime (&tm); /* normalize the time */ - - /* We need this comparison because an event may span more than one year (!). - * Yes, this is not the most efficient way of doing this (we could just clip - * the event to the current year), but it will do for now. - */ - - if ((tm.tm_year + 1900) == yv->year) { - /* Figure out the month item and day index that correspond to this time */ - - mitem = yv->mitems[tm.tm_mon]; - day_index = gnome_month_item_day2index (GNOME_MONTH_ITEM (mitem), tm.tm_mday); - g_assert (day_index != -1); - - /* Mark the day box */ - - item = gnome_month_item_num2child (GNOME_MONTH_ITEM (mitem), - GNOME_MONTH_ITEM_DAY_BOX + day_index); - gnome_canvas_item_set (item, - "fill_color", "tan", - NULL); - - /* Mark the day label */ - - item = gnome_month_item_num2child (GNOME_MONTH_ITEM (mitem), - GNOME_MONTH_ITEM_DAY_LABEL + day_index); - gnome_canvas_item_set (item, - "fill_color", "black", - NULL); - } - - /* Next day */ - - tm.tm_mday++; - } -} - -/* Queries the calendar for all the events in the current year and marks the days that have at least - * one event in them. - */ -static void -mark_days (YearView *yv) -{ - time_t year_begin, year_end; - GList *list, *l; - CalendarObject *co; - - year_begin = time_year_begin (yv->year); - year_end = time_year_end (yv->year); - - list = calendar_get_events_in_range (yv->calendar->cal, year_begin, year_end); - - for (l = list; l; l = l->next) { - co = l->data; - mark_event (yv, co->ev_start, co->ev_end); - } - - calendar_destroy_event_list (list); + year_view_set (yv, time_year_begin (time_from_day (yv->year, 0, 1))); } void @@ -415,8 +316,12 @@ year_view_set (YearView *yv, time_t year) "month", i, NULL); - unmark_days (yv); - mark_days (yv); + /* Unmark and re-mark all the months */ + + for (i = 0; i < 12; i++) { + unmark_month_item (GNOME_MONTH_ITEM (yv->mitems[i])); + mark_month_item (GNOME_MONTH_ITEM (yv->mitems[i]), yv->calendar->cal); + } } void @@ -432,5 +337,5 @@ year_view_time_format_changed (YearView *yv) "start_on_monday", week_starts_on_monday, NULL); - year_view_set (yv, time_year_begin (yv->year)); + year_view_set (yv, time_year_begin (time_from_day (yv->year, 0, 1))); } |