* added window position and size restore.
* added tasks sort column/order restore.
* fixed error message displayed when a note does not exist.
+ * new task dialog allow to set description and priority.
v0.0.3
------
<property name="margin_top">4</property>
<property name="margin_bottom">4</property>
<property name="model">prioritystore</property>
- <property name="active">0</property>
+ <property name="active">2</property>
<child>
<object class="GtkCellRendererText" id="cellrenderertext1"/>
<attributes>
return task_exec(opts2);
}
-static struct json_object *task_exec_json(char *opts)
+static struct json_object *task_exec_json(const char *opts)
{
struct json_object *o;
char *str, *cmd;
char *opts;
opts = malloc(strlen("export status:") + strlen(status) + 1);
- sprintf(opts, "export status:%s", status);
+
+ strcpy(opts, "export status:");
+ strcat(opts, status);
jtasks = task_exec_json(opts);
free(opts);
while (*txt) {
switch (*txt) {
case '"':
- *c = '\\'; c++;
- *c = '"';
- break;
case '$':
- *c = '\\'; c++;
- *c = '$';
- break;
case '&':
+ case '<':
+ case '>':
*c = '\\'; c++;
- *c = '&';
+ *c = *txt;
break;
default:
*c = *txt;
free(opts);
}
-void tw_add(const char *newdesc)
+void tw_add(const char *newdesc, const char *prj, const char *prio)
{
- char *str;
- char *opts;
-
- str = escape(newdesc);
-
- opts = malloc(1
- + strlen(" add \"")
- + strlen(str)
+ char *opts, *eprj;
+
+ eprj = escape(prj);
+
+ opts = malloc(strlen(" add")
+ + strlen(" priority:")
+ + 1
+ + strlen(" project:\\\"")
+ + strlen(eprj)
+ + strlen("\\\"")
+ + strlen(" \"")
+ + strlen(newdesc)
+ strlen("\"")
+ 1);
- sprintf(opts, " add \"%s\"", str);
+
+ strcpy(opts, " add");
+
+ if (prio && strlen(prio) == 1) {
+ strcat(opts, " priority:");
+ strcat(opts, prio);
+ }
+
+ if (eprj && strlen(prj)) {
+ strcat(opts, " project:\\\"");
+ strcat(opts, eprj);
+ strcat(opts, "\\\"");
+ }
+
+ strcat(opts, " \"");
+ strcat(opts, newdesc);
+ strcat(opts, " \"");
tw_exec(opts);
- free(str);
free(opts);
+ free(eprj);
}
void tw_done(const char *uuid)
void tw_modify_project(const char *uuid, const char *newproj);
void tw_modify_priority(const char *uuid, const char *priority);
void tw_done(const char *uuid);
-void tw_add(const char *newdesc);
+void tw_add(const char *newdesc, const char *prj, const char *prio);
void tw_task_list_free(struct task **tasks);
#endif
#include <tw.h>
#include <ui.h>
+static const char *ui_get_priority(GtkComboBox *combo)
+{
+ int prio;
+
+ prio = gtk_combo_box_get_active(combo);
+
+ switch (prio) {
+ case 3:
+ return "H";
+ case 2:
+ return "M";
+ case 1:
+ return "L";
+ default:
+ return "";
+ }
+}
+
void ui_newtask()
{
gint result;
static GtkDialog *diag;
GtkBuilder *builder;
GtkEntry *entry;
- const char *ctxt;
+ const char *desc, *prj, *prio;
+ GtkComboBox *combo;
- log_debug("newtask_clicked_cbk");
+ log_debug("ui_newtask()");
builder = gtk_builder_new();
gtk_builder_add_from_file
result = gtk_dialog_run(diag);
if (result == GTK_RESPONSE_ACCEPT) {
- log_debug("ok");
+ log_debug("ui_newtask(): ok");
+
entry = GTK_ENTRY(gtk_builder_get_object
(builder, "diag_tasknew_description"));
- ctxt = gtk_entry_get_text(entry);
+ desc = gtk_entry_get_text(entry);
+
+ entry = GTK_ENTRY(gtk_builder_get_object
+ (builder, "diag_tasknew_project"));
+ prj = gtk_entry_get_text(entry);
+
+ combo = GTK_COMBO_BOX(gtk_builder_get_object
+ (builder, "diag_tasknew_priority"));
+ prio = ui_get_priority(combo);
- log_debug("%s", ctxt);
+ log_debug("ui_newtask(): description=%s project=%s priority=%d",
+ desc,
+ prj,
+ prio);
- tw_add(ctxt);
+ tw_add(desc, prj, prio);
refresh();
} else {
- log_debug("cancel");
+ log_debug("ui_newtask(): cancel");
}
g_object_unref(G_OBJECT(builder));