GtkSharp/gtk/GtkSharp.GtkClipboardGetFuncNative.cs
Gonzalo Paniagua Javier 3821938764 2003-04-03 Gonzalo Paniagua Javier <gonzalo@ximian.com>
* generator/CallbackGen.cs: the new generated wrappers have:
		-(optional) Field of the same type returned by the callback.
		-A call to RemoveIfNotAlive at the beginning. It returns true,
		return the dummy field.
		-Added an object to the ctor signature and pass it to the base
		class.

	* generator/Ctor.cs: added a Params property.

	* generator/Method.cs: set Static property in Parameters if the method
	is static.

	* generator/Parameters.cs: added Static property. The call creation of
	the delegate wrapper (if applicable) uses the new signature. Pass a null
	as object is the method is static.

	* generator/StructBase.cs: set Static for the parameters of the ctors.

	* glib/DelegateWrapper.cs: the ctor takes an object (the one creating
	the wrapper or null) and creates a weak reference to it. Store it in
	a static Hashtable (this way the wrapper itself is not garbage
	collected).
	(RemoveIfNotAlive): called from the native delegate callbacks. If the
	target of the weak reference has been garbage collected, removes itself
	from the hashtable to let the GC dispose this instance and returns true.

	* gdk/Pixbuf.custom:
	* gtk/Clipboard.custom:
	* gtk/GtkSharp.GtkClipboardClearFuncNative.cs:
	* gtk/GtkSharp.GtkClipboardGetFuncNative.cs:
	* glade/XML.custom: changed delegate wrappers to match the new
	signature.

svn path=/trunk/gtk-sharp/; revision=13237
2003-04-06 09:21:15 +00:00

34 lines
1.1 KiB
C#

namespace GtkSharp {
using System;
using System.Collections;
public delegate void GtkClipboardGetFuncNative(IntPtr clipboard, ref Gtk.SelectionData selection_data, uint info, uint obj_id);
public class GtkClipboardGetFuncWrapper : GLib.DelegateWrapper {
public void NativeCallback (IntPtr clipboard, ref Gtk.SelectionData selection_data, uint info, uint obj_id)
{
if (RemoveIfNotAlive ()) return;
object[] _args = new object[4];
_args[0] = (Gtk.Clipboard) GLib.Opaque.GetOpaque(clipboard);
if (_args[0] == null)
_args[0] = new Gtk.Clipboard(clipboard);
_args[1] = selection_data;
_args[2] = info;
_args[3] = Gtk.Clipboard.clipboard_objects[obj_id];
_managed ((Gtk.Clipboard) _args[0], ref selection_data, (uint) _args[2], _args[3]);
}
public GtkClipboardGetFuncNative NativeDelegate;
protected Gtk.ClipboardGetFunc _managed;
public GtkClipboardGetFuncWrapper (Gtk.ClipboardGetFunc managed, object o) : base (o)
{
NativeDelegate = new GtkClipboardGetFuncNative (NativeCallback);
_managed = managed;
}
}
}