// This file was generated by the Gtk# code generator.
// Any changes made will be lost if regenerated.

namespace GtkSharp {

	using System;
	using System.Runtime.InteropServices;

#region Autogenerated code
	internal delegate bool FlowBoxFilterFuncNative(IntPtr child, IntPtr user_data);

	internal class FlowBoxFilterFuncInvoker {

		FlowBoxFilterFuncNative native_cb;
		IntPtr __data;
		GLib.DestroyNotify __notify;

		~FlowBoxFilterFuncInvoker ()
		{
			if (__notify == null)
				return;
			__notify (__data);
		}

		internal FlowBoxFilterFuncInvoker (FlowBoxFilterFuncNative native_cb) : this (native_cb, IntPtr.Zero, null) {}

		internal FlowBoxFilterFuncInvoker (FlowBoxFilterFuncNative native_cb, IntPtr data) : this (native_cb, data, null) {}

		internal FlowBoxFilterFuncInvoker (FlowBoxFilterFuncNative native_cb, IntPtr data, GLib.DestroyNotify notify)
		{
			this.native_cb = native_cb;
			__data = data;
			__notify = notify;
		}

		internal Gtk.FlowBoxFilterFunc Handler {
			get {
				return new Gtk.FlowBoxFilterFunc(InvokeNative);
			}
		}

		bool InvokeNative (Gtk.FlowBoxChild child)
		{
			bool __result = native_cb (child == null ? IntPtr.Zero : child.Handle, __data);
			return __result;
		}
	}

	internal class FlowBoxFilterFuncWrapper {

		public bool NativeCallback (IntPtr child, IntPtr user_data)
		{
			try {
				bool __ret = managed (GLib.Object.GetObject(child) as Gtk.FlowBoxChild);
				if (release_on_call)
					gch.Free ();
				return __ret;
			} catch (Exception e) {
				GLib.ExceptionManager.RaiseUnhandledException (e, false);
				return false;
			}
		}

		bool release_on_call = false;
		GCHandle gch;

		public void PersistUntilCalled ()
		{
			release_on_call = true;
			gch = GCHandle.Alloc (this);
		}

		internal FlowBoxFilterFuncNative NativeDelegate;
		Gtk.FlowBoxFilterFunc managed;

		public FlowBoxFilterFuncWrapper (Gtk.FlowBoxFilterFunc managed)
		{
			this.managed = managed;
			if (managed != null)
				NativeDelegate = new FlowBoxFilterFuncNative (NativeCallback);
		}

		public static Gtk.FlowBoxFilterFunc GetManagedDelegate (FlowBoxFilterFuncNative native)
		{
			if (native == null)
				return null;
			FlowBoxFilterFuncWrapper wrapper = (FlowBoxFilterFuncWrapper) native.Target;
			if (wrapper == null)
				return null;
			return wrapper.managed;
		}
	}
#endregion
}
