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

namespace GLib {

	using System;
	using System.Runtime.InteropServices;

#region Autogenerated code
	public partial class ActionAdapter : GLib.GInterfaceAdapter, GLib.IAction {

		[StructLayout (LayoutKind.Sequential)]
		struct GActionInterface {
			public GetNameNativeDelegate GetName;
			public GetParameterTypeNativeDelegate GetParameterType;
			public GetStateTypeNativeDelegate GetStateType;
			public GetStateHintNativeDelegate GetStateHint;
			public GetEnabledNativeDelegate GetEnabled;
			public GetStateNativeDelegate GetState;
			public ChangeStateNativeDelegate ChangeState;
			public ActivateNativeDelegate Activate;
		}

		static GActionInterface iface;

		static ActionAdapter ()
		{
			GLib.GType.Register (_gtype, typeof (ActionAdapter));
			iface.GetName = new GetNameNativeDelegate (GetName_cb);
			iface.GetParameterType = new GetParameterTypeNativeDelegate (GetParameterType_cb);
			iface.GetStateType = new GetStateTypeNativeDelegate (GetStateType_cb);
			iface.GetStateHint = new GetStateHintNativeDelegate (GetStateHint_cb);
			iface.GetEnabled = new GetEnabledNativeDelegate (GetEnabled_cb);
			iface.GetState = new GetStateNativeDelegate (GetState_cb);
			iface.ChangeState = new ChangeStateNativeDelegate (ChangeState_cb);
			iface.Activate = new ActivateNativeDelegate (Activate_cb);
		}

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

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

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

