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

namespace WebKit {

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

#region Autogenerated code
	public partial class InputMethodContext : GLib.Object {

		protected InputMethodContext (IntPtr raw) : base(raw) {}

		protected InputMethodContext() : base(IntPtr.Zero)
		{
			CreateNativeObject (Array.Empty<string> (), Array.Empty<GLib.Value> ());
		}

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

		[UnmanagedFunctionPointer (CallingConvention.Cdecl)]
		delegate void d_webkit_input_method_context_set_input_hints(IntPtr raw, int hints);
		static d_webkit_input_method_context_set_input_hints webkit_input_method_context_set_input_hints = FuncLoader.LoadFunction<d_webkit_input_method_context_set_input_hints>(FuncLoader.GetProcAddress(GLibrary.Load(Library.Webkit), "webkit_input_method_context_set_input_hints"));

		[GLib.Property ("input-hints")]
		public WebKit.InputHints InputHints {
			get  {
				int raw_ret = webkit_input_method_context_get_input_hints(Handle);
				WebKit.InputHints ret = (WebKit.InputHints) raw_ret;
				return ret;
			}
			set  {
				webkit_input_method_context_set_input_hints(Handle, (int) value);
			}
		}

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

		[UnmanagedFunctionPointer (CallingConvention.Cdecl)]
		delegate void d_webkit_input_method_context_set_input_purpose(IntPtr raw, int purpose);
		static d_webkit_input_method_context_set_input_purpose webkit_input_method_context_set_input_purpose = FuncLoader.LoadFunction<d_webkit_input_method_context_set_input_purpose>(FuncLoader.GetProcAddress(GLibrary.Load(Library.Webkit), "webkit_input_method_context_set_input_purpose"));

		[GLib.Property ("input-purpose")]
		public WebKit.InputPurpose InputPurpose {
			get  {
				int raw_ret = webkit_input_method_context_get_input_purpose(Handle);
				WebKit.InputPurpose ret = (WebKit.InputPurpose) raw_ret;
				return ret;
			}
			set  {
				webkit_input_method_context_set_input_purpose(Handle, (int) value);
			}
		}

		[GLib.Signal("delete-surrounding")]
		public event WebKit.DeleteSurroundingHandler DeleteSurrounding {
			add {
				this.AddSignalHandler ("delete-surrounding", value, typeof (WebKit.DeleteSurroundingArgs));
			}
			remove {
				this.RemoveSignalHandler ("delete-surrounding", value);
			}
		}

		[GLib.Signal("preedit-started")]
		public event System.EventHandler PreeditStarted {
			add {
				this.AddSignalHandler ("preedit-started", value);
			}
			remove {
				this.RemoveSignalHandler ("preedit-started", value);
			}
		}

		[GLib.Signal("preedit-changed")]
		public event System.EventHandler PreeditChanged {
			add {
				this.AddSignalHandler ("preedit-changed", value);
			}
			remove {
				this.RemoveSignalHandler ("preedit-changed", value);
			}
		}

		[GLib.Signal("committed")]
		public event WebKit.CommittedHandler Committed {
			add {
				this.AddSignalHandler ("committed", value, typeof (WebKit.CommittedArgs));
			}
			remove {
				this.RemoveSignalHandler ("committed", value);
			}
		}

		[GLib.Signal("preedit-finished")]
		public event System.EventHandler PreeditFinished {
			add {
				this.AddSignalHandler ("preedit-finished", value);
			}
			remove {
				this.RemoveSignalHandler ("preedit-finished", value);
			}
		}

		static PreeditStartedNativeDelegate PreeditStarted_cb_delegate;
		static PreeditStartedNativeDelegate PreeditStartedVMCallback {
			get {
				if (PreeditStarted_cb_delegate == null)
					PreeditStarted_cb_delegate = new PreeditStartedNativeDelegate (PreeditStarted_cb);
				return PreeditStarted_cb_delegate;
			}
		}

		static void OverridePreeditStarted (GLib.GType gtype)
		{
			OverridePreeditStarted (gtype, PreeditStartedVMCallback);
		}

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

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

		static void PreeditStarted_cb (IntPtr inst)
		{
			try {
				InputMethodContext __obj = GLib.Object.GetObject (inst, false) as InputMethodContext;
				__obj.OnPreeditStarted ();
			} catch (Exception e) {
				GLib.ExceptionManager.RaiseUnhandledException (e, false);
			}
		}

