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

namespace Gtk {

	using System;
	using System.Runtime.InteropServices;

#region Autogenerated code
	public partial class ActionableAdapter : GLib.GInterfaceAdapter, Gtk.IActionable {

		[StructLayout (LayoutKind.Sequential)]
		struct GtkActionableInterface {
			public GetActionNameNativeDelegate GetActionName;
			public SetActionNameNativeDelegate SetActionName;
			public GetActionTargetValueNativeDelegate GetActionTargetValue;
			public SetActionTargetValueNativeDelegate SetActionTargetValue;
		}

		static GtkActionableInterface iface;

		static ActionableAdapter ()
		{
			GLib.GType.Register (_gtype, typeof (ActionableAdapter));
			iface.GetActionName = new GetActionNameNativeDelegate (GetActionName_cb);
			iface.SetActionName = new SetActionNameNativeDelegate (SetActionName_cb);
			iface.GetActionTargetValue = new GetActionTargetValueNativeDelegate (GetActionTargetValue_cb);
			iface.SetActionTargetValue = new SetActionTargetValueNativeDelegate (SetActionTargetValue_cb);
		}

		[UnmanagedFunctionPointer (CallingConvention.Cdecl)]
		delegate IntPtr GetActionNameNativeDelegate (IntPtr inst);

		static IntPtr GetActionName_cb (IntPtr inst)
		{
			try {
				IActionableImplementor __obj = GLib.Object.GetObject (inst, false) as IActionableImplementor;
				string __result;
				__result = __obj.ActionName;
				return GLib.Marshaller.StringToPtrGStrdup(__result);
			} catch (Exception e) {
				GLib.ExceptionManager.RaiseUnhandledException (e, true);
				// NOTREACHED: above call does not return.
				throw;
			}
		}

		[UnmanagedFunctionPointer (CallingConvention.Cdecl)]
		delegate void SetActionNameNativeDelegate (IntPtr inst, IntPtr action_name);

		static void SetActionName_cb (IntPtr inst, IntPtr action_name)
		{
			try {
				IActionableImplementor __obj = GLib.Object.GetObject (inst, false) as IActionableImplementor;
				__obj.ActionName = GLib.Marshaller.Utf8PtrToString (action_name);
			} catch (Exception e) {
				GLib.ExceptionManager.RaiseUnhandledException (e, false);
			}
		}

		[UnmanagedFunctionPointer (CallingConvention.Cdecl)]
		delegate IntPtr GetActionTargetValueNativeDelegate (IntPtr inst);

		static IntPtr GetActionTargetValue_cb (IntPtr inst)
		{
			try {
				IActionableImplementor __obj = GLib.Object.GetObject (inst, false) as IActionableImplementor;
				GLib.Variant __result;
				__result = __obj.ActionTargetValue;
				return __result == null ? IntPtr.Zero : __result.Handle;
			} catch (Exception e) {
				GLib.ExceptionManager.RaiseUnhandledException (e, true);
				// NOTREACHED: above call does not return.
				throw;
			}
		}

		[UnmanagedFunctionPointer (CallingConvention.Cdecl)]
		delegate void SetActionTargetValueNativeDelegate (IntPtr inst, IntPtr target_value);

		static void SetActionTargetValue_cb (IntPtr inst, IntPtr target_value)
		{
			try {
				IActionableImplementor __obj = GLib.Object.GetObject (inst, false) as IActionableImplementor;
				__obj.ActionTargetValue = new GLib.Variant(target_value);
			} catch (Exception e) {
				GLib.ExceptionManager.RaiseUnhandledException (e, false);
			}
		}

		static int class_offset = 2 * IntPtr.Size;

		static void Initialize (IntPtr ptr, IntPtr data)
		{
			IntPtr ifaceptr = new IntPtr (ptr.ToInt64 () + class_offset);
			GtkActionableInterface native_iface = (GtkActionableInterface) Marshal.PtrToStructure (ifaceptr, typeof (GtkActionableInterface));
			native_iface.GetActionName = iface.GetActionName;
			native_iface.SetActionName = iface.SetActionName;
			native_iface.GetActionTargetValue = iface.GetActionTargetValue;
			native_iface.SetActionTargetValue = iface.SetActionTargetValue;
			Marshal.StructureToPtr (native_iface, ifaceptr, false);
		}

		GLib.Object implementor;

		public ActionableAdapter ()
		{
			InitHandler = new GLib.GInterfaceInitHandler (Initialize);
		}

		public ActionableAdapter (IActionableImplementor implementor)
		{
			if (implementor == null)
				throw new ArgumentNullException ("implementor");
			else if (!(implementor is GLib.Object))
				throw new ArgumentException ("implementor must be a subclass of GLib.Object");
			this.implementor = implementor as GLib.Object;
		}

		public ActionableAdapter (IntPtr handle)
		{
			if (!_gtype.IsInstance (handle))
				throw new ArgumentException ("The gobject doesn't implement the GInterface of this adapter", "handle");
			implementor = GLib.Object.GetObject (handle);
		}

