/// <summary> /// Create a new task using "New Task NNN" format /// </summary> void OnNewTask(object sender, EventArgs args) { int new_num = manager.Tasks.IterNChildren(); string summary; while (true) { summary = String.Format(Catalog.GetString("New Task {0}"), ++new_num); if (manager.Find(summary) == null) { break; } } try { Task newTask = manager.Create(summary); tree.SetCursor(manager.GetTreePathFromTask(newTask), summary_column, true); } catch (Exception e) { Logger.Error("Could not create a new task with summary: {0}:{1}", summary, e.Message); } }
void ApplyTaskTagToBlock(ref Gtk.TextIter start, Gtk.TextIter end) { Gtk.TextIter line_end = start; while (line_end.EndsLine() == false) { line_end.ForwardChar(); } // For some reason, the above code behaves like it should (i.e., // without advancing to the next line). The line below that's // commented out doesn't work. It ends up advancing the iter to // the end of the next line. Very strange! // line_end.ForwardToLineEnd (); TaskTag task_tag = GetTaskTagFromLineIter(ref start); if (task_tag != null) { Buffer.RemoveTag(task_tag, start, line_end); } else { task_tag = last_removed_tag; } string text = start.GetText(line_end); // Logger.Debug ("Evaluating with regex: {0}", text); TaskManager task_mgr = TasksApplicationAddin.DefaultTaskManager; Task task; Match match = regex.Match(text); if (match.Success) { string summary = GetTaskSummaryFromLine(text); if (task_tag == null) { task = task_mgr.Create(summary); task.QueueSave(true); task.OriginNoteUri = Note.Uri; task_tag = (TaskTag) Note.TagTable.CreateDynamicTag("task"); task_tag.Uri = task.Uri; } else { task = task_mgr.FindByUri(task_tag.Uri); if (task != null) { task.Summary = summary; } else { Logger.Debug("FIXME: Add code to remove the task tag if this case is hit"); } } Buffer.ApplyTag(task_tag, start, line_end); last_removed_tag = null; } else if (task_tag != null) { // This task should be deleted task = task_mgr.FindByUri(task_tag.Uri); if (task != null) { task_mgr.Delete(task); } last_removed_tag = null; } }