switch (status) {
case 0:
- tasks = get_all_tasks("pending");
+ tasks = tw_get_all_tasks("pending");
break;
case 1:
- tasks = get_all_tasks("completed");
+ tasks = tw_get_all_tasks("completed");
break;
default:
- tasks = get_all_tasks("pending");
+ tasks = tw_get_all_tasks("pending");
}
model = gtk_tree_view_get_model(GTK_TREE_VIEW(w_treeview));
{
struct task *task;
GtkTextBuffer *buf;
- char *txt, *opts;
+ char *txt;
GtkTextIter sIter, eIter;
const char *ctxt;
}
ctxt = gtk_entry_get_text(w_description);
- txt = escape(ctxt);
+ if (!task->description || strcmp(ctxt, task->description))
+ tw_modify_description(task->uuid, ctxt);
- opts = malloc(1
- + strlen(task->uuid)
- + strlen(" modify description:\"")
- + strlen(txt)
- + strlen("\"")
- + 1);
- sprintf(opts, " %s modify \"%s\"", task->uuid, txt);
-
- task_exec(opts);
-
- free(txt);
+ ctxt = gtk_entry_get_text(w_project);
+ if (!task->project || strcmp(ctxt, task->project))
+ tw_modify_project(task->uuid, ctxt);
refresh();
return NULL;
}
-struct task **get_all_tasks(const char *status)
+struct task **tw_get_all_tasks(const char *status)
{
int i, n;
struct json_object *jtasks, *jtask, *json;
return result;
}
+void tw_modify_description(const char *uuid, const char *newdesc)
+{
+ char *str;
+ char *opts;
+
+ str = escape(newdesc);
+
+ opts = malloc(1
+ + strlen(uuid)
+ + strlen(" modify :\"")
+ + strlen(str)
+ + strlen("\"")
+ + 1);
+ sprintf(opts, " %s modify \"%s\"", uuid, str);
+
+ task_exec(opts);
+
+ free(str);
+ free(opts);
+}
+
+void tw_modify_project(const char *uuid, const char *newproject)
+{
+ char *str;
+ char *opts;
+
+ str = escape(newproject);
+
+ opts = malloc(1
+ + strlen(uuid)
+ + strlen(" modify project:\"")
+ + strlen(str)
+ + strlen("\"")
+ + 1);
+ sprintf(opts, " %s modify project:\"%s\"", uuid, str);
+
+ task_exec(opts);
+
+ free(str);
+ free(opts);
+}
char *project;
};
-struct task **get_all_tasks(const char *status);
+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);
+
char *task_exec(char *opts);
char *escape(const char *txt);