		[UnmanagedFunctionPointer (CallingConvention.Cdecl)]
		delegate IntPtr d_gtk_actionable_get_type();
		static d_gtk_actionable_get_type gtk_actionable_get_type = FuncLoader.LoadFunction<d_gtk_actionable_get_type>(FuncLoader.GetProcAddress(GLibrary.Load(Library.Gtk), "gtk_actionable_get_type"));

		private static GLib.GType _gtype = new GLib.GType (gtk_actionable_get_type ());

		public static GLib.GType GType {
			get {
				return _gtype;
			}
		}

		public override GLib.GType GInterfaceGType {
			get {
				return _gtype;
			}
		}

		public override IntPtr Handle {
			get {
				return implementor.Handle;
			}
		}

		public IntPtr OwnedHandle {
			get {
				return implementor.OwnedHandle;
			}
		}

		public static IActionable GetObject (IntPtr handle, bool owned)
		{
			GLib.Object obj = GLib.Object.GetObject (handle, owned);
			return GetObject (obj);
		}

		public static IActionable GetObject (GLib.Object obj)
		{
			if (obj == null)
				return null;
			else if (obj is IActionableImplementor)
				return new ActionableAdapter (obj as IActionableImplementor);
			else if (obj as IActionable == null)
				return new ActionableAdapter (obj.Handle);
			else
				return obj as IActionable;
		}

		public IActionableImplementor Implementor {
			get {
				return implementor as IActionableImplementor;
			}
		}

		[UnmanagedFunctionPointer (CallingConvention.Cdecl)]
		delegate IntPtr d_gtk_actionable_get_action_name(IntPtr raw);
		static d_gtk_actionable_get_action_name gtk_actionable_get_action_name = FuncLoader.LoadFunction<d_gtk_actionable_get_action_name>(FuncLoader.GetProcAddress(GLibrary.Load(Library.Gtk), "gtk_actionable_get_action_name"));

		[UnmanagedFunctionPointer (CallingConvention.Cdecl)]
		delegate void d_gtk_actionable_set_action_name(IntPtr raw, IntPtr action_name);
		static d_gtk_actionable_set_action_name gtk_actionable_set_action_name = FuncLoader.LoadFunction<d_gtk_actionable_set_action_name>(FuncLoader.GetProcAddress(GLibrary.Load(Library.Gtk), "gtk_actionable_set_action_name"));

		public string ActionName { 
			get {
				IntPtr raw_ret = gtk_actionable_get_action_name(Handle);
				string ret = GLib.Marshaller.Utf8PtrToString (raw_ret);
				return ret;
			}
			set {
				IntPtr native_value = GLib.Marshaller.StringToPtrGStrdup (value);
				gtk_actionable_set_action_name(Handle, native_value);
				GLib.Marshaller.Free (native_value);
			}
		}

		[UnmanagedFunctionPointer (CallingConvention.Cdecl)]
		delegate IntPtr d_gtk_actionable_get_action_target_value(IntPtr raw);
		static d_gtk_actionable_get_action_target_value gtk_actionable_get_action_target_value = FuncLoader.LoadFunction<d_gtk_actionable_get_action_target_value>(FuncLoader.GetProcAddress(GLibrary.Load(Library.Gtk), "gtk_actionable_get_action_target_value"));

		[UnmanagedFunctionPointer (CallingConvention.Cdecl)]
		delegate void d_gtk_actionable_set_action_target_value(IntPtr raw, IntPtr target_value);
		static d_gtk_actionable_set_action_target_value gtk_actionable_set_action_target_value = FuncLoader.LoadFunction<d_gtk_actionable_set_action_target_value>(FuncLoader.GetProcAddress(GLibrary.Load(Library.Gtk), "gtk_actionable_set_action_target_value"));

		public GLib.Variant ActionTargetValue { 
			get {
				IntPtr raw_ret = gtk_actionable_get_action_target_value(Handle);
				GLib.Variant ret = new GLib.Variant(raw_ret);
				return ret;
			}
			set {
				gtk_actionable_set_action_target_value(Handle, value == null ? IntPtr.Zero : value.Handle);
			}
		}

		[UnmanagedFunctionPointer (CallingConvention.Cdecl)]
		delegate void d_gtk_actionable_set_detailed_action_name(IntPtr raw, IntPtr detailed_action_name);
		static d_gtk_actionable_set_detailed_action_name gtk_actionable_set_detailed_action_name = FuncLoader.LoadFunction<d_gtk_actionable_set_detailed_action_name>(FuncLoader.GetProcAddress(GLibrary.Load(Library.Gtk), "gtk_actionable_set_detailed_action_name"));

		public string DetailedActionName { 
			set {
				IntPtr native_value = GLib.Marshaller.StringToPtrGStrdup (value);
				gtk_actionable_set_detailed_action_name(Handle, native_value);
				GLib.Marshaller.Free (native_value);
			}
		}

#endregion
	}
}
