GtkSharp/glib/SignalCallback.cs
Mike Kestner bb8d2c4ee9 2001-11-24 Mike Kestner <mkestner@speakeasy.net>
* codegen/defs-parse.pl : mkdir the glib/generated dir.
	(gen_signal): Call new get_sighandler sub. Doesn't use the returned
	  value yet.  s/event/ev3nt on arg names.
	(get_sighandler): new sub to lookup or gen a signal helper/delegate.
	  Only generates the delegate so far.
	* codegen/hardcoded.defs : Added a stub for Gdk.Event.
	* gdk/Event.cs : Killed, now a generated struct.
	* gdk/SimpleEvent.cs (SimpleEventCallback): Use Marshal.PtrToStructure
	  to create the Event, not a ctor(IntPtr).
	* glib/SignalCallback.cs : New abstract base class for signal helpers.

svn path=/trunk/gtk-sharp/; revision=1437
2001-11-25 00:25:47 +00:00

59 lines
1.3 KiB
C#

// GtkSharp.SignalCallback.cs - Signal callback base class implementation
//
// Authors: Mike Kestner <mkestner@speakeasy.net>
//
// (c) 2001 Mike Kestner
namespace GtkSharp {
using System;
using System.Collections;
using System.Runtime.InteropServices;
using GLib;
/// <summary>
/// SignalCallback Class
/// </summary>
///
/// <remarks>
/// Base Class for GSignal to C# event marshalling.
/// </remarks>
public abstract class SignalCallback {
// A counter used to produce unique keys for instances.
protected static int _NextKey = 0;
// Hashtable containing refs to all current instances.
protected static Hashtable _Instances = new Hashtable ();
// protected instance members
protected GLib.Object _obj;
protected EventHandler _handler;
protected int _key;
/// <summary>
/// SignalCallback Constructor
/// </summary>
///
/// <remarks>
/// Initializes instance data.
/// </remarks>
public SignalCallback (GLib.Object obj, IntPtr raw,
String name, EventHandler eh)
{
_key = _NextKey++;
_obj = obj;
_handler = eh;
_Instances [_key] = this;
}
// Destructor needed to release references from the instance
// table and unpin the delegate if no refs remain.
~SignalCallback ()
{
_Instances.Remove (_key);
}
}
}