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

namespace Gtk {

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

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

		public RecentManager (IntPtr raw) : base(raw) {}

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

		public RecentManager () : base (IntPtr.Zero)
		{
			if (GetType () != typeof (RecentManager)) {
				CreateNativeObject (Array.Empty<string> (), Array.Empty<GLib.Value> ());
				return;
			}
			Raw = gtk_recent_manager_new();
		}

		[GLib.Property ("filename")]
		public string Filename {
			get {
				GLib.Value val = GetProperty ("filename");
				string ret = (string) val;
				val.Dispose ();
				return ret;
			}
		}

		[GLib.Property ("size")]
		public int Size {
			get {
				GLib.Value val = GetProperty ("size");
				int ret = (int) val;
				val.Dispose ();
				return ret;
			}
		}

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

		static ChangedNativeDelegate Changed_cb_delegate;
		static ChangedNativeDelegate ChangedVMCallback {
			get {
				if (Changed_cb_delegate == null)
					Changed_cb_delegate = new ChangedNativeDelegate (Changed_cb);
				return Changed_cb_delegate;
			}
		}

		static void OverrideChanged (GLib.GType gtype)
		{
			OverrideChanged (gtype, ChangedVMCallback);
		}

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

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

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

		[GLib.DefaultSignalHandler(Type=typeof(Gtk.RecentManager), ConnectionMethod="OverrideChanged")]
		protected virtual void OnChanged ()
		{
			InternalChanged ();
		}

