From bba515a79c91c90e413403d1f03251cf0ed33457 Mon Sep 17 00:00:00 2001 From: Federico Mena Quintero Date: Fri, 11 Aug 2000 17:49:53 +0000 Subject: Handle the PERCENT-COMPLETE property. (free_icalcomponent): Likewise. 2000-08-11 Federico Mena Quintero * cal-util/cal-component.c (scan_property): Handle the PERCENT-COMPLETE property. (free_icalcomponent): Likewise. (cal_component_get_percent): Likewise. (cal_component_set_percent): Likewise. (cal_component_free_percent): Likewise. (scan_property): Handle the PRIORITY property. (free_icalcomponent): Likewise. (cal_component_get_priority): Likewise. (cal_component_set_priority): Likewise. (cal_component_free_priority): Likewise. * cal-util/cal-component.h (CalComponentField): New enumeration with the list of fields we support for ETable. svn path=/trunk/; revision=4745 --- calendar/cal-util/cal-component.c | 172 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 172 insertions(+) (limited to 'calendar/cal-util/cal-component.c') diff --git a/calendar/cal-util/cal-component.c b/calendar/cal-util/cal-component.c index 1c5bddd4fc..1fdfc5da8c 100644 --- a/calendar/cal-util/cal-component.c +++ b/calendar/cal-util/cal-component.c @@ -72,6 +72,8 @@ struct _CalComponentPrivate { GSList *exrule_list; /* list of icalproperty objects */ icalproperty *last_modified; + icalproperty *percent; + icalproperty *priority; struct period { icalproperty *prop; @@ -243,6 +245,8 @@ free_icalcomponent (CalComponent *comp) priv->exrule_list = NULL; priv->last_modified = NULL; + priv->percent = NULL; + priv->priority = NULL; priv->rdate_list = free_slist (priv->rdate_list); @@ -517,6 +521,14 @@ scan_property (CalComponent *comp, icalproperty *prop) priv->last_modified = prop; break; + case ICAL_PERCENTCOMPLETE_PROPERTY: + priv->percent = prop; + break; + + case ICAL_PRIORITY_PROPERTY: + priv->priority = prop; + break; + case ICAL_RDATE_PROPERTY: scan_period (comp, &priv->rdate_list, prop); break; @@ -2142,6 +2154,136 @@ cal_component_set_last_modified (CalComponent *comp, struct icaltimetype *t) t); } +/** + * cal_component_get_percent: + * @comp: A calendar component object. + * @percent: Return value for the percent-complete property. This should be + * freed using the cal_component_free_percent() function. + * + * Queries the percent-complete property of a calendar component object. + **/ +void +cal_component_get_percent (CalComponent *comp, int **percent) +{ + CalComponentPrivate *priv; + + g_return_if_fail (comp != NULL); + g_return_if_fail (IS_CAL_COMPONENT (comp)); + g_return_if_fail (percent != NULL); + + priv = comp->priv; + g_return_if_fail (priv->icalcomp != NULL); + + if (priv->percent) { + *percent = g_new (int, 1); + **percent = icalproperty_get_percentcomplete (priv->percent); + } else + *percent = NULL; +} + +/** + * cal_component_set_percent: + * @comp: A calendar component object. + * @percent: Value for the percent-complete property. + * + * Sets the percent-complete property of a calendar component object. + **/ +void +cal_component_set_percent (CalComponent *comp, int *percent) +{ + CalComponentPrivate *priv; + + g_return_if_fail (comp != NULL); + g_return_if_fail (IS_CAL_COMPONENT (comp)); + + priv = comp->priv; + g_return_if_fail (priv->icalcomp != NULL); + + if (!percent) { + if (priv->percent) { + icalcomponent_remove_property (priv->icalcomp, priv->percent); + icalproperty_free (priv->percent); + priv->percent = NULL; + } + + return; + } + + g_return_if_fail (*percent >= 0 && *percent <= 100); + + if (priv->percent) + icalproperty_set_percentcomplete (priv->percent, *percent); + else { + priv->percent = icalproperty_new_percentcomplete (*percent); + icalcomponent_add_property (priv->icalcomp, priv->percent); + } +} + +/** + * cal_component_get_priority: + * @comp: A calendar component object. + * @priority: Return value for the priority property. This should be freed using + * the cal_component_free_priority() function. + * + * Queries the priority property of a calendar component object. + **/ +void +cal_component_get_priority (CalComponent *comp, int **priority) +{ + CalComponentPrivate *priv; + + g_return_if_fail (comp != NULL); + g_return_if_fail (IS_CAL_COMPONENT (comp)); + g_return_if_fail (priority != NULL); + + priv = comp->priv; + g_return_if_fail (priv->icalcomp != NULL); + + if (priv->priority) { + *priority = g_new (int, 1); + **priority = icalproperty_get_priority (priv->priority); + } else + *priority = NULL; +} + +/** + * cal_component_set_priority: + * @comp: A calendar component object. + * @priority: Value for the priority property. + * + * Sets the priority property of a calendar component object. + **/ +void +cal_component_set_priority (CalComponent *comp, int *priority) +{ + CalComponentPrivate *priv; + + g_return_if_fail (comp != NULL); + g_return_if_fail (IS_CAL_COMPONENT (comp)); + + priv = comp->priv; + g_return_if_fail (priv->icalcomp != NULL); + + if (!priority) { + if (priv->priority) { + icalcomponent_remove_property (priv->icalcomp, priv->priority); + icalproperty_free (priv->priority); + priv->priority = NULL; + } + + return; + } + + g_return_if_fail (*priority >= 0 && *priority <= 9); + + if (priv->priority) + icalproperty_set_priority (priv->priority, *priority); + else { + priv->priority = icalproperty_new_priority (*priority); + icalcomponent_add_property (priv->icalcomp, priv->priority); + } +} + /** * cal_component_get_rdate_list: * @comp: A calendar component object. @@ -2621,6 +2763,36 @@ cal_component_free_icaltimetype (struct icaltimetype *t) g_free (t); } +/** + * cal_component_free_percent: + * @percent: Percent value. + * + * Frees a percent value as returned by the cal_component_get_percent() + * function. + **/ +void +cal_component_free_percent (int *percent) +{ + g_return_if_fail (percent != NULL); + + g_free (percent); +} + +/** + * cal_component_free_priority: + * @priority: Priority value. + * + * Frees a priority value as returned by the cal_component_get_priority() + * function. + **/ +void +cal_component_free_priority (int *priority) +{ + g_return_if_fail (priority != NULL); + + g_free (priority); +} + /** * cal_component_free_period_list: * @period_list: List of #CalComponentPeriod structures. -- cgit v1.2.3