コード例 #1
0
ファイル: TaskManager.cs プロジェクト: MichaelAquilina/tomboy
		/// <summary>
		/// Delete the specified task from the system.
		/// </summary>
		public void Delete (Task task)
		{
			if (File.Exists (task.FilePath)) {
				if (archive_dir != null) {
					// FIXME: Instead of moving deleted tasks into the archive dir, move them into a backup dir
					if (!Directory.Exists (archive_dir))
						Directory.CreateDirectory (archive_dir);

					string archive_path =
					        Path.Combine (archive_dir,
					                      Path.GetFileName (task.FilePath));
					if (File.Exists (archive_path))
						File.Delete (archive_path);

					File.Move (task.FilePath, archive_path);
				} else
					File.Delete (task.FilePath);
			}

			string uri = task.Uri;
			if (task_iters.ContainsKey (uri)) {
				Gtk.TreeIter iter = task_iters [uri];
				tasks.Remove (ref iter);
				task_iters.Remove (uri);
				task.Delete ();
			}

			Logger.Log ("Deleting task '{0}'.", task.Summary);

			if (TaskDeleted != null)
				TaskDeleted (this, task);
		}
コード例 #2
0
ファイル: TaskManager.cs プロジェクト: MichaelAquilina/tomboy
		/// <summary>
		/// Gets a Gtk.TreePath for the passed task.
		/// </summary>
		public Gtk.TreePath GetTreePathFromTask(Task task)
		{
			if (!task_iters.ContainsKey(task.Uri))
				throw new Exception("Cannot find task in tree");

			return tasks.GetPath(task_iters[task.Uri]);
		}
コード例 #3
0
		/// <summary>
		/// If the specified task is included inside this note, this
		/// handler will update the task's status representation.
		/// </summary>
		private void OnTaskStatusChanged (Task task)
		{
			if (task.OriginNoteUri == null || task.OriginNoteUri != Note.Uri)
				return;

			// Search through the note looking for the TaskTag so that it can
			// be updated

			// Iterate through the lines looking for tasks
			Gtk.TextIter iter = Buffer.StartIter;
			iter.ForwardLine (); // Move past the note's title

			do {
				TaskTag task_tag = (TaskTag)
				                   Buffer.GetDynamicTag ("task", iter);
				if (task_tag != null) {
					if (task_tag.Uri != task.Uri)
						continue;
					
					task_tag.CompletionDate = task.CompletionDate;
					break;
				}
			} while (iter.ForwardLine());
		}
コード例 #4
0
		/// <summary>
		/// If the renamed task is included inside this note, this
		/// handler will update the task summary in the note buffer.
		/// </summary>
		private void OnTaskRenamed (Task task, string old_title)
		{
			if (task.OriginNoteUri == null || task.OriginNoteUri != Note.Uri)
				return;

			// Search through the note looking for the TaskTag so that it can
			// be renamed

			if (!ContainsText (old_title))
				return;

			// Iterate through the lines looking for tasks
			Gtk.TextIter iter = Buffer.StartIter;
			iter.ForwardLine (); // Move past the note's title

			do {
				TaskTag task_tag = (TaskTag)
				                   Buffer.GetDynamicTag ("task", iter);
				if (task_tag != null) {
					if (task_tag.Uri != task.Uri)
						continue;

					Gtk.TextIter line_start = iter;
					while (line_start.StartsLine () == false)
						line_start.BackwardChar ();
					Gtk.TextIter line_end = iter;
					while (line_end.EndsLine () == false) {
						line_end.ForwardChar ();
					}
//     line_end.ForwardToLineEnd ();

					Buffer.Delete (ref line_start, ref line_end);
					last_removed_tag = task_tag;
					Buffer.Insert (ref line_start,
					               string.Format ("{0}: {1}",
					                              Catalog.GetString ("todo"),
					                              task.Summary));
					break;
				}
			} while (iter.ForwardLine());
		}
コード例 #5
0
		/// <summary>
		/// If the deleted task is included inside this note, this
		/// handler removes the TextTag surrounding the task.
		/// </summary>
		private void OnTaskDeleted (TaskManager manager, Task task)
		{
			if (task.OriginNoteUri == null || task.OriginNoteUri != Note.Uri)
				return;

			// Search through the note looking for the TaskTag so that it can
			// be renamed

			// Iterate through the lines looking for tasks
			Gtk.TextIter iter = Buffer.StartIter;
			iter.ForwardLine (); // Move past the note's title

			do {
				TaskTag task_tag = (TaskTag)
				                   Buffer.GetDynamicTag ("task", iter);
				if (task_tag != null) {
					if (task_tag.Uri != task.Uri)
						continue;

					RemoveTaskFromLine (ref iter);
					break;
				}
			} while (iter.ForwardLine());
		}
