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

namespace GtkSource {

	using System;
	using System.Runtime.InteropServices;

#region Autogenerated code
	public partial class StyleSchemeChooserAdapter : GLib.GInterfaceAdapter, GtkSource.IStyleSchemeChooser {

		[StructLayout (LayoutKind.Sequential)]
		struct GtkSourceStyleSchemeChooserInterface {
			public GetStyleSchemeNativeDelegate GetStyleScheme;
			public SetStyleSchemeNativeDelegate SetStyleScheme;
			[MarshalAs (UnmanagedType.ByValArray, SizeConst=12)]
			public IntPtr[] Padding;
		}

		static GtkSourceStyleSchemeChooserInterface iface;

		static StyleSchemeChooserAdapter ()
		{
			GLib.GType.Register (_gtype, typeof (StyleSchemeChooserAdapter));
			iface.GetStyleScheme = new GetStyleSchemeNativeDelegate (GetStyleScheme_cb);
			iface.SetStyleScheme = new SetStyleSchemeNativeDelegate (SetStyleScheme_cb);
		}

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

		static IntPtr GetStyleScheme_cb (IntPtr inst)
		{
			try {
				IStyleSchemeChooserImplementor __obj = GLib.Object.GetObject (inst, false) as IStyleSchemeChooserImplementor;
				GtkSource.StyleScheme __result;
				__result = __obj.StyleScheme;
				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 SetStyleSchemeNativeDelegate (IntPtr inst, IntPtr scheme);

		static void SetStyleScheme_cb (IntPtr inst, IntPtr scheme)
		{
			try {
				IStyleSchemeChooserImplementor __obj = GLib.Object.GetObject (inst, false) as IStyleSchemeChooserImplementor;
				__obj.StyleScheme = GLib.Object.GetObject(scheme) as GtkSource.StyleScheme;
			} 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);
			GtkSourceStyleSchemeChooserInterface native_iface = (GtkSourceStyleSchemeChooserInterface) Marshal.PtrToStructure (ifaceptr, typeof (GtkSourceStyleSchemeChooserInterface));
			native_iface.GetStyleScheme = iface.GetStyleScheme;
			native_iface.SetStyleScheme = iface.SetStyleScheme;
			Marshal.StructureToPtr (native_iface, ifaceptr, false);
		}

		GLib.Object implementor;

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

		public StyleSchemeChooserAdapter (IStyleSchemeChooserImplementor 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 StyleSchemeChooserAdapter (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_source_style_scheme_chooser_get_type();
		static d_gtk_source_style_scheme_chooser_get_type gtk_source_style_scheme_chooser_get_type = FuncLoader.LoadFunction<d_gtk_source_style_scheme_chooser_get_type>(FuncLoader.GetProcAddress(GLibrary.Load(Library.GtkSource), "gtk_source_style_scheme_chooser_get_type"));

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

		public static IStyleSchemeChooser GetObject (GLib.Object obj)
		{
			if (obj == null)
				return null;
			else if (obj is IStyleSchemeChooserImplementor)
				return new StyleSchemeChooserAdapter (obj as IStyleSchemeChooserImplementor);
			else if (obj as IStyleSchemeChooser == null)
				return new StyleSchemeChooserAdapter (obj.Handle);
			else
				return obj as IStyleSchemeChooser;
		}

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

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

		[UnmanagedFunctionPointer (CallingConvention.Cdecl)]
		delegate void d_gtk_source_style_scheme_chooser_set_style_scheme(IntPtr raw, IntPtr scheme);
		static d_gtk_source_style_scheme_chooser_set_style_scheme gtk_source_style_scheme_chooser_set_style_scheme = FuncLoader.LoadFunction<d_gtk_source_style_scheme_chooser_set_style_scheme>(FuncLoader.GetProcAddress(GLibrary.Load(Library.GtkSource), "gtk_source_style_scheme_chooser_set_style_scheme"));

		public GtkSource.StyleScheme StyleScheme { 
			get {
				IntPtr raw_ret = gtk_source_style_scheme_chooser_get_style_scheme(Handle);
				GtkSource.StyleScheme ret = GLib.Object.GetObject(raw_ret) as GtkSource.StyleScheme;
				return ret;
			}
			set {
				gtk_source_style_scheme_chooser_set_style_scheme(Handle, value == null ? IntPtr.Zero : value.Handle);
			}
		}

#endregion
	}
}
