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

namespace Gtk {

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

#region Autogenerated code
	public partial class CssProvider : GLib.Object, Gtk.IStyleProvider {

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

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

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

		[GLib.Signal("parsing-error")]
		public event Gtk.ParsingErrorHandler ParsingError {
			add {
				this.AddSignalHandler ("parsing-error", value, typeof (Gtk.ParsingErrorArgs));
			}
			remove {
				this.RemoveSignalHandler ("parsing-error", value);
			}
		}

		static ParsingErrorNativeDelegate ParsingError_cb_delegate;
		static ParsingErrorNativeDelegate ParsingErrorVMCallback {
			get {
				if (ParsingError_cb_delegate == null)
					ParsingError_cb_delegate = new ParsingErrorNativeDelegate (ParsingError_cb);
				return ParsingError_cb_delegate;
			}
		}

		static void OverrideParsingError (GLib.GType gtype)
		{
			OverrideParsingError (gtype, ParsingErrorVMCallback);
		}

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

		[UnmanagedFunctionPointer (CallingConvention.Cdecl)]
		delegate void ParsingErrorNativeDelegate (IntPtr inst, IntPtr section, IntPtr error);

		static void ParsingError_cb (IntPtr inst, IntPtr section, IntPtr error)
		{
			try {
				CssProvider __obj = GLib.Object.GetObject (inst, false) as CssProvider;
				__obj.OnParsingError (section == IntPtr.Zero ? null : (Gtk.CssSection) GLib.Opaque.GetOpaque (section, typeof (Gtk.CssSection), false), error);
			} catch (Exception e) {
				GLib.ExceptionManager.RaiseUnhandledException (e, false);
			}
		}

		[GLib.DefaultSignalHandler(Type=typeof(Gtk.CssProvider), ConnectionMethod="OverrideParsingError")]
		protected virtual void OnParsingError (Gtk.CssSection section, IntPtr error)
		{
			InternalParsingError (section, error);
		}

		private void InternalParsingError (Gtk.CssSection section, IntPtr error)
		{
			ParsingErrorNativeDelegate unmanaged = class_abi.BaseOverride<ParsingErrorNativeDelegate>(this.LookupGType(), "parsing_error");
			if (unmanaged == null) return;

			unmanaged (this.Handle, section == null ? IntPtr.Zero : section.Handle, error);
		}


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

