From 07dacea3edab82eecc1cd487c493edc0ca65da6a Mon Sep 17 00:00:00 2001 From: Federico Mena Quintero Date: Mon, 2 Jul 2001 21:46:36 +0000 Subject: Support for repeat/duration properties in alarm components. 2001-07-02 Federico Mena Quintero Support for repeat/duration properties in alarm components. * cal-util/cal-component.h (CalAlarmRepeat): New structure that pairs the repeat/duration values of an alarm component, which must be set both together or not set at all. * cal-util/cal-component.c (CalComponentAlarm): Added fields for the repeat and duration properties. (scan_alarm_property): Scan the DURATION and REPEAT properties. (make_alarm): Nullify/initialize all the fields in the alarm. (cal_component_alarm_get_repeat): New function. (cal_component_alarm_set_repeat): New function. * gui/dialogs/alarm-page.glade: Changed the label of display alarms from "Show a dialog" to "Display a message". svn path=/trunk/; revision=10706 --- calendar/ChangeLog | 18 +++++++++ calendar/cal-util/cal-component.c | 74 +++++++++++++++++++++++++++++++++++ calendar/cal-util/cal-component.h | 11 ++++++ calendar/gui/dialogs/alarm-page.glade | 2 +- 4 files changed, 104 insertions(+), 1 deletion(-) (limited to 'calendar') diff --git a/calendar/ChangeLog b/calendar/ChangeLog index 29d6595ac6..a969c0d5b3 100644 --- a/calendar/ChangeLog +++ b/calendar/ChangeLog @@ -1,3 +1,21 @@ +2001-07-02 Federico Mena Quintero + + Support for repeat/duration properties in alarm components. + + * cal-util/cal-component.h (CalAlarmRepeat): New structure that + pairs the repeat/duration values of an alarm component, which must + be set both together or not set at all. + + * cal-util/cal-component.c (CalComponentAlarm): Added fields for + the repeat and duration properties. + (scan_alarm_property): Scan the DURATION and REPEAT properties. + (make_alarm): Nullify/initialize all the fields in the alarm. + (cal_component_alarm_get_repeat): New function. + (cal_component_alarm_set_repeat): New function. + + * gui/dialogs/alarm-page.glade: Changed the label of display + alarms from "Show a dialog" to "Display a message". + 2001-07-02 JP Rosevear * gui/dialogs/task-details-page.c diff --git a/calendar/cal-util/cal-component.c b/calendar/cal-util/cal-component.c index 2398840a19..a9c39143f2 100644 --- a/calendar/cal-util/cal-component.c +++ b/calendar/cal-util/cal-component.c @@ -152,6 +152,8 @@ struct _CalComponentAlarm { /* Properties */ icalproperty *action; + icalproperty *duration; + icalproperty *repeat; icalproperty *trigger; }; @@ -4126,6 +4128,14 @@ scan_alarm_property (CalComponentAlarm *alarm, icalproperty *prop) alarm->action = prop; break; + case ICAL_DURATION_PROPERTY: + alarm->duration = prop; + break; + + case ICAL_REPEAT_PROPERTY: + alarm->repeat = prop; + break; + case ICAL_TRIGGER_PROPERTY: alarm->trigger = prop; break; @@ -4156,6 +4166,11 @@ make_alarm (icalcomponent *subcomp) alarm->icalcomp = subcomp; alarm->uid = NULL; + alarm->action = NULL; + alarm->duration = NULL; + alarm->repeat = NULL; + alarm->trigger = NULL; + for (prop = icalcomponent_get_first_property (subcomp, ICAL_ANY_PROPERTY); prop; prop = icalcomponent_get_next_property (subcomp, ICAL_ANY_PROPERTY)) @@ -4601,6 +4616,65 @@ cal_component_alarm_set_trigger (CalComponentAlarm *alarm, CalAlarmTrigger trigg } } +/** + * cal_component_alarm_get_repeat: + * @alarm: An alarm. + * @repeat: Return value for the repeat/duration properties. + * + * Queries the repeat/duration properties of an alarm. + **/ +void +cal_component_alarm_get_repeat (CalComponentAlarm *alarm, CalAlarmRepeat *repeat) +{ + g_return_if_fail (alarm != NULL); + g_return_if_fail (repeat != NULL); + + g_assert (alarm->icalcomp != NULL); + + if (!(alarm->repeat && alarm->duration)) { + repeat->repetitions = 0; + memset (&repeat->duration, 0, sizeof (repeat->duration)); + return; + } + + repeat->repetitions = icalproperty_get_repeat (alarm->repeat); + repeat->duration = icalproperty_get_duration (alarm->duration); +} + +void +cal_component_alarm_set_repeat (CalComponentAlarm *alarm, CalAlarmRepeat repeat) +{ + g_return_if_fail (alarm != NULL); + g_return_if_fail (repeat.repetitions >= 0); + + g_assert (alarm->icalcomp != NULL); + + /* Delete old properties */ + + if (alarm->repeat) { + icalcomponent_remove_property (alarm->icalcomp, alarm->repeat); + icalproperty_free (alarm->repeat); + alarm->repeat = NULL; + } + + if (alarm->duration) { + icalcomponent_remove_property (alarm->icalcomp, alarm->duration); + icalproperty_free (alarm->duration); + alarm->duration = NULL; + } + + /* Set the new properties */ + + if (repeat.repetitions == 0) + return; /* For zero extra repetitions the properties should not exist */ + + alarm->repeat = icalproperty_new_repeat (repeat.repetitions); + icalcomponent_add_property (alarm->icalcomp, alarm->repeat); + + alarm->duration = icalproperty_new_duration (repeat.duration); + icalcomponent_add_property (alarm->icalcomp, alarm->duration); +} + /** * cal_component_alarm_free: * @alarm: A calendar alarm. diff --git a/calendar/cal-util/cal-component.h b/calendar/cal-util/cal-component.h index c8f21963b4..54f9c03a33 100644 --- a/calendar/cal-util/cal-component.h +++ b/calendar/cal-util/cal-component.h @@ -406,6 +406,14 @@ typedef struct { } u; } CalAlarmTrigger; +typedef struct { + /* Number of extra repetitions, zero for none */ + int repetitions; + + /* Interval between repetitions */ + struct icaldurationtype duration; +} CalAlarmRepeat; + gboolean cal_component_has_alarms (CalComponent *comp); void cal_component_add_alarm (CalComponent *comp, CalComponentAlarm *alarm); void cal_component_remove_alarm (CalComponent *comp, const char *auid); @@ -427,6 +435,9 @@ void cal_component_alarm_set_action (CalComponentAlarm *alarm, CalAlarmAction ac void cal_component_alarm_get_trigger (CalComponentAlarm *alarm, CalAlarmTrigger *trigger); void cal_component_alarm_set_trigger (CalComponentAlarm *alarm, CalAlarmTrigger trigger); +void cal_component_alarm_get_repeat (CalComponentAlarm *alarm, CalAlarmRepeat *repeat); +void cal_component_alarm_set_repeat (CalComponentAlarm *alarm, CalAlarmRepeat repeat); + void cal_component_alarm_free (CalComponentAlarm *alarm); diff --git a/calendar/gui/dialogs/alarm-page.glade b/calendar/gui/dialogs/alarm-page.glade index 183ec1b95b..80db7edc76 100644 --- a/calendar/gui/dialogs/alarm-page.glade +++ b/calendar/gui/dialogs/alarm-page.glade @@ -196,7 +196,7 @@ GtkOptionMenu action True - Show a dialog + Display a message Play a sound Send an email Run a program -- cgit