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

namespace GLib {

	using System;
	using System.Collections;
	using System.Collections.Generic;
	using System.Runtime.InteropServices;
	using static GLib.AbiStructExtension;

#region Autogenerated code
	public partial class AppLaunchContext : GLib.Object {

		public AppLaunchContext (IntPtr raw) : base(raw) {}

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

		public AppLaunchContext () : base (IntPtr.Zero)
		{
			if (GetType () != typeof (AppLaunchContext)) {
				CreateNativeObject (Array.Empty<string> (), Array.Empty<GLib.Value> ());
				return;
			}
			Raw = g_app_launch_context_new();
		}

		[GLib.Signal("launched")]
		public event GLib.LaunchedHandler Launched {
			add {
				this.AddSignalHandler ("launched", value, typeof (GLib.LaunchedArgs));
			}
			remove {
				this.RemoveSignalHandler ("launched", value);
			}
		}

		[GLib.Signal("launch-failed")]
		public event GLib.LaunchedFailedHandler LaunchedFailed {
			add {
				this.AddSignalHandler ("launch-failed", value, typeof (GLib.LaunchedFailedArgs));
			}
			remove {
				this.RemoveSignalHandler ("launch-failed", value);
			}
		}

		static GetDisplayNativeDelegate GetDisplay_cb_delegate;
		static GetDisplayNativeDelegate GetDisplayVMCallback {
			get {
				if (GetDisplay_cb_delegate == null)
					GetDisplay_cb_delegate = new GetDisplayNativeDelegate (GetDisplay_cb);
				return GetDisplay_cb_delegate;
			}
		}

		static void OverrideGetDisplay (GLib.GType gtype)
		{
			OverrideGetDisplay (gtype, GetDisplayVMCallback);
		}

		static void OverrideGetDisplay (GLib.GType gtype, GetDisplayNativeDelegate callback)
		{
			unsafe {
				IntPtr* raw_ptr = (IntPtr*)(((long) gtype.GetClassPtr()) + (long) class_abi.GetFieldOffset("get_display"));
				*raw_ptr = Marshal.GetFunctionPointerForDelegate(callback);
			}
		}

		[UnmanagedFunctionPointer (CallingConvention.Cdecl)]
		delegate IntPtr GetDisplayNativeDelegate (IntPtr inst, IntPtr info, IntPtr files);

		static IntPtr GetDisplay_cb (IntPtr inst, IntPtr info, IntPtr files)
		{
			try {
				AppLaunchContext __obj = GLib.Object.GetObject (inst, false) as AppLaunchContext;
				string __result;
				__result = __obj.OnGetDisplay (GLib.AppInfoAdapter.GetObject (info, false), new GLib.List(files));
				return GLib.Marshaller.StringToPtrGStrdup(__result);
			} catch (Exception e) {
				GLib.ExceptionManager.RaiseUnhandledException (e, true);
				// NOTREACHED: above call does not return.
				throw;
			}
		}

		[GLib.DefaultSignalHandler(Type=typeof(GLib.AppLaunchContext), ConnectionMethod="OverrideGetDisplay")]
		protected virtual string OnGetDisplay (GLib.IAppInfo info, GLib.List files)
		{
			return InternalGetDisplay (info, files);
		}

		private string InternalGetDisplay (GLib.IAppInfo info, GLib.List files)
		{
			GetDisplayNativeDelegate unmanaged = class_abi.BaseOverride<GetDisplayNativeDelegate>(this.LookupGType(), "get_display");
			if (unmanaged == null) return null;

			IntPtr __result = unmanaged (this.Handle, info == null ? IntPtr.Zero : ((info is GLib.Object) ? (info as GLib.Object).Handle : (info as GLib.AppInfoAdapter).Handle), files == null ? IntPtr.Zero : files.Handle);
			return GLib.Marshaller.PtrToStringGFree(__result);
		}

		static GetStartupNotifyIdNativeDelegate GetStartupNotifyId_cb_delegate;
		static GetStartupNotifyIdNativeDelegate GetStartupNotifyIdVMCallback {
			get {
				if (GetStartupNotifyId_cb_delegate == null)
					GetStartupNotifyId_cb_delegate = new GetStartupNotifyIdNativeDelegate (GetStartupNotifyId_cb);
				return GetStartupNotifyId_cb_delegate;
			}
		}