		[GLib.DefaultSignalHandler(Type=typeof(WebKit.InputMethodContext), ConnectionMethod="OverridePreeditStarted")]
		protected virtual void OnPreeditStarted ()
		{
			InternalPreeditStarted ();
		}

		private void InternalPreeditStarted ()
		{
			PreeditStartedNativeDelegate unmanaged = class_abi.BaseOverride<PreeditStartedNativeDelegate>(this.LookupGType(), "preedit_started");
			if (unmanaged == null) return;

			unmanaged (this.Handle);
		}

		static PreeditChangedNativeDelegate PreeditChanged_cb_delegate;
		static PreeditChangedNativeDelegate PreeditChangedVMCallback {
			get {
				if (PreeditChanged_cb_delegate == null)
					PreeditChanged_cb_delegate = new PreeditChangedNativeDelegate (PreeditChanged_cb);
				return PreeditChanged_cb_delegate;
			}
		}

		static void OverridePreeditChanged (GLib.GType gtype)
		{
			OverridePreeditChanged (gtype, PreeditChangedVMCallback);
		}

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

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

		static void PreeditChanged_cb (IntPtr inst)
		{
			try {
				InputMethodContext __obj = GLib.Object.GetObject (inst, false) as InputMethodContext;
				__obj.OnPreeditChanged ();
			} catch (Exception e) {
				GLib.ExceptionManager.RaiseUnhandledException (e, false);
			}
		}

		[GLib.DefaultSignalHandler(Type=typeof(WebKit.InputMethodContext), ConnectionMethod="OverridePreeditChanged")]
		protected virtual void OnPreeditChanged ()
		{
			InternalPreeditChanged ();
		}

		private void InternalPreeditChanged ()
		{
			PreeditChangedNativeDelegate unmanaged = class_abi.BaseOverride<PreeditChangedNativeDelegate>(this.LookupGType(), "preedit_changed");
			if (unmanaged == null) return;

			unmanaged (this.Handle);
		}

		static PreeditFinishedNativeDelegate PreeditFinished_cb_delegate;
		static PreeditFinishedNativeDelegate PreeditFinishedVMCallback {
			get {
				if (PreeditFinished_cb_delegate == null)
					PreeditFinished_cb_delegate = new PreeditFinishedNativeDelegate (PreeditFinished_cb);
				return PreeditFinished_cb_delegate;
			}
		}

		static void OverridePreeditFinished (GLib.GType gtype)
		{
			OverridePreeditFinished (gtype, PreeditFinishedVMCallback);
		}

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

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

		static void PreeditFinished_cb (IntPtr inst)
		{
			try {
				InputMethodContext __obj = GLib.Object.GetObject (inst, false) as InputMethodContext;
				__obj.OnPreeditFinished ();
			} catch (Exception e) {
				GLib.ExceptionManager.RaiseUnhandledException (e, false);
			}
		}

		[GLib.DefaultSignalHandler(Type=typeof(WebKit.InputMethodContext), ConnectionMethod="OverridePreeditFinished")]
		protected virtual void OnPreeditFinished ()
		{
			InternalPreeditFinished ();
		}

		private void InternalPreeditFinished ()
		{
			PreeditFinishedNativeDelegate unmanaged = class_abi.BaseOverride<PreeditFinishedNativeDelegate>(this.LookupGType(), "preedit_finished");
			if (unmanaged == null) return;

			unmanaged (this.Handle);
		}

		static CommittedNativeDelegate Committed_cb_delegate;
		static CommittedNativeDelegate CommittedVMCallback {
			get {
				if (Committed_cb_delegate == null)
					Committed_cb_delegate = new CommittedNativeDelegate (Committed_cb);
				return Committed_cb_delegate;
			}
		}

		static void OverrideCommitted (GLib.GType gtype)
		{
			OverrideCommitted (gtype, CommittedVMCallback);
		}

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

		[UnmanagedFunctionPointer (CallingConvention.Cdecl)]
		delegate void CommittedNativeDelegate (IntPtr inst, IntPtr text);

		static void Committed_cb (IntPtr inst, IntPtr text)
		{
			try {
				InputMethodContext __obj = GLib.Object.GetObject (inst, false) as InputMethodContext;
				__obj.OnCommitted (GLib.Marshaller.Utf8PtrToString (text));
			} catch (Exception e) {
				GLib.ExceptionManager.RaiseUnhandledException (e, false);
			}
		}

		[GLib.DefaultSignalHandler(Type=typeof(WebKit.InputMethodContext), ConnectionMethod="OverrideCommitted")]
		protected virtual void OnCommitted (string text)
		{
			InternalCommitted (text);
		}

