76 lines
2.2 KiB
Diff
76 lines
2.2 KiB
Diff
diff --git a/calendar/libecal/e-cal-component.c b/calendar/libecal/e-cal-component.c
|
|
index d62760b..7d00adf 100644
|
|
--- a/calendar/libecal/e-cal-component.c
|
|
+++ b/calendar/libecal/e-cal-component.c
|
|
@@ -3485,6 +3485,56 @@ e_cal_component_get_percent (ECalComponent *comp, int **percent)
|
|
*percent = NULL;
|
|
}
|
|
|
|
+void
|
|
+e_cal_component_set_percent_as_int (ECalComponent *comp, int percent)
|
|
+{
|
|
+ ECalComponentPrivate *priv;
|
|
+
|
|
+ g_return_if_fail (comp != NULL);
|
|
+ g_return_if_fail (E_IS_CAL_COMPONENT (comp));
|
|
+
|
|
+ priv = comp->priv;
|
|
+ g_return_if_fail (priv->icalcomp != NULL);
|
|
+
|
|
+ if (percent == -1) {
|
|
+ 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);
|
|
+ }
|
|
+
|
|
+
|
|
+}
|
|
+
|
|
+int
|
|
+e_cal_component_get_percent_as_int (ECalComponent *comp)
|
|
+{
|
|
+ ECalComponentPrivate *priv;
|
|
+ int percent;
|
|
+
|
|
+ priv = comp->priv;
|
|
+ g_return_val_if_fail (priv->icalcomp != NULL, -1);
|
|
+
|
|
+ if (priv->percent) {
|
|
+ percent = icalproperty_get_percentcomplete (priv->percent);
|
|
+ } else
|
|
+ percent = -1;
|
|
+
|
|
+ return percent;
|
|
+}
|
|
+
|
|
/**
|
|
* e_cal_component_set_percent:
|
|
* @comp: A calendar component object.
|
|
diff --git a/calendar/libecal/e-cal-component.h b/calendar/libecal/e-cal-component.h
|
|
index b8dc492..94c6f3a 100644
|
|
--- a/calendar/libecal/e-cal-component.h
|
|
+++ b/calendar/libecal/e-cal-component.h
|
|
@@ -285,6 +285,9 @@ void e_cal_component_get_organizer (ECalComponent *comp, ECalComponentOrganizer
|
|
void e_cal_component_set_organizer (ECalComponent *comp, ECalComponentOrganizer *organizer);
|
|
gboolean e_cal_component_has_organizer (ECalComponent *comp);
|
|
|
|
+int e_cal_component_get_percent_as_int (ECalComponent *comp);
|
|
+void e_cal_component_set_percent_as_int (ECalComponent *comp, int percent);
|
|
+
|
|
void e_cal_component_get_percent (ECalComponent *comp, int **percent);
|
|
void e_cal_component_set_percent (ECalComponent *comp, int *percent);
|
|
|