From: Jean-Philippe Orsini Date: Tue, 16 Oct 2012 20:23:26 +0000 (+0000) Subject: (no commit message) X-Git-Tag: v0.0.6~150 X-Git-Url: https://git.wpitchoune.net/gitweb/?p=ptask.git;a=commitdiff_plain;h=d1d78bf94968b488c5f175d6859f76de0c8eb41d --- diff --git a/src/main.c b/src/main.c index 0c059ff..fd58304 100644 --- a/src/main.c +++ b/src/main.c @@ -38,7 +38,8 @@ enum { COL_ID, COL_DESCRIPTION, COL_PROJECT, - COL_UUID + COL_UUID, + COL_PRIORITY }; static struct task *get_selected_task(GtkTreeView *treeview) @@ -62,7 +63,7 @@ static struct task *get_selected_task(GtkTreeView *treeview) uuid = g_value_get_string(&value); - for(tasks_cur = tasks; *tasks_cur; tasks_cur++) + for (tasks_cur = tasks; *tasks_cur; tasks_cur++) if (!strcmp((*tasks_cur)->uuid, uuid)) return *tasks_cur; @@ -132,6 +133,7 @@ static void refresh() COL_ID, (*tasks_cur)->id, COL_DESCRIPTION, (*tasks_cur)->description, COL_UUID, (*tasks_cur)->uuid, + COL_PRIORITY, (*tasks_cur)->priority, -1); } } diff --git a/src/tw.c b/src/tw.c index 9a551bc..d65ae61 100644 --- a/src/tw.c +++ b/src/tw.c @@ -127,6 +127,13 @@ struct task **tw_get_all_tasks(const char *status) else tasks[i]->project = NULL; + json = json_object_object_get(jtask, "priority"); + if (json) + tasks[i]->priority + = strdup(json_object_get_string(json)); + else + tasks[i]->priority = strdup(""); + json = json_object_object_get(jtask, "uuid"); tasks[i]->uuid = strdup(json_object_get_string(json)); @@ -216,6 +223,27 @@ void tw_modify_project(const char *uuid, const char *newproject) free(opts); } +void tw_modify_priority(const char *uuid, const char *priority) +{ + char *str; + char *opts; + + str = escape(priority); + + opts = malloc(1 + + strlen(uuid) + + strlen(" modify priority:\"") + + strlen(str) + + strlen("\"") + + 1); + sprintf(opts, " %s modify priority:\"%s\"", uuid, str); + + task_exec(opts); + + free(str); + free(opts); +} + void tw_add(const char *newdesc) { char *str; diff --git a/src/tw.h b/src/tw.h index 9c6f0b2..f6718cb 100644 --- a/src/tw.h +++ b/src/tw.h @@ -27,11 +27,13 @@ struct task { char *uuid; char *note; char *project; + char *priority; }; struct task **tw_get_all_tasks(const char *status); void tw_modify_description(const char *uuid, const char *newdesc); void tw_modify_project(const char *uuid, const char *newproj); +void tw_modify_priority(const char *uuid, const char *priority); void tw_add(const char *newdesc); char *task_exec(char *opts);