		static void OverrideGetStartupNotifyId (GLib.GType gtype)
		{
			OverrideGetStartupNotifyId (gtype, GetStartupNotifyIdVMCallback);
		}

		static void OverrideGetStartupNotifyId (GLib.GType gtype, GetStartupNotifyIdNativeDelegate callback)
		{
			unsafe {
				IntPtr* raw_ptr = (IntPtr*)(((long) gtype.GetClassPtr()) + (long) class_abi.GetFieldOffset("get_startup_notify_id"));
				*raw_ptr = Marshal.GetFunctionPointerForDelegate(callback);
			}
		}

		[UnmanagedFunctionPointer (CallingConvention.Cdecl)]
		delegate IntPtr GetStartupNotifyIdNativeDelegate (IntPtr inst, IntPtr info, IntPtr files);

		static IntPtr GetStartupNotifyId_cb (IntPtr inst, IntPtr info, IntPtr files)
		{
			try {
				AppLaunchContext __obj = GLib.Object.GetObject (inst, false) as AppLaunchContext;
				string __result;
				__result = __obj.OnGetStartupNotifyId (GLib.AppInfoAdapter.GetObject (info, false), new GLib.List(files));
				return GLib.Marshaller.StringToPtrGStrdup(__result);
			} catch (Exception e) {
				GLib.ExceptionManager.RaiseUnhandledException (e, true);
				// NOTREACHED: above call does not return.
				throw;
			}
		}

		[GLib.DefaultSignalHandler(Type=typeof(GLib.AppLaunchContext), ConnectionMethod="OverrideGetStartupNotifyId")]
		protected virtual string OnGetStartupNotifyId (GLib.IAppInfo info, GLib.List files)
		{
			return InternalGetStartupNotifyId (info, files);
		}

		private string InternalGetStartupNotifyId (GLib.IAppInfo info, GLib.List files)
		{
			GetStartupNotifyIdNativeDelegate unmanaged = class_abi.BaseOverride<GetStartupNotifyIdNativeDelegate>(this.LookupGType(), "get_startup_notify_id");
			if (unmanaged == null) return null;

			IntPtr __result = unmanaged (this.Handle, info == null ? IntPtr.Zero : ((info is GLib.Object) ? (info as GLib.Object).Handle : (info as GLib.AppInfoAdapter).Handle), files == null ? IntPtr.Zero : files.Handle);
			return GLib.Marshaller.PtrToStringGFree(__result);
		}

		static LaunchedFailedNativeDelegate LaunchedFailed_cb_delegate;
		static LaunchedFailedNativeDelegate LaunchedFailedVMCallback {
			get {
				if (LaunchedFailed_cb_delegate == null)
					LaunchedFailed_cb_delegate = new LaunchedFailedNativeDelegate (LaunchedFailed_cb);
				return LaunchedFailed_cb_delegate;
			}
		}

		static void OverrideLaunchedFailed (GLib.GType gtype)
		{
			OverrideLaunchedFailed (gtype, LaunchedFailedVMCallback);
		}

		static void OverrideLaunchedFailed (GLib.GType gtype, LaunchedFailedNativeDelegate callback)
		{
			unsafe {
				IntPtr* raw_ptr = (IntPtr*)(((long) gtype.GetClassPtr()) + (long) class_abi.GetFieldOffset("launch_failed"));
				*raw_ptr = Marshal.GetFunctionPointerForDelegate(callback);
			}
		}

		[UnmanagedFunctionPointer (CallingConvention.Cdecl)]
		delegate void LaunchedFailedNativeDelegate (IntPtr inst, IntPtr startup_notify_id);

		static void LaunchedFailed_cb (IntPtr inst, IntPtr startup_notify_id)
		{
			try {
				AppLaunchContext __obj = GLib.Object.GetObject (inst, false) as AppLaunchContext;
				__obj.OnLaunchedFailed (GLib.Marshaller.Utf8PtrToString (startup_notify_id));
			} catch (Exception e) {
				GLib.ExceptionManager.RaiseUnhandledException (e, false);
			}
		}

