[gnome-todo] todo-txt: Subclass GtdTask to GtdTaskTodoTxt
- From: Georges Basile Stavracas Neto <gbsneto src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-todo] todo-txt: Subclass GtdTask to GtdTaskTodoTxt
- Date: Fri, 8 Jun 2018 14:16:50 +0000 (UTC)
commit 71f8182bf7e249dd93b44077e94c825b2951a27e
Author: Rohit Kaushik <kaushikrohit325 gmail com>
Date: Mon Jun 4 22:51:03 2018 +0530
todo-txt: Subclass GtdTask to GtdTaskTodoTxt
plugins/todo-txt/gtd-provider-todo-txt.c | 7 +++--
plugins/todo-txt/gtd-provider-todo-txt.h | 3 +-
plugins/todo-txt/gtd-task-todo-txt.c | 53 ++++++++++++++++++++++++++++++++
plugins/todo-txt/gtd-task-todo-txt.h | 34 ++++++++++++++++++++
plugins/todo-txt/gtd-todo-txt-parser.c | 2 +-
plugins/todo-txt/gtd-todo-txt-parser.h | 1 +
plugins/todo-txt/meson.build | 3 +-
7 files changed, 97 insertions(+), 6 deletions(-)
---
diff --git a/plugins/todo-txt/gtd-provider-todo-txt.c b/plugins/todo-txt/gtd-provider-todo-txt.c
index a96cf09..0dcb5ac 100644
--- a/plugins/todo-txt/gtd-provider-todo-txt.c
+++ b/plugins/todo-txt/gtd-provider-todo-txt.c
@@ -23,6 +23,7 @@
#include "gtd-provider-todo-txt.h"
#include "gtd-plugin-todo-txt.h"
#include "gtd-todo-txt-parser.h"
+#include "gtd-task-todo-txt.h"
#include <string.h>
#include <stdlib.h>
@@ -442,7 +443,7 @@ gtd_provider_todo_txt_create_task (GtdProvider *provider,
self = GTD_PROVIDER_TODO_TXT (provider);
/* Create the new task */
- new_task = gtd_provider_todo_txt_generate_task (self);
+ new_task = GTD_TASK (gtd_provider_todo_txt_generate_task (self));
gtd_task_set_due_date (new_task, due_date);
gtd_task_set_list (new_task, list);
gtd_task_set_title (new_task, title);
@@ -688,7 +689,7 @@ gtd_provider_todo_txt_new (GFile *source_file)
NULL);
}
-GtdTask*
+GtdTaskTodoTxt*
gtd_provider_todo_txt_generate_task (GtdProviderTodoTxt *self)
{
g_autofree gchar *uid = NULL;
@@ -696,5 +697,5 @@ gtd_provider_todo_txt_generate_task (GtdProviderTodoTxt *self)
g_return_val_if_fail (GTD_IS_PROVIDER_TODO_TXT (self), NULL);
uid = g_uuid_string_random ();
- return g_object_new (GTD_TYPE_TASK, "uid", uid, NULL);
+ return g_object_new (GTD_TYPE_TASK_TODO_TXT, "uid", uid, NULL);
}
diff --git a/plugins/todo-txt/gtd-provider-todo-txt.h b/plugins/todo-txt/gtd-provider-todo-txt.h
index 62ad2af..a7e8f74 100644
--- a/plugins/todo-txt/gtd-provider-todo-txt.h
+++ b/plugins/todo-txt/gtd-provider-todo-txt.h
@@ -20,6 +20,7 @@
#define GTD_PROVIDER_TODO_TXT_H
#include "gnome-todo.h"
+#include "gtd-task-todo-txt.h"
#include <glib.h>
@@ -31,7 +32,7 @@ G_DECLARE_FINAL_TYPE (GtdProviderTodoTxt, gtd_provider_todo_txt, GTD, PROVIDER_T
GtdProviderTodoTxt* gtd_provider_todo_txt_new (GFile *source_file);
-GtdTask* gtd_provider_todo_txt_generate_task (GtdProviderTodoTxt *self);
+GtdTaskTodoTxt* gtd_provider_todo_txt_generate_task (GtdProviderTodoTxt *self);
G_END_DECLS
diff --git a/plugins/todo-txt/gtd-task-todo-txt.c b/plugins/todo-txt/gtd-task-todo-txt.c
new file mode 100644
index 0000000..e701889
--- /dev/null
+++ b/plugins/todo-txt/gtd-task-todo-txt.c
@@ -0,0 +1,53 @@
+/* gtd-task-todo-txt.c
+ *
+ * Copyright (C) 2018 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 "GtdTaskTodoTxt"
+
+#include "gtd-task-todo-txt.h"
+
+struct _GtdTaskTodoTxt
+{
+ GtdTask parent;
+};
+
+G_DEFINE_TYPE (GtdTaskTodoTxt, gtd_task_todo_txt, GTD_TYPE_TASK)
+
+static void
+gtd_task_todo_txt_class_init (GtdTaskTodoTxtClass *klass)
+{
+}
+
+static void
+gtd_task_todo_txt_init (GtdTaskTodoTxt *self)
+{
+}
+
+GtdTaskTodoTxt*
+gtd_task_todo_txt_new (void)
+{
+ return g_object_new (GTD_TYPE_TASK_TODO_TXT, NULL);
+}
+
+void
+gtd_task_todo_txt_set_completion_date (GtdTaskTodoTxt *self,
+ GDateTime *dt)
+{
+ g_return_if_fail (GTD_IS_TASK_TODO_TXT (self));
+
+ GTD_TASK_CLASS (gtd_task_todo_txt_parent_class)->set_completion_date (GTD_TASK (self), dt);
+}
diff --git a/plugins/todo-txt/gtd-task-todo-txt.h b/plugins/todo-txt/gtd-task-todo-txt.h
new file mode 100644
index 0000000..11ffdb2
--- /dev/null
+++ b/plugins/todo-txt/gtd-task-todo-txt.h
@@ -0,0 +1,34 @@
+/* gtd-task-todo-txt.h
+ *
+ * Copyright (C) 2018 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/>.
+ */
+
+#pragma once
+
+#include "gnome-todo.h"
+
+G_BEGIN_DECLS
+
+#define GTD_TYPE_TASK_TODO_TXT (gtd_task_todo_txt_get_type())
+
+G_DECLARE_FINAL_TYPE (GtdTaskTodoTxt, gtd_task_todo_txt, GTD, TASK_TODO_TXT, GtdTask)
+
+GtdTaskTodoTxt* gtd_task_todo_txt_new (void);
+
+void gtd_task_todo_txt_set_completion_date (GtdTaskTodoTxt *self,
+ GDateTime *dt);
+
+G_END_DECLS
diff --git a/plugins/todo-txt/gtd-todo-txt-parser.c b/plugins/todo-txt/gtd-todo-txt-parser.c
index 7b141cc..5e1db05 100644
--- a/plugins/todo-txt/gtd-todo-txt-parser.c
+++ b/plugins/todo-txt/gtd-todo-txt-parser.c
@@ -234,7 +234,7 @@ gtd_todo_txt_parser_parse_task (GtdProvider *provider,
state.last_token = TOKEN_START;
state.in_description = FALSE;
- task = gtd_provider_todo_txt_generate_task (GTD_PROVIDER_TODO_TXT (provider));
+ task = GTD_TASK (gtd_provider_todo_txt_generate_task (GTD_PROVIDER_TODO_TXT (provider)));
tokens = tokenize_line (line);
for (i = 0; tokens && tokens[i]; i++)
diff --git a/plugins/todo-txt/gtd-todo-txt-parser.h b/plugins/todo-txt/gtd-todo-txt-parser.h
index a6a6669..be758aa 100644
--- a/plugins/todo-txt/gtd-todo-txt-parser.h
+++ b/plugins/todo-txt/gtd-todo-txt-parser.h
@@ -20,6 +20,7 @@
#define GTD_TODO_TXT_PARSE_H
#include "gnome-todo.h"
+#include "gtd-task-todo-txt.h"
#include <glib.h>
diff --git a/plugins/todo-txt/meson.build b/plugins/todo-txt/meson.build
index ddaba56..9128b07 100644
--- a/plugins/todo-txt/meson.build
+++ b/plugins/todo-txt/meson.build
@@ -5,7 +5,8 @@ plugins_ldflags += ['-Wl,--undefined=gtd_plugin_todo_txt_register_types']
sources = files(
'gtd-plugin-' + plugin_name + '.c',
'gtd-provider-' + plugin_name + '.c',
- 'gtd-' + plugin_name + '-parser.c'
+ 'gtd-' + plugin_name + '-parser.c',
+ 'gtd-' + 'task-' + plugin_name + '.c'
)
plugins_libs += static_library(
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]