Example #1
0
		public static TaskListWindow GetInstance (TaskManager manager)
		{
			if (instance == null)
				instance = new TaskListWindow (manager);
			System.Diagnostics.Debug.Assert (
			        instance.manager == manager,
			        "Multiple TaskManagers not supported");
			return instance;
		}
		public override void Initialize ()
		{
			Logger.Debug ("TasksApplicationAddin.Initialize ()");

			if (manager == null) {
				lock (locker) {
					if (manager == null) {
						manager = new TaskManager (
						        Path.Combine (Tomboy.DefaultNoteManager.NoteDirectoryPath, "Tasks"));
					}
				}

				///
				/// Add a "To Do List" to Tomboy's Tray Icon Menu
				///
				action_group = new Gtk.ActionGroup ("Tasks");
				action_group.Add (new Gtk.ActionEntry [] {
					new Gtk.ActionEntry ("ToolsMenuAction", null,
					Catalog.GetString ("_Tools"), null, null, null),
					new Gtk.ActionEntry ("OpenToDoListAction", null,
					Catalog.GetString ("To Do List"), null, null,
					delegate { OnOpenToDoListAction (); })
				});

				//    tray_icon_ui = Tomboy.ActionManager.UI.AddUiFromString (@"
				//     <ui>
				//      <popup name='TrayIconMenu' action='TrayIconMenuAction'>
				//       <menuitem name='OpenToDoList' action='OpenToDoListAction' />
				//      </popup>
				//     </ui>
				//    ");

				tools_menu_ui = Tomboy.ActionManager.UI.AddUiFromString (@"
				                <ui>
				                <menubar name='MainWindowMenubar'>
				                <placeholder name='MainWindowMenuPlaceholder'>
				                <menu name='ToolsMenu' action='ToolsMenuAction'>
				                <menuitem name='OpenToDoList' action='OpenToDoListAction' />
				                </menu>
				                </placeholder>
				                </menubar>
				                </ui>
				                ");

				Tomboy.ActionManager.UI.InsertActionGroup (action_group, 0);

				Tomboy.DefaultNoteManager.NoteDeleted += OnNoteDeleted;

				tomboy_tray_menu = GetTomboyTrayMenu ();
				tomboy_tray_menu.Shown += OnTomboyTrayMenuShown;
				tomboy_tray_menu.Hidden += OnTomboyTrayMenuHidden;

				initialized = true;
			}
		}
Example #3
0
		/// <summary>
		/// Construct a task object.
		/// </summary>
		Task (TaskData data, string filepath, TaskManager manager)
		{
			this.data = data;
			this.filepath = filepath;
			this.manager = manager;

			save_timeout = new InterruptableTimeout ();
			save_timeout.Timeout += SaveTimeout;

			// If an OriginNoteUri exists, make sure the note
			// actually exists.  If it doesn't, clean it up
			string origin_note_uri = OriginNoteUri;
			if (origin_note_uri != null && origin_note_uri != string.Empty) {
				Note note =
				        Tomboy.DefaultNoteManager.FindByUri (origin_note_uri);
				if (note == null)
					OriginNoteUri = String.Empty;
			}
		}
Example #4
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());
		}
Example #5
0
		/// <summary>
		/// Load from an existing Task...
		/// </summary>
		public static Task Load (string read_file, TaskManager manager)
		{
			TaskData data = TaskArchiver.Read (read_file, UrlFromPath (read_file));
			Task task = CreateExistingTask (data, read_file, manager);

			return task;
		}
Example #6
0
		public static Task CreateExistingTask (TaskData data,
		                                       string filepath,
		                                       TaskManager manager)
		{
			if (data.CreateDate == DateTime.MinValue)
				data.CreateDate = File.GetCreationTime (filepath);
			if (data.LastChangeDate == DateTime.MinValue)
				data.LastChangeDate = File.GetLastWriteTime (filepath);
			return new Task (data, filepath, manager);
		}
Example #7
0
		public static Task CreateNewTask (string summary,
		                                  string filepath,
		                                  TaskManager manager)
		{
			TaskData data = new TaskData (UrlFromPath (filepath));
			data.Summary = summary;
			data.CreateDate = DateTime.Now;
			data.LastChangeDate = data.CreateDate;
			return new Task (data, filepath, manager);
		}
		public override void Shutdown ()
		{
			Logger.Debug ("TasksApplicationAddin.Shutdown ()");
			manager.Shutdown ();
			manager = null;

			try {
				Tomboy.ActionManager.UI.RemoveActionGroup (action_group);
			} catch {}
			try {
				Tomboy.ActionManager.UI.RemoveUi (tray_icon_ui);
					Tomboy.ActionManager.UI.RemoveUi (tools_menu_ui);
				} catch {}

				tomboy_tray_menu.Shown -= OnTomboyTrayMenuShown;
		tomboy_tray_menu.Hidden -= OnTomboyTrayMenuHidden;

		initialized = false;
	}
Example #9
0
		protected TaskListWindow (TaskManager manager)
