[Monodevelop-patches-list] r1812 - in trunk/MonoDevelop/src/Main/Base: . Gui/Dialogs Gui/Pads/ClassScout Services/DispatchService

commit-watcher at mono-cvs.ximian.com commit-watcher at mono-cvs.ximian.com
Wed Jun 23 13:57:20 EDT 2004


Author: tberman
Date: 2004-06-23 13:57:20 -0400 (Wed, 23 Jun 2004)
New Revision: 1812

Modified:
   trunk/MonoDevelop/src/Main/Base/ChangeLog
   trunk/MonoDevelop/src/Main/Base/Gui/Dialogs/NewFileDialog.cs
   trunk/MonoDevelop/src/Main/Base/Gui/Pads/ClassScout/ClassScout.cs
   trunk/MonoDevelop/src/Main/Base/Services/DispatchService/DispatchService.cs
Log:
new stuff in dispatch service to allow for void and stateful messages.


Modified: trunk/MonoDevelop/src/Main/Base/ChangeLog
===================================================================
--- trunk/MonoDevelop/src/Main/Base/ChangeLog	2004-06-23 16:52:42 UTC (rev 1811)
+++ trunk/MonoDevelop/src/Main/Base/ChangeLog	2004-06-23 17:57:20 UTC (rev 1812)
@@ -1,5 +1,14 @@
 2004-06-23  Todd Berman  <tberman at off.net>
 
+	* Services/DispatchService/DispatchService.cs: change up a bit
+	to allow a void blah () delegate and a void blah (object) delegate.
+	Added overloads to hit those.
+	* Gui/Pads/ClassScout/ClassScout.cs: Update to new DispatchService
+	API.
+	* Gui/Dialogs/NewFileDialog.cs: Update to new DispatchService API.
+
+2004-06-23  Todd Berman  <tberman at off.net>
+
 	* Commands/FileCommands.cs: Cleanup a bit, move some code around.
 	* Gui/Dialogs/NewFileDialog.cs: Convert to using DispatchService.
 	This also tests the BackgroundDispatch method, which seems to be

Modified: trunk/MonoDevelop/src/Main/Base/Gui/Dialogs/NewFileDialog.cs
===================================================================
--- trunk/MonoDevelop/src/Main/Base/Gui/Dialogs/NewFileDialog.cs	2004-06-23 16:52:42 UTC (rev 1811)
+++ trunk/MonoDevelop/src/Main/Base/Gui/Dialogs/NewFileDialog.cs	2004-06-23 17:57:20 UTC (rev 1812)
@@ -52,7 +52,7 @@
 			this.BorderWidth = 6;
 			this.HasSeparator = false;
 			
-			dispatcher.BackgroundDispatch (new MessageHandler (InitializeTemplates), null);
+			dispatcher.BackgroundDispatch (new MessageHandler (InitializeTemplates));
 		}
 		
 		void InitializeView()
@@ -114,7 +114,7 @@
 			return newcategory;
 		}
 		
-		void InitializeTemplates(object blank)
+		void InitializeTemplates()
 		{
 			foreach (FileTemplate template in FileTemplate.FileTemplates) {
 				TemplateItem titem = new TemplateItem(template);
@@ -135,7 +135,7 @@
 				}
 				alltemplates.Add(titem);
 			}
-			dispatcher.GuiDispatch (new MessageHandler (InitializeComponents), null);
+			dispatcher.GuiDispatch (new MessageHandler (InitializeComponents));
 		}
 		
 		// tree view event handlers
@@ -292,7 +292,7 @@
 			Destroy ();
 		}
 