コード例 #6
0
		public TaskOptionsDialog(Gtk.Window parent,
		                         Gtk.DialogFlags flags,
		                         Task task)
: base (Catalog.GetString ("Task Options"), parent, flags)
		{
			HasSeparator = false;
			//BorderWidth = 0;
			Resizable = false;
			//Decorated = false;
			this.SetDefaultSize (400, 300);
			this.task = task;

//   Frame frame = new Frame();
//   frame.Shadow = ShadowType.Out;
//   frame.Show();
//   VBox.PackStart (frame, true, true, 0);

			VBox vbox = new VBox (false, 6);
			vbox.BorderWidth = 6;
			vbox.Show ();
			VBox.PackStart (vbox, true, true, 0);
//   frame.Add (vbox);

			ActionArea.Layout = Gtk.ButtonBoxStyle.End;

			accel_group = new Gtk.AccelGroup ();
			AddAccelGroup (accel_group);

//   Gtk.Label l = new Gtk.Label (
//     string.Format (
//      "<span weight=\"bold\">{0}</span>",
//      Catalog.GetString ("Task Options")));
//   l.UseMarkup = true;
//   l.Show ();
//   vbox.PackStart (l, false, false, 0);

			///
			/// Summary
			///
			Gtk.Label l = new Label (Catalog.GetString ("_Summary:"));
			l.Xalign = 0;
			l.Show ();
			vbox.PackStart (l, false, false, 0);

			summary_entry = new Gtk.Entry ();
			l.MnemonicWidget = summary_entry;
			summary_entry.Text = task.Summary;
			summary_entry.Show ();
			vbox.PackStart (summary_entry, false, false, 0);

			///
			/// Details
			///
			l = new Label (Catalog.GetString ("_Details:"));
			l.Xalign = 0;
			l.Show ();
			vbox.PackStart (l, false, false, 0);

			details_text_view = new TextView ();
			l.MnemonicWidget = details_text_view;
			details_text_view.WrapMode = WrapMode.Word;
			details_text_view.Show ();

			ScrolledWindow sw = new ScrolledWindow ();
			sw.ShadowType = Gtk.ShadowType.EtchedIn;
			sw.Add (details_text_view);
			sw.Show ();

			vbox.PackStart (sw, true, true, 0);

			///
			/// Completion Checkbox
			///
			HBox hbox = new Gtk.HBox (false, 4);

			completed_check_button = new Gtk.CheckButton (
			        task.IsComplete ?
			        Catalog.GetString ("_Completed:") :
			        Catalog.GetString ("_Complete"));
			if (task.IsComplete)
				completed_check_button.Active = true;
			completed_check_button.UseUnderline = true;
			completed_check_button.Toggled += OnCompletedCheckButtonToggled;
			completed_check_button.Show ();
			hbox.PackStart (completed_check_button, false, false, 0);

			completed_label = new Gtk.Label (
			        task.IsComplete ?
			        GuiUtils.GetPrettyPrintDate (task.CompletionDate, true) :
			        string.Empty);
			completed_label.Xalign = 0;
			completed_label.Show ();
			hbox.PackStart (completed_label, true, true, 0);

			hbox.Show ();
			vbox.PackStart (hbox, false, false, 0);

			///
			/// Due Date
			///
			hbox = new HBox (false, 4);
			due_date_check_button = new CheckButton (Catalog.GetString ("Due Date:"));
			if (task.DueDate != DateTime.MinValue)
				due_date_check_button.Active = true;
			due_date_check_button.Toggled += OnDueDateCheckButtonToggled;
			due_date_check_button.Show ();
			hbox.PackStart (due_date_check_button, false, false, 0);

			due_date_button =
			        new Gtk.Extras.DateButton (task.DueDate, false);
			if (task.DueDate == DateTime.MinValue)
				due_date_button.Sensitive = false;
			due_date_button.Show ();
			hbox.PackStart (due_date_button, false, false, 0);

			// Spacer
			hbox.PackStart (new Gtk.Label (string.Empty), true, true, 0);

			hbox.Show ();
			vbox.PackStart (hbox, false, false, 0);

			///
			/// Priority
			///
			hbox = new HBox (false, 4);
			priority_check_button = new CheckButton (Catalog.GetString ("Priority:"));
			if (task.Priority != TaskPriority.Undefined)
				priority_check_button.Active = true;
			priority_check_button.Toggled += OnPriorityCheckButtonToggled;
			priority_check_button.Show ();
			hbox.PackStart (priority_check_button, false, false, 0);

			priority_combo_box = ComboBox.NewText ();
			priority_combo_box.AppendText (Catalog.GetString ("None"));
			priority_combo_box.AppendText (Catalog.GetString ("Low"));
			priority_combo_box.AppendText (Catalog.GetString ("Normal"));
			priority_combo_box.AppendText (Catalog.GetString ("High"));
			if (task.Priority == TaskPriority.Undefined)
				priority_combo_box.Sensitive = false;
			priority_combo_box.Active = (int) task.Priority;
			priority_combo_box.Changed += OnPriorityComboBoxChanged;
			priority_combo_box.Show ();
			hbox.PackStart (priority_combo_box, false, false, 0);

			// Spacer
			hbox.PackStart (new Gtk.Label (string.Empty), true, true, 0);
			hbox.Show ();
			vbox.PackStart (hbox, false, false, 0);

			AddButton (Gtk.Stock.Cancel, Gtk.ResponseType.Cancel, false);
			AddButton (Gtk.Stock.Save, Gtk.ResponseType.Ok, true);

//   if (parent != null)
//    TransientFor = parent;

//   if ((int) (flags & Gtk.DialogFlags.Modal) != 0)
//    Modal = true;

//   if ((int) (flags & Gtk.DialogFlags.DestroyWithParent) != 0)
//    DestroyWithParent = true;
		}
