(no commit message)
authorJean-Philippe Orsini <jeanfi@gmail.com>
Tue, 16 Oct 2012 20:23:26 +0000 (20:23 +0000)
committerJean-Philippe Orsini <jeanfi@gmail.com>
Tue, 16 Oct 2012 20:23:26 +0000 (20:23 +0000)
src/main.c
src/tw.c
src/tw.h

index 0c059ff..fd58304 100644 (file)
@@ -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);
        }
 }
index 9a551bc..d65ae61 100644 (file)
--- 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;
index 9c6f0b2..f6718cb 100644 (file)
--- 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);