From 1cca3628386aa66324f4e407e73e761d379b64b3 Mon Sep 17 00:00:00 2001 From: Federico Mena Quintero Date: Mon, 17 Sep 2001 21:11:38 +0000 Subject: Duh, only setup the timeout if the list was empty. (alarm_ready_cb): 2001-09-17 Federico Mena Quintero * gui/alarm-notify/alarm.c (queue_alarm): Duh, only setup the timeout if the list was empty. (alarm_ready_cb): Notify with the ID of the original alarm. (alarm_remove): Likewise. svn path=/trunk/; revision=12912 --- calendar/ChangeLog | 7 +++++++ calendar/gui/alarm-notify/alarm.c | 22 +++++++++++++++------- 2 files changed, 22 insertions(+), 7 deletions(-) diff --git a/calendar/ChangeLog b/calendar/ChangeLog index 802eb2598e..d1f4b4e41c 100644 --- a/calendar/ChangeLog +++ b/calendar/ChangeLog @@ -1,3 +1,10 @@ +2001-09-17 Federico Mena Quintero + + * gui/alarm-notify/alarm.c (queue_alarm): Duh, only setup the + timeout if the list was empty. + (alarm_ready_cb): Notify with the ID of the original alarm. + (alarm_remove): Likewise. + 2001-09-17 Federico Mena Quintero Switch the alarm system from using SIGALRM to normal glib timers. diff --git a/calendar/gui/alarm-notify/alarm.c b/calendar/gui/alarm-notify/alarm.c index 7f1a2eaa5f..7f45a72712 100644 --- a/calendar/gui/alarm-notify/alarm.c +++ b/calendar/gui/alarm-notify/alarm.c @@ -81,7 +81,7 @@ alarm_ready_cb (gpointer data) now = time (NULL); while (alarms) { - AlarmRecord *ar; + AlarmRecord *notify_id, *ar; AlarmRecord ar_copy; ar = alarms->data; @@ -89,15 +89,17 @@ alarm_ready_cb (gpointer data) if (ar->trigger > now) break; + notify_id = ar; + ar_copy = *ar; ar = &ar_copy; pop_alarm (); /* This will free the original AlarmRecord; that's why we copy it */ - (* ar->alarm_fn) (ar, ar->trigger, ar->data); + (* ar->alarm_fn) (notify_id, ar->trigger, ar->data); if (ar->destroy_notify_fn) - (* ar->destroy_notify_fn) (ar, ar->data); + (* ar->destroy_notify_fn) (notify_id, ar->data); } if (alarms) @@ -165,8 +167,10 @@ queue_alarm (AlarmRecord *ar) /* Set the timer for removal upon activation */ - now = time (NULL); - setup_timeout (now); + if (!old_head) { + now = time (NULL); + setup_timeout (now); + } } @@ -201,6 +205,8 @@ alarm_add (time_t trigger, AlarmFunction alarm_fn, gpointer data, queue_alarm (ar); + g_print ("alarm_add(): Adding alarm %p for %s\n", ar, ctime (&trigger)); + return ar; } @@ -213,7 +219,7 @@ alarm_add (time_t trigger, AlarmFunction alarm_fn, gpointer data, void alarm_remove (gpointer alarm) { - AlarmRecord *ar; + AlarmRecord *notify_id, *ar; AlarmRecord ar_copy; AlarmRecord *old_head; GList *l; @@ -230,6 +236,8 @@ alarm_remove (gpointer alarm) old_head = alarms->data; + notify_id = ar; + if (old_head == ar) { ar_copy = *ar; ar = &ar_copy; @@ -251,7 +259,7 @@ alarm_remove (gpointer alarm) /* Notify about destructiono of the alarm */ if (ar->destroy_notify_fn) - (* ar->destroy_notify_fn) (ar, ar->data); + (* ar->destroy_notify_fn) (notify_id, ar->data); } -- cgit v1.2.3