		[GLib.DefaultSignalHandler(Type=typeof(GLib.AppLaunchContext), ConnectionMethod="OverrideLaunchedFailed")]
		protected virtual void OnLaunchedFailed (string startup_notify_id)
		{
			InternalLaunchedFailed (startup_notify_id);
		}

		private void InternalLaunchedFailed (string startup_notify_id)
		{
			LaunchedFailedNativeDelegate unmanaged = class_abi.BaseOverride<LaunchedFailedNativeDelegate>(this.LookupGType(), "launch_failed");
			if (unmanaged == null) return;

			IntPtr native_startup_notify_id = GLib.Marshaller.StringToPtrGStrdup (startup_notify_id);
			unmanaged (this.Handle, native_startup_notify_id);
			GLib.Marshaller.Free (native_startup_notify_id);
		}

		static LaunchedNativeDelegate Launched_cb_delegate;
		static LaunchedNativeDelegate LaunchedVMCallback {
			get {
				if (Launched_cb_delegate == null)
					Launched_cb_delegate = new LaunchedNativeDelegate (Launched_cb);
				return Launched_cb_delegate;
			}
		}

		static void OverrideLaunched (GLib.GType gtype)
		{
			OverrideLaunched (gtype, LaunchedVMCallback);
		}

		static void OverrideLaunched (GLib.GType gtype, LaunchedNativeDelegate callback)
		{
			unsafe {
				IntPtr* raw_ptr = (IntPtr*)(((long) gtype.GetClassPtr()) + (long) class_abi.GetFieldOffset("launched"));
				*raw_ptr = Marshal.GetFunctionPointerForDelegate(callback);
			}
		}

		[UnmanagedFunctionPointer (CallingConvention.Cdecl)]
		delegate void LaunchedNativeDelegate (IntPtr inst, IntPtr info, IntPtr platform_data);

		static void Launched_cb (IntPtr inst, IntPtr info, IntPtr platform_data)
		{
			try {
				AppLaunchContext __obj = GLib.Object.GetObject (inst, false) as AppLaunchContext;
				__obj.OnLaunched (GLib.AppInfoAdapter.GetObject (info, false), new GLib.Variant(platform_data));
			} catch (Exception e) {
				GLib.ExceptionManager.RaiseUnhandledException (e, false);
			}
		}

		[GLib.DefaultSignalHandler(Type=typeof(GLib.AppLaunchContext), ConnectionMethod="OverrideLaunched")]
		protected virtual void OnLaunched (GLib.IAppInfo info, GLib.Variant platform_data)
		{
			InternalLaunched (info, platform_data);
		}

		private void InternalLaunched (GLib.IAppInfo info, GLib.Variant platform_data)
		{
			LaunchedNativeDelegate unmanaged = class_abi.BaseOverride<LaunchedNativeDelegate>(this.LookupGType(), "launched");
			if (unmanaged == null) return;

			unmanaged (this.Handle, info == null ? IntPtr.Zero : ((info is GLib.Object) ? (info as GLib.Object).Handle : (info as GLib.AppInfoAdapter).Handle), platform_data == null ? IntPtr.Zero : platform_data.Handle);
		}


		// Internal representation of the wrapped structure ABI.
		static GLib.AbiStruct _class_abi = null;
		static public unsafe new GLib.AbiStruct class_abi {
			get {
				if (_class_abi == null)
					_class_abi = new GLib.AbiStruct (new List<GLib.AbiField>{ 
						new GLib.AbiField("get_display"
							, GLib.Object.class_abi.Fields
							, (uint) sizeof( IntPtr ) // get_display
							, null
							, "get_startup_notify_id"
							, (uint) sizeof(IntPtr)
							, 0
							),
						new GLib.AbiField("get_startup_notify_id"
							, -1
							, (uint) sizeof( IntPtr ) // get_startup_notify_id
							, "get_display"
							, "launch_failed"
							, (uint) sizeof(IntPtr)
							, 0
							),
						new GLib.AbiField("launch_failed"
							, -1
							, (uint) sizeof( IntPtr ) // launch_failed
							, "get_startup_notify_id"
							, "launched"
							, (uint) sizeof(IntPtr)
							, 0
							),
						new GLib.AbiField("launched"
							, -1
							, (uint) sizeof( IntPtr ) // launched
							, "launch_failed"
							, "_g_reserved1"
							, (uint) sizeof(IntPtr)
							, 0
							),
						new GLib.AbiField("_g_reserved1"
							, -1
							, (uint) sizeof( IntPtr ) // _g_reserved1
							, "launched"
							, "_g_reserved2"
							, (uint) sizeof(IntPtr)
							, 0
							),
						new GLib.AbiField("_g_reserved2"
							, -1
							, (uint) sizeof( IntPtr ) // _g_reserved2
							, "_g_reserved1"
							, "_g_reserved3"
							, (uint) sizeof(IntPtr)
							, 0
							),
						new GLib.AbiField("_g_reserved3"
							, -1
							, (uint) sizeof( IntPtr ) // _g_reserved3
							, "_g_reserved2"
							, "_g_reserved4"
							, (uint) sizeof(IntPtr)
							, 0
							),
						new GLib.AbiField("_g_reserved4"
							, -1
							, (uint) sizeof( IntPtr ) // _g_reserved4
							, "_g_reserved3"
							, null
							, (uint) sizeof(IntPtr)
							, 0
							),
					});

				return _class_abi;
			}
		}


		// End of the ABI representation.

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

		public string GetDisplay(GLib.IAppInfo info, GLib.List files) {
			IntPtr raw_ret = g_app_launch_context_get_display(Handle, info == null ? IntPtr.Zero : ((info is GLib.Object) ? (info as GLib.Object).Handle : (info as GLib.AppInfoAdapter).Handle), files == null ? IntPtr.Zero : files.Handle);
			string ret = GLib.Marshaller.PtrToStringGFree(raw_ret);
			return ret;
		}

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

		public string Environment { 
			get {
				IntPtr raw_ret = g_app_launch_context_get_environment(Handle);
				string ret = GLib.Marshaller.PtrToStringGFree(raw_ret);
				return ret;
			}
		}

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

		public string GetStartupNotifyId(GLib.IAppInfo info, GLib.List files) {
			IntPtr raw_ret = g_app_launch_context_get_startup_notify_id(Handle, info == null ? IntPtr.Zero : ((info is GLib.Object) ? (info as GLib.Object).Handle : (info as GLib.AppInfoAdapter).Handle), files == null ? IntPtr.Zero : files.Handle);
			string ret = GLib.Marshaller.PtrToStringGFree(raw_ret);
			return ret;
		}

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

		public static new GLib.GType GType { 
			get {
				IntPtr raw_ret = g_app_launch_context_get_type();
				GLib.GType ret = new GLib.GType(raw_ret);
				return ret;
			}
		}

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

		public void LaunchFailed(string startup_notify_id) {
			IntPtr native_startup_notify_id = GLib.Marshaller.StringToPtrGStrdup (startup_notify_id);
			g_app_launch_context_launch_failed(Handle, native_startup_notify_id);
			GLib.Marshaller.Free (native_startup_notify_id);
		}

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

		public void Setenv(string variable, string value) {
			IntPtr native_variable = GLib.Marshaller.StringToPtrGStrdup (variable);
			IntPtr native_value = GLib.Marshaller.StringToPtrGStrdup (value);
			g_app_launch_context_setenv(Handle, native_variable, native_value);
			GLib.Marshaller.Free (native_variable);
			GLib.Marshaller.Free (native_value);
		}

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

		public void Unsetenv(string variable) {
			IntPtr native_variable = GLib.Marshaller.StringToPtrGStrdup (variable);
			g_app_launch_context_unsetenv(Handle, native_variable);
			GLib.Marshaller.Free (native_variable);
		}


		// Internal representation of the wrapped structure ABI.
		static GLib.AbiStruct _abi_info = null;
		static public unsafe new GLib.AbiStruct abi_info {
			get {
				if (_abi_info == null)
					_abi_info = new GLib.AbiStruct (new List<GLib.AbiField>{ 
						new GLib.AbiField("priv"
							, GLib.Object.abi_info.Fields
							, (uint) sizeof( IntPtr ) // priv
							, null
							, null
							, (uint) sizeof(IntPtr)
							, 0
							),
					});

				return _abi_info;
			}
		}


		// End of the ABI representation.

#endregion
	}
}
