// 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 InitableAdapter : GLib.GInterfaceAdapter, GLib.IInitable {

		GLib.Object implementor;

		public InitableAdapter (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_initable_get_type();
		static d_g_initable_get_type g_initable_get_type = FuncLoader.LoadFunction<d_g_initable_get_type>(FuncLoader.GetProcAddress(GLibrary.Load(Library.Gio), "g_initable_get_type"));

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

		public static IInitable GetObject (GLib.Object obj)
		{
			if (obj == null)
				return null;
			else if (obj as IInitable == null)
				return new InitableAdapter (obj.Handle);
			else
				return obj as IInitable;
		}

		[UnmanagedFunctionPointer (CallingConvention.Cdecl)]
		delegate bool d_g_initable_init(IntPtr raw, IntPtr cancellable, out IntPtr error);
		static d_g_initable_init g_initable_init = FuncLoader.LoadFunction<d_g_initable_init>(FuncLoader.GetProcAddress(GLibrary.Load(Library.Gio), "g_initable_init"));

		public bool Init(GLib.Cancellable cancellable) {
			IntPtr error = IntPtr.Zero;
			bool raw_ret = g_initable_init(Handle, cancellable == null ? IntPtr.Zero : cancellable.Handle, out error);
			bool ret = raw_ret;
			if (error != IntPtr.Zero) throw new GLib.GException (error);
			return ret;
		}

#endregion
	}
}
