[tasque] Flag added to toggle timer when task is marked as done.



commit f7cc72b3ead56ebc46eb5d401342641f7da6f777
Author: Mario Carrion <mario carrion mx>
Date:   Mon Apr 19 17:31:04 2010 -0400

    Flag added to toggle timer when task is marked as done.

 src/TaskTreeView.cs |   16 ++++++++++++++--
 1 files changed, 14 insertions(+), 2 deletions(-)
---
diff --git a/src/TaskTreeView.cs b/src/TaskTreeView.cs
index b9f2569..efeeadc 100644
--- a/src/TaskTreeView.cs
+++ b/src/TaskTreeView.cs
@@ -21,6 +21,7 @@ namespace Tasque
 		private Gtk.TreeModelFilter modelFilter;
 		private ICategory filterCategory;	
 		private ITask taskBeingEdited = null;
+		private bool toggled;
 
 		private static string status;
 		
@@ -250,6 +251,9 @@ namespace Tasque
 
 		void CellRenderer_EditingStarted (object o, EditingStartedArgs args)
 		{
+			if (!toggled)
+				return;
+
 			Gtk.TreeIter iter;
 			Gtk.TreePath path = new Gtk.TreePath (args.Path);
 			if (!Model.GetIter (out iter, path))
@@ -269,10 +273,11 @@ namespace Tasque
 			renderer.EditingStarted += CellRenderer_EditingStarted;
 			// Canceled: timer can continue.
 			renderer.EditingCanceled += (o, args) => {
-				if (taskBeingEdited != null) {
+				if (toggled && taskBeingEdited != null) {
 					taskBeingEdited.Inactivate ();
 					InactivateTimer.ToggleTimer (taskBeingEdited);
 					taskBeingEdited = null;
+					toggled = false;
 				}
 			};
 			// Edited: after calling the delegate the timer can continue.
@@ -280,10 +285,11 @@ namespace Tasque
 				if (handler != null)
 					handler (o, args);
 
-				if (taskBeingEdited != null) {
+				if (toggled && taskBeingEdited != null) {
 					taskBeingEdited.Inactivate ();
 					InactivateTimer.ToggleTimer (taskBeingEdited);
 					taskBeingEdited = null;
+					toggled = false;
 				}
 			};
 		}
@@ -466,6 +472,9 @@ namespace Tasque
 		{
 			Gtk.CellRendererCombo crc = renderer as Gtk.CellRendererCombo;
 			ITask task = Model.GetValue (iter, 0) as ITask;
+			if (task == null)
+				return;
+			
 			DateTime date = task.State == TaskState.Completed ?
 									task.CompletionDate :
 									task.DueDate;
@@ -633,6 +642,7 @@ namespace Tasque
 					InactivateTimer timer =
 						new InactivateTimer (this, iter, task, (uint) timeout);
 					timer.StartTimer ();
+					toggled = true;
 				}
 			} else {
 				status = Catalog.GetString ("Action Canceled");
@@ -760,6 +770,8 @@ namespace Tasque
 				}
 			}
 			
+			Console.WriteLine ("task.State {0}", task.State);
+			
 			if (task.State == TaskState.Completed) {
 				// Modify the completion date
 				task.CompletionDate = newDate;



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]