				return _class_abi;
			}
		}


		// End of the ABI representation.

		[UnmanagedFunctionPointer (CallingConvention.Cdecl)]
		delegate int d_gtk_css_provider_error_quark();
		static d_gtk_css_provider_error_quark gtk_css_provider_error_quark = FuncLoader.LoadFunction<d_gtk_css_provider_error_quark>(FuncLoader.GetProcAddress(GLibrary.Load(Library.Gtk), "gtk_css_provider_error_quark"));

		public static int ErrorQuark() {
			int raw_ret = gtk_css_provider_error_quark();
			int ret = raw_ret;
			return ret;
		}

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

		public static Gtk.CssProvider Default { 
			get {
				IntPtr raw_ret = gtk_css_provider_get_default();
				Gtk.CssProvider ret = GLib.Object.GetObject(raw_ret) as Gtk.CssProvider;
				return ret;
			}
		}

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

		public static Gtk.CssProvider GetNamed(string name, string variant) {
			IntPtr native_name = GLib.Marshaller.StringToPtrGStrdup (name);
			IntPtr native_variant = GLib.Marshaller.StringToPtrGStrdup (variant);
			IntPtr raw_ret = gtk_css_provider_get_named(native_name, native_variant);
			Gtk.CssProvider ret = GLib.Object.GetObject(raw_ret) as Gtk.CssProvider;
			GLib.Marshaller.Free (native_name);
			GLib.Marshaller.Free (native_variant);
			return ret;
		}

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

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

		[UnmanagedFunctionPointer (CallingConvention.Cdecl)]
		delegate bool d_gtk_css_provider_load_from_data(IntPtr raw, IntPtr data, IntPtr length, out IntPtr error);
		static d_gtk_css_provider_load_from_data gtk_css_provider_load_from_data = FuncLoader.LoadFunction<d_gtk_css_provider_load_from_data>(FuncLoader.GetProcAddress(GLibrary.Load(Library.Gtk), "gtk_css_provider_load_from_data"));

		public unsafe bool LoadFromData(string data) {
			IntPtr native_data = GLib.Marshaller.StringToPtrGStrdup (data);
			IntPtr error = IntPtr.Zero;
			bool raw_ret = gtk_css_provider_load_from_data(Handle, native_data, new IntPtr ((long) System.Text.Encoding.UTF8.GetByteCount (data)), out error);
			bool ret = raw_ret;
			GLib.Marshaller.Free (native_data);
			if (error != IntPtr.Zero) throw new GLib.GException (error);
			return ret;
		}

		[UnmanagedFunctionPointer (CallingConvention.Cdecl)]
		delegate bool d_gtk_css_provider_load_from_file(IntPtr raw, IntPtr file, out IntPtr error);
		static d_gtk_css_provider_load_from_file gtk_css_provider_load_from_file = FuncLoader.LoadFunction<d_gtk_css_provider_load_from_file>(FuncLoader.GetProcAddress(GLibrary.Load(Library.Gtk), "gtk_css_provider_load_from_file"));

		public unsafe bool LoadFromFile(GLib.IFile file) {
			IntPtr error = IntPtr.Zero;
			bool raw_ret = gtk_css_provider_load_from_file(Handle, file == null ? IntPtr.Zero : ((file is GLib.Object) ? (file as GLib.Object).Handle : (file as GLib.FileAdapter).Handle), out error);
			bool ret = raw_ret;
			if (error != IntPtr.Zero) throw new GLib.GException (error);
			return ret;
		}

		[UnmanagedFunctionPointer (CallingConvention.Cdecl)]
		delegate bool d_gtk_css_provider_load_from_path(IntPtr raw, IntPtr path, out IntPtr error);
		static d_gtk_css_provider_load_from_path gtk_css_provider_load_from_path = FuncLoader.LoadFunction<d_gtk_css_provider_load_from_path>(FuncLoader.GetProcAddress(GLibrary.Load(Library.Gtk), "gtk_css_provider_load_from_path"));

		public unsafe bool LoadFromPath(string path) {
			IntPtr native_path = GLib.Marshaller.StringToPtrGStrdup (path);
			IntPtr error = IntPtr.Zero;
			bool raw_ret = gtk_css_provider_load_from_path(Handle, native_path, out error);
			bool ret = raw_ret;
			GLib.Marshaller.Free (native_path);
			if (error != IntPtr.Zero) throw new GLib.GException (error);
			return ret;
		}

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

		public override string ToString() {
			IntPtr raw_ret = gtk_css_provider_to_string(Handle);
			string ret = GLib.Marshaller.PtrToStringGFree(raw_ret);
			return ret;
		}

		[UnmanagedFunctionPointer (CallingConvention.Cdecl)]
		delegate bool d_gtk_style_provider_get_style_property(IntPtr raw, IntPtr path, int state, IntPtr pspec, IntPtr value);
		static d_gtk_style_provider_get_style_property gtk_style_provider_get_style_property = FuncLoader.LoadFunction<d_gtk_style_provider_get_style_property>(FuncLoader.GetProcAddress(GLibrary.Load(Library.Gtk), "gtk_style_provider_get_style_property"));

		public bool GetStyleProperty(Gtk.WidgetPath path, Gtk.StateFlags state, IntPtr pspec, GLib.Value value) {
			IntPtr native_value = GLib.Marshaller.StructureToPtrAlloc (value);
			bool raw_ret = gtk_style_provider_get_style_property(Handle, path == null ? IntPtr.Zero : path.Handle, (int) state, pspec, native_value);
			bool ret = raw_ret;
			Marshal.FreeHGlobal (native_value);
			return ret;
		}


		// 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
	}
}
