tasque r29 - in branches/cache: . src src/Backends/Rtm



Author: calvinrg
Date: Fri Mar 14 21:35:42 2008
New Revision: 29
URL: http://svn.gnome.org/viewvc/tasque?rev=29&view=rev

Log:
* src/TaskTreeView.cs, src/PreferencesDialog.cs, src/NoteDialog.cs,
  src/TaskCalendar.cs, src/Application.cs,
  src/Backends/Rtm/RtmPreferencesWidget.cs, src/AllCategory.cs,
  src/CompletedTaskGroup.cs, src/Category.cs, src/TaskGroup.cs,
  src/TaskWindow.cs, src/RemoteControl.cs: Removed all (or most)
  references to ITask, ICategory, and IBackend to build locacl cache

Modified:
   branches/cache/ChangeLog
   branches/cache/src/AllCategory.cs
   branches/cache/src/Application.cs
   branches/cache/src/Backends/Rtm/RtmPreferencesWidget.cs
   branches/cache/src/Category.cs
   branches/cache/src/CompletedTaskGroup.cs
   branches/cache/src/NoteDialog.cs
   branches/cache/src/PreferencesDialog.cs
   branches/cache/src/RemoteControl.cs
   branches/cache/src/TaskCalendar.cs
   branches/cache/src/TaskGroup.cs
   branches/cache/src/TaskTreeView.cs
   branches/cache/src/TaskWindow.cs

Modified: branches/cache/src/AllCategory.cs
==============================================================================
--- branches/cache/src/AllCategory.cs	(original)
+++ branches/cache/src/AllCategory.cs	Fri Mar 14 21:35:42 2008
@@ -7,7 +7,7 @@
 
 namespace Tasque
 {
-	public class AllCategory : ICategory
+	public class AllCategory : Category
 	{
 		// A "set" of categories specified by the user to show when the "All"
 		// category is selected in the TaskWindow.  If the list is empty, tasks
@@ -15,7 +15,7 @@
 		// specified lists will be shown.
 		List<string> categoriesToHide;
 		
-		public AllCategory ()
+		public AllCategory () : base(Application.LocalCache, Catalog.GetString ("All"))
 		{
 			Preferences preferences = Application.Preferences;
 			categoriesToHide =
@@ -23,16 +23,11 @@
 			Application.Preferences.SettingChanged += OnSettingChanged;
 		}
 		
-		public string Name
-		{
-			get { return Catalog.GetString ("All"); }
-		}
-		
-		public bool ContainsTask(ITask task)
+		public new bool ContainsTask(Task task)
 		{
 			// Filter out tasks based on the user's preferences of which
 			// categories should be displayed in the AllCategory.
-			ICategory category = task.Category;
+			Category category = task.Category;
 			if (category == null)
 				return true;
 			

Modified: branches/cache/src/Application.cs
==============================================================================
--- branches/cache/src/Application.cs	(original)
+++ branches/cache/src/Application.cs	Fri Mar 14 21:35:42 2008
@@ -60,7 +60,7 @@
 		private Egg.TrayIcon trayIcon;	
 		private Preferences preferences;
 		private EventBox eb;
-		private IBackend backend;
+		//private IBackend backend;
 		private PreferencesDialog preferencesDialog;
 		private LocalCache localCache;
 		
@@ -68,10 +68,11 @@
 		/// Keep track of the available backends.  The key is the Type name of
 		/// the backend.
 		/// </value>
-		private Dictionary<string, IBackend> availableBackends;
+		//private Dictionary<string, IBackend> availableBackends;
 		
-		private IBackend customBackend;
+		//private IBackend customBackend;
 
+		/*
 		public static IBackend Backend
 		{
 			get { return Application.Instance.backend; }
@@ -110,11 +111,12 @@
 				}
 			}
 		}
+		*/
 		
 		public static List<IBackend> AvailableBackends
 		{
 			get {
-				return new List<IBackend> (Application.Instance.availableBackends.Values);
+				return null; //new List<IBackend> (Application.Instance.availableBackends.Values);
 			}
 //			get { return Application.Instance.availableBackends; }
 		}
@@ -186,13 +188,14 @@
 				            e.Message);
 			}
 			
+/*
 			// Read the args and check to see if a specific backend is specified
 			if (args.Length > 0) {
-Logger.Debug ("args [0]: {0}", args [0]);
+				Logger.Debug ("args [0]: {0}", args [0]);
 				// We're only looking at the first argument
 				string potentialBackendClassName = args [0];
 				
-				customBackend = null;
+				//customBackend = null;
 				Assembly asm = Assembly.GetCallingAssembly ();
 				try {
 					customBackend = (IBackend)
@@ -205,7 +208,7 @@
 			
 			// Discover all available backends
 			LoadAvailableBackends ();
-
+*/
 			GLib.Idle.Add(InitializeIdle);
 		}
 		
@@ -214,7 +217,7 @@
 		/// Tasque.exe and then for other DLLs in the same directory Tasque.ex
 		/// resides.
 		/// </summary>
-		private void LoadAvailableBackends ()
+/*		private void LoadAvailableBackends ()
 		{
 			availableBackends = new Dictionary<string,IBackend> ();
 			
@@ -298,12 +301,13 @@
 			
 			return backends;
 		}
-
+*/
 		private bool InitializeIdle()
 		{
 			localCache = new LocalCache ();
 			localCache.Initialize ();
 			
+			/*
 			if (customBackend != null) {
 				Application.Backend = customBackend;
 			} else {
@@ -317,9 +321,10 @@
 					Application.Backend = availableBackends [backendTypeString];
 				}
 			}
-			
+			*/
 			SetupTrayIcon ();
 			
+			/*
 			if (backend == null) {
 				// Pop open the preferences dialog so the user can choose a
 				// backend service to use.
@@ -327,6 +332,8 @@
 			} else {
 				TaskWindow.ShowWindow();
 			}
+			*/
+			TaskWindow.ShowWindow();
 			
 			return false;
 		}
