diff --git a/src/gui/event-editor/gcal-event-editor-section.c b/src/gui/event-editor/gcal-event-editor-section.c new file mode 100644 index 00000000..1ac13125 --- /dev/null +++ b/src/gui/event-editor/gcal-event-editor-section.c @@ -0,0 +1,68 @@ +/* gcal-event-editor-section.c + * + * Copyright 2020 Georges Basile Stavracas Neto + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + * + * SPDX-License-Identifier: GPL-3.0-or-later + */ + +#include "gcal-context.h" +#include "gcal-event-editor-section.h" + +G_DEFINE_INTERFACE (GcalEventEditorSection, gcal_event_editor_section, GTK_TYPE_WIDGET) + +static void +gcal_event_editor_section_default_init (GcalEventEditorSectionInterface *iface) +{ + g_object_interface_install_property (iface, + g_param_spec_object ("context", + "Context", + "Context", + GCAL_TYPE_CONTEXT, + G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS)); +} + +/** + * gcal_event_editor_section_set_event: + * @self: a #GcalEventEditorSection + * @event: (nullable): a #GcalEvent + * + * Sets the current event to be displayed / edited. + */ +void +gcal_event_editor_section_set_event (GcalEventEditorSection *self, + GcalEvent *event, + GcalEventEditorFlags flags) +{ + g_return_if_fail (GCAL_IS_EVENT_EDITOR_SECTION (self)); + g_return_if_fail (GCAL_EVENT_EDITOR_SECTION_GET_IFACE (self)->set_event); + + GCAL_EVENT_EDITOR_SECTION_GET_IFACE (self)->set_event (self, event, flags); +} + +/** + * gcal_event_editor_section_apply: + * @self: a #GcalEventEditorSection + * + * Applies the changes to the event. + */ +void +gcal_event_editor_section_apply (GcalEventEditorSection *self) +{ + g_return_if_fail (GCAL_IS_EVENT_EDITOR_SECTION (self)); + + if (GCAL_EVENT_EDITOR_SECTION_GET_IFACE (self)->apply) + GCAL_EVENT_EDITOR_SECTION_GET_IFACE (self)->apply (self); +} diff --git a/src/gui/event-editor/gcal-event-editor-section.h b/src/gui/event-editor/gcal-event-editor-section.h new file mode 100644 index 00000000..fc2b5ed3 --- /dev/null +++ b/src/gui/event-editor/gcal-event-editor-section.h @@ -0,0 +1,56 @@ +/* gcal-event-editor-section.h + * + * Copyright 2020 Georges Basile Stavracas Neto + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + * + * SPDX-License-Identifier: GPL-3.0-or-later + */ + +#pragma once + +#include "gcal-event.h" + +#include + +G_BEGIN_DECLS + +#define GCAL_TYPE_EVENT_EDITOR_SECTION (gcal_event_editor_section_get_type ()) + +G_DECLARE_INTERFACE (GcalEventEditorSection, gcal_event_editor_section, GCAL, EVENT_EDITOR_SECTION, GtkWidget) + +typedef enum +{ + GCAL_EVENT_EDITOR_FLAG_NONE = 0, + GCAL_EVENT_EDITOR_FLAG_NEW_EVENT = 1 << 0, +} GcalEventEditorFlags; + +struct _GcalEventEditorSectionInterface +{ + GTypeInterface parent; + + void (*set_event) (GcalEventEditorSection *self, + GcalEvent *event, + GcalEventEditorFlags flags); + + void (*apply) (GcalEventEditorSection *self); +}; + +void gcal_event_editor_section_set_event (GcalEventEditorSection *self, + GcalEvent *event, + GcalEventEditorFlags flags); + +void gcal_event_editor_section_apply (GcalEventEditorSection *self); + +G_END_DECLS diff --git a/src/gui/event-editor/meson.build b/src/gui/event-editor/meson.build index 8667b2e9..2c9f717e 100644 --- a/src/gui/event-editor/meson.build +++ b/src/gui/event-editor/meson.build @@ -12,6 +12,7 @@ sources += files( 'gcal-date-chooser-day.c', 'gcal-date-selector.c', 'gcal-event-editor-dialog.c', + 'gcal-event-editor-section.c', 'gcal-multi-choice.c', 'gcal-time-selector.c', )