: base (Catalog.GetString ("To Do List"))
		{
			this.manager = manager;
			this.IconName = "tomboy";
			this.SetDefaultSize (500, 300);
			this.sort_column = SortColumn.CompletionDate;

			AddAccelGroup (Tomboy.ActionManager.UI.AccelGroup);

			action_group = new Gtk.ActionGroup ("TaskList");
			action_group.Add (new Gtk.ActionEntry [] {
				new Gtk.ActionEntry ("TaskListFileMenuAction", null,
				Catalog.GetString ("_File"), null, null, null),

				new Gtk.ActionEntry ("NewTaskAction", Gtk.Stock.New,
				Catalog.GetString ("New _Task"), "<Control>T",
				Catalog.GetString ("Create a new task"), null),

				new Gtk.ActionEntry ("OpenTaskAction", String.Empty,
				Catalog.GetString ("_Options..."), "<Control>O",
				Catalog.GetString ("Open the selected task"), null),

				new Gtk.ActionEntry ("CloseTaskListWindowAction", Gtk.Stock.Close,
				Catalog.GetString ("_Close"), "<Control>W",
				Catalog.GetString ("Close this window"), null),

				new Gtk.ActionEntry ("TaskListEditMenuAction", null,
				Catalog.GetString ("_Edit"), null, null, null),

				new Gtk.ActionEntry ("DeleteTaskAction", Gtk.Stock.Preferences,
				Catalog.GetString ("_Delete"), "Delete",
				Catalog.GetString ("Delete the selected task"), null),

				new Gtk.ActionEntry ("OpenOriginNoteAction", null,
				Catalog.GetString ("Open Associated _Note"), null,
				Catalog.GetString ("Open the note containing the task"), null),

				new Gtk.ActionEntry ("TaskListViewMenuAction", null,
				Catalog.GetString ("_View"), null, null, null),

				new Gtk.ActionEntry ("TaskListHelpMenuAction", null,
				Catalog.GetString ("_Help"), null, null, null),

				new Gtk.ActionEntry ("ShowTaskHelpAction", Gtk.Stock.Help,
				Catalog.GetString ("_Contents"), "F1",
				Catalog.GetString ("Tasks Help"), null)
			});

			action_group.Add (new Gtk.ToggleActionEntry [] {
				new Gtk.ToggleActionEntry ("ShowCompletedTasksAction", null,
				Catalog.GetString ("Show _Completed Tasks"), null,
				Catalog.GetString ("Show completed tasks in the list"), null, true),

				new Gtk.ToggleActionEntry ("ShowDueDateColumnAction", null,
				Catalog.GetString ("Show _Due Date Column"), null,
				Catalog.GetString ("Show the due date column in the list"), null, true),

				new Gtk.ToggleActionEntry ("ShowPriorityColumnAction", null,
				Catalog.GetString ("Show _Priority Column"), null,
				Catalog.GetString ("Show the priority column in the list"), null, true)
			});

			Tomboy.ActionManager.UI.InsertActionGroup (action_group, 0);

			menu_bar = CreateMenuBar ();

			MakeTasksTree ();
			tree.Show ();

			// Update on changes to tasks
			TaskManager.TaskAdded += OnTaskAdded;
			TaskManager.TaskDeleted += OnTaskDeleted;
			TaskManager.TaskStatusChanged += OnTaskStatusChanged;

			tasks_sw = new Gtk.ScrolledWindow ();
			tasks_sw.ShadowType = Gtk.ShadowType.In;
			tasks_sw.VscrollbarPolicy = Gtk.PolicyType.Automatic;
			tasks_sw.HscrollbarPolicy = Gtk.PolicyType.Automatic;

			// Reign in the window size if there are notes with long
			// names, or a lot of notes...

			Gtk.Requisition tree_req = tree.SizeRequest ();
			if (tree_req.Height > 420)
				tasks_sw.HeightRequest = 420;

			if (tree_req.Width > 480)
				tasks_sw.WidthRequest = 480;

			tasks_sw.Add (tree);
			tasks_sw.Show ();

			task_count = new Gtk.Label ();
			task_count.Xalign = 0;
			task_count.Show ();

			Gtk.HBox status_box = new Gtk.HBox (false, 8);
			status_box.PackStart (task_count, true, true, 0);
			status_box.Show ();

			Gtk.VBox vbox = new Gtk.VBox (false, 8);
			vbox.BorderWidth = 6;
			vbox.PackStart (tasks_sw, true, true, 0);
			vbox.PackStart (status_box, false, false, 0);
			vbox.Show ();

			// Use another VBox to place the MenuBar
			// right at thetop of the window.
			content_vbox = new Gtk.VBox (false, 0);
			content_vbox.PackStart (menu_bar, false, false, 0);
			content_vbox.PackStart (vbox, true, true, 0);
			content_vbox.Show ();

			this.Add (content_vbox);
			this.DeleteEvent += OnDelete;
			this.KeyPressEvent += OnKeyPressed; // For Escape

			SetUpTreeModel ();
		}
Example #10
0
		void OnTaskDeleted (TaskManager manager, Task task)
		{
			int cnt = manager.Tasks.IterNChildren ();
			UpdateTaskCount (cnt);
		}