@@ -428,16 +435,18 @@
 		private void OnQuit (object sender, EventArgs args)
 		{
 			Logger.Info ("OnQuitAction called - terminating application");
+			/*
 			if (backend != null) {
 				backend.Cleanup();
 			}
+			*/
 			TaskWindow.SavePosition();			
 			program.Quit (); // Should this be called instead?
 		}
 		
 		private void OnRefreshAction (object sender, EventArgs args)
 		{
-			Application.Backend.Refresh();
+			//Application.Backend.Refresh();
 		}
 		
 		
@@ -454,14 +463,16 @@
 					(Catalog.GetString ("Show Tasks ..."));
 
 				showTasksItem.Image = new Gtk.Image(Utilities.GetIcon ("tasque-16", 16));
-				showTasksItem.Sensitive = backend != null && backend.Initialized;
+				//showTasksItem.Sensitive = backend != null && backend.Initialized;
+				showTasksItem.Sensitive = true;
 				showTasksItem.Activated += OnShowTaskWindow;
 				popupMenu.Add (showTasksItem);
 				
 				ImageMenuItem newTaskItem = new ImageMenuItem
 					(Catalog.GetString ("New Task ..."));
 				newTaskItem.Image = new Gtk.Image (Gtk.Stock.New, IconSize.Menu);
-				newTaskItem.Sensitive = backend != null && backend.Initialized;
+//				newTaskItem.Sensitive = backend != null && backend.Initialized;
+				newTaskItem.Sensitive = true;
 				newTaskItem.Activated += OnNewTask;
 				popupMenu.Add (newTaskItem);
 
@@ -483,7 +494,8 @@
 					(Catalog.GetString ("Refresh Tasks"));
 
 				refreshAction.Image = new Gtk.Image(Utilities.GetIcon (Gtk.Stock.Execute, 16));
-				refreshAction.Sensitive = backend != null && backend.Initialized;
+//				refreshAction.Sensitive = backend != null && backend.Initialized;
+				refreshAction.Sensitive = true;
 				refreshAction.Activated += OnRefreshAction;
 				popupMenu.Add (refreshAction);
 				

