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

namespace Atk {

	using System;
	using System.Runtime.InteropServices;

#region Autogenerated code
	public partial class DocumentAdapter : GLib.GInterfaceAdapter, Atk.IDocument {

		[StructLayout (LayoutKind.Sequential)]
		struct AtkDocumentIface {
			public GetDocumentTypeNativeDelegate GetDocumentType;
			public GetTheDocumentNativeDelegate GetTheDocument;
			public GetLocaleNativeDelegate GetLocale;
			public GetAttributesNativeDelegate GetAttributes;
			public GetAttributeValueNativeDelegate GetAttributeValue;
			public SetAttributeValueNativeDelegate SetAttributeValue;
			public GetCurrentPageNumberNativeDelegate GetCurrentPageNumber;
			public GetPageCountNativeDelegate GetPageCount;
		}

		static AtkDocumentIface iface;

		static DocumentAdapter ()
		{
			GLib.GType.Register (_gtype, typeof (DocumentAdapter));
			iface.GetDocumentType = new GetDocumentTypeNativeDelegate (GetDocumentType_cb);
			iface.GetTheDocument = new GetTheDocumentNativeDelegate (GetTheDocument_cb);
			iface.GetLocale = new GetLocaleNativeDelegate (GetLocale_cb);
			iface.GetAttributes = new GetAttributesNativeDelegate (GetAttributes_cb);
			iface.GetAttributeValue = new GetAttributeValueNativeDelegate (GetAttributeValue_cb);
			iface.SetAttributeValue = new SetAttributeValueNativeDelegate (SetAttributeValue_cb);
			iface.GetCurrentPageNumber = new GetCurrentPageNumberNativeDelegate (GetCurrentPageNumber_cb);
			iface.GetPageCount = new GetPageCountNativeDelegate (GetPageCount_cb);
		}

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

		static IntPtr GetDocumentType_cb (IntPtr inst)
		{
			try {
				IDocumentImplementor __obj = GLib.Object.GetObject (inst, false) as IDocumentImplementor;
				string __result;
				__result = __obj.DocumentType;
				return GLib.Marshaller.StringToPtrGStrdup(__result);
			} catch (Exception e) {
				GLib.ExceptionManager.RaiseUnhandledException (e, true);
				// NOTREACHED: above call does not return.
				throw;
			}
		}

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

		static IntPtr GetTheDocument_cb (IntPtr inst)
		{
			try {
				IDocumentImplementor __obj = GLib.Object.GetObject (inst, false) as IDocumentImplementor;
				IntPtr __result;
				__result = __obj.TheDocument;
				return __result;
			} catch (Exception e) {
				GLib.ExceptionManager.RaiseUnhandledException (e, true);
				// NOTREACHED: above call does not return.
				throw;
			}
		}

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

		static IntPtr GetLocale_cb (IntPtr inst)
		{
			try {
				IDocumentImplementor __obj = GLib.Object.GetObject (inst, false) as IDocumentImplementor;
				string __result;
				__result = __obj.Locale;
				return GLib.Marshaller.StringToPtrGStrdup(__result);
			} catch (Exception e) {
				GLib.ExceptionManager.RaiseUnhandledException (e, true);
				// NOTREACHED: above call does not return.
				throw;
			}
		}

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

		static IntPtr GetAttributes_cb (IntPtr inst)
		{
			try {
				IDocumentImplementor __obj = GLib.Object.GetObject (inst, false) as IDocumentImplementor;
				Atk.Attribute[] __result;
				__result = __obj.Attributes;
				return new GLib.SList(__result, typeof (Atk.Attribute), false, false) == null ? IntPtr.Zero : new GLib.SList(__result, typeof (Atk.Attribute), false, false).Handle;
			} catch (Exception e) {
				GLib.ExceptionManager.RaiseUnhandledException (e, true);
				// NOTREACHED: above call does not return.
				throw;
			}
		}

		[UnmanagedFunctionPointer (CallingConvention.Cdecl)]
		delegate IntPtr GetAttributeValueNativeDelegate (IntPtr inst, IntPtr attribute_name);

		static IntPtr GetAttributeValue_cb (IntPtr inst, IntPtr attribute_name)
		{
			try {
				IDocumentImplementor __obj = GLib.Object.GetObject (inst, false) as IDocumentImplementor;
				string __result;
				__result = __obj.GetAttributeValue (GLib.Marshaller.Utf8PtrToString (attribute_name));
				return GLib.Marshaller.StringToPtrGStrdup(__result);
			} catch (Exception e) {
				GLib.ExceptionManager.RaiseUnhandledException (e, true);
				// NOTREACHED: above call does not return.
				throw;
			}
		}

