event-editor/sections: Add vfunc to check for changes

This will be useful for next commits where we will need to check
if the schedule section actually changed something.
This commit is contained in:
Georges Basile Stavracas Neto
2022-10-17 23:37:13 -03:00
parent dbd2f0df58
commit 82d8ec31ca
7 changed files with 185 additions and 0 deletions
@@ -361,11 +361,54 @@ gcal_reminders_section_apply (GcalEventEditorSection *section)
GCAL_EXIT;
}
static gboolean
gcal_reminders_section_changed (GcalEventEditorSection *section)
{
GcalRemindersSection *self;
g_autoptr (GList) alarms = NULL;
GCAL_ENTRY;
self = GCAL_REMINDERS_SECTION (section);
alarms = gcal_event_get_alarms (self->event);
if (g_list_length (alarms) != self->alarms->len)
GCAL_RETURN (FALSE);
for (GList *l = alarms; l != NULL; l = l->next)
{
ECalComponentAlarm *other_alarm;
ECalComponentAlarm *alarm;
alarm = l->data;
other_alarm = NULL;
for (guint i = 0; i < self->alarms->len; i++)
{
ECalComponentAlarm *aux = g_ptr_array_index (self->alarms, i);
if (get_alarm_trigger_minutes (self->event, alarm) == get_alarm_trigger_minutes (self->event, aux))
{
other_alarm = aux;
break;
}
}
if (!other_alarm)
GCAL_RETURN (TRUE);
/* TODO: this certainly needs deeper comparisons! */
}
GCAL_RETURN (FALSE);
}
static void
gcal_event_editor_section_iface_init (GcalEventEditorSectionInterface *iface)
{
iface->set_event = gcal_reminders_section_set_event;
iface->apply = gcal_reminders_section_apply;
iface->changed = gcal_reminders_section_changed;
}