[gnome-calendar/gbsneto/edit-dialog-cleanup: 8/23] Introduce GcalEventEditorSection




commit a839a0d8606851e5244894c77fd5d005312c4824
Author: Georges Basile Stavracas Neto <georges stavracas gmail com>
Date:   Fri Oct 30 18:07:58 2020 -0300

    Introduce GcalEventEditorSection
    
    This is the interface to represent sections of the event editor
    dialog.

 src/gui/event-editor/gcal-event-editor-section.c | 68 ++++++++++++++++++++++++
 src/gui/event-editor/gcal-event-editor-section.h | 56 +++++++++++++++++++
 src/gui/event-editor/meson.build                 |  1 +
 3 files changed, 125 insertions(+)
---
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 <georges stavracas gmail com>
+ *
+ * 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 <http://www.gnu.org/licenses/>.
+ *
+ * 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 <georges stavracas gmail com>
+ *
+ * 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 <http://www.gnu.org/licenses/>.
+ *
+ * SPDX-License-Identifier: GPL-3.0-or-later
+ */
+
+#pragma once
+
+#include "gcal-event.h"
+
+#include <gtk/gtk.h>
+
+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',
 )


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]