		[UnmanagedFunctionPointer (CallingConvention.Cdecl)]
		delegate bool SetAttributeValueNativeDelegate (IntPtr inst, IntPtr attribute_name, IntPtr attribute_value);

		static bool SetAttributeValue_cb (IntPtr inst, IntPtr attribute_name, IntPtr attribute_value)
		{
			try {
				IDocumentImplementor __obj = GLib.Object.GetObject (inst, false) as IDocumentImplementor;
				bool __result;
				__result = __obj.SetAttributeValue (GLib.Marshaller.Utf8PtrToString (attribute_name), GLib.Marshaller.Utf8PtrToString (attribute_value));
				return __result;
			} catch (Exception e) {
				GLib.ExceptionManager.RaiseUnhandledException (e, true);
				// NOTREACHED: above call does not return.
				throw;
			}
		}

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

		static int GetCurrentPageNumber_cb (IntPtr inst)
		{
			try {
				IDocumentImplementor __obj = GLib.Object.GetObject (inst, false) as IDocumentImplementor;
				int __result;
				__result = __obj.CurrentPageNumber;
				return __result;
			} catch (Exception e) {
				GLib.ExceptionManager.RaiseUnhandledException (e, true);
				// NOTREACHED: above call does not return.
				throw;
			}
		}

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

		static int GetPageCount_cb (IntPtr inst)
		{
			try {
				IDocumentImplementor __obj = GLib.Object.GetObject (inst, false) as IDocumentImplementor;
				int __result;
				__result = __obj.PageCount;
				return __result;
			} catch (Exception e) {
				GLib.ExceptionManager.RaiseUnhandledException (e, true);
				// NOTREACHED: above call does not return.
				throw;
			}
		}

		static int class_offset = 2 * IntPtr.Size;

		static void Initialize (IntPtr ptr, IntPtr data)
		{
			IntPtr ifaceptr = new IntPtr (ptr.ToInt64 () + class_offset);
			AtkDocumentIface native_iface = (AtkDocumentIface) Marshal.PtrToStructure (ifaceptr, typeof (AtkDocumentIface));
			native_iface.GetDocumentType = iface.GetDocumentType;
			native_iface.GetTheDocument = iface.GetTheDocument;
			native_iface.GetLocale = iface.GetLocale;
			native_iface.GetAttributes = iface.GetAttributes;
			native_iface.GetAttributeValue = iface.GetAttributeValue;
			native_iface.SetAttributeValue = iface.SetAttributeValue;
			native_iface.GetCurrentPageNumber = iface.GetCurrentPageNumber;
			native_iface.GetPageCount = iface.GetPageCount;
			Marshal.StructureToPtr (native_iface, ifaceptr, false);
		}

		GLib.Object implementor;

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

