[gnome-todo/wip/gbsneto/plugins] eds plugin: export Today & Scheduled panels



commit 964f12423f762475418cc7d2aacb5b6b0025ca5c
Author: Georges Basile Stavracas Neto <georges stavracas gmail com>
Date:   Mon Dec 28 12:49:15 2015 -0200

    eds plugin: export Today & Scheduled panels
    
    These are the default panels for GNOME To Do,
    and they are provided by the default plugin.

 plugins/eds/Makefile.am           |    4 +
 plugins/eds/gtd-panel-scheduled.c |  280 ++++++++++++++++++++++++++++++
 plugins/eds/gtd-panel-scheduled.h |   35 ++++
 plugins/eds/gtd-panel-today.c     |  347 +++++++++++++++++++++++++++++++++++++
 plugins/eds/gtd-panel-today.h     |   35 ++++
 plugins/eds/gtd-plugin-eds.c      |   26 +++
 6 files changed, 727 insertions(+), 0 deletions(-)
---
diff --git a/plugins/eds/Makefile.am b/plugins/eds/Makefile.am
index 5310323..aeb4bdf 100644
--- a/plugins/eds/Makefile.am
+++ b/plugins/eds/Makefile.am
@@ -9,6 +9,10 @@ BUILT_SOURCES = \
        gtd-plugin-eds-resources.c
 
 libeds_la_SOURCES = \
+       gtd-panel-today.c \
+       gtd-panel-today.h \
+       gtd-panel-scheduled.c \
+       gtd-panel-scheduled.h \
        gtd-plugin-eds.c \
        gtd-plugin-eds.h \
        gtd-provider-eds.c \