		private void InternalChanged ()
		{
			ChangedNativeDelegate unmanaged = class_abi.BaseOverride<ChangedNativeDelegate>(this.LookupGType(), "changed");
			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("changed"
							, GLib.Object.class_abi.Fields
							, (uint) sizeof( IntPtr ) // changed
							, null
							, "_gtk_recent1"
							, (uint) sizeof(IntPtr)
							, 0
							),
						new GLib.AbiField("_gtk_recent1"
							, -1
							, (uint) sizeof( IntPtr ) // _gtk_recent1
							, "changed"
							, "_gtk_recent2"
							, (uint) sizeof(IntPtr)
							, 0
							),
						new GLib.AbiField("_gtk_recent2"
							, -1
							, (uint) sizeof( IntPtr ) // _gtk_recent2
							, "_gtk_recent1"
							, "_gtk_recent3"
							, (uint) sizeof(IntPtr)
							, 0
							),
						new GLib.AbiField("_gtk_recent3"
							, -1
							, (uint) sizeof( IntPtr ) // _gtk_recent3
							, "_gtk_recent2"
							, "_gtk_recent4"
							, (uint) sizeof(IntPtr)
							, 0
							),
						new GLib.AbiField("_gtk_recent4"
							, -1
							, (uint) sizeof( IntPtr ) // _gtk_recent4
							, "_gtk_recent3"
							, null
							, (uint) sizeof(IntPtr)
							, 0
							),
					});

				return _class_abi;
			}
		}


		// End of the ABI representation.

		[UnmanagedFunctionPointer (CallingConvention.Cdecl)]
		delegate bool d_gtk_recent_manager_add_full(IntPtr raw, IntPtr uri, IntPtr recent_data);
		static d_gtk_recent_manager_add_full gtk_recent_manager_add_full = FuncLoader.LoadFunction<d_gtk_recent_manager_add_full>(FuncLoader.GetProcAddress(GLibrary.Load(Library.Gtk), "gtk_recent_manager_add_full"));

		public bool AddFull(string uri, Gtk.RecentData recent_data) {
			IntPtr native_uri = GLib.Marshaller.StringToPtrGStrdup (uri);
			IntPtr native_recent_data = GLib.Marshaller.StructureToPtrAlloc (recent_data);
			bool raw_ret = gtk_recent_manager_add_full(Handle, native_uri, native_recent_data);
			bool ret = raw_ret;
			GLib.Marshaller.Free (native_uri);
			Marshal.FreeHGlobal (native_recent_data);
			return ret;
		}

		[UnmanagedFunctionPointer (CallingConvention.Cdecl)]
		delegate bool d_gtk_recent_manager_add_item(IntPtr raw, IntPtr uri);
		static d_gtk_recent_manager_add_item gtk_recent_manager_add_item = FuncLoader.LoadFunction<d_gtk_recent_manager_add_item>(FuncLoader.GetProcAddress(GLibrary.Load(Library.Gtk), "gtk_recent_manager_add_item"));

		public bool AddItem(string uri) {
			IntPtr native_uri = GLib.Marshaller.StringToPtrGStrdup (uri);
			bool raw_ret = gtk_recent_manager_add_item(Handle, native_uri);
			bool ret = raw_ret;
			GLib.Marshaller.Free (native_uri);
			return ret;
		}

		[UnmanagedFunctionPointer (CallingConvention.Cdecl)]
		delegate int d_gtk_recent_manager_error_quark();
		static d_gtk_recent_manager_error_quark gtk_recent_manager_error_quark = FuncLoader.LoadFunction<d_gtk_recent_manager_error_quark>(FuncLoader.GetProcAddress(GLibrary.Load(Library.Gtk), "gtk_recent_manager_error_quark"));

		public static int ErrorQuark() {
			int raw_ret = gtk_recent_manager_error_quark();
			int ret = raw_ret;
			return ret;
		}

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

		public static Gtk.RecentManager Default { 
			get {
				IntPtr raw_ret = gtk_recent_manager_get_default();
				Gtk.RecentManager ret = GLib.Object.GetObject(raw_ret) as Gtk.RecentManager;
				return ret;
			}
		}

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

		public Gtk.RecentInfo[] RecentItems { 
			get {
				IntPtr raw_ret = gtk_recent_manager_get_items(Handle);
				Gtk.RecentInfo[] ret = GLib.Marshaller.ListPtrToArray<Gtk.RecentInfo, Gtk.RecentInfo> (raw_ret, true, true);
				return ret;
			}
		}

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

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

		[UnmanagedFunctionPointer (CallingConvention.Cdecl)]
		delegate bool d_gtk_recent_manager_has_item(IntPtr raw, IntPtr uri);
		static d_gtk_recent_manager_has_item gtk_recent_manager_has_item = FuncLoader.LoadFunction<d_gtk_recent_manager_has_item>(FuncLoader.GetProcAddress(GLibrary.Load(Library.Gtk), "gtk_recent_manager_has_item"));

		public bool HasItem(string uri) {
			IntPtr native_uri = GLib.Marshaller.StringToPtrGStrdup (uri);
			bool raw_ret = gtk_recent_manager_has_item(Handle, native_uri);
			bool ret = raw_ret;
			GLib.Marshaller.Free (native_uri);
			return ret;
		}

		[UnmanagedFunctionPointer (CallingConvention.Cdecl)]
		delegate IntPtr d_gtk_recent_manager_lookup_item(IntPtr raw, IntPtr uri, out IntPtr error);
		static d_gtk_recent_manager_lookup_item gtk_recent_manager_lookup_item = FuncLoader.LoadFunction<d_gtk_recent_manager_lookup_item>(FuncLoader.GetProcAddress(GLibrary.Load(Library.Gtk), "gtk_recent_manager_lookup_item"));

		public unsafe Gtk.RecentInfo LookupItem(string uri) {
			IntPtr native_uri = GLib.Marshaller.StringToPtrGStrdup (uri);
			IntPtr error = IntPtr.Zero;
			IntPtr raw_ret = gtk_recent_manager_lookup_item(Handle, native_uri, out error);
			Gtk.RecentInfo ret = raw_ret == IntPtr.Zero ? null : (Gtk.RecentInfo) GLib.Opaque.GetOpaque (raw_ret, typeof (Gtk.RecentInfo), false);
			GLib.Marshaller.Free (native_uri);
			if (error != IntPtr.Zero) throw new GLib.GException (error);
			return ret;
		}

		[UnmanagedFunctionPointer (CallingConvention.Cdecl)]
		delegate bool d_gtk_recent_manager_move_item(IntPtr raw, IntPtr uri, IntPtr new_uri, out IntPtr error);
		static d_gtk_recent_manager_move_item gtk_recent_manager_move_item = FuncLoader.LoadFunction<d_gtk_recent_manager_move_item>(FuncLoader.GetProcAddress(GLibrary.Load(Library.Gtk), "gtk_recent_manager_move_item"));

		public unsafe bool MoveItem(string uri, string new_uri) {
			IntPtr native_uri = GLib.Marshaller.StringToPtrGStrdup (uri);
			IntPtr native_new_uri = GLib.Marshaller.StringToPtrGStrdup (new_uri);
			IntPtr error = IntPtr.Zero;
			bool raw_ret = gtk_recent_manager_move_item(Handle, native_uri, native_new_uri, out error);
			bool ret = raw_ret;
			GLib.Marshaller.Free (native_uri);
			GLib.Marshaller.Free (native_new_uri);
			if (error != IntPtr.Zero) throw new GLib.GException (error);
			return ret;
		}

		[UnmanagedFunctionPointer (CallingConvention.Cdecl)]
		delegate int d_gtk_recent_manager_purge_items(IntPtr raw, out IntPtr error);
		static d_gtk_recent_manager_purge_items gtk_recent_manager_purge_items = FuncLoader.LoadFunction<d_gtk_recent_manager_purge_items>(FuncLoader.GetProcAddress(GLibrary.Load(Library.Gtk), "gtk_recent_manager_purge_items"));

		public unsafe int PurgeItems() {
			IntPtr error = IntPtr.Zero;
			int raw_ret = gtk_recent_manager_purge_items(Handle, out error);
			int ret = raw_ret;
			if (error != IntPtr.Zero) throw new GLib.GException (error);
			return ret;
		}

		[UnmanagedFunctionPointer (CallingConvention.Cdecl)]
		delegate bool d_gtk_recent_manager_remove_item(IntPtr raw, IntPtr uri, out IntPtr error);
		static d_gtk_recent_manager_remove_item gtk_recent_manager_remove_item = FuncLoader.LoadFunction<d_gtk_recent_manager_remove_item>(FuncLoader.GetProcAddress(GLibrary.Load(Library.Gtk), "gtk_recent_manager_remove_item"));

		public unsafe bool RemoveItem(string uri) {
			IntPtr native_uri = GLib.Marshaller.StringToPtrGStrdup (uri);
			IntPtr error = IntPtr.Zero;
			bool raw_ret = gtk_recent_manager_remove_item(Handle, native_uri, out error);
			bool ret = raw_ret;
			GLib.Marshaller.Free (native_uri);
			if (error != IntPtr.Zero) throw new GLib.GException (error);
			return ret;
		}


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