diff --git a/ChangeLog b/ChangeLog index 8f58f66d2..6aa0815b2 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,12 @@ +2003-02-06 Gonzalo Paniagua Javier + + * glib/SignalCallback.cs: new methods AddDelegate and RemoveDelegate. + + * generator/Signal.cs: add/remove signal handlers from the delegate used + to invoke them. + + * generator/SignalHandler.cs: use Delegate instead of MulticastDelegate. + 2003-02-05 Rodrigo Moya * gda/Application.cs: diff --git a/generator/Signal.cs b/generator/Signal.cs index 06f53f1ab..c2b189a9c 100644 --- a/generator/Signal.cs +++ b/generator/Signal.cs @@ -163,13 +163,16 @@ namespace GtkSharp.Generation { sw.Write("(this, Handle, " + cname + ", value, System.Type.GetType(\"" + argsname); if (argsname != "System.EventArgs") sw.Write("," + container_type.NS.ToLower() + "-sharp"); - sw.WriteLine("\"));"); + sw.WriteLine("\"));\n\t\t\t\telse"); + sw.WriteLine("\t\t\t\t\t((GtkSharp.SignalCallback) Signals [{0}]).AddDelegate (value);", cname); sw.WriteLine("\t\t\t\tEventList.AddHandler(" + cname + ", value);"); sw.WriteLine("\t\t\t}"); sw.WriteLine("\t\t\tremove {"); sw.WriteLine("\t\t\t\tEventList.RemoveHandler(" + cname + ", value);"); sw.WriteLine("\t\t\t\tif (EventList[" + cname + "] == null)"); sw.WriteLine("\t\t\t\t\tSignals.Remove(" + cname + ");"); + sw.WriteLine("\t\t\t\telse"); + sw.WriteLine("\t\t\t\t\t((GtkSharp.SignalCallback) Signals [{0}]).RemoveDelegate (value);", cname); sw.WriteLine("\t\t\t}"); sw.WriteLine("\t\t}"); sw.WriteLine(); diff --git a/generator/SignalHandler.cs b/generator/SignalHandler.cs index 47efd9ee0..db764c669 100644 --- a/generator/SignalHandler.cs +++ b/generator/SignalHandler.cs @@ -168,7 +168,7 @@ namespace GtkSharp.Generation { sw.WriteLine(" int flags);"); sw.WriteLine(); sw.Write("\t\tpublic " + sname + "(GLib.Object obj, IntPtr raw, "); - sw.WriteLine("String name, MulticastDelegate eh, Type argstype) : base(obj, eh, argstype)"); + sw.WriteLine("String name, Delegate eh, Type argstype) : base(obj, eh, argstype)"); sw.WriteLine("\t\t{"); sw.WriteLine("\t\t\tif (_Delegate == null) {"); sw.WriteLine("\t\t\t\t_Delegate = new " + dname + "(" + cbname + ");"); diff --git a/glib/SignalCallback.cs b/glib/SignalCallback.cs index f0f5ebf8d..c54045a75 100644 --- a/glib/SignalCallback.cs +++ b/glib/SignalCallback.cs @@ -28,7 +28,7 @@ namespace GtkSharp { // protected instance members protected GLib.Object _obj; - protected MulticastDelegate _handler; + protected Delegate _handler; protected int _key; protected Type _argstype; @@ -40,7 +40,7 @@ namespace GtkSharp { /// Initializes instance data. /// - public SignalCallback (GLib.Object obj, MulticastDelegate eh, Type argstype) + public SignalCallback (GLib.Object obj, Delegate eh, Type argstype) { _key = _NextKey++; _obj = obj; @@ -49,5 +49,14 @@ namespace GtkSharp { _Instances [_key] = this; } + public void AddDelegate (Delegate d) + { + _handler = Delegate.Combine (_handler, d); + } + + public void RemoveDelegate (Delegate d) + { + _handler = Delegate.Remove (_handler, d); + } } }