		private void InternalCommitted (string text)
		{
			CommittedNativeDelegate unmanaged = class_abi.BaseOverride<CommittedNativeDelegate>(this.LookupGType(), "committed");
			if (unmanaged == null) return;

			IntPtr native_text = GLib.Marshaller.StringToPtrGStrdup (text);
			unmanaged (this.Handle, native_text);
			GLib.Marshaller.Free (native_text);
		}

		static DeleteSurroundingNativeDelegate DeleteSurrounding_cb_delegate;
		static DeleteSurroundingNativeDelegate DeleteSurroundingVMCallback {
			get {
				if (DeleteSurrounding_cb_delegate == null)
					DeleteSurrounding_cb_delegate = new DeleteSurroundingNativeDelegate (DeleteSurrounding_cb);
				return DeleteSurrounding_cb_delegate;
			}
		}

		static void OverrideDeleteSurrounding (GLib.GType gtype)
		{
			OverrideDeleteSurrounding (gtype, DeleteSurroundingVMCallback);
		}

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

		[UnmanagedFunctionPointer (CallingConvention.Cdecl)]
		delegate void DeleteSurroundingNativeDelegate (IntPtr inst, int offset, uint n_chars);

		static void DeleteSurrounding_cb (IntPtr inst, int offset, uint n_chars)
		{
			try {
				InputMethodContext __obj = GLib.Object.GetObject (inst, false) as InputMethodContext;
				__obj.OnDeleteSurrounding (offset, n_chars);
			} catch (Exception e) {
				GLib.ExceptionManager.RaiseUnhandledException (e, false);
			}
		}

		[GLib.DefaultSignalHandler(Type=typeof(WebKit.InputMethodContext), ConnectionMethod="OverrideDeleteSurrounding")]
		protected virtual void OnDeleteSurrounding (int offset, uint n_chars)
		{
			InternalDeleteSurrounding (offset, n_chars);
		}

		private void InternalDeleteSurrounding (int offset, uint n_chars)
		{
			DeleteSurroundingNativeDelegate unmanaged = class_abi.BaseOverride<DeleteSurroundingNativeDelegate>(this.LookupGType(), "delete_surrounding");
			if (unmanaged == null) return;

			unmanaged (this.Handle, offset, n_chars);
		}

		static SetEnablePreeditNativeDelegate SetEnablePreedit_cb_delegate;
		static SetEnablePreeditNativeDelegate SetEnablePreeditVMCallback {
			get {
				if (SetEnablePreedit_cb_delegate == null)
					SetEnablePreedit_cb_delegate = new SetEnablePreeditNativeDelegate (SetEnablePreedit_cb);
				return SetEnablePreedit_cb_delegate;
			}
		}

		static void OverrideSetEnablePreedit (GLib.GType gtype)
		{
			OverrideSetEnablePreedit (gtype, SetEnablePreeditVMCallback);
		}

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

		[UnmanagedFunctionPointer (CallingConvention.Cdecl)]
		delegate void SetEnablePreeditNativeDelegate (IntPtr inst, bool enabled);

		static void SetEnablePreedit_cb (IntPtr inst, bool enabled)
		{
			try {
				InputMethodContext __obj = GLib.Object.GetObject (inst, false) as InputMethodContext;
				__obj.OnSetEnablePreedit (enabled);
			} catch (Exception e) {
				GLib.ExceptionManager.RaiseUnhandledException (e, false);
			}
		}

		[GLib.DefaultSignalHandler(Type=typeof(WebKit.InputMethodContext), ConnectionMethod="OverrideSetEnablePreedit")]
		protected virtual void OnSetEnablePreedit (bool enabled)
		{
			InternalSetEnablePreedit (enabled);
		}

		private void InternalSetEnablePreedit (bool enabled)
		{
			SetEnablePreeditNativeDelegate unmanaged = class_abi.BaseOverride<SetEnablePreeditNativeDelegate>(this.LookupGType(), "set_enable_preedit");
			if (unmanaged == null) return;

			unmanaged (this.Handle, enabled);
		}

		static GetPreeditNativeDelegate GetPreedit_cb_delegate;
		static GetPreeditNativeDelegate GetPreeditVMCallback {
			get {
				if (GetPreedit_cb_delegate == null)
					GetPreedit_cb_delegate = new GetPreeditNativeDelegate (GetPreedit_cb);
				return GetPreedit_cb_delegate;
			}
		}

		static void OverrideGetPreedit (GLib.GType gtype)
		{
			OverrideGetPreedit (gtype, GetPreeditVMCallback);
		}

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

