tasque r75 - in trunk: . src



Author: sharm
Date: Mon Jun 23 12:47:37 2008
New Revision: 75
URL: http://svn.gnome.org/viewvc/tasque?rev=75&view=rev

Log:
* src/Application.cs: Check every minute to see if the day has changed.
   If it has, and the TaskWindow is open, reinitialize the
  TaskWindow.  Fixes bug #525306.
* src/TaskWindow.cs: Add static IsOpen property to determine if a
  TaskWindow exists and is currently realized.

Modified:
   trunk/ChangeLog
   trunk/src/Application.cs
   trunk/src/TaskWindow.cs

Modified: trunk/src/Application.cs
==============================================================================
--- trunk/src/Application.cs	(original)
+++ trunk/src/Application.cs	Mon Jun 23 12:47:37 2008
@@ -63,6 +63,8 @@
 		private IBackend backend;
 		private PreferencesDialog preferencesDialog;
 		
+		private DateTime currentDay = DateTime.Today;
+		
 		/// <value>
 		/// Keep track of the available backends.  The key is the Type name of
 		/// the backend.
@@ -201,6 +203,7 @@
 			LoadAvailableBackends ();
 
 			GLib.Idle.Add(InitializeIdle);
+			GLib.Timeout.Add (60000, CheckForDaySwitch);
 		}
 		
 		/// <summary>
@@ -321,6 +324,19 @@
 			
 			return false;
 		}
+		
+		private bool CheckForDaySwitch ()
+		{
+			if (DateTime.Today != currentDay) {
+				Logger.Debug ("Day has changed, reloading tasks");
+				currentDay = DateTime.Today;
+				// Reinitialize window according to new date
+				if (TaskWindow.IsOpen)
+					TaskWindow.Reinitialize ();
+			}
+			
+			return true;
+		}
 
 		private void UpdateTrayIcon()
 		{
@@ -417,7 +433,7 @@
 			if (backend != null) {
 				backend.Cleanup();
 			}
-			TaskWindow.SavePosition();			
+			TaskWindow.SavePosition();
 			program.Quit (); // Should this be called instead?
 		}
 		
@@ -518,8 +534,10 @@
 
 		public static void OnExitSignal (int signal)
 		{
-			if (ExitingEvent != null) ExitingEvent (null, EventArgs.Empty);
-			if (signal >= 0) System.Environment.Exit (0);
+			if (ExitingEvent != null)
+				ExitingEvent (null, EventArgs.Empty);
+			if (signal >= 0)
+				System.Environment.Exit (0);
 		}
 
 		public static event EventHandler ExitingEvent = null;

Modified: trunk/src/TaskWindow.cs
==============================================================================
--- trunk/src/TaskWindow.cs	(original)
+++ trunk/src/TaskWindow.cs	Mon Jun 23 12:47:37 2008
@@ -484,6 +484,13 @@
 				taskWindow.statusbar.Push (taskWindow.statusContext,
 										   statusText);
 		}
+
+		public static bool IsOpen
+		{
+			get {
+				return taskWindow != null && taskWindow.IsRealized;
+			}
+		}
 		
 		/// <summary>
 		/// This should be called after a new IBackend has been set



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