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

namespace Gtk {

	using System;
	using System.Runtime.InteropServices;

#region Autogenerated code
	public partial class PrintOperationPreviewAdapter : GLib.GInterfaceAdapter, Gtk.IPrintOperationPreview {

		[StructLayout (LayoutKind.Sequential)]
		struct GtkPrintOperationPreviewIface {
			IntPtr Ready;
			IntPtr GotPageSize;
			public RenderPageNativeDelegate RenderPage;
			public IsSelectedNativeDelegate IsSelected;
			public EndPreviewNativeDelegate EndPreview;
			IntPtr GtkReserved1;
			IntPtr GtkReserved2;
			IntPtr GtkReserved3;
			IntPtr GtkReserved4;
			IntPtr GtkReserved5;
			IntPtr GtkReserved6;
			IntPtr GtkReserved7;
			IntPtr GtkReserved8;
		}

		static GtkPrintOperationPreviewIface iface;

		static PrintOperationPreviewAdapter ()
		{
			GLib.GType.Register (_gtype, typeof (PrintOperationPreviewAdapter));
			iface.RenderPage = new RenderPageNativeDelegate (RenderPage_cb);
			iface.IsSelected = new IsSelectedNativeDelegate (IsSelected_cb);
			iface.EndPreview = new EndPreviewNativeDelegate (EndPreview_cb);
		}

		[UnmanagedFunctionPointer (CallingConvention.Cdecl)]
		delegate void RenderPageNativeDelegate (IntPtr inst, int page_nr);

		static void RenderPage_cb (IntPtr inst, int page_nr)
		{
			try {
				IPrintOperationPreviewImplementor __obj = GLib.Object.GetObject (inst, false) as IPrintOperationPreviewImplementor;
				__obj.RenderPage (page_nr);
			} catch (Exception e) {
				GLib.ExceptionManager.RaiseUnhandledException (e, false);
			}
		}

		[UnmanagedFunctionPointer (CallingConvention.Cdecl)]
		delegate bool IsSelectedNativeDelegate (IntPtr inst, int page_nr);

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

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

		static void EndPreview_cb (IntPtr inst)
		{
			try {
				IPrintOperationPreviewImplementor __obj = GLib.Object.GetObject (inst, false) as IPrintOperationPreviewImplementor;
				__obj.EndPreview ();
			} 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);
			GtkPrintOperationPreviewIface native_iface = (GtkPrintOperationPreviewIface) Marshal.PtrToStructure (ifaceptr, typeof (GtkPrintOperationPreviewIface));
			native_iface.RenderPage = iface.RenderPage;
			native_iface.IsSelected = iface.IsSelected;
			native_iface.EndPreview = iface.EndPreview;
			Marshal.StructureToPtr (native_iface, ifaceptr, false);
		}

		GLib.Object implementor;

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

		public PrintOperationPreviewAdapter (IPrintOperationPreviewImplementor 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 PrintOperationPreviewAdapter (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_print_operation_preview_get_type();
		static d_gtk_print_operation_preview_get_type gtk_print_operation_preview_get_type = FuncLoader.LoadFunction<d_gtk_print_operation_preview_get_type>(FuncLoader.GetProcAddress(GLibrary.Load(Library.Gtk), "gtk_print_operation_preview_get_type"));

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

		public static IPrintOperationPreview GetObject (GLib.Object obj)
		{
			if (obj == null)
				return null;
			else if (obj is IPrintOperationPreviewImplementor)
				return new PrintOperationPreviewAdapter (obj as IPrintOperationPreviewImplementor);
			else if (obj as IPrintOperationPreview == null)
				return new PrintOperationPreviewAdapter (obj.Handle);
			else
				return obj as IPrintOperationPreview;
		}

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

		[GLib.Signal("got-page-size")]
		public event Gtk.GotPageSizeHandler GotPageSize {
			add {
				GLib.Object.GetObject (Handle).AddSignalHandler ("got-page-size", value, typeof (Gtk.GotPageSizeArgs));
			}
			remove {
				GLib.Object.GetObject (Handle).RemoveSignalHandler ("got-page-size", value);
			}
		}

		[GLib.Signal("ready")]
		public event Gtk.ReadyHandler Ready {
			add {
				GLib.Object.GetObject (Handle).AddSignalHandler ("ready", value, typeof (Gtk.ReadyArgs));
			}
			remove {
				GLib.Object.GetObject (Handle).RemoveSignalHandler ("ready", value);
			}
		}

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

		public void EndPreview() {
			gtk_print_operation_preview_end_preview(Handle);
		}

		[UnmanagedFunctionPointer (CallingConvention.Cdecl)]
		delegate bool d_gtk_print_operation_preview_is_selected(IntPtr raw, int page_nr);
		static d_gtk_print_operation_preview_is_selected gtk_print_operation_preview_is_selected = FuncLoader.LoadFunction<d_gtk_print_operation_preview_is_selected>(FuncLoader.GetProcAddress(GLibrary.Load(Library.Gtk), "gtk_print_operation_preview_is_selected"));

		public bool IsSelected(int page_nr) {
			bool raw_ret = gtk_print_operation_preview_is_selected(Handle, page_nr);
			bool ret = raw_ret;
			return ret;
		}

		[UnmanagedFunctionPointer (CallingConvention.Cdecl)]
		delegate void d_gtk_print_operation_preview_render_page(IntPtr raw, int page_nr);
		static d_gtk_print_operation_preview_render_page gtk_print_operation_preview_render_page = FuncLoader.LoadFunction<d_gtk_print_operation_preview_render_page>(FuncLoader.GetProcAddress(GLibrary.Load(Library.Gtk), "gtk_print_operation_preview_render_page"));

		public void RenderPage(int page_nr) {
			gtk_print_operation_preview_render_page(Handle, page_nr);
		}

#endregion
	}
}