		[UnmanagedFunctionPointer (CallingConvention.Cdecl)]
		delegate void GetPreeditNativeDelegate (IntPtr inst, out IntPtr text, out IntPtr underlines, out uint cursor_offset);

		static void GetPreedit_cb (IntPtr inst, out IntPtr text, out IntPtr underlines, out uint cursor_offset)
		{
			try {
				InputMethodContext __obj = GLib.Object.GetObject (inst, false) as InputMethodContext;
				string mytext;
				GLib.List myunderlines;
				__obj.OnGetPreedit (out mytext, out myunderlines, out cursor_offset);
				text = GLib.Marshaller.StringToPtrGStrdup(mytext);
				underlines = myunderlines == null ? IntPtr.Zero : myunderlines.Handle;
			} catch (Exception e) {
				GLib.ExceptionManager.RaiseUnhandledException (e, true);
				// NOTREACHED: above call does not return.
				throw;
			}
		}

		[GLib.DefaultSignalHandler(Type=typeof(WebKit.InputMethodContext), ConnectionMethod="OverrideGetPreedit")]
		protected virtual void OnGetPreedit (out string text, out GLib.List underlines, out uint cursor_offset)
		{
			InternalGetPreedit (out text, out underlines, out cursor_offset);
		}

		private void InternalGetPreedit (out string text, out GLib.List underlines, out uint cursor_offset)
		{
			GetPreeditNativeDelegate unmanaged = class_abi.BaseOverride<GetPreeditNativeDelegate>(this.LookupGType(), "get_preedit");
			if (unmanaged == null) throw new InvalidOperationException ("No base method to invoke");

			IntPtr native_text;
			IntPtr native_underlines;
			unmanaged (this.Handle, out native_text, out native_underlines, out cursor_offset);
			text = GLib.Marshaller.PtrToStringGFree(native_text);
			underlines = new GLib.List(native_underlines);
		}

		static FilterKeyEventNativeDelegate FilterKeyEvent_cb_delegate;
		static FilterKeyEventNativeDelegate FilterKeyEventVMCallback {
			get {
				if (FilterKeyEvent_cb_delegate == null)
					FilterKeyEvent_cb_delegate = new FilterKeyEventNativeDelegate (FilterKeyEvent_cb);
				return FilterKeyEvent_cb_delegate;
			}
		}

		static void OverrideFilterKeyEvent (GLib.GType gtype)
		{
			OverrideFilterKeyEvent (gtype, FilterKeyEventVMCallback);
		}

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

		[UnmanagedFunctionPointer (CallingConvention.Cdecl)]
		delegate bool FilterKeyEventNativeDelegate (IntPtr inst, IntPtr key_event);

		static bool FilterKeyEvent_cb (IntPtr inst, IntPtr key_event)
		{
			try {
				InputMethodContext __obj = GLib.Object.GetObject (inst, false) as InputMethodContext;
				bool __result;
				__result = __obj.OnFilterKeyEvent (new Gdk.EventKey(key_event));
				return __result;
			} catch (Exception e) {
				GLib.ExceptionManager.RaiseUnhandledException (e, true);
				// NOTREACHED: above call does not return.
				throw;
			}
		}

		[GLib.DefaultSignalHandler(Type=typeof(WebKit.InputMethodContext), ConnectionMethod="OverrideFilterKeyEvent")]
		protected virtual bool OnFilterKeyEvent (Gdk.EventKey key_event)
		{
			return InternalFilterKeyEvent (key_event);
		}

		private bool InternalFilterKeyEvent (Gdk.EventKey key_event)
		{
			FilterKeyEventNativeDelegate unmanaged = class_abi.BaseOverride<FilterKeyEventNativeDelegate>(this.LookupGType(), "filter_key_event");
			if (unmanaged == null) return false;

			bool __result = unmanaged (this.Handle, key_event == null ? IntPtr.Zero : key_event.Handle);
			return __result;
		}

		static NotifyFocusInNativeDelegate NotifyFocusIn_cb_delegate;
		static NotifyFocusInNativeDelegate NotifyFocusInVMCallback {
			get {
				if (NotifyFocusIn_cb_delegate == null)
					NotifyFocusIn_cb_delegate = new NotifyFocusInNativeDelegate (NotifyFocusIn_cb);
				return NotifyFocusIn_cb_delegate;
			}
		}

		static void OverrideNotifyFocusIn (GLib.GType gtype)
		{
			OverrideNotifyFocusIn (gtype, NotifyFocusInVMCallback);
		}

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

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

