[gnome-todo] todo-txt: generate task with provider vfunc
- From: Georges Basile Stavracas Neto <gbsneto src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-todo] todo-txt: generate task with provider vfunc
- Date: Thu, 28 Sep 2017 03:58:14 +0000 (UTC)
commit e4b80a6582bd478aa5bed6f14b03503f7b6d95b4
Author: Georges Basile Stavracas Neto <georges stavracas gmail com>
Date: Thu Sep 28 00:57:35 2017 -0300
todo-txt: generate task with provider vfunc
plugins/todo-txt/gtd-provider-todo-txt.c | 5 ++++-
plugins/todo-txt/gtd-provider-todo-txt.h | 2 --
plugins/todo-txt/gtd-todo-txt-parser.c | 28 +++++++++++-----------------
plugins/todo-txt/gtd-todo-txt-parser.h | 3 ++-
4 files changed, 17 insertions(+), 21 deletions(-)
---
diff --git a/plugins/todo-txt/gtd-provider-todo-txt.c b/plugins/todo-txt/gtd-provider-todo-txt.c
index e628981..f9dd8b9 100644
--- a/plugins/todo-txt/gtd-provider-todo-txt.c
+++ b/plugins/todo-txt/gtd-provider-todo-txt.c
@@ -274,8 +274,11 @@ gtd_provider_todo_txt_load_tasks (GtdProviderTodoTxt *self)
continue;
}
- task = gtd_todo_txt_parser_parse_tokens (tokens);
+ task = gtd_provider_generate_task (GTD_PROVIDER (self));
+ gtd_todo_txt_parser_parse_tokens (task, tokens);
+
g_hash_table_insert (self->tasks, g_strdup (gtd_task_get_title (task)), task);
+
list = create_list (self, g_object_get_data (G_OBJECT (task), "list_name"));
gtd_task_set_list (task, list);
diff --git a/plugins/todo-txt/gtd-provider-todo-txt.h b/plugins/todo-txt/gtd-provider-todo-txt.h
index 53c19b7..583e741 100644
--- a/plugins/todo-txt/gtd-provider-todo-txt.h
+++ b/plugins/todo-txt/gtd-provider-todo-txt.h
@@ -31,8 +31,6 @@ G_DECLARE_FINAL_TYPE (GtdProviderTodoTxt, gtd_provider_todo_txt, GTD, PROVIDER_T
GtdProviderTodoTxt* gtd_provider_todo_txt_new (GFile *source_file);
-GtdTask* create_task (void);
-
G_END_DECLS
#endif /* GTD_PROVIDER_TODO_TXT_H */
diff --git a/plugins/todo-txt/gtd-todo-txt-parser.c b/plugins/todo-txt/gtd-todo-txt-parser.c
index 012a50e..2b8650a 100644
--- a/plugins/todo-txt/gtd-todo-txt-parser.c
+++ b/plugins/todo-txt/gtd-todo-txt-parser.c
@@ -26,7 +26,8 @@ struct _GtdTodoTxtParser
GtdObject parent;
};
-enum {
+enum
+{
TASK_COMPLETE,
TASK_PRIORITY,
TASK_DATE,
@@ -79,10 +80,7 @@ gtd_todo_txt_parser_get_date (gchar *token)
month = g_date_get_month (&date);
day = g_date_get_day (&date);
- dt = g_date_time_new_utc (year,
- month,
- day,
- 0, 0, 0);
+ dt = g_date_time_new_utc (year, month, day, 0, 0, 0);
return dt;
}
@@ -159,27 +157,25 @@ gtd_todo_txt_parser_get_token_id (gchar *token,
return -1;
}
-GtdTask*
-gtd_todo_txt_parser_parse_tokens (GList *tokens)
+void
+gtd_todo_txt_parser_parse_tokens (GtdTask *task,
+ GList *tokens)
{
- GtdTask *task;
GDateTime *dt;
GString *list_name;
GString *title;
GString *root_task_name;
- gboolean is_subtask;
-
GList *l;
+ gboolean is_subtask;
gint last_read_token;
gint token_id;
- dt = NULL;
l = NULL;
- task = gtd_task_new ();
- list_name = g_string_new (NULL);
+ dt = NULL;
+ is_subtask = FALSE;
title = g_string_new (NULL);
+ list_name = g_string_new (NULL);
root_task_name = g_string_new (NULL);
- is_subtask = FALSE;
last_read_token = TASK_COMPLETE;
@@ -235,7 +231,7 @@ gtd_todo_txt_parser_parse_tokens (GList *tokens)
break;
default:
- return NULL;
+ return;
}
}
@@ -251,8 +247,6 @@ gtd_todo_txt_parser_parse_tokens (GList *tokens)
g_string_free (root_task_name, TRUE);
g_string_free (list_name, TRUE);
g_string_free (title, TRUE);
-
- return task;
}
gboolean
diff --git a/plugins/todo-txt/gtd-todo-txt-parser.h b/plugins/todo-txt/gtd-todo-txt-parser.h
index 8d3b567..12ccbc4 100644
--- a/plugins/todo-txt/gtd-todo-txt-parser.h
+++ b/plugins/todo-txt/gtd-todo-txt-parser.h
@@ -42,7 +42,8 @@ gboolean gtd_todo_txt_parser_is_word (gchar
gint gtd_todo_txt_parser_get_token_id (gchar *token,
gint last_read);
-GtdTask* gtd_todo_txt_parser_parse_tokens (GList *tokens);
+void gtd_todo_txt_parser_parse_tokens (GtdTask *task,
+ GList *tokens);
gboolean gtd_todo_txt_parser_validate_token_format (GList *tokens);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]