[gnome-todo/gbsneto/planning: 4/6] Introduce GtdPlanner



commit f746d907824fc2013a45f33b3e2dead7eb89a2b7
Author: Georges Basile Stavracas Neto <georges stavracas gmail com>
Date:   Sun May 3 14:51:33 2020 -0300

    Introduce GtdPlanner

 src/gnome-todo.h             |   1 +
 src/interfaces/gtd-planner.c | 133 +++++++++++++++++++++++++++++++++++++++++++
 src/interfaces/gtd-planner.h |  59 +++++++++++++++++++
 src/meson.build              |   4 ++
 4 files changed, 197 insertions(+)
---
diff --git a/src/gnome-todo.h b/src/gnome-todo.h
index e8203df..c086360 100644
--- a/src/gnome-todo.h
+++ b/src/gnome-todo.h
@@ -33,6 +33,7 @@
 #include "gtd-omni-area.h"
 #include "gtd-omni-area-addin.h"
 #include "gtd-panel.h"
+#include "gtd-planner.h"
 #include "gtd-provider.h"
 #include "gtd-provider-popover.h"
 #include "gtd-star-widget.h"
diff --git a/src/interfaces/gtd-planner.c b/src/interfaces/gtd-planner.c
new file mode 100644
index 0000000..96c0558
--- /dev/null
+++ b/src/interfaces/gtd-planner.c
@@ -0,0 +1,133 @@
+/* gtd-planner.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 "gtd-planner.h"
+
+G_DEFINE_INTERFACE (GtdPlanner, gtd_planner, GTK_TYPE_WIDGET)
+
+static void
+gtd_planner_default_init (GtdPlannerInterface *iface)
+{
+}
+
+/**
+ * gtd_planner_get_id:
+ * @self: a #GtdPlanner
+ *
+ * Retrieves the id of @self. It is mandatory to implement
+ * this.
+ *
+ * Returns: (transfer none): the id of @self
+ */
+const gchar*
+gtd_planner_get_id (GtdPlanner *self)
+{
+  g_return_val_if_fail (GTD_IS_PLANNER (self), NULL);
+  g_return_val_if_fail (GTD_PLANNER_GET_IFACE (self)->get_id, NULL);
+
+  return GTD_PLANNER_GET_IFACE (self)->get_id (self);
+}
+
+/**
+ * gtd_planner_get_title:
+ * @self: a #GtdPlanner
+ *
+ * Retrieves the title of @self. It is mandatory to implement
+ * this.
+ *
+ * Returns: the title of @self
+ */
+const gchar*
+gtd_planner_get_title (GtdPlanner *self)
+{
+  g_return_val_if_fail (GTD_IS_PLANNER (self), NULL);
+  g_return_val_if_fail (GTD_PLANNER_GET_IFACE (self)->get_title, NULL);
+
+  return GTD_PLANNER_GET_IFACE (self)->get_title (self);
+}
+
+/**
+ * gtd_planner_get_priority:
+ * @self: a #GtdPlanner
+ *
+ * Retrieves the priority of @self. It is mandatory to implement
+ * this.
+ *
+ * Returns: the priority of @self
+ */
+gint
+gtd_planner_get_priority (GtdPlanner *self)
+{
+  g_return_val_if_fail (GTD_IS_PLANNER (self), 0);
+  g_return_val_if_fail (GTD_PLANNER_GET_IFACE (self)->get_priority, 0);
+
+  return GTD_PLANNER_GET_IFACE (self)->get_priority (self);
+}
+
+/**
+ * gtd_planner_get_priority:
+ * @self: a #GtdPlanner
+ *
+ * Retrieves the icon of @self. It is mandatory to implement
+ * this.
+ *
+ * Returns: (transfer full): a #GIcon
+ */
+GIcon*
+gtd_planner_get_icon (GtdPlanner *self)
+{
+  g_return_val_if_fail (GTD_IS_PLANNER (self), NULL);
+  g_return_val_if_fail (GTD_PLANNER_GET_IFACE (self)->get_icon, NULL);
+
+  return GTD_PLANNER_GET_IFACE (self)->get_icon (self);
+}
+
+/**
+ * gtd_planner_activate:
+ * @self: a #GtdPlanner
+ *
+ * Activates @self. This happens when the planner
+ * becomes active in the main planner.
+ */
+void
+gtd_planner_activate (GtdPlanner *self)
+{
+  g_return_if_fail (GTD_IS_PLANNER (self));
+
+  if (GTD_PLANNER_GET_IFACE (self)->activate)
+    GTD_PLANNER_GET_IFACE (self)->activate (self);
+}
+
+/**
+ * gtd_planner_deactivate:
+ * @self: a #GtdPlanner
+ *
+ * Deactivates @self. This happens when the planner
+ * is switched away in the planner.
+ */
+void
+gtd_planner_deactivate (GtdPlanner *self)
+{
+  g_return_if_fail (GTD_IS_PLANNER (self));
+
+  if (GTD_PLANNER_GET_IFACE (self)->deactivate)
+    GTD_PLANNER_GET_IFACE (self)->deactivate (self);
+}
+
diff --git a/src/interfaces/gtd-planner.h b/src/interfaces/gtd-planner.h
new file mode 100644
index 0000000..126f046
--- /dev/null
+++ b/src/interfaces/gtd-planner.h
@@ -0,0 +1,59 @@
+/* gtd-planner.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 <gtk/gtk.h>
+
+G_BEGIN_DECLS
+
+#define GTD_TYPE_PLANNER (gtd_planner_get_type ())
+G_DECLARE_INTERFACE (GtdPlanner, gtd_planner, GTD, PLANNER, GtkWidget)
+
+struct _GtdPlannerInterface
+{
+  GTypeInterface      parent;
+
+  const gchar*       (*get_id)                                   (GtdPlanner         *self);
+
+  const gchar*       (*get_title)                                (GtdPlanner         *self);
+
+  gint               (*get_priority)                             (GtdPlanner         *self);
+
+  GIcon*             (*get_icon)                                 (GtdPlanner         *self);
+
+  void               (*activate)                                 (GtdPlanner         *self);
+
+  void               (*deactivate)                               (GtdPlanner         *self);
+};
+
+const gchar*         gtd_planner_get_id                          (GtdPlanner         *self);
+
+const gchar*         gtd_planner_get_title                       (GtdPlanner         *self);
+
+gint                 gtd_planner_get_priority                    (GtdPlanner         *self);
+
+GIcon*               gtd_planner_get_icon                        (GtdPlanner         *self);
+
+void                 gtd_planner_activate                        (GtdPlanner         *self);
+
+void                 gtd_planner_deactivate                      (GtdPlanner         *self);
+
+G_END_DECLS
diff --git a/src/meson.build b/src/meson.build
index d18aff1..424209b 100644
--- a/src/meson.build
+++ b/src/meson.build
@@ -53,6 +53,7 @@ headers = enum_headers + files(
   'engine/gtd-manager.h',
   'interfaces/gtd-activatable.h',
   'interfaces/gtd-panel.h',
+  'interfaces/gtd-planner.h',
   'interfaces/gtd-provider.h',
   'interfaces/gtd-workspace.h',
   'models/gtd-list-model-filter.h',
@@ -87,6 +88,7 @@ sources += files(
   'engine/gtd-plugin-manager.c',
   'interfaces/gtd-activatable.c',
   'interfaces/gtd-panel.c',
+  'interfaces/gtd-planner.c',
   'interfaces/gtd-provider.c',
   'interfaces/gtd-workspace.c',
   'logging/gtd-log.c',
@@ -252,6 +254,8 @@ if get_option('introspection')
     'interfaces/gtd-activatable.h',
     'interfaces/gtd-panel.c',
     'interfaces/gtd-panel.h',
+    'interfaces/gtd-planner.c',
+    'interfaces/gtd-planner.h',
     'interfaces/gtd-provider.c',
     'interfaces/gtd-provider.h',
     'interfaces/gtd-workspace.c',


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