		static void NotifyFocusIn_cb (IntPtr inst)
		{
			try {
				InputMethodContext __obj = GLib.Object.GetObject (inst, false) as InputMethodContext;
				__obj.OnNotifyFocusIn ();
			} catch (Exception e) {
				GLib.ExceptionManager.RaiseUnhandledException (e, false);
			}
		}

		[GLib.DefaultSignalHandler(Type=typeof(WebKit.InputMethodContext), ConnectionMethod="OverrideNotifyFocusIn")]
		protected virtual void OnNotifyFocusIn ()
		{
			InternalNotifyFocusIn ();
		}

		private void InternalNotifyFocusIn ()
		{
			NotifyFocusInNativeDelegate unmanaged = class_abi.BaseOverride<NotifyFocusInNativeDelegate>(this.LookupGType(), "notify_focus_in");
			if (unmanaged == null) return;

			unmanaged (this.Handle);
		}

		static NotifyFocusOutNativeDelegate NotifyFocusOut_cb_delegate;
		static NotifyFocusOutNativeDelegate NotifyFocusOutVMCallback {
			get {
				if (NotifyFocusOut_cb_delegate == null)
					NotifyFocusOut_cb_delegate = new NotifyFocusOutNativeDelegate (NotifyFocusOut_cb);
				return NotifyFocusOut_cb_delegate;
			}
		}

		static void OverrideNotifyFocusOut (GLib.GType gtype)
		{
			OverrideNotifyFocusOut (gtype, NotifyFocusOutVMCallback);
		}

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

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

		static void NotifyFocusOut_cb (IntPtr inst)
		{
			try {
				InputMethodContext __obj = GLib.Object.GetObject (inst, false) as InputMethodContext;
				__obj.OnNotifyFocusOut ();
			} catch (Exception e) {
				GLib.ExceptionManager.RaiseUnhandledException (e, false);
			}
		}

		[GLib.DefaultSignalHandler(Type=typeof(WebKit.InputMethodContext), ConnectionMethod="OverrideNotifyFocusOut")]
		protected virtual void OnNotifyFocusOut ()
		{
			InternalNotifyFocusOut ();
		}

		private void InternalNotifyFocusOut ()
		{
			NotifyFocusOutNativeDelegate unmanaged = class_abi.BaseOverride<NotifyFocusOutNativeDelegate>(this.LookupGType(), "notify_focus_out");
			if (unmanaged == null) return;

			unmanaged (this.Handle);
		}

		static NotifyCursorAreaNativeDelegate NotifyCursorArea_cb_delegate;
		static NotifyCursorAreaNativeDelegate NotifyCursorAreaVMCallback {
			get {
				if (NotifyCursorArea_cb_delegate == null)
					NotifyCursorArea_cb_delegate = new NotifyCursorAreaNativeDelegate (NotifyCursorArea_cb);
				return NotifyCursorArea_cb_delegate;
			}
		}

		static void OverrideNotifyCursorArea (GLib.GType gtype)
		{
			OverrideNotifyCursorArea (gtype, NotifyCursorAreaVMCallback);
		}

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

		[UnmanagedFunctionPointer (CallingConvention.Cdecl)]
		delegate void NotifyCursorAreaNativeDelegate (IntPtr inst, int x, int y, int width, int height);

		static void NotifyCursorArea_cb (IntPtr inst, int x, int y, int width, int height)
		{
			try {
				InputMethodContext __obj = GLib.Object.GetObject (inst, false) as InputMethodContext;
				__obj.OnNotifyCursorArea (x, y, width, height);
			} catch (Exception e) {
				GLib.ExceptionManager.RaiseUnhandledException (e, false);
			}
		}

		[GLib.DefaultSignalHandler(Type=typeof(WebKit.InputMethodContext), ConnectionMethod="OverrideNotifyCursorArea")]
		protected virtual void OnNotifyCursorArea (int x, int y, int width, int height)
		{
			InternalNotifyCursorArea (x, y, width, height);
		}

		private void InternalNotifyCursorArea (int x, int y, int width, int height)
		{
			NotifyCursorAreaNativeDelegate unmanaged = class_abi.BaseOverride<NotifyCursorAreaNativeDelegate>(this.LookupGType(), "notify_cursor_area");
			if (unmanaged == null) return;

			unmanaged (this.Handle, x, y, width, height);
		}

