+static GtkTextView *w_note;
+static GtkEntry *w_description;
+static GtkEntry *w_project;
+static GtkComboBox *w_priority;
+static GtkButton *w_tasksave_btn;
+static GtkButton *w_taskremove_btn;
+static GtkButton *w_taskdone_btn;
+static GtkButton *w_taskcancel_btn;
+static GtkLabel *w_tasktags;
+
+static struct task *current_task;
+
+static void enable(int enable)
+{
+ GtkTextBuffer *buf;
+
+ gtk_widget_set_sensitive(GTK_WIDGET(w_tasksave_btn), enable);
+ gtk_widget_set_sensitive(GTK_WIDGET(w_taskdone_btn), enable);
+
+ if (current_task && current_task->recur) {
+ gtk_widget_set_sensitive(GTK_WIDGET(w_taskremove_btn), FALSE);
+ gtk_widget_set_tooltip_text
+ (GTK_WIDGET(w_taskremove_btn),
+ "The removal of recurrent tasks is not supported due "
+ "to the taskwarrior bug TW-638");
+ gtk_widget_set_has_tooltip(GTK_WIDGET(w_taskremove_btn), TRUE);
+ } else {
+ gtk_widget_set_sensitive(GTK_WIDGET(w_taskremove_btn), enable);
+ gtk_widget_set_has_tooltip(GTK_WIDGET(w_taskremove_btn), FALSE);
+ }
+
+ gtk_widget_set_sensitive(GTK_WIDGET(w_taskcancel_btn), enable);
+
+ buf = gtk_text_view_get_buffer(w_note);
+ if (!enable)
+ gtk_text_buffer_set_text(buf, "", 0);
+ gtk_widget_set_sensitive(GTK_WIDGET(w_note), enable);
+
+ if (!enable)
+ gtk_entry_set_text(w_description, "");
+ gtk_widget_set_sensitive(GTK_WIDGET(w_description), enable);
+
+ if (!enable)
+ gtk_entry_set_text(w_project, "");
+ gtk_widget_set_sensitive(GTK_WIDGET(w_project), enable);
+
+ if (!enable)
+ gtk_label_set_label(w_tasktags, "");
+
+ if (!enable)
+ gtk_combo_box_set_active(w_priority, 0);
+ gtk_widget_set_sensitive(GTK_WIDGET(w_priority), enable);
+}
+
+static int tasksave_clicked_cbk(GtkButton *btn, gpointer data)
+{
+ struct task *task;
+ GtkTextBuffer *buf;
+ char *txt, *pri;
+ GtkTextIter sIter, eIter;
+ const char *ctxt;
+ int priority;
+
+ log_fct_enter();
+
+ task = current_task;
+
+ log_fct("%d", task->id);
+
+ buf = gtk_text_view_get_buffer(w_note);
+
+ gtk_text_buffer_get_iter_at_offset(buf, &sIter, 0);
+ gtk_text_buffer_get_iter_at_offset(buf, &eIter, -1);
+ txt = gtk_text_buffer_get_text(buf, &sIter, &eIter, TRUE);
+
+ log_debug("note=%s", txt);
+
+ if (!task->note || strcmp(txt, task->note))
+ note_put(task->uuid, txt);
+
+ ctxt = gtk_entry_get_text(w_description);
+ if (!task->description || strcmp(ctxt, task->description))
+ tw_modify_description(task->uuid, ctxt);
+
+ ctxt = gtk_entry_get_text(w_project);
+ if (!task->project || strcmp(ctxt, task->project))
+ tw_modify_project(task->uuid, ctxt);
+
+ priority = gtk_combo_box_get_active(w_priority);
+ log_debug("priority: %d", priority);
+
+ switch (priority) {
+ case 3:
+ pri = "H";
+ break;
+ case 2:
+ pri = "M";
+ break;
+ case 1:
+ pri = "L";
+ break;
+ default:
+ pri = "";
+ }
+
+ if (strcmp(task->priority, pri))
+ tw_modify_priority(task->uuid, pri);
+
+ refresh();
+
+ return FALSE;
+}
+