2001-10-04 Mike Kestner <mkestner@speakeasy.net>
* gdk/SimpleEvent.cs : Temporarily comment the GCHandle code until a layout is ready and exceptions can be avoided. * gtk/Widget.cs : Killed all the signal and event attaching methods. They never belonged here, and now they exist in the SimpleEvent. Add a Signals hash to hold refs of the Signal handlers. Killed default ctor and the dtor. The event Add/Remove methods now create a SimpleEvent, stuff it in the hash, and remove it when the last handler disappears. svn path=/trunk/gtk-sharp/; revision=1078
This commit is contained in:
parent
bb326f46c9
commit
3c0213de88
3 changed files with 25 additions and 82 deletions
11
ChangeLog
11
ChangeLog
|
@ -1,3 +1,14 @@
|
|||
2001-10-04 Mike Kestner <mkestner@speakeasy.net>
|
||||
|
||||
* gdk/SimpleEvent.cs : Temporarily uncomment the GCHandle code until
|
||||
a layout is ready and exceptions can be avoided.
|
||||
* gtk/Widget.cs : Killed all the signal and event attaching methods.
|
||||
They never belonged here, and now they exist in the SimpleEvent.
|
||||
Add a Signals hash to hold refs of the Signal handlers. Killed default
|
||||
ctor and the dtor. The event Add/Remove methods now create a
|
||||
SimpleEvent, stuff it in the hash, and remove it when the last handler
|
||||
disappears.
|
||||
|
||||
2001-10-04 Mike Kestner <mkestner@speakeasy.net>
|
||||
|
||||
* HACKING : Little bit of cleanup.
|
||||
|
|
|
@ -1,8 +1,9 @@
|
|||
// Gdk.Signals.SimpleEvent.cs - Gdk Simple Event Signal implementation
|
||||
// Gdk.SimpleEvent.cs - Gdk Simple Event Signal implementation
|
||||
//
|
||||
// Author: Bob Smith <bob@thestuff.net>
|
||||
// Mike Kestner <mkestner@speakeasy.net>
|
||||
//
|
||||
// (c) 2001 Bob Smith
|
||||
// (c) 2001 Bob Smith and Mike Kestner
|
||||
|
||||
namespace Gdk {
|
||||
using System;
|
||||
|
@ -104,8 +105,10 @@ namespace Gdk {
|
|||
if (_Delegate == null) {
|
||||
_Delegate = new SimpleEventDelegate (
|
||||
SimpleEventCallback);
|
||||
/* FIXME: Exception thrown for lack of layout
|
||||
_GCHandle = GCHandle.Alloc (
|
||||
_Delegate, GCHandleType.Pinned);
|
||||
*/
|
||||
}
|
||||
|
||||
_key = _NextKey++;
|
||||
|
@ -127,7 +130,9 @@ namespace Gdk {
|
|||
_Instances.Remove (_key);
|
||||
|
||||
if (_Instances.Count == 0) {
|
||||
/* FIXME: when the handle can be obtained
|
||||
_GCHandle.Free();
|
||||
*/
|
||||
_Delegate = null;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -7,107 +7,34 @@
|
|||
namespace Gtk {
|
||||
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Runtime.InteropServices;
|
||||
using GLib;
|
||||
using Gdk;
|
||||
|
||||
|
||||
public class Widget : Object {
|
||||
public Widget() {}
|
||||
~Widget()
|
||||
{
|
||||
/* FIXME: Find a valid way to Delete the handlers
|
||||
foreach (EventHandler e in Events[DelEvName])
|
||||
{
|
||||
DeleteEvent -= e;
|
||||
}
|
||||
*/
|
||||
}
|
||||
|
||||
private static readonly string DelEvName = "delete-event";
|
||||
|
||||
private Hashtable Signals = new Hashtable ();
|
||||
|
||||
public event EventHandler DeleteEvent {
|
||||
add {
|
||||
if (Events [DelEvName] == null)
|
||||
ConnectSignal(DelEvName);
|
||||
Signals [DelEvName] = new SimpleEvent (
|
||||
this, RawObject,
|
||||
DelEvName, value);
|
||||
|
||||
Events.AddHandler(DelEvName, value);
|
||||
}
|
||||
remove {
|
||||
Events.RemoveHandler(DelEvName, value);
|
||||
if (Events [DelEvName] == null)
|
||||
DisconnectSignal (DelEvName);
|
||||
}
|
||||
}
|
||||
/*
|
||||
public void AddSimpleEvent(Object type, string name, EventHandler value)
|
||||
{
|
||||
if (Events[type] == null)
|
||||
{
|
||||
ConnectSimpleSignal(name, type);
|
||||
}
|
||||
Events.AddHandler(type, value);
|
||||
}
|
||||
|
||||
public void RemoveSimpleEvent(Object type, string name, EventHandler value)
|
||||
{
|
||||
Events.RemoveHandler(type, value);
|
||||
if (Events[type] == null)
|
||||
{
|
||||
DisconnectSimpleSignal(name, type);
|
||||
Signals.Remove (DelEvName);
|
||||
}
|
||||
}
|
||||
|
||||
public void AddGdkSimpleEvent(Object type, string name, EventHandler value)
|
||||
{
|
||||
if (Events[type] == null)
|
||||
{
|
||||
ConnectGdkSimpleEventSignal(name, type);
|
||||
}
|
||||
Events.AddHandler(type, value);
|
||||
}
|
||||
|
||||
public void RemoveGdkSimpleEvent(Object type, string name, EventHandler value)
|
||||
{
|
||||
Events.RemoveHandler(type, value);
|
||||
if (Events[type] == null)
|
||||
{
|
||||
DisconnectGdkSimpleEventSignal(name, type);
|
||||
}
|
||||
}
|
||||
*/
|
||||
[DllImport("gtk-1.3.dll")]
|
||||
static extern void gtk_signal_connect_full (
|
||||
IntPtr obj, string evname,
|
||||
SimpleDelegate cb, IntPtr unsupported,
|
||||
String data, IntPtr destroycb,
|
||||
int objsig, int after );
|
||||
|
||||
public void ConnectSignal(string name)
|
||||
{
|
||||
gtk_signal_connect_full(RawObject, name, SimpleSignal.Delegate,
|
||||
new IntPtr (0), name,
|
||||
new IntPtr (0), 0, 0);
|
||||
}
|
||||
|
||||
public void DisconnectSignal(string name)
|
||||
{
|
||||
SimpleSignal.Unref();
|
||||
}
|
||||
|
||||
/*
|
||||
public void ConnectGdkSimpleSignal(string name, Object signal)
|
||||
{
|
||||
gtk_signal_connect_full(RawObject, name, SimpleEvent.Delegate,
|
||||
new IntPtr (0), name,
|
||||
new IntPtr (0), 0, 0);
|
||||
}
|
||||
|
||||
public void DisconnectGdkSimpleSignal(string name, Object signal)
|
||||
{
|
||||
SimpleEvent.Unref();
|
||||
}
|
||||
*/
|
||||
/// <summary>
|
||||
/// Show Method
|
||||
/// </summary>
|
||||
|
|
Loading…
Reference in a new issue