		static IntPtr GetParameterType_cb (IntPtr inst)
		{
			try {
				IActionImplementor __obj = GLib.Object.GetObject (inst, false) as IActionImplementor;
				GLib.VariantType __result;
				__result = __obj.ParameterType;
				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 IntPtr GetStateTypeNativeDelegate (IntPtr inst);

		static IntPtr GetStateType_cb (IntPtr inst)
		{
			try {
				IActionImplementor __obj = GLib.Object.GetObject (inst, false) as IActionImplementor;
				GLib.VariantType __result;
				__result = __obj.StateType;
				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 IntPtr GetStateHintNativeDelegate (IntPtr inst);

		static IntPtr GetStateHint_cb (IntPtr inst)
		{
			try {
				IActionImplementor __obj = GLib.Object.GetObject (inst, false) as IActionImplementor;
				GLib.Variant __result;
				__result = __obj.StateHint;
				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 bool GetEnabledNativeDelegate (IntPtr inst);

		static bool GetEnabled_cb (IntPtr inst)
		{
			try {
				IActionImplementor __obj = GLib.Object.GetObject (inst, false) as IActionImplementor;
				bool __result;
				__result = __obj.Enabled;
				return __result;
			} catch (Exception e) {
				GLib.ExceptionManager.RaiseUnhandledException (e, true);
				// NOTREACHED: above call does not return.
				throw;
			}
		}

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

		static IntPtr GetState_cb (IntPtr inst)
		{
			try {
				IActionImplementor __obj = GLib.Object.GetObject (inst, false) as IActionImplementor;
				GLib.Variant __result;
				__result = __obj.State;
				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 ChangeStateNativeDelegate (IntPtr inst, IntPtr value);

		static void ChangeState_cb (IntPtr inst, IntPtr value)
		{
			try {
				IActionImplementor __obj = GLib.Object.GetObject (inst, false) as IActionImplementor;
				__obj.ChangeState (new GLib.Variant(value));
			} catch (Exception e) {
				GLib.ExceptionManager.RaiseUnhandledException (e, false);
			}
		}

		[UnmanagedFunctionPointer (CallingConvention.Cdecl)]
		delegate void ActivateNativeDelegate (IntPtr inst, IntPtr parameter);

		static void Activate_cb (IntPtr inst, IntPtr parameter)
		{
			try {
				IActionImplementor __obj = GLib.Object.GetObject (inst, false) as IActionImplementor;
				__obj.Activate (new GLib.Variant(parameter));
			} 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);
			GActionInterface native_iface = (GActionInterface) Marshal.PtrToStructure (ifaceptr, typeof (GActionInterface));
			native_iface.GetName = iface.GetName;
			native_iface.GetParameterType = iface.GetParameterType;
			native_iface.GetStateType = iface.GetStateType;
			native_iface.GetStateHint = iface.GetStateHint;
			native_iface.GetEnabled = iface.GetEnabled;
			native_iface.GetState = iface.GetState;
			native_iface.ChangeState = iface.ChangeState;
			native_iface.Activate = iface.Activate;
			Marshal.StructureToPtr (native_iface, ifaceptr, false);
		}

		GLib.Object implementor;

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

		public ActionAdapter (IActionImplementor 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 ActionAdapter (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_g_action_get_type();
		static d_g_action_get_type g_action_get_type = FuncLoader.LoadFunction<d_g_action_get_type>(FuncLoader.GetProcAddress(GLibrary.Load(Library.Gio), "g_action_get_type"));

		private static GLib.GType _gtype = new GLib.GType (g_action_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 IAction GetObject (IntPtr handle, bool owned)
		{
			GLib.Object obj = GLib.Object.GetObject (handle, owned);
			return GetObject (obj);
		}

		public static IAction GetObject (GLib.Object obj)
		{
			if (obj == null)
				return null;
			else if (obj is IActionImplementor)
				return new ActionAdapter (obj as IActionImplementor);
			else if (obj as IAction == null)
				return new ActionAdapter (obj.Handle);
			else
				return obj as IAction;
		}

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

		[UnmanagedFunctionPointer (CallingConvention.Cdecl)]
		delegate void d_g_action_activate(IntPtr raw, IntPtr parameter);
		static d_g_action_activate g_action_activate = FuncLoader.LoadFunction<d_g_action_activate>(FuncLoader.GetProcAddress(GLibrary.Load(Library.Gio), "g_action_activate"));

		public void Activate(GLib.Variant parameter) {
			g_action_activate(Handle, parameter == null ? IntPtr.Zero : parameter.Handle);
		}

		[UnmanagedFunctionPointer (CallingConvention.Cdecl)]
		delegate void d_g_action_change_state(IntPtr raw, IntPtr value);
		static d_g_action_change_state g_action_change_state = FuncLoader.LoadFunction<d_g_action_change_state>(FuncLoader.GetProcAddress(GLibrary.Load(Library.Gio), "g_action_change_state"));

		public void ChangeState(GLib.Variant value) {
			g_action_change_state(Handle, value == null ? IntPtr.Zero : value.Handle);
		}

		[UnmanagedFunctionPointer (CallingConvention.Cdecl)]
		delegate bool d_g_action_get_enabled(IntPtr raw);
		static d_g_action_get_enabled g_action_get_enabled = FuncLoader.LoadFunction<d_g_action_get_enabled>(FuncLoader.GetProcAddress(GLibrary.Load(Library.Gio), "g_action_get_enabled"));

		public bool Enabled { 
			get {
				bool raw_ret = g_action_get_enabled(Handle);
				bool ret = raw_ret;
				return ret;
			}
		}

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

		public string Name { 
			get {
				IntPtr raw_ret = g_action_get_name(Handle);
				string ret = GLib.Marshaller.Utf8PtrToString (raw_ret);
				return ret;
			}
		}

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

		public GLib.VariantType ParameterType { 
			get {
				IntPtr raw_ret = g_action_get_parameter_type(Handle);
				GLib.VariantType ret = new GLib.VariantType(raw_ret);
				return ret;
			}
		}

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

		public GLib.Variant State { 
			get {
				IntPtr raw_ret = g_action_get_state(Handle);
				GLib.Variant ret = new GLib.Variant(raw_ret);
				return ret;
			}
		}

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

		public GLib.Variant StateHint { 
			get {
				IntPtr raw_ret = g_action_get_state_hint(Handle);
				GLib.Variant ret = new GLib.Variant(raw_ret);
				return ret;
			}
		}

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

		public GLib.VariantType StateType { 
			get {
				IntPtr raw_ret = g_action_get_state_type(Handle);
				GLib.VariantType ret = new GLib.VariantType(raw_ret);
				return ret;
			}
		}

		[UnmanagedFunctionPointer (CallingConvention.Cdecl)]
		delegate bool d_g_action_name_is_valid(IntPtr action_name);
		static d_g_action_name_is_valid g_action_name_is_valid = FuncLoader.LoadFunction<d_g_action_name_is_valid>(FuncLoader.GetProcAddress(GLibrary.Load(Library.Gio), "g_action_name_is_valid"));

		public static bool NameIsValid(string action_name) {
			IntPtr native_action_name = GLib.Marshaller.StringToPtrGStrdup (action_name);
			bool raw_ret = g_action_name_is_valid(native_action_name);
			bool ret = raw_ret;
			GLib.Marshaller.Free (native_action_name);
			return ret;
		}

		[UnmanagedFunctionPointer (CallingConvention.Cdecl)]
		delegate bool d_g_action_parse_detailed_name(IntPtr detailed_name, IntPtr action_name, IntPtr target_value, out IntPtr error);
		static d_g_action_parse_detailed_name g_action_parse_detailed_name = FuncLoader.LoadFunction<d_g_action_parse_detailed_name>(FuncLoader.GetProcAddress(GLibrary.Load(Library.Gio), "g_action_parse_detailed_name"));

		public static bool ParseDetailedName(string detailed_name, string action_name, GLib.Variant target_value) {
			IntPtr native_detailed_name = GLib.Marshaller.StringToPtrGStrdup (detailed_name);
			IntPtr error = IntPtr.Zero;
			bool raw_ret = g_action_parse_detailed_name(native_detailed_name, GLib.Marshaller.StringToPtrGStrdup(action_name), target_value == null ? IntPtr.Zero : target_value.Handle, out error);
			bool ret = raw_ret;
			GLib.Marshaller.Free (native_detailed_name);
			if (error != IntPtr.Zero) throw new GLib.GException (error);
			return ret;
		}

		[UnmanagedFunctionPointer (CallingConvention.Cdecl)]
		delegate IntPtr d_g_action_print_detailed_name(IntPtr action_name, IntPtr target_value);
		static d_g_action_print_detailed_name g_action_print_detailed_name = FuncLoader.LoadFunction<d_g_action_print_detailed_name>(FuncLoader.GetProcAddress(GLibrary.Load(Library.Gio), "g_action_print_detailed_name"));

		public static string PrintDetailedName(string action_name, GLib.Variant target_value) {
			IntPtr native_action_name = GLib.Marshaller.StringToPtrGStrdup (action_name);
			IntPtr raw_ret = g_action_print_detailed_name(native_action_name, target_value == null ? IntPtr.Zero : target_value.Handle);
			string ret = GLib.Marshaller.PtrToStringGFree(raw_ret);
			GLib.Marshaller.Free (native_action_name);
			return ret;
		}

#endregion
	}
}