		static NotifySurroundingNativeDelegate NotifySurrounding_cb_delegate;
		static NotifySurroundingNativeDelegate NotifySurroundingVMCallback {
			get {
				if (NotifySurrounding_cb_delegate == null)
					NotifySurrounding_cb_delegate = new NotifySurroundingNativeDelegate (NotifySurrounding_cb);
				return NotifySurrounding_cb_delegate;
			}
		}

		static void OverrideNotifySurrounding (GLib.GType gtype)
		{
			OverrideNotifySurrounding (gtype, NotifySurroundingVMCallback);
		}

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

		[UnmanagedFunctionPointer (CallingConvention.Cdecl)]
		delegate void NotifySurroundingNativeDelegate (IntPtr inst, IntPtr text, uint length, uint cursor_index, uint selection_index);

		static void NotifySurrounding_cb (IntPtr inst, IntPtr text, uint length, uint cursor_index, uint selection_index)
		{
			try {
				InputMethodContext __obj = GLib.Object.GetObject (inst, false) as InputMethodContext;
				__obj.OnNotifySurrounding (GLib.Marshaller.Utf8PtrToString (text), cursor_index, selection_index);
			} catch (Exception e) {
				GLib.ExceptionManager.RaiseUnhandledException (e, false);
			}
		}

		[GLib.DefaultSignalHandler(Type=typeof(WebKit.InputMethodContext), ConnectionMethod="OverrideNotifySurrounding")]
		protected virtual void OnNotifySurrounding (string text, uint cursor_index, uint selection_index)
		{
			InternalNotifySurrounding (text, cursor_index, selection_index);
		}

		private void InternalNotifySurrounding (string text, uint cursor_index, uint selection_index)
		{
			NotifySurroundingNativeDelegate unmanaged = class_abi.BaseOverride<NotifySurroundingNativeDelegate>(this.LookupGType(), "notify_surrounding");
			if (unmanaged == null) return;

			IntPtr native_text = GLib.Marshaller.StringToPtrGStrdup (text);
			unmanaged (this.Handle, native_text, (uint) System.Text.Encoding.UTF8.GetByteCount (text), cursor_index, selection_index);
			GLib.Marshaller.Free (native_text);
		}

		static ResetNativeDelegate Reset_cb_delegate;
		static ResetNativeDelegate ResetVMCallback {
			get {
				if (Reset_cb_delegate == null)
					Reset_cb_delegate = new ResetNativeDelegate (Reset_cb);
				return Reset_cb_delegate;
			}
		}

		static void OverrideReset (GLib.GType gtype)
		{
			OverrideReset (gtype, ResetVMCallback);
		}

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

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

		static void Reset_cb (IntPtr inst)
		{
			try {
				InputMethodContext __obj = GLib.Object.GetObject (inst, false) as InputMethodContext;
				__obj.OnReset ();
			} catch (Exception e) {
				GLib.ExceptionManager.RaiseUnhandledException (e, false);
			}
		}

		[GLib.DefaultSignalHandler(Type=typeof(WebKit.InputMethodContext), ConnectionMethod="OverrideReset")]
		protected virtual void OnReset ()
		{
			InternalReset ();
		}

		private void InternalReset ()
		{
			ResetNativeDelegate unmanaged = class_abi.BaseOverride<ResetNativeDelegate>(this.LookupGType(), "reset");
			if (unmanaged == null) return;

			unmanaged (this.Handle);
		}