diff --git a/plugins/eds/gtd-panel-scheduled.c b/plugins/eds/gtd-panel-scheduled.c
new file mode 100644
index 0000000..f831715
--- /dev/null
+++ b/plugins/eds/gtd-panel-scheduled.c
@@ -0,0 +1,280 @@
+/* gtd-panel-scheduled.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-panel-scheduled.h"
+
+#include <glib/gi18n.h>
+#include <gnome-todo/gnome-todo.h>
+
+struct _GtdPanelScheduled
+{
+  GtkBox              parent;
+
+  gchar              *title;
+  guint               number_of_tasks;
+  GtdTaskList        *task_list;
+  GtkWidget          *view;
+};
+
+static void          gtd_panel_iface_init                        (GtdPanelInterface  *iface);
+
+G_DEFINE_TYPE_EXTENDED (GtdPanelScheduled, gtd_panel_scheduled, GTK_TYPE_BOX,
+                        0,
+                        G_IMPLEMENT_INTERFACE (GTD_TYPE_PANEL,
+                                               gtd_panel_iface_init))
+
+#define GTD_PANEL_SCHEDULED_NAME "panel-scheduled"
+
+enum {
+  PROP_0,
+  PROP_HEADER_WIDGETS,
+  PROP_MENU,
+  PROP_NAME,
+  PROP_TITLE,
+  N_PROPS
+};
+
+static void
+gtd_panel_scheduled_clear (GtdPanelScheduled *panel)
+{
+  GList *tasks;
+  GList *t;
+
+  tasks = gtd_task_list_get_tasks (panel->task_list);
+
+  for (t = tasks; t != NULL; t = t->next)
+    gtd_task_list_remove_task (panel->task_list, t->data);
+
+  g_list_free (tasks);
+}
+
+static void
+gtd_panel_scheduled_count_tasks (GtdPanelScheduled *panel)
+{
+  GtdManager *manager;
+  GList *tasklists;
+  GList *l;
+  guint number_of_tasks;
+
+  manager = gtd_manager_get_default ();
+  tasklists = gtd_manager_get_task_lists (manager);
+  number_of_tasks = 0;
+
+  /* Reset list */
+  gtd_panel_scheduled_clear (panel);
+
+  /* Recount tasks */
+  for (l = tasklists; l != NULL; l = l->next)
+    {
+      GList *tasks;
+      GList *t;
+
+      tasks = gtd_task_list_get_tasks (l->data);
+
+      for (t = tasks; t != NULL; t = t->next)
+        {
+          GDateTime *task_dt;
+
+          task_dt = gtd_task_get_due_date (t->data);
+
+          /*
+           * GtdTaskListView automagically updates the list
+           * whever a task is added/removed/changed.
+           */
+          if (task_dt)
+            {
+              gtd_task_list_save_task (panel->task_list, t->data);
+              number_of_tasks++;
+            }
+
+          g_clear_pointer (&task_dt, g_date_time_unref);
+        }
+
+      g_list_free (tasks);
+    }
+
+  if (number_of_tasks != panel->number_of_tasks)
+    {
+      panel->number_of_tasks = number_of_tasks;
+
+      /* Update title */
+      g_clear_pointer (&panel->title, g_free);
+      if (number_of_tasks == 0)
+        {
+          panel->title = g_strdup (_("Scheduled"));
+        }
+      else
+        {
+          panel->title = g_strdup_printf ("%s (%d)",
+                                          _("Scheduled"),
+                                          panel->number_of_tasks);
+        }
+
+      g_object_notify (G_OBJECT (panel), "title");
+    }
+
+  g_list_free (tasklists);
+}
+
+/**********************
+ * GtdPanel iface init
+ **********************/
+static const gchar*
+gtd_panel_scheduled_get_name (GtdPanel *panel)
+{
+  return GTD_PANEL_SCHEDULED_NAME;
+}
+
+static const gchar*
+gtd_panel_scheduled_get_title (GtdPanel *panel)
+{
+  return GTD_PANEL_SCHEDULED (panel)->title;
+}
+
+static GList*
+gtd_panel_scheduled_get_header_widgets (GtdPanel *panel)
+{
+  return NULL;
+}
+
+static const GMenu*
+gtd_panel_scheduled_get_menu (GtdPanel *panel)
+{
+  return NULL;
+}
+
+static void
+gtd_panel_iface_init (GtdPanelInterface *iface)
+{
+  iface->get_name = gtd_panel_scheduled_get_name;
+  iface->get_title = gtd_panel_scheduled_get_title;
+  iface->get_header_widgets = gtd_panel_scheduled_get_header_widgets;
+  iface->get_menu = gtd_panel_scheduled_get_menu;
+}
+
+static void
+gtd_panel_scheduled_finalize (GObject *object)
+{
+  GtdPanelScheduled *self = (GtdPanelScheduled *)object;
+
+  g_clear_pointer (&self->title, g_free);
+
+  G_OBJECT_CLASS (gtd_panel_scheduled_parent_class)->finalize (object);
+}
+
+static void
+gtd_panel_scheduled_get_property (GObject    *object,
+                                  guint       prop_id,
+                                  GValue     *value,
+                                  GParamSpec *pspec)
+{
+  GtdPanelScheduled *self = GTD_PANEL_SCHEDULED (object);
+
+  switch (prop_id)
+    {
+    case PROP_HEADER_WIDGETS:
+      g_value_set_pointer (value, NULL);
+      break;
+
+    case PROP_MENU:
+      g_value_set_object (value, NULL);
+      break;
+
+    case PROP_NAME:
+      g_value_set_string (value, GTD_PANEL_SCHEDULED_NAME);
+      break;
+
+    case PROP_TITLE:
+      g_value_set_string (value, self->title);
+      break;
+
+    default:
+      G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+    }
+}
+
+static void
+gtd_panel_scheduled_set_property (GObject      *object,
+                                  guint         prop_id,
+                                  const GValue *value,
+                                  GParamSpec   *pspec)
+{
+  G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+}
+
+static void
+gtd_panel_scheduled_class_init (GtdPanelScheduledClass *klass)
+{
+  GObjectClass *object_class = G_OBJECT_CLASS (klass);
+
+  object_class->finalize = gtd_panel_scheduled_finalize;
+  object_class->get_property = gtd_panel_scheduled_get_property;
+  object_class->set_property = gtd_panel_scheduled_set_property;
+
+  g_object_class_override_property (object_class, PROP_HEADER_WIDGETS, "header-widgets");
+  g_object_class_override_property (object_class, PROP_MENU, "menu");
+  g_object_class_override_property (object_class, PROP_NAME, "name");
+  g_object_class_override_property (object_class, PROP_TITLE, "title");
+}
+
+static void
+gtd_panel_scheduled_init (GtdPanelScheduled *self)
+{
+  GtdManager *manager;
+
+  /* Connect to GtdManager::list-* signals to update the title */
+  manager = gtd_manager_get_default ();
+
+  g_signal_connect_swapped (manager,
+                            "list-added",
+                            G_CALLBACK (gtd_panel_scheduled_count_tasks),
+                            self);
+
+  g_signal_connect_swapped (manager,
+                            "list-removed",
+                            G_CALLBACK (gtd_panel_scheduled_count_tasks),
+                            self);
+
+  g_signal_connect_swapped (manager,
+                            "list-changed",
+                            G_CALLBACK (gtd_panel_scheduled_count_tasks),
+                            self);
+
+  /* Setup a title */
+  self->title = g_strdup (_("Scheduled"));
+
+  /* Task list */
+  self->task_list = gtd_task_list_new (NULL);
+
+  /* The main view */
+  self->view = gtd_task_list_view_new ();
+  gtd_task_list_view_set_task_list (GTD_TASK_LIST_VIEW (self->view), self->task_list);
+
+  gtk_widget_set_hexpand (self->view, TRUE);
+  gtk_widget_set_vexpand (self->view, TRUE);
+  gtk_container_add (GTK_CONTAINER (self), self->view);
+
+  gtk_widget_show_all (GTK_WIDGET (self));
+}
+
+GtkWidget*
+gtd_panel_scheduled_new (void)
+{
+  return g_object_new (GTD_TYPE_PANEL_SCHEDULED, NULL);
+}
+
diff --git a/plugins/eds/gtd-panel-scheduled.h b/plugins/eds/gtd-panel-scheduled.h
new file mode 100644
index 0000000..59af3b5
--- /dev/null
+++ b/plugins/eds/gtd-panel-scheduled.h
@@ -0,0 +1,35 @@
+/* gtd-panel-scheduled.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_PANEL_SCHEDULED_H
+#define GTD_PANEL_SCHEDULED_H
+
+#include <glib.h>
+#include <gtk/gtk.h>
+
+G_BEGIN_DECLS
+
+#define GTD_TYPE_PANEL_SCHEDULED (gtd_panel_scheduled_get_type())
+
+G_DECLARE_FINAL_TYPE (GtdPanelScheduled, gtd_panel_scheduled, GTD, PANEL_SCHEDULED, GtkBox)
+
+GtkWidget*           gtd_panel_scheduled_new                     (void);
+
+G_END_DECLS
+
+#endif /* GTD_PANEL_SCHEDULED_H */
diff --git a/plugins/eds/gtd-panel-today.c b/plugins/eds/gtd-panel-today.c
new file mode 100644
index 0000000..e8e77c3
--- /dev/null
+++ b/plugins/eds/gtd-panel-today.c
@@ -0,0 +1,347 @@
+/* gtd-panel-today.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-panel-today.h"
+
+#include <glib/gi18n.h>
+#include <gnome-todo/gnome-todo.h>
+
+struct _GtdPanelToday
+{
+  GtkBox              parent;
+
+  GtkWidget          *view;
+
+  gint                day_change_callback_id;
+
+  gchar              *title;
+  guint               number_of_tasks;
+  GtdTaskList        *task_list;
+  GDateTime          *today;
+};
+
+static void          gtd_panel_iface_init                        (GtdPanelInterface  *iface);
+
+G_DEFINE_TYPE_EXTENDED (GtdPanelToday, gtd_panel_today, GTK_TYPE_BOX,
+                        0,
+                        G_IMPLEMENT_INTERFACE (GTD_TYPE_PANEL,
+                                               gtd_panel_iface_init))
+
+
+#define GTD_PANEL_TODAY_NAME "panel-today"
+
+enum {
+  PROP_0,
+  PROP_HEADER_WIDGETS,
+  PROP_MENU,
+  PROP_NAME,
+  PROP_TITLE,
+  N_PROPS
+};
+
+static void
+gtd_panel_today_clear (GtdPanelToday *panel)
+{
+  GList *tasks;
+  GList *t;
+
+  tasks = gtd_task_list_get_tasks (panel->task_list);
+
+  for (t = tasks; t != NULL; t = t->next)
+    gtd_task_list_remove_task (panel->task_list, t->data);
+
+  g_list_free (tasks);
+}
+
+static void
+gtd_panel_today_count_tasks (GtdPanelToday *panel)
+{
+  GtdManager *manager;
+  GList *tasklists;
+  GList *l;
+  guint number_of_tasks;
+
+  manager = gtd_manager_get_default ();
+  tasklists = gtd_manager_get_task_lists (manager);
+  number_of_tasks = 0;
+
+  /* Reset list */
+  gtd_panel_today_clear (panel);
+
+  /* Recount tasks */
+  for (l = tasklists; l != NULL; l = l->next)
+    {
+      GList *tasks;
+      GList *t;
+
+      tasks = gtd_task_list_get_tasks (l->data);
+
+      for (t = tasks; t != NULL; t = t->next)
+        {
+          GDateTime *task_dt;
+
+          task_dt = gtd_task_get_due_date (t->data);
+
+          /*
+           * GtdTaskListView automagically updates the list
+           * whever a task is added/removed/changed.
+           */
+          if (task_dt && g_date_time_equal (task_dt, panel->today))
+            {
+              gtd_task_list_save_task (panel->task_list, t->data);
+              number_of_tasks++;
+            }
+
+          g_clear_pointer (&task_dt, g_date_time_unref);
+        }
+
+      g_list_free (tasks);
+    }
+
+  if (number_of_tasks != panel->number_of_tasks)
+    {
+      panel->number_of_tasks = number_of_tasks;
+
+      /* Update title */
+      g_clear_pointer (&panel->title, g_free);
+      if (number_of_tasks == 0)
+        {
+          panel->title = g_strdup (_("Today"));
+        }
+      else
+        {
+          panel->title = g_strdup_printf ("%s (%d)",
+                                          _("Today"),
+                                          panel->number_of_tasks);
+        }
+
+      g_message ("%s: setting title to '%s'",
+                 G_STRFUNC,
+                 panel->title);
+
+      g_object_notify (G_OBJECT (panel), "title");
+    }
+
+  g_list_free (tasklists);
+}
+
+static GDateTime*
+get_today (void)
+{
+  GDateTime *now_local;
+  GDateTime *today;
+
+  now_local = g_date_time_new_now_local ();
+  today = g_date_time_new_local (g_date_time_get_year (now_local),
+                                 g_date_time_get_month (now_local),
+                                 g_date_time_get_day_of_month (now_local),
+                                 0,
+                                 0,
+                                 0);
+
+  g_clear_pointer (&now_local, g_date_time_unref);
+
+  return today;
+}
+
+static void
+gtd_panel_today_update_today (GtdPanelToday *panel)
+{
+  g_clear_pointer (&panel->today, g_date_time_unref);
+  panel->today = get_today ();
+
+  /* Recount tasks */
+  gtd_panel_today_count_tasks (panel);
+}
+
+static gboolean
+gtd_panel_today_update_today_timeout_cb (GtdPanelToday *panel)
+{
+  GDateTime *tomorrow;
+  GDateTime *today;
+  GDateTime *now;
+  gint seconds;
+
+  now = g_date_time_new_now_local ();
+  today = get_today ();
+  tomorrow = g_date_time_add_days (today, 1);
+  seconds = g_date_time_difference (now, tomorrow) / G_TIME_SPAN_SECOND;
+
+  /* Update today and recount tasks */
+  gtd_panel_today_update_today (panel);
+
+  panel->day_change_callback_id = g_timeout_add_seconds (seconds,
+                                                         (GSourceFunc) 
gtd_panel_today_update_today_timeout_cb,
+                                                         panel);
+
+  g_clear_pointer (&tomorrow, g_date_time_unref);
+  g_clear_pointer (&today, g_date_time_unref);
+  g_clear_pointer (&now, g_date_time_unref);
+
+  return G_SOURCE_REMOVE;
+}
+
+/**********************
+ * GtdPanel iface init
+ **********************/
+static const gchar*
+gtd_panel_today_get_name (GtdPanel *panel)
+{
+  return GTD_PANEL_TODAY_NAME;
+}
+
+static const gchar*
+gtd_panel_today_get_title (GtdPanel *panel)
+{
+  return GTD_PANEL_TODAY (panel)->title;
+}
+
+static GList*
+gtd_panel_today_get_header_widgets (GtdPanel *panel)
+{
+  return NULL;
+}
+
+static const GMenu*
+gtd_panel_today_get_menu (GtdPanel *panel)
+{
+  return NULL;
+}
+
+static void
+gtd_panel_iface_init (GtdPanelInterface *iface)
+{
+  iface->get_name = gtd_panel_today_get_name;
+  iface->get_title = gtd_panel_today_get_title;
+  iface->get_header_widgets = gtd_panel_today_get_header_widgets;
+  iface->get_menu = gtd_panel_today_get_menu;
+}
+
+static void
+gtd_panel_today_finalize (GObject *object)
+{
+  GtdPanelToday *self = (GtdPanelToday *)object;
+
+  g_clear_pointer (&self->today, g_date_time_unref);
+
+  G_OBJECT_CLASS (gtd_panel_today_parent_class)->finalize (object);
+}
+
+static void
+gtd_panel_today_get_property (GObject    *object,
+                              guint       prop_id,
+                              GValue     *value,
+                              GParamSpec *pspec)
+{
+  GtdPanelToday *self = GTD_PANEL_TODAY (object);
+
+  switch (prop_id)
+    {
+    case PROP_HEADER_WIDGETS:
+      g_value_set_pointer (value, NULL);
+      break;
+
+    case PROP_MENU:
+      g_value_set_object (value, NULL);
+      break;
+
+    case PROP_NAME:
+      g_value_set_string (value, GTD_PANEL_TODAY_NAME);
+      break;
+
+    case PROP_TITLE:
+      g_value_set_string (value, self->title);
+      break;
+
+    default:
+      G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+    }
+}
+
+static void
+gtd_panel_today_set_property (GObject      *object,
+                              guint         prop_id,
+                              const GValue *value,
+                              GParamSpec   *pspec)
+{
+  G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+}
+
+static void
+gtd_panel_today_class_init (GtdPanelTodayClass *klass)
+{
+  GObjectClass *object_class = G_OBJECT_CLASS (klass);
+
+  object_class->finalize = gtd_panel_today_finalize;
+  object_class->get_property = gtd_panel_today_get_property;
+  object_class->set_property = gtd_panel_today_set_property;
+
+  g_object_class_override_property (object_class, PROP_HEADER_WIDGETS, "header-widgets");
+  g_object_class_override_property (object_class, PROP_MENU, "menu");
+  g_object_class_override_property (object_class, PROP_NAME, "name");
+  g_object_class_override_property (object_class, PROP_TITLE, "title");
+}
+
+static void
+gtd_panel_today_init (GtdPanelToday *self)
+{
+  GtdManager *manager;
+
+  /* Connect to GtdManager::list-* signals to update the title */
+  manager = gtd_manager_get_default ();
+
+  g_signal_connect_swapped (manager,
+                            "list-added",
+                            G_CALLBACK (gtd_panel_today_count_tasks),
+                            self);
+
+  g_signal_connect_swapped (manager,
+                            "list-removed",
+                            G_CALLBACK (gtd_panel_today_count_tasks),
+                            self);
+
+  g_signal_connect_swapped (manager,
+                            "list-changed",
+                            G_CALLBACK (gtd_panel_today_count_tasks),
+                            self);
+
+  /* Setup a title */
+  self->title = g_strdup (_("Today"));
+
+  /* Task list */
+  self->task_list = gtd_task_list_new (NULL);
+
+  /* The main view */
+  self->view = gtd_task_list_view_new ();
+  gtd_task_list_view_set_task_list (GTD_TASK_LIST_VIEW (self->view), self->task_list);
+
+  gtk_widget_set_hexpand (self->view, TRUE);
+  gtk_widget_set_vexpand (self->view, TRUE);
+  gtk_container_add (GTK_CONTAINER (self), self->view);
+
+  gtk_widget_show_all (GTK_WIDGET (self));
+
+  /* Start timer */
+  gtd_panel_today_update_today_timeout_cb (self);
+}
+
+GtkWidget*
+gtd_panel_today_new (void)
+{
+  return g_object_new (GTD_TYPE_PANEL_TODAY, NULL);
+}
diff --git a/plugins/eds/gtd-panel-today.h b/plugins/eds/gtd-panel-today.h
new file mode 100644
index 0000000..135e67a
--- /dev/null
+++ b/plugins/eds/gtd-panel-today.h
@@ -0,0 +1,35 @@
+/* gtd-panel-today.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_PANEL_TODAY_H
+#define GTD_PANEL_TODAY_H
+
+#include <glib.h>
+#include <gtk/gtk.h>
+
+G_BEGIN_DECLS
+
+#define GTD_TYPE_PANEL_TODAY (gtd_panel_today_get_type())
+
+G_DECLARE_FINAL_TYPE (GtdPanelToday, gtd_panel_today, GTD, PANEL_TODAY, GtkBox)
+
+GtkWidget*           gtd_panel_today_new                         (void);
+
+G_END_DECLS
+
+#endif /* GTD_PANEL_TODAY_H */
diff --git a/plugins/eds/gtd-plugin-eds.c b/plugins/eds/gtd-plugin-eds.c
index 393af12..a04267a 100644
--- a/plugins/eds/gtd-plugin-eds.c
+++ b/plugins/eds/gtd-plugin-eds.c
@@ -16,6 +16,8 @@
  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
  */
 
