diff options
author | Miguel de Icaza <miguel@nuclecu.unam.mx> | 1999-01-29 08:51:55 +0800 |
---|---|---|
committer | Arturo Espinosa <unammx@src.gnome.org> | 1999-01-29 08:51:55 +0800 |
commit | 7fa29f65a4b068db075d0da9dbf05c2a3c4569a4 (patch) | |
tree | 10b40041921cbd83857d3ed707562efedb04f53e /calendar/calendar.c | |
parent | 1ae6dea2dbe31f7aef33db4f6c099b4476a545e9 (diff) | |
download | gsoc2013-evolution-7fa29f65a4b068db075d0da9dbf05c2a3c4569a4.tar gsoc2013-evolution-7fa29f65a4b068db075d0da9dbf05c2a3c4569a4.tar.gz gsoc2013-evolution-7fa29f65a4b068db075d0da9dbf05c2a3c4569a4.tar.bz2 gsoc2013-evolution-7fa29f65a4b068db075d0da9dbf05c2a3c4569a4.tar.lz gsoc2013-evolution-7fa29f65a4b068db075d0da9dbf05c2a3c4569a4.tar.xz gsoc2013-evolution-7fa29f65a4b068db075d0da9dbf05c2a3c4569a4.tar.zst gsoc2013-evolution-7fa29f65a4b068db075d0da9dbf05c2a3c4569a4.zip |
Schedule an alarm for midnight to change the
1999-01-28 Miguel de Icaza <miguel@nuclecu.unam.mx>
* calendar.c (calendar_init_alarms): Schedule an alarm for
midnight to change the calendar_day_begin/calendar_day_end.
* alarm.c (alarm_ready): If we reschedule, there is no need to
activate any pending alarms.
svn path=/trunk/; revision=634
Diffstat (limited to 'calendar/calendar.c')
-rw-r--r-- | calendar/calendar.c | 41 |
1 files changed, 35 insertions, 6 deletions
diff --git a/calendar/calendar.c b/calendar/calendar.c index e5b050620e..c9f4dc9493 100644 --- a/calendar/calendar.c +++ b/calendar/calendar.c @@ -23,14 +23,19 @@ /* Our day range */ time_t calendar_day_begin, calendar_day_end; +static void calendar_init_alarms (Calendar *cal); + Calendar * calendar_new (char *title) { Calendar *cal; cal = g_new0 (Calendar, 1); + cal->title = g_strdup (title); + calendar_init_alarms (cal); + return cal; } @@ -47,7 +52,7 @@ try_add (iCalObject *ico, CalendarAlarm *alarm, time_t start, time_t end) } static int -add_alarm (iCalObject *obj, time_t start, time_t end, void *closure) +add_object_alarms (iCalObject *obj, time_t start, time_t end, void *closure) { if (obj->aalarm.enabled) try_add (obj, &obj->aalarm, start, end); @@ -78,7 +83,7 @@ ical_object_try_alarms (iCalObject *obj) if (max_o == -1) return; - ical_object_generate_events (obj, calendar_day_begin, calendar_day_end + max_o, add_alarm, obj); + ical_object_generate_events (obj, calendar_day_begin, calendar_day_end + max_o, add_object_alarms, obj); } void @@ -275,12 +280,21 @@ calendar_load_from_vobject (Calendar *cal, VObject *vcal) } } +static void +calendar_set_day (void) +{ + time_t calendar_today; + + calendar_today = time (NULL); + calendar_day_begin = time_day_begin (calendar_today); + calendar_day_end = time_day_end (calendar_today); +} + /* Loads a calendar from a file */ char * calendar_load (Calendar *cal, char *fname) { VObject *vcal; - time_t calendar_today; struct stat s; if (cal->filename){ @@ -295,9 +309,8 @@ calendar_load (Calendar *cal, char *fname) stat (fname, &s); cal->file_time = s.st_mtime; - calendar_today = time (NULL); - calendar_day_begin = time_day_begin (calendar_today); - calendar_day_end = time_day_end (calendar_today); + + calendar_set_day (); calendar_load_from_vobject (cal, vcal); cleanVObject (vcal); @@ -417,3 +430,19 @@ calendar_object_changed (Calendar *cal, iCalObject *obj, int flags) ; ical_object_try_alarms (obj); } + +static void +calendar_day_change (time_t time, CalendarAlarm *which, void *closure) +{ + calendar_set_day (); +} + +static void +calendar_init_alarms (Calendar *cal) +{ + CalendarAlarm day_change_alarm; + + day_change_alarm.trigger = calendar_day_end; + alarm_add (&day_change_alarm, calendar_day_change, cal); +} + |