Modified: branches/cache/src/Backends/Rtm/RtmPreferencesWidget.cs
==============================================================================
--- branches/cache/src/Backends/Rtm/RtmPreferencesWidget.cs	(original)
+++ branches/cache/src/Backends/Rtm/RtmPreferencesWidget.cs	Fri Mar 14 21:35:42 2008
@@ -99,7 +99,7 @@
 		
 		private void OnAuthButtonClicked (object sender, EventArgs args)
 		{
-			RtmBackend rtmBackend = Application.Backend as RtmBackend;
+			RtmBackend rtmBackend = null; //Application.Backend as RtmBackend;
 			if (rtmBackend != null) {
 				if (!isAuthorized && !authRequested) {
 					string url = rtmBackend.GetAuthUrl();

Modified: branches/cache/src/Category.cs
==============================================================================
--- branches/cache/src/Category.cs	(original)
+++ branches/cache/src/Category.cs	Fri Mar 14 21:35:42 2008
@@ -54,8 +54,8 @@
 			this.cache = cache;
 			this.id = id;
 		}
-
-		public bool ContainsTask(ITask task)
+		
+		public bool ContainsTask(Task task)
 		{
 			if(task.Category is Category)
 				return ((task.Category as Category).ID == id);

Modified: branches/cache/src/CompletedTaskGroup.cs
==============================================================================
--- branches/cache/src/CompletedTaskGroup.cs	(original)
+++ branches/cache/src/CompletedTaskGroup.cs	Fri Mar 14 21:35:42 2008
@@ -21,7 +21,7 @@
 	
 	public class CompletedTaskGroup : TaskGroup
 	{
-		ICategory selectedCategory;
+		Category selectedCategory;
 		HScale rangeSlider;
 		ShowCompletedRange currentRange;
 		
@@ -94,7 +94,7 @@
 			if (showCompletedTasks == false)
 				return false;
 			
-			ITask task = model.GetValue (iter, 0) as ITask;
+			Task task = model.GetValue (iter, 0) as Task;
 			if (task == null || task.State != TaskState.Completed)
 				return false;
 			
@@ -133,19 +133,19 @@
 			Refilter (selectedCategory);
 		}
 		
-		protected ICategory GetSelectedCategory ()
+		protected Category GetSelectedCategory ()
 		{
-			ICategory foundCategory = null;
+			Category foundCategory = null;
 			
 			string cat = Application.Preferences.Get (
 							Preferences.SelectedCategoryKey);
 			if (cat != null) {
 				TreeIter iter;
-				TreeModel model = Application.Backend.Categories;
+				TreeModel model = Application.LocalCache.Categories;
 				
 				if (model.GetIterFirst (out iter) == true) {
 					do {
-						ICategory category = model.GetValue (iter, 0) as ICategory;
+						Category category = model.GetValue (iter, 0) as Category;
 						if (category.Name.CompareTo (cat) == 0) {
 							foundCategory = category;
 							break;
@@ -265,8 +265,8 @@
 										 Gtk.TreeIter a,
 										 Gtk.TreeIter b)
 		{
-			ITask taskA = model.GetValue (a, 0) as ITask;
-			ITask taskB = model.GetValue (b, 0) as ITask;
+			Task taskA = model.GetValue (a, 0) as Task;
+			Task taskB = model.GetValue (b, 0) as Task;
 			
 			if (taskA == null || taskB == null)
 				return 0;

Modified: branches/cache/src/NoteDialog.cs
==============================================================================
--- branches/cache/src/NoteDialog.cs	(original)
+++ branches/cache/src/NoteDialog.cs	Fri Mar 14 21:35:42 2008
@@ -9,12 +9,12 @@
 {
 	public class NoteDialog : Gtk.Dialog
 	{
-		private ITask task;
+		private Task task;
 		
 		Gtk.VBox targetVBox;
 		
 		#region Constructors
-		public NoteDialog (Gtk.Window parentWindow, ITask task)
+		public NoteDialog (Gtk.Window parentWindow, Task task)
 			: base ()
 		{
 			this.ParentWindow = parentWindow.GdkWindow;
@@ -79,7 +79,7 @@
 		#endregion // Constructors
 		
 		#region Properties
-		public ITask Task
+		public Task Task
 		{
 			get { return task; }
 		}

Modified: branches/cache/src/PreferencesDialog.cs
==============================================================================
--- branches/cache/src/PreferencesDialog.cs	(original)
+++ branches/cache/src/PreferencesDialog.cs	Fri Mar 14 21:35:42 2008
@@ -112,6 +112,7 @@
 			backendPage = null;
 			backendPageId = -1;
 			
+			/*
 			if (Application.Backend != null) {
 				backendPage = Application.Backend.GetPreferencesWidget ();
 				if (backendPage != null) {
@@ -125,7 +126,7 @@
 						notebook.AppendPage (backendPage, l);
 				}
 			}
-			
+			*/
 			notebook.Show ();
 			this.VBox.PackStart (notebook, true, true, 0);
 
@@ -182,8 +183,11 @@
 			backendComboBox = ComboBox.NewText ();
 			backendComboMap = new Dictionary<int,IBackend> ();
 			// Fill out the ComboBox
-			int i = 0;
+			//int i = 0;
 			selectedBackend = -1;
+
+			// disabling all of this for backend rework
+/*
 			foreach (IBackend backend in Application.AvailableBackends) {
 				backendComboBox.AppendText (backend.Name);
 				backendComboMap [i] = backend;
@@ -194,6 +198,7 @@
 			if (selectedBackend >= 0)
 				backendComboBox.Active = selectedBackend;
 			backendComboBox.Changed += OnBackendComboBoxChanged;
+*/
 			backendComboBox.Show ();
 			
 			HBox hbox = new HBox (false, 6);
@@ -322,7 +327,7 @@
 		
 		private void OnBackendComboBoxChanged (object sender, EventArgs args)
 		{
-			if (selectedBackend >= 0) {
+/*			if (selectedBackend >= 0) {
 				// TODO: Prompt the user and make sure they really want to change
 				// which backend they are using.
 				
@@ -389,6 +394,7 @@
 			//Application.Preferences.SetStringList (Preferences.HideInAllCategory,
 			//									   categoriesToHide);
 			RebuildCategoryTree ();
+*/
 		}
 		
 		private void ToggleCellDataFunc (Gtk.TreeViewColumn column,

Modified: branches/cache/src/RemoteControl.cs
==============================================================================
--- branches/cache/src/RemoteControl.cs	(original)
+++ branches/cache/src/RemoteControl.cs	Fri Mar 14 21:35:42 2008
@@ -54,7 +54,7 @@
 								  bool enterEditMode)
 		{
 			Gtk.TreeIter iter;
-			Gtk.TreeModel model = Application.Backend.Categories;
+			Gtk.TreeModel model = Application.LocalCache.Categories;
 			
 			//
 			// Validate the input parameters.  Don't allow null or empty strings
@@ -72,9 +72,9 @@
 				return string.Empty;
 			}
 			
-			ICategory category = null;
+			Category category = null;
 			do {
-				ICategory tempCategory = model.GetValue (iter, 0) as ICategory;
+				Category tempCategory = model.GetValue (iter, 0) as Category;
 				if (tempCategory.Name.ToLower ().CompareTo (categoryName.ToLower ()) == 0) {
 					// Found a match
 					category = tempCategory;
@@ -85,9 +85,9 @@
 				return string.Empty;
 			}
 			
-			ITask task = null;
+			Task task = null;
 			try {
-				task = Application.Backend.CreateTask (taskName, category);
+				task = Application.LocalCache.CreateTask(taskName, category);
 			} catch (Exception e) {
 				Logger.Error ("Exception calling Application.Backend.CreateTask from RemoteControl: {0}", e.Message);
 				return string.Empty;
@@ -129,13 +129,13 @@
 			string[] emptyArray = categories.ToArray ();
 			
 			Gtk.TreeIter iter;
-			Gtk.TreeModel model = Application.Backend.Categories;
+			Gtk.TreeModel model = Application.LocalCache.Categories;
 			
 			if (model.GetIterFirst (out iter) == false)
 				return emptyArray;
 			
 			do {
-				ICategory category = model.GetValue (iter, 0) as ICategory;
+				Category category = model.GetValue (iter, 0) as Category;
 				if (category is AllCategory)
 					continue; // Prevent the AllCategory from being returned
 				categories.Add (category.Name);

Modified: branches/cache/src/TaskCalendar.cs
==============================================================================
--- branches/cache/src/TaskCalendar.cs	(original)
+++ branches/cache/src/TaskCalendar.cs	Fri Mar 14 21:35:42 2008
@@ -22,11 +22,11 @@
 		Gtk.Widget parent;
 		int eventCount;
 
-		private ITask task;
+		private Task task;
 		
 		private const uint CURRENT_TIME = 0;
 
-		public TaskCalendar(ITask task, Gtk.Widget parent)
+		public TaskCalendar(Task task, Gtk.Widget parent)
 		{
 			this.task = task;
 			

Modified: branches/cache/src/TaskGroup.cs
==============================================================================
--- branches/cache/src/TaskGroup.cs	(original)
+++ branches/cache/src/TaskGroup.cs	Fri Mar 14 21:35:42 2008
@@ -199,7 +199,7 @@
 		#endregion // Public Properties
 		
 		#region Public Methods
-		public void Refilter (ICategory selectedCategory)
+		public void Refilter (Category selectedCategory)
 		{
 			filteredTasks.Refilter ();
 			treeView.Refilter (selectedCategory);
@@ -210,18 +210,18 @@
 		/// currently shown in this TaskGroup.
 		/// </summary>
 		/// <param name="task">
-		/// A <see cref="ITask"/>
+		/// A <see cref="Task"/>
 		/// </param>
 		/// <param name="iter">
 		/// A <see cref="Gtk.TreeIter"/>
 		/// </param>
 		/// <returns>
 		/// A <see cref="System.Boolean"/> True if the specified <see
-		/// cref="ITask">task</see> is currently shown inside this TaskGroup.
+		/// cref="Task">task</see> is currently shown inside this TaskGroup.
 		/// Additionally, if true, the <see cref="Gtk.TreeIter">iter</see> will
-		/// point to the specified <see cref="ITask">task</see>.
+		/// point to the specified <see cref="Task">task</see>.
 		/// </returns>
-		public bool ContainsTask (ITask task, out Gtk.TreeIter iter)
+		public bool ContainsTask (Task task, out Gtk.TreeIter iter)
 		{
 			Gtk.TreeIter tempIter;
 			Gtk.TreeModel model = treeView.Model;
@@ -233,7 +233,7 @@
 			
 			// Loop through the model looking for a matching task
 			do {
-				ITask tempTask = model.GetValue (tempIter, 0) as ITask;
+				Task tempTask = model.GetValue (tempIter, 0) as Task;
 				if (tempTask == task) {
 					iter = tempIter;
 					return true;
@@ -258,7 +258,7 @@
 			int pos = 0;
 			Gtk.TreeIter tempIter;
 			Gtk.TreeModel model = treeView.Model;
-			ITask task = model.GetValue (iter, 0) as ITask;
+			Task task = model.GetValue (iter, 0) as Task;
 			
 			if (model.GetIterFirst (out tempIter) == false)
 				return 0;
@@ -266,7 +266,7 @@
 			// This is ugly, but figure out what position the specified iter is
 			// at so we can return a value accordingly.
 			do {
-				ITask tempTask = model.GetValue (tempIter, 0) as ITask;
+				Task tempTask = model.GetValue (tempIter, 0) as Task;
 				if (tempTask == task)
 					break;
 				
@@ -287,7 +287,7 @@
 			int pos = 0;
 			Gtk.TreeIter tempIter;
 			Gtk.TreeModel model = treeView.Model;
-			ITask task = model.GetValue (iter, 0) as ITask;
+			Task task = model.GetValue (iter, 0) as Task;
 			
 			if (model.GetIterFirst (out tempIter) == false)
 				return 0;
@@ -295,7 +295,7 @@
 			// This is ugly, but figure out what position the specified iter is
 			// at so we can return a value accordingly.
 			do {
-				ITask tempTask = model.GetValue (tempIter, 0) as ITask;
+				Task tempTask = model.GetValue (tempIter, 0) as Task;
 				if (tempTask == task)
 					break;
 				
@@ -309,7 +309,7 @@
 			return pos * height + header.Requisition.Height;
 		}
 		
-		public void EnterEditMode (ITask task, Gtk.TreeIter iter)
+		public void EnterEditMode (Task task, Gtk.TreeIter iter)
 		{
 			Gtk.TreePath path;
 			
@@ -344,7 +344,7 @@
         /// </summary>
 		protected virtual bool FilterTasks (Gtk.TreeModel model, Gtk.TreeIter iter)
 		{
-			ITask task = model.GetValue (iter, 0) as ITask;
+			Task task = model.GetValue (iter, 0) as Task;
 			if (task == null)
 				return false;
 			
@@ -370,7 +370,7 @@
 			return true;
 		}
 		
-		private bool ShowCompletedTask (ITask task)
+		private bool ShowCompletedTask (Task task)
 		{
 			if (task.State == TaskState.Completed) {
 				if (showCompletedTasks == false)
@@ -404,7 +404,7 @@
 		/// </summary>
 		private void Refilter ()
 		{
-			ICategory cat = GetSelectedCategory ();
+			Category cat = GetSelectedCategory ();
 			if (cat != null)
 				Refilter (cat);
 		}
@@ -415,24 +415,24 @@
 		/// or something.
 		/// </summary>
 		/// <returns>
-		/// A <see cref="ICategory"/>
+		/// A <see cref="Category"/>
 		/// </returns>
-		private ICategory GetSelectedCategory ()
+		private Category GetSelectedCategory ()
 		{
 			// TODO: Move this code into some function in the backend/somewhere
-			// with the signature of GetCategoryForName (string catName):ICategory
+			// with the signature of GetCategoryForName (string catName):Category
 			string selectedCategoryName =
 				Application.Preferences.Get (Preferences.SelectedCategoryKey);
 			
 			if (selectedCategoryName != null) {
 				Gtk.TreeIter iter;
-				Gtk.TreeModel model = Application.Backend.Categories;
+				Gtk.TreeModel model = Application.LocalCache.Categories;
 
 				// Iterate through (yeah, I know this is gross!) and find the
 				// matching category
 				if (model.GetIterFirst (out iter) == true) {
 					do {
-						ICategory cat = model.GetValue (iter, 0) as ICategory;
+						Category cat = model.GetValue (iter, 0) as Category;
 						if (cat == null)
 							continue; // Needed for some reason to prevent crashes from some backends
 						if (cat.Name.CompareTo (selectedCategoryName) == 0) {
@@ -486,7 +486,7 @@
 			
 			showCompletedTasks = newValue;
 			
-			ICategory cat = GetSelectedCategory ();
+			Category cat = GetSelectedCategory ();
 			if (cat != null)
 				Refilter (cat);
 		}

Modified: branches/cache/src/TaskTreeView.cs
==============================================================================
--- branches/cache/src/TaskTreeView.cs	(original)
+++ branches/cache/src/TaskTreeView.cs	Fri Mar 14 21:35:42 2008
@@ -19,7 +19,7 @@
 		private static Gdk.Pixbuf[] inactiveAnimPixbufs;
 		
 		private Gtk.TreeModelFilter modelFilter;
-		private ICategory filterCategory;
+		private Category filterCategory;
 		
 		static TaskTreeView ()
 		{
@@ -241,7 +241,7 @@
 			Refilter (filterCategory);
 		}
 		
-		public void Refilter (ICategory selectedCategory)
+		public void Refilter (Category selectedCategory)
 		{
 			this.filterCategory = selectedCategory;
 			Model = modelFilter;
@@ -272,7 +272,7 @@
 											 Gtk.TreeIter iter)
 		{
 			Gtk.CellRendererToggle crt = cell as Gtk.CellRendererToggle;
-			ITask task = model.GetValue (iter, 0) as ITask;
+			Task task = model.GetValue (iter, 0) as Task;
 			if (task == null)
 				crt.Active = false;
 			else {
@@ -288,7 +288,7 @@
 		{
 			// TODO: Add bold (for high), light (for None), and also colors to priority?
 			Gtk.CellRendererCombo crc = cell as Gtk.CellRendererCombo;
-			ITask task = Model.GetValue (iter, 0) as ITask;
+			Task task = Model.GetValue (iter, 0) as Task;
 			switch (task.Priority) {
 			case TaskPriority.Low:
 				crc.Text = Catalog.GetString ("3");
@@ -311,7 +311,7 @@
 		{
 			Gtk.CellRendererText crt = renderer as Gtk.CellRendererText;
 			crt.Ellipsize = Pango.EllipsizeMode.End;
-			ITask task = model.GetValue (iter, 0) as ITask;
+			Task task = model.GetValue (iter, 0) as Task;
 			if (task == null) {
 				crt.Text = string.Empty;
 				return;
@@ -341,7 +341,7 @@
 				Gtk.TreeIter iter)
 		{
 			Gtk.CellRendererCombo crc = renderer as Gtk.CellRendererCombo;
-			ITask task = Model.GetValue (iter, 0) as ITask;
+			Task task = Model.GetValue (iter, 0) as Task;
 			DateTime date = task.State == TaskState.Completed ?
 									task.CompletionDate :
 									task.DueDate;
@@ -362,7 +362,7 @@
 				Gtk.TreeIter iter)
 		{
 			Gtk.CellRendererPixbuf crp = renderer as Gtk.CellRendererPixbuf;
-			ITask task = model.GetValue (iter, 0) as ITask;
+			Task task = model.GetValue (iter, 0) as Task;
 			if (task == null) {
 				crp.Pixbuf = null;
 				return;
@@ -376,7 +376,7 @@
 				Gtk.TreeIter iter)
 		{
 			Gtk.CellRendererPixbuf crp = renderer as Gtk.CellRendererPixbuf;
-			ITask task = model.GetValue (iter, 0) as ITask;
+			Task task = model.GetValue (iter, 0) as Task;
 			if (task == null)
 				return;
 			
@@ -453,7 +453,7 @@
 										   Gtk.TreeIter iter)
 		{
 			// Filter out deleted tasks
-			ITask task = model.GetValue (iter, 0) as ITask;
+			Task task = model.GetValue (iter, 0) as Task;
 			
 			if (task.State == TaskState.Deleted) {
 				//Logger.Debug ("TaskTreeView.FilterFunc:\n\t{0}\n\t{1}\n\tReturning false", task.Name, task.State);  
@@ -476,7 +476,7 @@
 			if (Model.GetIter (out iter, path) == false)
 				return; // Do nothing
 			
-			ITask task = Model.GetValue (iter, 0) as ITask;
+			Task task = Model.GetValue (iter, 0) as Task;
 			if (task == null)
 				return;
 
@@ -527,7 +527,7 @@
 				newPriority = TaskPriority.None;
 
 			// Update the priority if it's different
-			ITask task = Model.GetValue (iter, 0) as ITask;
+			Task task = Model.GetValue (iter, 0) as Task;
 			if (task.Priority != newPriority)
 				task.Priority = newPriority;
 		}
@@ -539,7 +539,7 @@
 			if (Model.GetIter (out iter, path) == false)
 				return;
 			
-			ITask task = Model.GetValue (iter, 0) as ITask;
+			Task task = Model.GetValue (iter, 0) as Task;
 			if (task == null)
 				return;
 			
@@ -595,7 +595,7 @@
 			
 			DateTime newDate = DateTime.MinValue;
 			DateTime today = DateTime.Now;
-			ITask task = Model.GetValue (iter, 0) as ITask;			
+			Task task = Model.GetValue (iter, 0) as Task;			
 			
 			if (args.NewText.CompareTo (
 							today.ToString(Catalog.GetString("M/d - ")) + Catalog.GetString("Today") ) == 0)
@@ -668,7 +668,7 @@
 			}
 			
 			private TaskTreeView tree;
-			private ITask task;
+			private Task task;
 			private uint delay;
 			protected uint pulseTimeoutId;
 			private Gtk.TreeIter iter;
@@ -676,7 +676,7 @@
 			
 			public InactivateTimer (TaskTreeView treeView,
 									Gtk.TreeIter taskIter,
-									ITask taskToComplete,
+									Task taskToComplete,
 									uint delayInSeconds)
 			{
 				tree = treeView;
@@ -694,7 +694,7 @@
 				timers [task.TimerID] = this;
 			}
 			
-			public static void CancelTimer(ITask task)
+			public static void CancelTimer(Task task)
 			{
 				Logger.Debug("Timeout Canceled for task: " + task.Name);
 				InactivateTimer timer = null;

Modified: branches/cache/src/TaskWindow.cs
==============================================================================
--- branches/cache/src/TaskWindow.cs	(original)
+++ branches/cache/src/TaskWindow.cs	Fri Mar 14 21:35:42 2008
@@ -44,7 +44,7 @@
 		private static int lastYPos;
 		private static Gdk.Pixbuf noteIcon;
 		
-		private IBackend backend;
+		//private IBackend backend;
 		private ScrolledWindow scrolledWindow;
 		
 		private Entry addTaskEntry;
@@ -61,13 +61,13 @@
 		
 		private List<TaskGroup> taskGroups;
 		
-		private Dictionary<ITask, NoteDialog> noteDialogs;
+		private Dictionary<Task, NoteDialog> noteDialogs;
 		
 		private Gtk.Statusbar statusbar;
 		private uint statusContext;
 		private uint currentStatusMessageId;
 		
-		private ITask clickedTask;
+		private Task clickedTask;
 		
 		private Gtk.AccelGroup accelGroup;
 		private GlobalKeybinder globalKeys;
@@ -77,11 +77,10 @@
 			noteIcon = Utilities.GetIcon ("note", 16);
 		}
 		
-		public TaskWindow (IBackend aBackend) : base (WindowType.Toplevel)
+		public TaskWindow () : base (WindowType.Toplevel)
 		{
-			this.backend = aBackend;
 			taskGroups = new List<TaskGroup> ();
-			noteDialogs = new Dictionary<ITask, NoteDialog> ();
+			noteDialogs = new Dictionary<Task, NoteDialog> ();
 			InitWindow();
 			
 			Realized += OnRealized;
@@ -227,13 +226,13 @@
 			Shown += OnWindowShown;
 			DeleteEvent += WindowDeleted;
 			
-			backend.BackendInitialized += OnBackendInitialized;
-			backend.BackendSyncStarted += OnBackendSyncStarted;
-			backend.BackendSyncFinished += OnBackendSyncFinished;
+			//backend.BackendInitialized += OnBackendInitialized;
+			//backend.BackendSyncStarted += OnBackendSyncStarted;
+			//backend.BackendSyncFinished += OnBackendSyncFinished;
 			// if the backend is already initialized, go ahead... initialize
-			if(backend.Initialized) {
+			//if(backend.Initialized) {
 				OnBackendInitialized();
-			}
+			//}
 			
 			Application.Preferences.SettingChanged += OnSettingChanged;
 		}
@@ -258,7 +257,7 @@
 			
 			overdueGroup = new TaskGroup (Catalog.GetString ("Overdue"),
 										  rangeStart, rangeEnd,
-										  backend.Tasks);
+										  Application.LocalCache.Tasks);
 			overdueGroup.RowActivated += OnRowActivated;
 			overdueGroup.ButtonPressed += OnButtonPressed;
 			overdueGroup.Show ();
@@ -276,7 +275,7 @@
 									 rangeEnd.Day, 23, 59, 59);
 			todayGroup = new TaskGroup (Catalog.GetString ("Today"),
 										rangeStart, rangeEnd,
-										backend.Tasks);
+										Application.LocalCache.Tasks);
 			todayGroup.RowActivated += OnRowActivated;
 			todayGroup.ButtonPressed += OnButtonPressed;
 			todayGroup.Show ();
@@ -294,7 +293,7 @@
 									 rangeEnd.Day, 23, 59, 59);
 			tomorrowGroup = new TaskGroup (Catalog.GetString ("Tomorrow"),
 										   rangeStart, rangeEnd,
-										   backend.Tasks);
+										   Application.LocalCache.Tasks);
 			tomorrowGroup.RowActivated += OnRowActivated;
 			tomorrowGroup.ButtonPressed += OnButtonPressed;			
 			tomorrowGroup.Show ();
@@ -312,7 +311,7 @@
 									 rangeEnd.Day, 23, 59, 59);
 			nextSevenDaysGroup = new TaskGroup (Catalog.GetString ("Next 7 Days"),
 										   rangeStart, rangeEnd,
-										   backend.Tasks);
+										   Application.LocalCache.Tasks);
 			nextSevenDaysGroup.RowActivated += OnRowActivated;
 			nextSevenDaysGroup.ButtonPressed += OnButtonPressed;				
 			nextSevenDaysGroup.Show ();
@@ -328,7 +327,7 @@
 			rangeEnd = DateTime.MaxValue;
 			futureGroup = new TaskGroup (Catalog.GetString ("Future"),
 										 rangeStart, rangeEnd,
-										 backend.Tasks);
+										 Application.LocalCache.Tasks);
 			futureGroup.RowActivated += OnRowActivated;
 			futureGroup.ButtonPressed += OnButtonPressed;			
 			futureGroup.Show ();
@@ -343,7 +342,7 @@
 			completedTaskGroup = new CompletedTaskGroup (
 					Catalog.GetString ("Completed"),
 					rangeStart, rangeEnd,
-					backend.Tasks);
+					Application.LocalCache.Tasks);
 			completedTaskGroup.RowActivated += OnRowActivated;
 			completedTaskGroup.ButtonPressed += OnButtonPressed;
 			completedTaskGroup.Show ();
@@ -358,7 +357,7 @@
 			
 			// Set up the combo box (after the above to set the current filter)
 
-			categoryComboBox.Model = Application.Backend.Categories;		
+			categoryComboBox.Model = Application.LocalCache.Categories;		
 
 			// Read preferences for the last-selected category and select it
 			string selectedCategoryName =
@@ -432,7 +431,7 @@
 				// something that will parse the command line to read which
 				// backend should be used.  If no specific backend is specified,
 				// use RtmTaskBackend by default.
-				TaskWindow.taskWindow = new TaskWindow(Application.Backend);
+				TaskWindow.taskWindow = new TaskWindow();
 				if(lastXPos == 0 || lastYPos == 0)
 				{
 					lastXPos = Application.Preferences.GetInt("MainWindowLastXPos");
@@ -457,7 +456,7 @@
 			taskWindow.addTaskEntry.GrabFocus ();
 		}
 		
-		public static void SelectAndEdit (ITask task)
+		public static void SelectAndEdit (Task task)
 		{
 			ShowWindow ();
 			taskWindow.EnterEditMode (task, true);
@@ -497,7 +496,7 @@
 			TaskWindow.ShowWindow ();
 		}
 		
-		public void HighlightTask (ITask task)
+		public void HighlightTask (Task task)
 		{
 			Gtk.TreeIter iter;
 			
@@ -522,9 +521,9 @@
 		/// adjust the window so the new task is showing.
 		/// </summary>
 		/// <param name="task">
-		/// A <see cref="ITask"/>
+		/// A <see cref="Task"/>
 		/// </param>
-		public void ScrollToTask (ITask task)
+		public void ScrollToTask (Task task)
 		{
 			// TODO: NEED to add something to NOT scroll the window if the new
 			// task is already showing in the window!
@@ -603,7 +602,7 @@
 									   Gtk.TreeIter iter)
 		{
 			Gtk.CellRendererText crt = renderer as Gtk.CellRendererText;
-			ICategory category = model.GetValue (iter, 0) as ICategory;
+			Category category = model.GetValue (iter, 0) as Category;
 
 			// CRG: What?  I added this check for null and we don't crash
 			// but I never see anything called unknown
@@ -616,20 +615,20 @@
 				crt.Text = "unknown";
 		}
 		
-		// TODO: Move this method into a property of ICategory.TaskCount
-		private int GetTaskCountInCategory (ICategory category)
+		// TODO: Move this method into a property of Category.TaskCount
+		private int GetTaskCountInCategory (Category category)
 		{
 			// This is disgustingly inefficient, but, oh well
 			int count = 0;
 			
 			Gtk.TreeIter iter;
-			Gtk.TreeModel model = Application.Backend.Tasks;
+			Gtk.TreeModel model = Application.LocalCache.Tasks;
 			
 			if (model.GetIterFirst (out iter) == false)
 				return 0;
 			
 			do {
-				ITask task = model.GetValue (iter, 0) as ITask;
+				Task task = model.GetValue (iter, 0) as Task;
 				if (task == null)
 					continue;
 				if (task.State != TaskState.Active
@@ -650,13 +649,13 @@
 		/// created.
 		/// </summary>
 		/// <param name="task">
-		/// A <see cref="ITask"/>
+		/// A <see cref="Task"/>
 		/// </param>
 		/// <param name="adjustScrolledWindow">
 		/// A <see cref="bool"/> which indicates whether the task should be
 		/// scrolled to.
 		/// </param>
-		private void EnterEditMode (ITask task, bool adjustScrolledWindow)
+		private void EnterEditMode (Task task, bool adjustScrolledWindow)
 		{
 			// Make sure we've waited around for the new task to fully
 			// be added to the TreeModel before continuing.  Some
@@ -689,8 +688,8 @@
 			Gtk.TreeIter iter;
 			if (categoriesModel.GetIterFirst (out iter) == true) {
 				do {
-					ICategory category =
-						categoriesModel.GetValue (iter, 0) as ICategory;
+					Category category =
+						categoriesModel.GetValue (iter, 0) as Category;
 					
 					if (category is AllCategory)
 						continue; // Skip this one
@@ -716,7 +715,7 @@
 				// matching category
 				if (model.GetIterFirst (out iter) == true) {
 					do {
-						ICategory cat = model.GetValue (iter, 0) as ICategory;
+						Category cat = model.GetValue (iter, 0) as Category;
 						if (cat == null)
 							continue; // Needed for some reason to prevent crashes from some backends
 						if (cat.Name.CompareTo (categoryName) == 0) {
@@ -733,14 +732,14 @@
 				// category.
 				if (model.GetIterFirst (out iter) == true) {
 					// Make sure we can actually get a category
-					ICategory cat = model.GetValue (iter, 0) as ICategory;
+					Category cat = model.GetValue (iter, 0) as Category;
 					if (cat != null)
 						categoryComboBox.SetActiveIter (iter);
 				}
 			}
 		}
 		
-		private void ShowTaskNotes (ITask task)
+		private void ShowTaskNotes (Task task)
 		{
 			NoteDialog dialog = null;
 			if (noteDialogs.ContainsKey (task) == false) {
@@ -754,9 +753,9 @@
 			dialog.Present ();
 		}
 		
-		private ITask CreateTask (string taskText, ICategory category)
+		private Task CreateTask (string taskText, Category category)
 		{
-			ITask task = backend.CreateTask (taskText, category);
+			Task task = Application.LocalCache.CreateTask (taskText, category);
 			
 			if (task == null) {
 				// TODO: Change the status to say there was an error
@@ -867,8 +866,8 @@
 			if (categoryComboBox.GetActiveIter (out iter) == false)
 				return;
 			
-			ICategory category =
-				categoryComboBox.Model.GetValue (iter, 0) as ICategory;
+			Category category =
+				categoryComboBox.Model.GetValue (iter, 0) as Category;
 		
 			// If enabled, attempt to parse due date information
 			// out of the entered task text.
@@ -882,7 +881,7 @@
 			else
 				taskName = enteredTaskText;
 			
-			ITask task = CreateTask (taskName, category);
+			Task task = CreateTask (taskName, category);
 			if (taskDueDate != DateTime.MinValue)
 				task.DueDate = taskDueDate;
 			
@@ -906,8 +905,8 @@
 			// the title of the task.
 			Gtk.TreeIter iter;
 			if (categoryComboBox.GetActiveIter (out iter) == true) {
-				ICategory selectedCategory =
-					categoryComboBox.Model.GetValue (iter, 0) as ICategory;
+				Category selectedCategory =
+					categoryComboBox.Model.GetValue (iter, 0) as Category;
 				
 				// Check to see if "All" is selected
 				if (selectedCategory is AllCategory) {
@@ -925,7 +924,7 @@
 				}
 			}
 			
-			ITask task = CreateTask (newTaskText, item.Category);
+			Task task = CreateTask (newTaskText, item.Category);
 			
 			HighlightTask (task);
 		}
@@ -936,8 +935,8 @@
 			if (categoryComboBox.GetActiveIter (out iter) == false)
 				return;
 			
-			ICategory category =
-				categoryComboBox.Model.GetValue (iter, 0) as ICategory;
+			Category category =
+				categoryComboBox.Model.GetValue (iter, 0) as Category;
 				
 			// Update the TaskGroups so they can filter accordingly
 			overdueGroup.Refilter (category);
@@ -967,7 +966,7 @@
 			if (model.GetIter (out iter, args.Path) == false)
 				return;
 			
-			ITask task = model.GetValue (iter, 0) as ITask;
+			Task task = model.GetValue (iter, 0) as Task;
 			if (task == null)
 				return;
 			
@@ -999,7 +998,7 @@
 					if (model.GetIter (out iter, path) == false)
 						return;
 					
-					clickedTask = model.GetValue (iter, 0) as ITask;
+					clickedTask = model.GetValue (iter, 0) as Task;
 					if (clickedTask == null)
 						return;
 					
@@ -1044,7 +1043,7 @@
 			if (clickedTask == null)
 				return;
 			
-			Application.Backend.DeleteTask(clickedTask);
+			Application.LocalCache.DeleteTask(clickedTask);
 		}
 
 
@@ -1078,7 +1077,7 @@
 		
 		private void OnBackendInitialized()
 		{		
-			backend.BackendInitialized -= OnBackendInitialized;
+			//backend.BackendInitialized -= OnBackendInitialized;
 			PopulateWindow();
 			OnBackendSyncFinished (); // To update the statusbar
 		}
@@ -1094,28 +1093,28 @@
 			string status =
 				string.Format ("Tasks loaded: {0}",DateTime.Now.ToString ());
 			TaskWindow.ShowStatus (status);
-			if (Application.Backend.Configured) {
-				RebuildAddTaskMenu (Application.Backend.Categories);
+			//if (Application.Backend.Configured) {
+				RebuildAddTaskMenu (Application.LocalCache.Categories);
 				addTaskEntry.Sensitive = true;
 				// Keep insensitive text color
 				Gdk.Color insensitiveColor =
 					addTaskEntry.Style.Text (Gtk.StateType.Insensitive);
 				addTaskEntry.ModifyText (Gtk.StateType.Normal, insensitiveColor);
-			}
+			//}
 		}
 		#endregion // Event Handlers
 		
 		#region Private Classes
 		class CategoryMenuItem : Gtk.MenuItem
 		{
-			private ICategory cat;
+			private Category cat;
 			
-			public CategoryMenuItem (ICategory category) : base (category.Name)
+			public CategoryMenuItem (Category category) : base (category.Name)
 			{
 				cat = category;
 			}
 			
-			public ICategory Category
+			public Category Category
 			{
 				get { return cat; }
 			}



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