+#include "gtd-panel-today.h"
+#include "gtd-panel-scheduled.h"
 #include "gtd-plugin-eds.h"
 #include "gtd-provider-goa.h"
 #include "gtd-provider-local.h"
@@ -43,6 +45,9 @@ struct _GtdPluginEds
 
   ESourceRegistry        *registry;
 
+  /* Panels */
+  GList                  *panels;
+
   /* Providers */
   GList                  *providers;
 };
@@ -52,6 +57,7 @@ enum
   PROP_0,
   PROP_OBJECT,
   PROP_PROVIDERS,
+  PROP_PANELS,
   LAST_PROP
 };
 
@@ -99,6 +105,14 @@ peas_activatable_iface_init (PeasActivatableInterface *iface)
  * GtdActivatable interface implementation
  */
 static GList*
+gtd_plugin_eds_get_panels (GtdActivatable *activatable)
+{
+  GtdPluginEds *plugin = GTD_PLUGIN_EDS (activatable);
+
+  return plugin->panels;
+}
+
+static GList*
 gtd_plugin_eds_get_providers (GtdActivatable *activatable)
 {
   GtdPluginEds *plugin = GTD_PLUGIN_EDS (activatable);
@@ -109,6 +123,7 @@ gtd_plugin_eds_get_providers (GtdActivatable *activatable)
 static void
 gtd_activatable_iface_init (GtdActivatableInterface *iface)
 {
+  iface->get_panels = gtd_plugin_eds_get_panels;
   iface->get_providers = gtd_plugin_eds_get_providers;
 }
 
@@ -309,6 +324,10 @@ gtd_plugin_eds_get_property (GObject    *object,
       g_value_set_object (value, NULL);
       break;
 
+    case PROP_PANELS:
+      g_value_set_pointer (value, self->panels);
+      break;
+
     case PROP_PROVIDERS:
       g_value_set_pointer (value, self->providers);
       break;
@@ -348,6 +367,10 @@ gtd_plugin_eds_class_init (GtdPluginEdsClass *klass)
                                     "object");
 
   g_object_class_override_property (object_class,
+                                    PROP_PANELS,
+                                    "panels");
+
+  g_object_class_override_property (object_class,
                                     PROP_PROVIDERS,
                                     "providers");
 }
@@ -355,6 +378,9 @@ gtd_plugin_eds_class_init (GtdPluginEdsClass *klass)
 static void
 gtd_plugin_eds_init (GtdPluginEds *self)
 {
+  self->panels = g_list_append (NULL, gtd_panel_today_new ());
+  self->panels = g_list_append (self->panels, gtd_panel_scheduled_new ());
+
   /* load the source registry */
   e_source_registry_new (NULL,
                          (GAsyncReadyCallback) gtd_plugin_eds_source_registry_finish_cb,


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