2003-10-17 22:31:46 +00:00
|
|
|
// Gtk.Object.custom - Gtk Object class customizations
|
2002-09-04 05:25:58 +00:00
|
|
|
//
|
2007-02-16 16:18:59 +00:00
|
|
|
// Author: Mike Kestner <mkestner@novell.com>
|
2002-09-04 05:25:58 +00:00
|
|
|
//
|
2004-06-25 18:42:19 +00:00
|
|
|
// Copyright (c) 2002-2003 Mike Kestner
|
2007-02-16 16:18:59 +00:00
|
|
|
// Copyright (c) 2007 Novell, Inc.
|
2002-09-04 05:25:58 +00:00
|
|
|
//
|
|
|
|
// This code is inserted after the automatically generated code.
|
2004-06-25 18:42:19 +00:00
|
|
|
//
|
|
|
|
// This program is free software; you can redistribute it and/or
|
|
|
|
// modify it under the terms of version 2 of the Lesser GNU General
|
|
|
|
// Public License as published by the Free Software Foundation.
|
|
|
|
//
|
|
|
|
// This program is distributed in the hope that it will be useful,
|
|
|
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
// Lesser General Public License for more details.
|
|
|
|
//
|
|
|
|
// You should have received a copy of the GNU Lesser General Public
|
|
|
|
// License along with this program; if not, write to the
|
|
|
|
// Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
|
|
|
// Boston, MA 02111-1307, USA.
|
|
|
|
|
2007-02-16 16:18:59 +00:00
|
|
|
static Hashtable destroy_handlers;
|
|
|
|
static Hashtable DestroyHandlers {
|
|
|
|
get {
|
|
|
|
if (destroy_handlers == null)
|
|
|
|
destroy_handlers = new Hashtable ();
|
|
|
|
return destroy_handlers;
|
|
|
|
}
|
|
|
|
}
|
2002-09-04 05:25:58 +00:00
|
|
|
|
2007-02-16 16:18:59 +00:00
|
|
|
private static void OverrideDestroyed (GLib.GType gtype)
|
|
|
|
{
|
|
|
|
// Do Nothing. We don't want to hook into the native vtable.
|
|
|
|
// We will manually invoke the VM on signal invocation. The signal
|
|
|
|
// always raises before the default handler because this signal
|
|
|
|
// is RUN_CLEANUP.
|
|
|
|
}
|
2002-09-12 05:21:16 +00:00
|
|
|
|
2007-02-16 16:18:59 +00:00
|
|
|
[GLib.DefaultSignalHandler(Type=typeof(Gtk.Object), ConnectionMethod="OverrideDestroyed")]
|
|
|
|
protected virtual void OnDestroyed ()
|
|
|
|
{
|
|
|
|
if (DestroyHandlers [Handle] == null)
|
|
|
|
return;
|
2004-09-29 18:45:59 +00:00
|
|
|
|
2007-02-16 16:18:59 +00:00
|
|
|
EventHandler handler = (EventHandler) DestroyHandlers [Handle];
|
|
|
|
handler (this, EventArgs.Empty);
|
|
|
|
DestroyHandlers [Handle] = null;
|
|
|
|
Dispose ();
|
|
|
|
}
|
|
|
|
|
|
|
|
[GLib.Signal("destroy")]
|
|
|
|
public event EventHandler Destroyed {
|
|
|
|
add {
|
|
|
|
EventHandler handler = (EventHandler) DestroyHandlers [Handle];
|
|
|
|
DestroyHandlers [Handle] = Delegate.Combine (handler, value);
|
|
|
|
}
|
|
|
|
remove {
|
|
|
|
EventHandler handler = (EventHandler) DestroyHandlers [Handle];
|
|
|
|
DestroyHandlers [Handle] = Delegate.Remove (handler, value);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
event EventHandler InternalDestroyed {
|
|
|
|
add {
|
|
|
|
GLib.Signal sig = GLib.Signal.Lookup (this, "destroy");
|
|
|
|
sig.AddDelegate (value);
|
|
|
|
}
|
|
|
|
remove {
|
|
|
|
GLib.Signal sig = GLib.Signal.Lookup (this, "destroy");
|
|
|
|
sig.RemoveDelegate (value);
|
|
|
|
}
|
|
|
|
}
|
2003-07-23 17:19:21 +00:00
|
|
|
|
2005-05-11 13:12:09 +00:00
|
|
|
static void NativeDestroy (object o, EventArgs args)
|
|
|
|
{
|
2005-05-12 02:49:26 +00:00
|
|
|
Gtk.Object obj = o as Gtk.Object;
|
2005-05-11 13:12:09 +00:00
|
|
|
if (obj == null)
|
|
|
|
return;
|
2007-02-16 16:18:59 +00:00
|
|
|
obj.OnDestroyed ();
|
2005-05-11 13:12:09 +00:00
|
|
|
}
|
2007-02-16 16:18:59 +00:00
|
|
|
|
2005-05-11 13:12:09 +00:00
|
|
|
static EventHandler native_destroy_handler;
|
|
|
|
static EventHandler NativeDestroyHandler {
|
|
|
|
get {
|
|
|
|
if (native_destroy_handler == null)
|
|
|
|
native_destroy_handler = new EventHandler (NativeDestroy);
|
|
|
|
return native_destroy_handler;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2005-05-13 17:38:51 +00:00
|
|
|
protected override void CreateNativeObject (string[] names, GLib.Value[] vals)
|
|
|
|
{
|
|
|
|
base.CreateNativeObject (names, vals);
|
|
|
|
}
|
|
|
|
|
|
|
|
public override void Dispose ()
|
|
|
|
{
|
2007-02-16 16:18:59 +00:00
|
|
|
InternalDestroyed -= NativeDestroyHandler;
|
2005-05-13 17:38:51 +00:00
|
|
|
base.Dispose ();
|
|
|
|
}
|
|
|
|
|
2007-02-16 16:18:59 +00:00
|
|
|
[DllImport("libgobject-2.0-0.dll")]
|
|
|
|
private static extern void g_object_ref_sink (IntPtr raw);
|
|
|
|
|
2002-11-10 10:03:51 +00:00
|
|
|
protected override IntPtr Raw {
|
|
|
|
get {
|
|
|
|
return base.Raw;
|
|
|
|
}
|
|
|
|
set {
|
|
|
|
base.Raw = value;
|
2004-04-07 19:15:01 +00:00
|
|
|
if (value == IntPtr.Zero)
|
|
|
|
return;
|
|
|
|
|
2007-02-16 16:18:59 +00:00
|
|
|
g_object_ref_sink (value);
|
|
|
|
InternalDestroyed += NativeDestroyHandler;
|
2002-11-10 10:03:51 +00:00
|
|
|
}
|
2002-09-12 05:21:16 +00:00
|
|
|
}
|
2004-09-29 18:45:59 +00:00
|
|
|
|
2004-12-17 23:21:53 +00:00
|
|
|
[DllImport("libgtk-win32-2.0-0.dll")]
|
|
|
|
private static extern void gtk_object_destroy (IntPtr raw);
|
|
|
|
|
2005-05-12 00:42:21 +00:00
|
|
|
public virtual void Destroy ()
|
|
|
|
{
|
2004-12-17 23:21:53 +00:00
|
|
|
gtk_object_destroy (Handle);
|
|
|
|
}
|
|
|
|
|
2007-02-16 16:18:59 +00:00
|
|
|
[DllImport("gtksharpglue-2")]
|
|
|
|
private static extern bool gtksharp_object_is_floating (IntPtr raw);
|
|
|
|
|
|
|
|
[DllImport("gtksharpglue-2")]
|
|
|
|
private static extern bool gtksharp_object_set_floating (IntPtr raw, bool val);
|
|
|
|
|
2004-09-29 18:45:59 +00:00
|
|
|
public bool IsFloating {
|
|
|
|
get {
|
|
|
|
return gtksharp_object_is_floating (Handle);
|
|
|
|
}
|
|
|
|
set {
|
|
|
|
gtksharp_object_set_floating (Handle, value);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|