[gnome-todo/wip/gbsneto/plugins] provider: stub out GtdProvider interface
- From: Georges Basile Stavracas Neto <gbsneto src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-todo/wip/gbsneto/plugins] provider: stub out GtdProvider interface
- Date: Sun, 13 Dec 2015 17:50:31 +0000 (UTC)
commit af7cbbb50a716d817fd25c7edefe0e6595ed3026
Author: Georges Basile Stavracas Neto <georges stavracas gmail com>
Date: Sun Dec 13 15:49:00 2015 -0200
provider: stub out GtdProvider interface
A GtdProvider is the handler of every interaction
of the data source (a file, a server, etc) and To
Do.
src/Makefile.am | 2 +
src/interfaces/gtd-provider.c | 198 +++++++++++++++++++++++++++++++++++++++++
src/interfaces/gtd-provider.h | 111 +++++++++++++++++++++++
3 files changed, 311 insertions(+), 0 deletions(-)
---
diff --git a/src/Makefile.am b/src/Makefile.am
index 0454d65..82bb23b 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -24,6 +24,8 @@ gnome_todo_SOURCES = \
interfaces/gtd-activatable.h \
interfaces/gtd-panel.c \
interfaces/gtd-panel.h \
+ interfaces/gtd-provider.c \
+ interfaces/gtd-provider.h \
notification/gtd-notification.c \
notification/gtd-notification.h \
notification/gtd-notification-widget.c \
diff --git a/src/interfaces/gtd-provider.c b/src/interfaces/gtd-provider.c
new file mode 100644
index 0000000..8d13be2
--- /dev/null
+++ b/src/interfaces/gtd-provider.c
@@ -0,0 +1,198 @@
+/* gtd-provider.c
+ *
+ * Copyright (C) 2015 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/>.
+ */
+
+#include "gtd-provider.h"
+
+G_DEFINE_INTERFACE (GtdProvider, gtd_provider, GTD_TYPE_OBJECT)
+
+static void
+gtd_provider_default_init (GtdProviderInterface *iface)
+{
+ /**
+ * GtdProvider::enabled:
+ *
+ * Whether the #GtdProvider is enabled.
+ */
+ g_object_interface_install_property (iface,
+ g_param_spec_boolean ("enabled",
+ "Identifier of the provider",
+ "The identifier of the provider",
+ FALSE,
+ G_PARAM_READABLE));
+
+ /**
+ * GtdProvider::id:
+ *
+ * The unique identifier of the #GtdProvider.
+ */
+ g_object_interface_install_property (iface,
+ g_param_spec_string ("id",
+ "Identifier of the provider",
+ "The identifier of the provider",
+ NULL,
+ G_PARAM_READABLE));
+
+ /**
+ * GtdProvider::name:
+ *
+ * The user-visible name of the #GtdProvider.
+ */
+ g_object_interface_install_property (iface,
+ g_param_spec_string ("name",
+ "Name of the provider",
+ "The user-visible name of the provider",
+ NULL,
+ G_PARAM_READABLE));
+
+ /**
+ * GtdProvider::description:
+ *
+ * The description of the #GtdProvider, e.g. the account user
+ * of a GNOME Online Accounts' account.
+ */
+ g_object_interface_install_property (iface,
+ g_param_spec_string ("description",
+ "Description of the provider",
+ "The description of the provider",
+ NULL,
+ G_PARAM_READABLE));
+}
+
+const gchar*
+gtd_provider_get_id (GtdProvider *provider)
+{
+ g_return_val_if_fail (GTD_IS_PROVIDER (provider), NULL);
+ g_return_val_if_fail (GTD_PROVIDER_GET_IFACE (provider)->get_id, NULL);
+
+ return GTD_PROVIDER_GET_IFACE (provider)->get_id (provider);
+}
+
+const gchar*
+gtd_provider_get_name (GtdProvider *provider)
+{
+ g_return_val_if_fail (GTD_IS_PROVIDER (provider), NULL);
+ g_return_val_if_fail (GTD_PROVIDER_GET_IFACE (provider)->get_name, NULL);
+
+ return GTD_PROVIDER_GET_IFACE (provider)->get_name (provider);
+}
+
+const gchar*
+gtd_provider_get_description (GtdProvider *provider)
+{
+ g_return_val_if_fail (GTD_IS_PROVIDER (provider), NULL);
+ g_return_val_if_fail (GTD_PROVIDER_GET_IFACE (provider)->get_description, NULL);
+
+ return GTD_PROVIDER_GET_IFACE (provider)->get_description (provider);
+}
+
+gboolean
+gtd_provider_get_enabled (GtdProvider *provider)
+{
+ g_return_val_if_fail (GTD_IS_PROVIDER (provider), FALSE);
+ g_return_val_if_fail (GTD_PROVIDER_GET_IFACE (provider)->get_enabled, FALSE);
+
+ return GTD_PROVIDER_GET_IFACE (provider)->get_enabled (provider);
+}
+
+const GIcon*
+gtd_provider_get_icon_for_list (GtdProvider *provider,
+ GtdTaskList *list)
+{
+ g_return_val_if_fail (GTD_IS_PROVIDER (provider), NULL);
+ g_return_val_if_fail (GTD_PROVIDER_GET_IFACE (provider)->get_icon_for_list, NULL);
+
+ return GTD_PROVIDER_GET_IFACE (provider)->get_icon_for_list (provider, list);
+}
+
+const GtkWidget*
+gtd_provider_get_edit_panel (GtdProvider *provider)
+{
+ g_return_val_if_fail (GTD_IS_PROVIDER (provider), NULL);
+ g_return_val_if_fail (GTD_PROVIDER_GET_IFACE (provider)->get_edit_panel, NULL);
+
+ return GTD_PROVIDER_GET_IFACE (provider)->get_edit_panel (provider);
+}
+
+void
+gtd_provider_create_task (GtdProvider *provider,
+ GtdTask *task)
+{
+ g_return_if_fail (GTD_IS_PROVIDER (provider));
+ g_return_if_fail (GTD_PROVIDER_GET_IFACE (provider)->create_task);
+
+ GTD_PROVIDER_GET_IFACE (provider)->create_task (provider, task);
+}
+
+void
+gtd_provider_update_task (GtdProvider *provider,
+ GtdTask *task)
+{
+ g_return_if_fail (GTD_IS_PROVIDER (provider));
+ g_return_if_fail (GTD_PROVIDER_GET_IFACE (provider)->update_task);
+
+ GTD_PROVIDER_GET_IFACE (provider)->update_task (provider, task);
+}
+
+void
+gtd_provider_remove_task (GtdProvider *provider,
+ GtdTask *task)
+{
+ g_return_if_fail (GTD_IS_PROVIDER (provider));
+ g_return_if_fail (GTD_PROVIDER_GET_IFACE (provider)->remove_task);
+
+ GTD_PROVIDER_GET_IFACE (provider)->remove_task (provider, task);
+}
+
+void
+gtd_provider_create_task_list (GtdProvider *provider,
+ GtdTaskList *list)
+{
+ g_return_if_fail (GTD_IS_PROVIDER (provider));
+ g_return_if_fail (GTD_PROVIDER_GET_IFACE (provider)->create_task_list);
+
+ GTD_PROVIDER_GET_IFACE (provider)->create_task_list (provider, list);
+}
+
+void
+gtd_provider_update_task_list (GtdProvider *provider,
+ GtdTaskList *list)
+{
+ g_return_if_fail (GTD_IS_PROVIDER (provider));
+ g_return_if_fail (GTD_PROVIDER_GET_IFACE (provider)->update_task_list);
+
+ GTD_PROVIDER_GET_IFACE (provider)->update_task_list (provider, list);
+}
+
+void
+gtd_provider_remove_task_list (GtdProvider *provider,
+ GtdTaskList *list)
+{
+ g_return_if_fail (GTD_IS_PROVIDER (provider));
+ g_return_if_fail (GTD_PROVIDER_GET_IFACE (provider)->remove_task_list);
+
+ GTD_PROVIDER_GET_IFACE (provider)->remove_task_list (provider, list);
+}
+
+GList*
+gtd_provider_get_task_lists (GtdProvider *provider)
+{
+ g_return_val_if_fail (GTD_IS_PROVIDER (provider), NULL);
+ g_return_val_if_fail (GTD_PROVIDER_GET_IFACE (provider)->get_task_lists, NULL);
+
+ return GTD_PROVIDER_GET_IFACE (provider)->get_task_lists (provider);
+}
diff --git a/src/interfaces/gtd-provider.h b/src/interfaces/gtd-provider.h
new file mode 100644
index 0000000..d93df75
--- /dev/null
+++ b/src/interfaces/gtd-provider.h
@@ -0,0 +1,111 @@
+/* gtd-storage.h
+ *
+ * Copyright (C) 2015 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/>.
+ */
+
+#ifndef GTD_PROVIDER_H
+#define GTD_PROVIDER_H
+
+#include "gtd-object.h"
+#include "gtd-types.h"
+
+#include <glib.h>
+#include <gtk/gtk.h>
+
+G_BEGIN_DECLS
+
+#define GTD_TYPE_PROVIDER (gtd_provider_get_type ())
+
+G_DECLARE_INTERFACE (GtdProvider, gtd_provider, GTD, PROVIDER, GtdObject)
+
+struct _GtdProviderInterface
+{
+ GTypeInterface parent;
+
+ /* Information */
+ const gchar* (*get_id) (GtdProvider *provider);
+
+ const gchar* (*get_name) (GtdProvider *provider);
+
+ const gchar* (*get_description) (GtdProvider *provider);
+
+ gboolean (*get_enabled) (GtdProvider *provider);
+
+ /* Customs */
+ const GIcon* (*get_icon_for_list) (GtdProvider *provider,
+ GtdTaskList *list);
+
+ const GtkWidget* (*get_edit_panel) (GtdProvider *provider);
+
+ /* Tasks */
+ void (*create_task) (GtdProvider *provider,
+ GtdTask *task);
+
+ void (*update_task) (GtdProvider *provider,
+ GtdTask *task);
+
+ void (*remove_task) (GtdProvider *provider,
+ GtdTask *task);
+
+ /* Task lists */
+ void (*create_task_list) (GtdProvider *provider,
+ GtdTaskList *list);
+
+ void (*update_task_list) (GtdProvider *provider,
+ GtdTaskList *list);
+
+ void (*remove_task_list) (GtdProvider *provider,
+ GtdTaskList *list);
+
+ GList* (*get_task_lists) (GtdProvider *provider);
+};
+
+const gchar* gtd_provider_get_id (GtdProvider *provider);
+
+const gchar* gtd_provider_get_name (GtdProvider *provider);
+
+const gchar* gtd_provider_get_description (GtdProvider *provider);
+
+gboolean gtd_provider_get_enabled (GtdProvider *provider);
+
+const GIcon* gtd_provider_get_icon_for_list (GtdProvider *provider,
+ GtdTaskList *list);
+
+const GtkWidget* gtd_provider_get_edit_panel (GtdProvider *provider);
+
+void gtd_provider_create_task (GtdProvider *provider,
+ GtdTask *task);
+
+void gtd_provider_update_task (GtdProvider *provider,
+ GtdTask *task);
+
+void gtd_provider_remove_task (GtdProvider *provider,
+ GtdTask *task);
+
+void gtd_provider_create_task_list (GtdProvider *provider,
+ GtdTaskList *list);
+
+void gtd_provider_update_task_list (GtdProvider *provider,
+ GtdTaskList *list);
+
+void gtd_provider_remove_task_list (GtdProvider *provider,
+ GtdTaskList *list);
+
+GList* gtd_provider_get_task_lists (GtdProvider *provider);
+
+G_END_DECLS
+
+#endif /* GTD_PROVIDER_H */
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]