-		void InitializeComponents(object blank)
+		void InitializeComponents()
 		{
 			
 			catStore = new Gtk.TreeStore (typeof(string), typeof(ArrayList), typeof(ArrayList), typeof(Gdk.Pixbuf));

Modified: trunk/MonoDevelop/src/Main/Base/Gui/Pads/ClassScout/ClassScout.cs
===================================================================
--- trunk/MonoDevelop/src/Main/Base/Gui/Pads/ClassScout/ClassScout.cs	2004-06-23 16:52:42 UTC (rev 1811)
+++ trunk/MonoDevelop/src/Main/Base/Gui/Pads/ClassScout/ClassScout.cs	2004-06-23 17:57:20 UTC (rev 1812)
@@ -150,7 +150,7 @@
 		void OnClassInformationChanged(object sender, ClassInformationEventArgs e)
 		{
 			DispatchService dispatcher = (DispatchService)ServiceManager.Services.GetService (typeof (DispatchService));
-			dispatcher.GuiDispatch (new MessageHandler (ChangeClassInfo), e);
+			dispatcher.GuiDispatch (new StatefulMessageHandler (ChangeClassInfo), e);
 		}
 		
 		void ChangeClassInfo (object e)

Modified: trunk/MonoDevelop/src/Main/Base/Services/DispatchService/DispatchService.cs
===================================================================
--- trunk/MonoDevelop/src/Main/Base/Services/DispatchService/DispatchService.cs	2004-06-23 16:52:42 UTC (rev 1811)
+++ trunk/MonoDevelop/src/Main/Base/Services/DispatchService/DispatchService.cs	2004-06-23 17:57:20 UTC (rev 1812)
@@ -24,9 +24,20 @@
 			thrBackground.Start ();
 		}
 
-		public void GuiDispatch (MessageHandler cb, object state)
+		public void GuiDispatch (MessageHandler cb)
 		{
-			arrGuiQueue.Add (new MessageContainer (cb, state));
+			arrGuiQueue.Add (new GenericMessageContainer (cb));
+			UpdateIdle ();
+		}
+
+		public void GuiDispatch (StatefulMessageHandler cb, object state)
+		{
+			arrGuiQueue.Add (new StatefulMessageContainer (cb, state));
+			UpdateIdle ();
+		}
+
+		void UpdateIdle ()
+		{
 			if (iIdle == 0) {
 				iIdle = GLib.Idle.Add (new GLib.IdleHandler (guiDispatcher));
 				/* This code is required because for some
@@ -40,9 +51,14 @@
 			}
 		}
 
-		public void BackgroundDispatch (MessageHandler cb, object state)
+		public void BackgroundDispatch (MessageHandler cb)
 		{
-			arrBackgroundQueue.Add (new MessageContainer (cb, state));
+			arrBackgroundQueue.Add (new GenericMessageContainer (cb));
+		}
+
+		public void BackgroundDispatch (StatefulMessageHandler cb, object state)
+		{
+			arrBackgroundQueue.Add (new StatefulMessageContainer (cb, state));
 			//thrBackground.Resume ();
 		}
 
@@ -52,9 +68,9 @@
 				iIdle = 0;
 				return false;
 			}
-			MessageContainer msg = null;
+			GenericMessageContainer msg = null;
 			lock (arrGuiQueue) {
-				msg = (MessageContainer)arrGuiQueue[0];
+				msg = (GenericMessageContainer)arrGuiQueue[0];
 				arrGuiQueue.RemoveAt (0);
 			}
 			if (msg != null)
@@ -74,9 +90,9 @@
 					//thrBackground.Suspend ();
 					continue;
 				}
-				MessageContainer msg = null;
+				GenericMessageContainer msg = null;
 				lock (arrBackgroundQueue) {
-					msg = (MessageContainer)arrBackgroundQueue[0];
+					msg = (GenericMessageContainer)arrBackgroundQueue[0];
 					arrBackgroundQueue.RemoveAt (0);
 				}
 				if (msg != null)
@@ -85,20 +101,38 @@
 		}
 	}
 
-	public delegate void MessageHandler (object state);
+	public delegate void MessageHandler ();
+	public delegate void StatefulMessageHandler (object state);
 
-	class MessageContainer
+	class GenericMessageContainer
 	{
-		object data;
 		MessageHandler callback;
 
-		public MessageContainer (MessageHandler cb, object state)
+		protected GenericMessageContainer () { }
+
+		public GenericMessageContainer (MessageHandler cb)
 		{
+			callback = cb;
+		}
+
+		public virtual void Run ()
+		{
+			callback ();
+		}
+	}
+
+	class StatefulMessageContainer : GenericMessageContainer
+	{
+		object data;
+		StatefulMessageHandler callback;
+
+		public StatefulMessageContainer (StatefulMessageHandler cb, object state)
+		{
 			data = state;
 			callback = cb;
 		}
 		
-		public void Run ()
+		public override void Run ()
 		{
 			callback (data);
 		}




More information about the Monodevelop-patches-list mailing list