diff options
-rw-r--r-- | calendar/ChangeLog | 17 | ||||
-rw-r--r-- | calendar/Makefile.am | 2 | ||||
-rw-r--r-- | calendar/cal-util/cal-component.c | 172 | ||||
-rw-r--r-- | calendar/cal-util/cal-component.h | 31 | ||||
-rw-r--r-- | calendar/gui/calendar-component.c | 4 | ||||
-rw-r--r-- | calendar/gui/calendar-model.c | 21 | ||||
-rw-r--r-- | calendar/gui/calendar-model.h | 2 | ||||
-rw-r--r-- | calendar/gui/component-factory.c | 4 | ||||
-rw-r--r-- | calendar/gui/control-factory.c | 4 |
9 files changed, 234 insertions, 23 deletions
diff --git a/calendar/ChangeLog b/calendar/ChangeLog index 2340a641b8..9a77279239 100644 --- a/calendar/ChangeLog +++ b/calendar/ChangeLog @@ -1,3 +1,20 @@ +2000-08-11 Federico Mena Quintero <federico@helixcode.com> + + * 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. + 2000-08-10 Dan Winship <danw@helixcode.com> * gui/component-factory.c (owner_set_cb): Update prototype. diff --git a/calendar/Makefile.am b/calendar/Makefile.am index 82accbfda5..00cd1f51b1 100644 --- a/calendar/Makefile.am +++ b/calendar/Makefile.am @@ -1,2 +1,2 @@ -SUBDIRS = idl cal-util pcs cal-client +SUBDIRS = idl cal-util pcs cal-client gui #SUBDIRS = idl cal-util pcs cal-client gui conduits 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; @@ -2143,6 +2155,136 @@ cal_component_set_last_modified (CalComponent *comp, struct icaltimetype *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. * @period_list: Return value for the list of recurrence dates, as a list of @@ -2622,6 +2764,36 @@ cal_component_free_icaltimetype (struct icaltimetype *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. * diff --git a/calendar/cal-util/cal-component.h b/calendar/cal-util/cal-component.h index 1fc1d455d4..faecd6621f 100644 --- a/calendar/cal-util/cal-component.h +++ b/calendar/cal-util/cal-component.h @@ -51,6 +51,29 @@ typedef enum { CAL_COMPONENT_TIMEZONE } CalComponentVType; +/* Field identifiers for a calendar component */ +typedef enum { + CAL_COMPONENT_FIELD_CATEGORIES, + CAL_COMPONENT_FIELD_CLASSIFICATION, + CAL_COMPONENT_FIELD_COMPLETED, + CAL_COMPONENT_FIELD_CREATED, + CAL_COMPONENT_FIELD_DTEND, + CAL_COMPONENT_FIELD_DTSTART, + CAL_COMPONENT_FIELD_DUE, + CAL_COMPONENT_FIELD_PERCENT, + CAL_COMPONENT_FIELD_PRIORITY, + CAL_COMPONENT_FIELD_SUMMARY, + CAL_COMPONENT_FIELD_TRANSPARENCY, + CAL_COMPONENT_FIELD_URL, + CAL_COMPONENT_FIELD_HAS_ALARMS, /* not a real field */ + CAL_COMPONENT_FIELD_ICON, /* not a real field */ + CAL_COMPONENT_FIELD_COMPLETE, /* not a real field */ + CAL_COMPONENT_FIELD_RECURRING, /* not a real field */ + CAL_COMPONENT_FIELD_OVERDUE, /* not a real field */ + CAL_COMPONENT_FIELD_COLOR, /* not a real field */ + CAL_COMPONETN_FIELD_NUM_FIELDS +} CalComponentField; + /* Structures to return properties and their parameters */ typedef enum { @@ -181,6 +204,12 @@ void cal_component_set_exrule_list (CalComponent *comp, GSList *recur_list); void cal_component_get_last_modified (CalComponent *comp, struct icaltimetype **t); void cal_component_set_last_modified (CalComponent *comp, struct icaltimetype *t); +void cal_component_get_percent (CalComponent *comp, int **percent); +void cal_component_set_percent (CalComponent *comp, int *percent); + +void cal_component_get_priority (CalComponent *comp, int **priority); +void cal_component_set_priority (CalComponent *comp, int *priority); + void cal_component_get_rdate_list (CalComponent *comp, GSList **period_list); void cal_component_set_rdate_list (CalComponent *comp, GSList *period_list); @@ -205,6 +234,8 @@ void cal_component_free_categories_list (GSList *categ_list); void cal_component_free_datetime (CalComponentDateTime *dt); void cal_component_free_exdate_list (GSList *exdate_list); void cal_component_free_icaltimetype (struct icaltimetype *t); +void cal_component_free_percent (int *percent); +void cal_component_free_priority (int *priority); void cal_component_free_period_list (GSList *period_list); void cal_component_free_recur_list (GSList *recur_list); void cal_component_free_sequence (int *sequence); diff --git a/calendar/gui/calendar-component.c b/calendar/gui/calendar-component.c index 4c546600a2..8644b8928c 100644 --- a/calendar/gui/calendar-component.c +++ b/calendar/gui/calendar-component.c @@ -21,16 +21,14 @@ * Author: Ettore Perazzoli */ -#ifdef HAVE_CONFIG_H #include <config.h> -#endif - #include <bonobo.h> #include "evolution-shell-component.h" #include "component-factory.h" #include "control-factory.h" + #ifdef USING_OAF #define COMPONENT_FACTORY_ID "OAFIID:evolution-shell-component-factory:evolution-calendar:cba77062-1466-4aac-8ce7-b019eaf2e921" #else diff --git a/calendar/gui/calendar-model.c b/calendar/gui/calendar-model.c index 5755e20d81..beb1c5f78e 100644 --- a/calendar/gui/calendar-model.c +++ b/calendar/gui/calendar-model.c @@ -149,7 +149,7 @@ calendar_model_init (CalendarModel *model) priv = g_new0 (CalendarModelPrivate, 1); model->priv = priv; - priv->objects = g_array_new (FALSE, TRUE, sizeof (iCalObject *)); + priv->objects = g_array_new (FALSE, TRUE, sizeof (CalComponent *)); priv->uid_index_hash = g_hash_table_new (g_str_hash, g_str_equal); } @@ -179,11 +179,11 @@ free_objects (CalendarModel *model) g_hash_table_foreach_remove (priv->uid_index_hash, free_uid_index, NULL); for (i = 0; i < priv->objects->len; i++) { - iCalObject *ico; + CalComponent *comp; - ico = g_array_index (priv->objects, iCalObject *, i); - g_assert (ico != NULL); - ical_object_unref (ico); + comp = g_array_index (priv->objects, CalComponent *, i); + g_assert (comp != NULL); + gtk_object_unref (GTK_OBJECT (comp)); } g_array_set_size (priv->objects, 0); @@ -295,7 +295,7 @@ calendar_model_value_at (ETableModel *etm, int col, int row) { CalendarModel *model; CalendarModelPrivate *priv; - iCalObject *ico; + CalComponent *comp; static char buffer[16]; model = CALENDAR_MODEL (etm); @@ -304,8 +304,8 @@ calendar_model_value_at (ETableModel *etm, int col, int row) g_return_val_if_fail (col >= 0 && col < ICAL_OBJECT_FIELD_NUM_FIELDS, NULL); g_return_val_if_fail (row >= 0 && row < priv->objects->len, NULL); - ico = g_array_index (priv->objects, iCalObject *, row); - g_assert (ico != NULL); + comp = g_array_index (priv->objects, CalComponent *, row); + g_assert (comp != NULL); switch (col) { case ICAL_OBJECT_FIELD_COMMENT: @@ -1527,7 +1527,7 @@ calendar_model_mark_task_complete (CalendarModel *model, /* Frees the objects stored in the calendar model */ -iCalObject* +CalComponent * calendar_model_get_cal_object (CalendarModel *model, gint row) { @@ -1535,6 +1535,5 @@ calendar_model_get_cal_object (CalendarModel *model, priv = model->priv; - return g_array_index (priv->objects, iCalObject *, row); + return g_array_index (priv->objects, CalComponent *, row); } - diff --git a/calendar/gui/calendar-model.h b/calendar/gui/calendar-model.h index d3317b11eb..d1481a4ece 100644 --- a/calendar/gui/calendar-model.h +++ b/calendar/gui/calendar-model.h @@ -65,7 +65,7 @@ void calendar_model_mark_task_complete (CalendarModel *model, void calendar_model_delete_task (CalendarModel *model, gint row); -iCalObject* calendar_model_get_cal_object (CalendarModel *model, +CalComponent* calendar_model_get_cal_object (CalendarModel *model, gint row); diff --git a/calendar/gui/component-factory.c b/calendar/gui/component-factory.c index 4c546600a2..8644b8928c 100644 --- a/calendar/gui/component-factory.c +++ b/calendar/gui/component-factory.c @@ -21,16 +21,14 @@ * Author: Ettore Perazzoli */ -#ifdef HAVE_CONFIG_H #include <config.h> -#endif - #include <bonobo.h> #include "evolution-shell-component.h" #include "component-factory.h" #include "control-factory.h" + #ifdef USING_OAF #define COMPONENT_FACTORY_ID "OAFIID:evolution-shell-component-factory:evolution-calendar:cba77062-1466-4aac-8ce7-b019eaf2e921" #else diff --git a/calendar/gui/control-factory.c b/calendar/gui/control-factory.c index bbfe796ce7..d7626d21f3 100644 --- a/calendar/gui/control-factory.c +++ b/calendar/gui/control-factory.c @@ -21,10 +21,6 @@ * Author: Ettore Perazzoli */ -#ifdef HAVE_CONFIG_H -#include <config.h> -#endif - #include <config.h> #include <gnome.h> #include <glade/glade.h> |