		// 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("preedit_started"
							, GLib.Object.class_abi.Fields
							, (uint) sizeof( IntPtr ) // preedit_started
							, null
							, "preedit_changed"
							, (uint) sizeof(IntPtr)
							, 0
							),
						new GLib.AbiField("preedit_changed"
							, -1
							, (uint) sizeof( IntPtr ) // preedit_changed
							, "preedit_started"
							, "preedit_finished"
							, (uint) sizeof(IntPtr)
							, 0
							),
						new GLib.AbiField("preedit_finished"
							, -1
							, (uint) sizeof( IntPtr ) // preedit_finished
							, "preedit_changed"
							, "committed"
							, (uint) sizeof(IntPtr)
							, 0
							),
						new GLib.AbiField("committed"
							, -1
							, (uint) sizeof( IntPtr ) // committed
							, "preedit_finished"
							, "delete_surrounding"
							, (uint) sizeof(IntPtr)
							, 0
							),
						new GLib.AbiField("delete_surrounding"
							, -1
							, (uint) sizeof( IntPtr ) // delete_surrounding
							, "committed"
							, "set_enable_preedit"
							, (uint) sizeof(IntPtr)
							, 0
							),
						new GLib.AbiField("set_enable_preedit"
							, -1
							, (uint) sizeof( IntPtr ) // set_enable_preedit
							, "delete_surrounding"
							, "get_preedit"
							, (uint) sizeof(IntPtr)
							, 0
							),
						new GLib.AbiField("get_preedit"
							, -1
							, (uint) sizeof( IntPtr ) // get_preedit
							, "set_enable_preedit"
							, "filter_key_event"
							, (uint) sizeof(IntPtr)
							, 0
							),
						new GLib.AbiField("filter_key_event"
							, -1
							, (uint) sizeof( IntPtr ) // filter_key_event
							, "get_preedit"
							, "notify_focus_in"
							, (uint) sizeof(IntPtr)
							, 0
							),
						new GLib.AbiField("notify_focus_in"
							, -1
							, (uint) sizeof( IntPtr ) // notify_focus_in
							, "filter_key_event"
							, "notify_focus_out"
							, (uint) sizeof(IntPtr)
							, 0
							),
						new GLib.AbiField("notify_focus_out"
							, -1
							, (uint) sizeof( IntPtr ) // notify_focus_out
							, "notify_focus_in"
							, "notify_cursor_area"
							, (uint) sizeof(IntPtr)
							, 0
							),
						new GLib.AbiField("notify_cursor_area"
							, -1
							, (uint) sizeof( IntPtr ) // notify_cursor_area
							, "notify_focus_out"
							, "notify_surrounding"
							, (uint) sizeof(IntPtr)
							, 0
							),
						new GLib.AbiField("notify_surrounding"
							, -1
							, (uint) sizeof( IntPtr ) // notify_surrounding
							, "notify_cursor_area"
							, "reset"
							, (uint) sizeof(IntPtr)
							, 0
							),
						new GLib.AbiField("reset"
							, -1
							, (uint) sizeof( IntPtr ) // reset
							, "notify_surrounding"
							, "_webkit_reserved0"
							, (uint) sizeof(IntPtr)
							, 0
							),
						new GLib.AbiField("_webkit_reserved0"
							, -1
							, (uint) sizeof( IntPtr ) // _webkit_reserved0
							, "reset"
							, "_webkit_reserved1"
							, (uint) sizeof(IntPtr)
							, 0
							),
						new GLib.AbiField("_webkit_reserved1"
							, -1
							, (uint) sizeof( IntPtr ) // _webkit_reserved1
							, "_webkit_reserved0"
							, "_webkit_reserved2"
							, (uint) sizeof(IntPtr)
							, 0
							),
						new GLib.AbiField("_webkit_reserved2"
							, -1
							, (uint) sizeof( IntPtr ) // _webkit_reserved2
							, "_webkit_reserved1"
							, "_webkit_reserved3"
							, (uint) sizeof(IntPtr)
							, 0
							),
						new GLib.AbiField("_webkit_reserved3"
							, -1
							, (uint) sizeof( IntPtr ) // _webkit_reserved3
							, "_webkit_reserved2"
							, "_webkit_reserved4"
							, (uint) sizeof(IntPtr)
							, 0
							),
						new GLib.AbiField("_webkit_reserved4"
							, -1
							, (uint) sizeof( IntPtr ) // _webkit_reserved4
							, "_webkit_reserved3"
							, "_webkit_reserved5"
							, (uint) sizeof(IntPtr)
							, 0
							),
						new GLib.AbiField("_webkit_reserved5"
							, -1
							, (uint) sizeof( IntPtr ) // _webkit_reserved5
							, "_webkit_reserved4"
							, "_webkit_reserved6"
							, (uint) sizeof(IntPtr)
							, 0
							),
						new GLib.AbiField("_webkit_reserved6"
							, -1
							, (uint) sizeof( IntPtr ) // _webkit_reserved6
							, "_webkit_reserved5"
							, "_webkit_reserved7"
							, (uint) sizeof(IntPtr)
							, 0
							),
						new GLib.AbiField("_webkit_reserved7"
							, -1
							, (uint) sizeof( IntPtr ) // _webkit_reserved7
							, "_webkit_reserved6"
							, null
							, (uint) sizeof(IntPtr)
							, 0
							),
					});

				return _class_abi;
			}
		}


		// End of the ABI representation.

		[UnmanagedFunctionPointer (CallingConvention.Cdecl)]
		delegate IntPtr d_webkit_input_method_context_get_type();
		static d_webkit_input_method_context_get_type webkit_input_method_context_get_type = FuncLoader.LoadFunction<d_webkit_input_method_context_get_type>(FuncLoader.GetProcAddress(GLibrary.Load(Library.Webkit), "webkit_input_method_context_get_type"));

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

		[UnmanagedFunctionPointer (CallingConvention.Cdecl)]
		delegate bool d_webkit_input_method_context_filter_key_event(IntPtr raw, IntPtr key_event);
		static d_webkit_input_method_context_filter_key_event webkit_input_method_context_filter_key_event = FuncLoader.LoadFunction<d_webkit_input_method_context_filter_key_event>(FuncLoader.GetProcAddress(GLibrary.Load(Library.Webkit), "webkit_input_method_context_filter_key_event"));

		public bool FilterKeyEvent(Gdk.EventKey key_event) {
			bool raw_ret = webkit_input_method_context_filter_key_event(Handle, key_event == null ? IntPtr.Zero : key_event.Handle);
			bool ret = raw_ret;
			return ret;
		}

		[UnmanagedFunctionPointer (CallingConvention.Cdecl)]
		delegate void d_webkit_input_method_context_get_preedit(IntPtr raw, out IntPtr text, out IntPtr underlines, out uint cursor_offset);
		static d_webkit_input_method_context_get_preedit webkit_input_method_context_get_preedit = FuncLoader.LoadFunction<d_webkit_input_method_context_get_preedit>(FuncLoader.GetProcAddress(GLibrary.Load(Library.Webkit), "webkit_input_method_context_get_preedit"));

		public void GetPreedit(out string text, out GLib.List underlines, out uint cursor_offset) {
			IntPtr native_text;
			IntPtr native_underlines;
			webkit_input_method_context_get_preedit(Handle, out native_text, out native_underlines, out cursor_offset);
			text = GLib.Marshaller.PtrToStringGFree(native_text);
			underlines = new GLib.List(native_underlines);
		}

		[UnmanagedFunctionPointer (CallingConvention.Cdecl)]
		delegate void d_webkit_input_method_context_notify_cursor_area(IntPtr raw, int x, int y, int width, int height);
		static d_webkit_input_method_context_notify_cursor_area webkit_input_method_context_notify_cursor_area = FuncLoader.LoadFunction<d_webkit_input_method_context_notify_cursor_area>(FuncLoader.GetProcAddress(GLibrary.Load(Library.Webkit), "webkit_input_method_context_notify_cursor_area"));

		public void NotifyCursorArea(int x, int y, int width, int height) {
			webkit_input_method_context_notify_cursor_area(Handle, x, y, width, height);
		}

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

		public void NotifyFocusIn() {
			webkit_input_method_context_notify_focus_in(Handle);
		}

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

		public void NotifyFocusOut() {
			webkit_input_method_context_notify_focus_out(Handle);
		}

		[UnmanagedFunctionPointer (CallingConvention.Cdecl)]
		delegate void d_webkit_input_method_context_notify_surrounding(IntPtr raw, IntPtr text, int length, uint cursor_index, uint selection_index);
		static d_webkit_input_method_context_notify_surrounding webkit_input_method_context_notify_surrounding = FuncLoader.LoadFunction<d_webkit_input_method_context_notify_surrounding>(FuncLoader.GetProcAddress(GLibrary.Load(Library.Webkit), "webkit_input_method_context_notify_surrounding"));

		public void NotifySurrounding(string text, uint cursor_index, uint selection_index) {
			IntPtr native_text = GLib.Marshaller.StringToPtrGStrdup (text);
			webkit_input_method_context_notify_surrounding(Handle, native_text, System.Text.Encoding.UTF8.GetByteCount (text), cursor_index, selection_index);
			GLib.Marshaller.Free (native_text);
		}

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

		public void Reset() {
			webkit_input_method_context_reset(Handle);
		}

		[UnmanagedFunctionPointer (CallingConvention.Cdecl)]
		delegate void d_webkit_input_method_context_set_enable_preedit(IntPtr raw, bool enabled);
		static d_webkit_input_method_context_set_enable_preedit webkit_input_method_context_set_enable_preedit = FuncLoader.LoadFunction<d_webkit_input_method_context_set_enable_preedit>(FuncLoader.GetProcAddress(GLibrary.Load(Library.Webkit), "webkit_input_method_context_set_enable_preedit"));

		public bool EnablePreedit { 
			set {
				webkit_input_method_context_set_enable_preedit(Handle, value);
			}
		}


		static InputMethodContext ()
		{
			GtkSharp.WebkitGtkSharp.ObjectManager.Initialize ();
		}

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