event: Add API to clone events
This will be useful for updating events without having to keep track of the event states. Add the new API, and also a unit test.
This commit is contained in:
@@ -799,6 +799,27 @@ gcal_event_new (GcalCalendar *calendar,
|
||||
NULL);
|
||||
}
|
||||
|
||||
/**
|
||||
* gcal_event_new:
|
||||
* @self: a #GcalEvent
|
||||
*
|
||||
* Clones @event into a new #GcalEvent instance. This is useful
|
||||
* for updating events.
|
||||
*
|
||||
* Returns: (transfer full)(nullable): a #GcalEvent
|
||||
*/
|
||||
GcalEvent*
|
||||
gcal_event_new_from_event (GcalEvent *self)
|
||||
{
|
||||
g_autoptr (ECalComponent) component = NULL;
|
||||
|
||||
g_return_val_if_fail (GCAL_IS_EVENT (self), NULL);
|
||||
|
||||
component = e_cal_component_clone (self->component);
|
||||
|
||||
return gcal_event_new (self->calendar, component, NULL);
|
||||
}
|
||||
|
||||
/**
|
||||
* gcal_event_get_all_day:
|
||||
* @self: a #GcalEvent
|
||||
|
||||
@@ -53,6 +53,8 @@ GcalEvent* gcal_event_new (GcalCalendar
|
||||
ECalComponent *component,
|
||||
GError **error);
|
||||
|
||||
GcalEvent* gcal_event_new_from_event (GcalEvent *self);
|
||||
|
||||
gboolean gcal_event_get_all_day (GcalEvent *self);
|
||||
|
||||
void gcal_event_set_all_day (GcalEvent *self,
|
||||
|
||||
Reference in New Issue
Block a user