Attached is a patch that adds a Invoke (Delegate d, params object[]
objs) overload to the Application.Invoke pattern.

This allows someone not yet using 2.0 functionality (anonymous
delegates) to easily pass parameters to an Invoke'd method.

Not really interested in discussing its merits either way (Ben), however
if it is something that the powers that be would like in gtk#, I will
commit, otherwise, no loss at all :).


--Todd
Index: gtk/Application.cs
===================================================================
--- gtk/Application.cs	(revision 51854)
+++ gtk/Application.cs	(working copy)
@@ -146,6 +146,8 @@
 			EventHandler d;
 			object sender;
 			EventArgs args;
+			object[] objs;
+			Delegate del;
 			
 			internal InvokeCB (EventHandler d)
 			{
@@ -160,10 +162,20 @@
 				this.args = args;
 				this.sender = sender;
 			}
+
+			internal InvokeCB (Delegate d, params object[] objs)
+			{
+				this.del = d;
+				this.objs = objs;
+			}
 			
 			internal bool Invoke ()
 			{
-				d (sender, args);
+				if (d != null) {
+					d (sender, args);
+				} else {
+					del.Method.Invoke (del.Target, objs);
+				}
 				return false;
 			}
 		}
@@ -181,5 +193,12 @@
 			
 			GLib.Timeout.Add (0, new GLib.TimeoutHandler (icb.Invoke));
 		}
+
+		public static void Invoke (Delegate d, params object[] objs)
+		{
+			InvokeCB icb = new InvokeCB (d, objs);
+			
+			GLib.Timeout.Add (0, new GLib.TimeoutHandler (icb.Invoke));
+		}
 	}
 }
Index: ChangeLog
===================================================================
--- ChangeLog	(revision 51854)
+++ ChangeLog	(working copy)
@@ -1,3 +1,8 @@
+2005-10-17  Todd Berman  <[EMAIL PROTECTED]>
+
+	* gtk/Application.cs: Add a Invoke (Delegate d, params object[])
+	overload
+
 2005-10-08  Miguel de Icaza  <[EMAIL PROTECTED]>
 
 	* gtk/Application.cs (Invoke): Use Timeout instead of Idle add to
_______________________________________________
Gtk-sharp-list maillist  -  [email protected]
http://lists.ximian.com/mailman/listinfo/gtk-sharp-list

Reply via email to