Commit cf778f83 authored by Rohit Kaushik's avatar Rohit Kaushik Committed by Georges Basile Stavracas Neto
Browse files

todoist-plugin: stub out

This patch includes the basic skeleton along with certain signal
and functions that will be required for todoist integration.
Many function are not implemented since we don't have a Todoist
Goa Account.
Classes added:
    1) TodoistPreferencesPanel
    2) TodoistProvider
    3) TodoistPlugin

https://bugzilla.gnome.org/show_bug.cgi?id=772278
parent 15a70bb1
......@@ -96,6 +96,7 @@ GNOME_TODO_ADD_PLUGIN([score], [Score], [yes])
GNOME_TODO_ADD_PLUGIN([today-panel], [Today Panel], [yes])
GNOME_TODO_ADD_PLUGIN([unscheduled-panel], [Unscheduled Tasks Panel], [yes])
GNOME_TODO_ADD_PLUGIN([todo-txt], [Todo.Txt], [yes])
GNOME_TODO_ADD_PLUGIN([todoist], [Todoist], [yes])
dnl ***********************************************************************
......@@ -146,6 +147,7 @@ echo "
Today panel ............. ${enable_today_panel_plugin}
Unscheduled panel ....... ${enable_unscheduled_panel_plugin}
Todo.txt ................ ${enable_todo_txt_plugin}
Todoist ................. ${enable_todoist_plugin}
Now type 'make' to build $PACKAGE
"
......@@ -91,6 +91,7 @@ declare -A default_options=(
['today-panel-plugin']=true
['unscheduled-panel-plugin']=true
['todo-txt-plugin']=true
['todoist-plugin']=true
['introspection']=true
)
......@@ -176,6 +177,7 @@ echo "
Today panel ............. $(echooption today-panel-plugin)
Unscheduled panel ....... $(echooption unscheduled-panel-plugin)
Todo.txt ................ $(echooption todo-txt-plugin)
Todoist ................. $(echooption todoist-plugin)
Now type '${NINJA} -C ${builddir}' to build
"
......
......@@ -53,4 +53,10 @@
<gresource prefix="/org/gnome/todo">
<file alias="plugins/todo-txt/todo-txt.plugin">../plugins/todo-txt/todo-txt.plugin</file>
</gresource>
<!--Todoist-->
<gresource prefix="/org/gnome/todo">
<file alias="plugins/todoist/todoist.plugin">../plugins/todoist/todoist.plugin</file>
<file compressed="true" alias="ui/todoist/preferences.ui">../plugins/todoist/ui/preferences.ui</file>
</gresource>
</gresources>
......@@ -7,5 +7,6 @@ option('enable-score-plugin', type: 'boolean', value: true, description: 'enable
option('enable-today-panel-plugin', type: 'boolean', value: true, description: 'enable Today Panel plugin')
option('enable-unscheduled-panel-plugin', type: 'boolean', value: true, description: 'enable Unscheduled Tasks Panel plugin')
option('enable-todo-txt-plugin', type: 'boolean', value: true, description: 'enable Todo.Txt plugin')
option('enable-todoist-plugin', type: 'boolean', value: true, description: 'enable Todoist plugin')
option('enable-gtk-doc', type: 'boolean', value: false, description: 'use gtk-doc to build documentation')
option('enable-introspection', type: 'boolean', value: true, description: 'Enable GObject Introspection (depends on GObject)')
......@@ -28,4 +28,8 @@ if BUILD_TODO_TXT_PLUGIN
SUBDIRS += todo-txt
endif
if BUILD_TODOIST_PLUGIN
SUBDIRS += todoist
endif
MAINTAINERCLEANFILES = Makefile.in
......@@ -34,3 +34,7 @@ endif
if get_option('enable-todo-txt-plugin')
subdir('todo-txt')
endif
if get_option('enable-todoist-plugin')
subdir('todoist')
endif
include $(top_srcdir)/common.am
noinst_LTLIBRARIES = libtodoist.la
libtodoist_la_SOURCES = \
gtd-plugin-todoist.c \
gtd-plugin-todoist.h \
gtd-provider-todoist.c \
gtd-provider-todoist.h \
gtd-todoist-preferences-panel.c \
gtd-todoist_preferences_panel.h
libtodoist_la_CFLAGS = \
$(GNOME_TODO_PLUGIN_CFLAGS) \
$(GNOME_TODO_PLUGIN_WARN_CFLAGS)
-DPACKAGE_DATA_DIR=\""$(pkgdatadir)"\"
EXTRA_DIST = \
todoist.plugin.in
/* gtd-plugin-todoist.c
*
* Copyright (C) 2017 Rohit Kaushik <kaushikrohit325@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/>.
*/
#define G_LOG_DOMAIN "Todoist"
#include "gtd-plugin-todoist.h"
#include "gtd-provider-todoist.h"
#include "gtd-todoist-preferences-panel.h"
#include <glib/gi18n.h>
#include <glib-object.h>
/**
* The #GtdPluginTodoist is a class that loads Todoist
* provider of GNOME To Do.
*/
struct _GtdPluginTodoist
{
PeasExtensionBase parent;
GtkWidget *preferences;
/* Providers */
GList *providers;
};
enum
{
PROP_0,
PROP_PREFERENCES_PANEL,
LAST_PROP
};
static void gtd_activatable_iface_init (GtdActivatableInterface *iface);
G_DEFINE_DYNAMIC_TYPE_EXTENDED (GtdPluginTodoist, gtd_plugin_todoist, PEAS_TYPE_EXTENSION_BASE,
0,
G_IMPLEMENT_INTERFACE_DYNAMIC (GTD_TYPE_ACTIVATABLE,
gtd_activatable_iface_init))
/*
* GtdActivatable interface implementation
*/
static void
gtd_plugin_todoist_activate (GtdActivatable *activatable)
{
;
}
static void
gtd_plugin_todoist_deactivate (GtdActivatable *activatable)
{
;
}
static GList*
gtd_plugin_todoist_get_header_widgets (GtdActivatable *activatable)
{
return NULL;
}
static GtkWidget*
gtd_plugin_todoist_get_preferences_panel (GtdActivatable *activatable)
{
GtdPluginTodoist *self = GTD_PLUGIN_TODOIST (activatable);
return self->preferences;
}
static GList*
gtd_plugin_todoist_get_panels (GtdActivatable *activatable)
{
return NULL;
}
static GList*
gtd_plugin_todoist_get_providers (GtdActivatable *activatable)
{
GtdPluginTodoist *plugin = GTD_PLUGIN_TODOIST (activatable);
return plugin->providers;
}
static void
gtd_plugin_todoist_account_added (GtdTodoistPreferencesPanel *panel,
GoaObject *account_object,
GtdPluginTodoist *self)
{
GtdProviderTodoist *provider;
GoaAccount *goa_account;
const gchar *provider_name;
goa_account = goa_object_get_account (account_object);
provider_name = goa_account_get_provider_name (goa_account);
if (g_strcmp0 (provider_name, "Todoist") != 0)
return;
provider = gtd_provider_todoist_new (account_object);
self->providers = g_list_append (self->providers, provider);
g_signal_emit_by_name (self, "provider-added", provider);
}
static void
gtd_plugin_todoist_account_removed (GtdTodoistPreferencesPanel *panel,
GoaObject *account_object,
GtdPluginTodoist *self)
{
GoaAccount *goa_account;
const gchar *provider_name;
GList *l;
goa_account = goa_object_get_account (account_object);
provider_name = goa_account_get_provider_name (goa_account);
l = NULL;
if (g_strcmp0 (provider_name, "Todoist") != 0)
return;
for (l = self->providers; l != NULL; l = l->next)
{
GoaObject *object;
object = gtd_provider_todoist_get_goa_object (l->data);
if (object == account_object)
{
self->providers = g_list_remove (self->providers, l->data);
g_signal_emit_by_name (self, "provider-removed", l->data);
break;
}
}
}
static void
gtd_plugin_todoist_account_changed (GtdTodoistPreferencesPanel *panel,
GoaObject *account_object,
GtdPluginTodoist *self)
{
GoaAccount *goa_account;
const gchar *provider_name;
goa_account = goa_object_get_account (account_object);
provider_name = goa_account_get_provider_name (goa_account);
if (g_strcmp0 (provider_name, "Todoist") != 0)
return;
}
static void
goa_client_ready (GObject *source,
GAsyncResult *res,
GtdPluginTodoist *self)
{
GoaClient *client;
client = goa_client_new_finish (res, NULL);
/* Connect signals */
g_signal_connect (client, "account-added", G_CALLBACK (gtd_plugin_todoist_account_added), self);
g_signal_connect (client, "account-removed", G_CALLBACK (gtd_plugin_todoist_account_removed), self);
g_signal_connect (client, "account-changed", G_CALLBACK (gtd_plugin_todoist_account_changed), self);
gtd_todoist_preferences_panel_set_client (GTD_TODOIST_PREFERENCES_PANEL (self->preferences), client);
}
static void
gtd_activatable_iface_init (GtdActivatableInterface *iface)
{
iface->activate = gtd_plugin_todoist_activate;
iface->deactivate = gtd_plugin_todoist_deactivate;
iface->get_header_widgets = gtd_plugin_todoist_get_header_widgets;
iface->get_preferences_panel = gtd_plugin_todoist_get_preferences_panel;
iface->get_panels = gtd_plugin_todoist_get_panels;
iface->get_providers = gtd_plugin_todoist_get_providers;
}
/*
* Init
*/
static void
gtd_plugin_todoist_finalize (GObject *object)
{
GtdPluginTodoist *self = (GtdPluginTodoist *) object;
g_list_free_full (self->providers, g_object_unref);
self->providers = NULL;
G_OBJECT_CLASS (gtd_plugin_todoist_parent_class)->finalize (object);
}
static void
gtd_plugin_todoist_get_property (GObject *object,
guint prop_id,
GValue *value,
GParamSpec *pspec)
{
GtdPluginTodoist *self = GTD_PLUGIN_TODOIST (object);
switch (prop_id)
{
case PROP_PREFERENCES_PANEL:
g_value_set_object (value, self->preferences);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
}
}
static void
gtd_plugin_todoist_class_init (GtdPluginTodoistClass *klass)
{
GObjectClass *object_class = G_OBJECT_CLASS (klass);
object_class->finalize = gtd_plugin_todoist_finalize;
object_class->get_property = gtd_plugin_todoist_get_property;
g_object_class_override_property (object_class,
PROP_PREFERENCES_PANEL,
"preferences-panel");
}
static void
gtd_plugin_todoist_init (GtdPluginTodoist *self)
{
self->preferences = GTK_WIDGET (gtd_todoist_preferences_panel_new ());
goa_client_new (NULL, (GAsyncReadyCallback) goa_client_ready, self);
}
/* Empty class_finalize method */
static void
gtd_plugin_todoist_class_finalize (GtdPluginTodoistClass *klass)
{
}
G_MODULE_EXPORT void
gtd_plugin_todoist_register_types (PeasObjectModule *module)
{
gtd_plugin_todoist_register_type (G_TYPE_MODULE (module));
peas_object_module_register_extension_type (module,
GTD_TYPE_ACTIVATABLE,
GTD_TYPE_PLUGIN_TODOIST);
}
/* gtd-plugin-todoist.h
*
* Copyright (C) 2017 Rohit Kaushik <kaushikrohit325@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_TODOIST_PLUGIN_H
#define GTD_TODOIST_PLUGIN_H
#include <glib.h>
#include <gnome-todo.h>
G_BEGIN_DECLS
#define GTD_TYPE_PLUGIN_TODOIST (gtd_plugin_todoist_get_type())
G_DECLARE_FINAL_TYPE (GtdPluginTodoist, gtd_plugin_todoist, GTD, PLUGIN_TODOIST, PeasExtensionBase)
G_MODULE_EXPORT void gtd_plugin_todoist_register_types (PeasObjectModule *module);
G_END_DECLS
#endif /* GTD_TODOIST_PLUGIN_H */
/* gtd-provider-todoist.c
*
* Copyright (C) 2017 Rohit Kaushik <kaushikrohit325@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-todoist.h"
#include "gtd-plugin-todoist.h"
#include <string.h>
#include <stdlib.h>
#include <glib/gi18n.h>
struct _GtdProviderTodoist
{
GtdObject parent;
GoaObject *account_object;
GIcon *icon;
GList *task_lists;
};
static void gtd_provider_iface_init (GtdProviderInterface *iface);
G_DEFINE_TYPE_WITH_CODE (GtdProviderTodoist, gtd_provider_todoist, GTD_TYPE_OBJECT,
G_IMPLEMENT_INTERFACE (GTD_TYPE_PROVIDER,
gtd_provider_iface_init))
enum {
PROP_0,
PROP_DEFAULT_TASKLIST,
PROP_DESCRIPTION,
PROP_ENABLED,
PROP_ICON,
PROP_ID,
PROP_NAME,
PROP_GOA_OBJECT,
LAST_PROP
};
/*
* GtdProviderInterface implementation
*/
static const gchar*
gtd_provider_todoist_get_id (GtdProvider *provider)
{
return "todoist";
}
static const gchar*
gtd_provider_todoist_get_name (GtdProvider *provider)
{
return _("Todoist");
}
static const gchar*
gtd_provider_todoist_get_description (GtdProvider *provider)
{
return _("Todoist Plugin for GNOME To Do");
}
static gboolean
gtd_provider_todoist_get_enabled (GtdProvider *provider)
{
return TRUE;
}
static GIcon*
gtd_provider_todoist_get_icon (GtdProvider *provider)
{
GtdProviderTodoist *self;
self = GTD_PROVIDER_TODOIST (provider);
return self->icon;
}
static const GtkWidget*
gtd_provider_todoist_get_edit_panel (GtdProvider *provider)
{
return NULL;
}
GoaObject*
gtd_provider_todoist_get_goa_object (GtdProviderTodoist *self)
{
return self->account_object;
}
static void
gtd_provider_todoist_create_task (GtdProvider *provider,
GtdTask *task)
{
}
static void
gtd_provider_todoist_update_task (GtdProvider *provider,
GtdTask *task)
{
}
static void
gtd_provider_todoist_remove_task (GtdProvider *provider,
GtdTask *task)
{
}
static void
gtd_provider_todoist_create_task_list (GtdProvider *provider,
GtdTaskList *list)
{
}
static void
gtd_provider_todoist_update_task_list (GtdProvider *provider,
GtdTaskList *list)
{
}
static void
gtd_provider_todoist_remove_task_list (GtdProvider *provider,
GtdTaskList *list)
{
}
static GList*
gtd_provider_todoist_get_task_lists (GtdProvider *provider)
{
GtdProviderTodoist *self;
self = GTD_PROVIDER_TODOIST (provider);
return self->task_lists;
}
static GtdTaskList*
gtd_provider_todoist_get_default_task_list (GtdProvider *provider)
{
return NULL;
}
static void
gtd_provider_todoist_set_default_task_list (GtdProvider *provider,
GtdTaskList *list)
{
}
static void
gtd_provider_iface_init (GtdProviderInterface *iface)
{
iface->get_id = gtd_provider_todoist_get_id;
iface->get_name = gtd_provider_todoist_get_name;
iface->get_description = gtd_provider_todoist_get_description;
iface->get_enabled = gtd_provider_todoist_get_enabled;
iface->get_icon = gtd_provider_todoist_get_icon;
iface->get_edit_panel = gtd_provider_todoist_get_edit_panel;
iface->create_task = gtd_provider_todoist_create_task;
iface->update_task = gtd_provider_todoist_update_task;
iface->remove_task = gtd_provider_todoist_remove_task;
iface->create_task_list = gtd_provider_todoist_create_task_list;
iface->update_task_list = gtd_provider_todoist_update_task_list;
iface->remove_task_list = gtd_provider_todoist_remove_task_list;
iface->get_task_lists = gtd_provider_todoist_get_task_lists;
iface->get_default_task_list = gtd_provider_todoist_get_default_task_list;
iface->set_default_task_list = gtd_provider_todoist_set_default_task_list;
}
GtdProviderTodoist*
gtd_provider_todoist_new (GoaObject *account_object)
{
return g_object_new (GTD_TYPE_PROVIDER_TODOIST,
"goa object",account_object,
NULL);
}
static void
gtd_provider_todoist_finalize (GObject *object)
{
GtdProviderTodoist *self = (GtdProviderTodoist *)object;
g_clear_pointer (&self->task_lists, g_clear_object);
g_clear_object (&self->icon);
G_OBJECT_CLASS (gtd_provider_todoist_parent_class)->finalize (object);
}
static void
gtd_provider_todoist_get_property (GObject *object,
guint prop_id,
GValue *value,
GParamSpec *pspec)
{
GtdProvider *provider = GTD_PROVIDER (object);
switch (prop_id)
{
case PROP_DESCRIPTION:
g_value_set_string (value, gtd_provider_todoist_get_description (provider));
break;
case PROP_ENABLED:
g_value_set_boolean (value, gtd_provider_todoist_get_enabled (provider));
break;
case PROP_ICON: