// 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 NotificationBackend : GLib.Object {

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

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

		public NotificationBackend (GLib.Application application) : base (IntPtr.Zero)
		{
			if (GetType () != typeof (NotificationBackend)) {
				var vals = new List<GLib.Value> ();
				var names = new List<string> ();
				CreateNativeObject (names.ToArray (), vals.ToArray ());
				return;
			}
			Raw = g_notification_backend_new_default(application == null ? IntPtr.Zero : application.Handle);
		}

		static SendNotificationNativeDelegate SendNotification_cb_delegate;
		static SendNotificationNativeDelegate SendNotificationVMCallback {
			get {
				if (SendNotification_cb_delegate == null)
					SendNotification_cb_delegate = new SendNotificationNativeDelegate (SendNotification_cb);
				return SendNotification_cb_delegate;
			}
		}

		static void OverrideSendNotification (GLib.GType gtype)
		{
			OverrideSendNotification (gtype, SendNotificationVMCallback);
		}

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

		[UnmanagedFunctionPointer (CallingConvention.Cdecl)]
		delegate void SendNotificationNativeDelegate (IntPtr inst, IntPtr id, IntPtr notification);

		static void SendNotification_cb (IntPtr inst, IntPtr id, IntPtr notification)
		{
			try {
				NotificationBackend __obj = GLib.Object.GetObject (inst, false) as NotificationBackend;
				__obj.OnSendNotification (GLib.Marshaller.Utf8PtrToString (id), GLib.Object.GetObject(notification) as GLib.Notification);
			} catch (Exception e) {
				GLib.ExceptionManager.RaiseUnhandledException (e, false);
			}
		}

		[GLib.DefaultSignalHandler(Type=typeof(GLib.NotificationBackend), ConnectionMethod="OverrideSendNotification")]
		protected virtual void OnSendNotification (string id, GLib.Notification notification)
		{
			InternalSendNotification (id, notification);
		}

		private void InternalSendNotification (string id, GLib.Notification notification)
		{
			SendNotificationNativeDelegate unmanaged = class_abi.BaseOverride<SendNotificationNativeDelegate>(this.LookupGType(), "send_notification");
			if (unmanaged == null) return;

			IntPtr native_id = GLib.Marshaller.StringToPtrGStrdup (id);
			unmanaged (this.Handle, native_id, notification == null ? IntPtr.Zero : notification.Handle);
			GLib.Marshaller.Free (native_id);
		}

		static WithdrawNotificationNativeDelegate WithdrawNotification_cb_delegate;
		static WithdrawNotificationNativeDelegate WithdrawNotificationVMCallback {
			get {
				if (WithdrawNotification_cb_delegate == null)
					WithdrawNotification_cb_delegate = new WithdrawNotificationNativeDelegate (WithdrawNotification_cb);
				return WithdrawNotification_cb_delegate;
			}
		}

		static void OverrideWithdrawNotification (GLib.GType gtype)
		{
			OverrideWithdrawNotification (gtype, WithdrawNotificationVMCallback);
		}

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

		[UnmanagedFunctionPointer (CallingConvention.Cdecl)]
		delegate void WithdrawNotificationNativeDelegate (IntPtr inst, IntPtr id);

		static void WithdrawNotification_cb (IntPtr inst, IntPtr id)
		{
			try {
				NotificationBackend __obj = GLib.Object.GetObject (inst, false) as NotificationBackend;
				__obj.OnWithdrawNotification (GLib.Marshaller.Utf8PtrToString (id));
			} catch (Exception e) {
				GLib.ExceptionManager.RaiseUnhandledException (e, false);
			}
		}

		[GLib.DefaultSignalHandler(Type=typeof(GLib.NotificationBackend), ConnectionMethod="OverrideWithdrawNotification")]
		protected virtual void OnWithdrawNotification (string id)
		{
			InternalWithdrawNotification (id);
		}

		private void InternalWithdrawNotification (string id)
		{
			WithdrawNotificationNativeDelegate unmanaged = class_abi.BaseOverride<WithdrawNotificationNativeDelegate>(this.LookupGType(), "withdraw_notification");
			if (unmanaged == null) return;

			IntPtr native_id = GLib.Marshaller.StringToPtrGStrdup (id);
			unmanaged (this.Handle, native_id);
			GLib.Marshaller.Free (native_id);
		}


		// 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("is_supported"
							, GLib.Object.class_abi.Fields
							, (uint) sizeof( IntPtr ) // is_supported
							, null
							, "send_notification"
							, (uint) sizeof(IntPtr)
							, 0
							),
						new GLib.AbiField("send_notification"
							, -1
							, (uint) sizeof( IntPtr ) // send_notification
							, "is_supported"
							, "withdraw_notification"
							, (uint) sizeof(IntPtr)
							, 0
							),
						new GLib.AbiField("withdraw_notification"
							, -1
							, (uint) sizeof( IntPtr ) // withdraw_notification
							, "send_notification"
							, null
							, (uint) sizeof(IntPtr)
							, 0
							),
					});

				return _class_abi;
			}
		}


		// End of the ABI representation.

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

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

		[UnmanagedFunctionPointer (CallingConvention.Cdecl)]
		delegate void d_g_notification_backend_send_notification(IntPtr raw, IntPtr id, IntPtr notification);
		static d_g_notification_backend_send_notification g_notification_backend_send_notification = FuncLoader.LoadFunction<d_g_notification_backend_send_notification>(FuncLoader.GetProcAddress(GLibrary.Load(Library.Gio), "g_notification_backend_send_notification"));

		public void SendNotification(string id, GLib.Notification notification) {
			IntPtr native_id = GLib.Marshaller.StringToPtrGStrdup (id);
			g_notification_backend_send_notification(Handle, native_id, notification == null ? IntPtr.Zero : notification.Handle);
			GLib.Marshaller.Free (native_id);
		}

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

		public void WithdrawNotification(string id) {
			IntPtr native_id = GLib.Marshaller.StringToPtrGStrdup (id);
			g_notification_backend_withdraw_notification(Handle, native_id);
			GLib.Marshaller.Free (native_id);
		}


		// 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("application"
							, GLib.Object.abi_info.Fields
							, (uint) sizeof( IntPtr ) // application
							, null
							, "dbus_connection"
							, (uint) sizeof(IntPtr)
							, 0
							),
						new GLib.AbiField("dbus_connection"
							, -1
							, (uint) sizeof( IntPtr ) // dbus_connection
							, "application"
							, null
							, (uint) sizeof(IntPtr)
							, 0
							),
					});

				return _abi_info;
			}
		}


		// End of the ABI representation.

#endregion
	}
}