		public DocumentAdapter (IDocumentImplementor 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 DocumentAdapter (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_atk_document_get_type();
		static d_atk_document_get_type atk_document_get_type = FuncLoader.LoadFunction<d_atk_document_get_type>(FuncLoader.GetProcAddress(GLibrary.Load(Library.Atk), "atk_document_get_type"));

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

		public static IDocument GetObject (GLib.Object obj)
		{
			if (obj == null)
				return null;
			else if (obj is IDocumentImplementor)
				return new DocumentAdapter (obj as IDocumentImplementor);
			else if (obj as IDocument == null)
				return new DocumentAdapter (obj.Handle);
			else
				return obj as IDocument;
		}

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

		[GLib.Signal("reload")]
		public event System.EventHandler Reload {
			add {
				GLib.Object.GetObject (Handle).AddSignalHandler ("reload", value);
			}
			remove {
				GLib.Object.GetObject (Handle).RemoveSignalHandler ("reload", value);
			}
		}

		[GLib.Signal("load_complete")]
		public event System.EventHandler LoadComplete {
			add {
				GLib.Object.GetObject (Handle).AddSignalHandler ("load_complete", value);
			}
			remove {
				GLib.Object.GetObject (Handle).RemoveSignalHandler ("load_complete", value);
			}
		}

		[GLib.Signal("load_stopped")]
		public event System.EventHandler LoadStopped {
			add {
				GLib.Object.GetObject (Handle).AddSignalHandler ("load_stopped", value);
			}
			remove {
				GLib.Object.GetObject (Handle).RemoveSignalHandler ("load_stopped", value);
			}
		}

		[GLib.Signal("page_changed")]
		public event Atk.PageChangedHandler PageChanged {
			add {
				GLib.Object.GetObject (Handle).AddSignalHandler ("page_changed", value, typeof (Atk.PageChangedArgs));
			}
			remove {
				GLib.Object.GetObject (Handle).RemoveSignalHandler ("page_changed", value);
			}
		}

		[UnmanagedFunctionPointer (CallingConvention.Cdecl)]
		delegate IntPtr d_atk_document_get_attribute_value(IntPtr raw, IntPtr attribute_name);
		static d_atk_document_get_attribute_value atk_document_get_attribute_value = FuncLoader.LoadFunction<d_atk_document_get_attribute_value>(FuncLoader.GetProcAddress(GLibrary.Load(Library.Atk), "atk_document_get_attribute_value"));

		public string GetAttributeValue(string attribute_name) {
			IntPtr native_attribute_name = GLib.Marshaller.StringToPtrGStrdup (attribute_name);
			IntPtr raw_ret = atk_document_get_attribute_value(Handle, native_attribute_name);
			string ret = GLib.Marshaller.Utf8PtrToString (raw_ret);
			GLib.Marshaller.Free (native_attribute_name);
			return ret;
		}

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

		public Atk.Attribute[] Attributes { 
			get {
				IntPtr raw_ret = atk_document_get_attributes(Handle);
				Atk.Attribute[] ret = GLib.Marshaller.SListPtrToArray<Atk.Attribute, Atk.Attribute> (raw_ret, false, false);
				return ret;
			}
		}

		[UnmanagedFunctionPointer (CallingConvention.Cdecl)]
		delegate int d_atk_document_get_current_page_number(IntPtr raw);
		static d_atk_document_get_current_page_number atk_document_get_current_page_number = FuncLoader.LoadFunction<d_atk_document_get_current_page_number>(FuncLoader.GetProcAddress(GLibrary.Load(Library.Atk), "atk_document_get_current_page_number"));

		public int CurrentPageNumber { 
			get {
				int raw_ret = atk_document_get_current_page_number(Handle);
				int ret = raw_ret;
				return ret;
			}
		}

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

		[Obsolete]
		public IntPtr TheDocument { 
			get {
				IntPtr raw_ret = atk_document_get_document(Handle);
				IntPtr ret = raw_ret;
				return ret;
			}
		}

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

		[Obsolete]
		public string DocumentType { 
			get {
				IntPtr raw_ret = atk_document_get_document_type(Handle);
				string ret = GLib.Marshaller.Utf8PtrToString (raw_ret);
				return ret;
			}
		}

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

		[Obsolete]
		public string Locale { 
			get {
				IntPtr raw_ret = atk_document_get_locale(Handle);
				string ret = GLib.Marshaller.Utf8PtrToString (raw_ret);
				return ret;
			}
		}

		[UnmanagedFunctionPointer (CallingConvention.Cdecl)]
		delegate int d_atk_document_get_page_count(IntPtr raw);
		static d_atk_document_get_page_count atk_document_get_page_count = FuncLoader.LoadFunction<d_atk_document_get_page_count>(FuncLoader.GetProcAddress(GLibrary.Load(Library.Atk), "atk_document_get_page_count"));

		public int PageCount { 
			get {
				int raw_ret = atk_document_get_page_count(Handle);
				int ret = raw_ret;
				return ret;
			}
		}

		[UnmanagedFunctionPointer (CallingConvention.Cdecl)]
		delegate bool d_atk_document_set_attribute_value(IntPtr raw, IntPtr attribute_name, IntPtr attribute_value);
		static d_atk_document_set_attribute_value atk_document_set_attribute_value = FuncLoader.LoadFunction<d_atk_document_set_attribute_value>(FuncLoader.GetProcAddress(GLibrary.Load(Library.Atk), "atk_document_set_attribute_value"));

		public bool SetAttributeValue(string attribute_name, string attribute_value) {
			IntPtr native_attribute_name = GLib.Marshaller.StringToPtrGStrdup (attribute_name);
			IntPtr native_attribute_value = GLib.Marshaller.StringToPtrGStrdup (attribute_value);
			bool raw_ret = atk_document_set_attribute_value(Handle, native_attribute_name, native_attribute_value);
			bool ret = raw_ret;
			GLib.Marshaller.Free (native_attribute_name);
			GLib.Marshaller.Free (native_attribute_value);
			return ret;
		}

#endregion
	}
}