コード例 #7
0
		public TomboyTaskMenuItem (Task task)
: base ()
		{
			this.task = task;

			summary = new Label ();
			summary.Markup = task.Summary;
			summary.UseUnderline = false;
			summary.UseMarkup = true;
			summary.Xalign = 0;

			summary.Show ();
			Add (summary);

			check_button = new BetterCheckButton ();
			check_button.Toggled += OnCheckButtonToggled;
			Image = check_button;
		}
コード例 #8
0
ファイル: TaskManager.cs プロジェクト: MichaelAquilina/tomboy
		void OnTaskStatusChanged (Task task)
		{
			EmitRowChangedForTask (task);

			if (TaskStatusChanged != null)
				TaskStatusChanged (task);
		}
コード例 #9
0
ファイル: TaskManager.cs プロジェクト: MichaelAquilina/tomboy
		void OnTaskRenamed (Task task, string old_summary)
		{
			EmitRowChangedForTask (task);

			if (TaskRenamed != null)
				TaskRenamed (task, old_summary);
		}
コード例 #10
0
ファイル: TaskManager.cs プロジェクト: MichaelAquilina/tomboy
		void EmitRowChangedForTask (Task task)
		{
			if (task_iters.ContainsKey (task.Uri)) {
				Gtk.TreeIter iter = task_iters [task.Uri];

				tasks.EmitRowChanged (tasks.GetPath (iter), iter);
			}
		}
コード例 #11
0
		/// <summary>
		/// Perform a search of the two tasks based on the
		/// SortColumn specified.
		/// </summary>
		int CompareTasks (Task a, Task b, SortColumn sort_type)
		{
			if (a == null)
				return -1;
			if (b == null)
				return 1;

			try {
				switch (sort_column) {
				case SortColumn.CompletionDate:
					return DateTime.Compare (a.CompletionDate, b.CompletionDate);
				case SortColumn.DueDate:
					return DateTime.Compare (a.DueDate, b.DueDate);
//    case SortColumn.OriginNote:
//     return a.OriginNoteUri.CompareTo (b.OriginNoteUri);
				case SortColumn.Priority:
					return (int) a.Priority - (int) b.Priority;
				case SortColumn.Summary:
					return a.Summary.CompareTo (b.Summary);
				}
			} catch (Exception e) {
				Logger.Warn ("Exception in TaskListWindow.CompareTasks ({0}): {1}",
				             sort_type, e.Message);
			}

			return -1;
		}
コード例 #12
0
		void OnTaskStatusChanged (Task task)
		{
			// FIXME: Eventually update the status bar to include the number of completed notes
		}
コード例 #13
0
		void OnTaskDeleted (TaskManager manager, Task task)
		{
			int cnt = manager.Tasks.IterNChildren ();
			UpdateTaskCount (cnt);
		}