// 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 TreeSelection : GLib.Object {

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

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

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

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

		[GLib.Property ("mode")]
		public Gtk.SelectionMode Mode {
			get  {
				int raw_ret = gtk_tree_selection_get_mode(Handle);
				Gtk.SelectionMode ret = (Gtk.SelectionMode) raw_ret;
				return ret;
			}
			set  {
				gtk_tree_selection_set_mode(Handle, (int) value);
			}
		}

		[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 {
				TreeSelection __obj = GLib.Object.GetObject (inst, false) as TreeSelection;
				__obj.OnChanged ();
			} catch (Exception e) {
				GLib.ExceptionManager.RaiseUnhandledException (e, false);
			}
		}

		[GLib.DefaultSignalHandler(Type=typeof(Gtk.TreeSelection), 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_reserved1"
							, (uint) sizeof(IntPtr)
							, 0
							),
						new GLib.AbiField("_gtk_reserved1"
							, -1
							, (uint) sizeof( IntPtr ) // _gtk_reserved1
							, "changed"
							, "_gtk_reserved2"
							, (uint) sizeof(IntPtr)
							, 0
							),
						new GLib.AbiField("_gtk_reserved2"
							, -1
							, (uint) sizeof( IntPtr ) // _gtk_reserved2
							, "_gtk_reserved1"
							, "_gtk_reserved3"
							, (uint) sizeof(IntPtr)
							, 0
							),
						new GLib.AbiField("_gtk_reserved3"
							, -1
							, (uint) sizeof( IntPtr ) // _gtk_reserved3
							, "_gtk_reserved2"
							, "_gtk_reserved4"
							, (uint) sizeof(IntPtr)
							, 0
							),
						new GLib.AbiField("_gtk_reserved4"
							, -1
							, (uint) sizeof( IntPtr ) // _gtk_reserved4
							, "_gtk_reserved3"
							, null
							, (uint) sizeof(IntPtr)
							, 0
							),
					});

				return _class_abi;
			}
		}


		// End of the ABI representation.

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

		public int CountSelectedRows() {
			int raw_ret = gtk_tree_selection_count_selected_rows(Handle);
			int ret = raw_ret;
			return ret;
		}

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

		[UnmanagedFunctionPointer (CallingConvention.Cdecl)]
		delegate void d_gtk_tree_selection_set_select_function(IntPtr raw, GtkSharp.TreeSelectionFuncNative func, IntPtr data, GLib.DestroyNotify destroy);
		static d_gtk_tree_selection_set_select_function gtk_tree_selection_set_select_function = FuncLoader.LoadFunction<d_gtk_tree_selection_set_select_function>(FuncLoader.GetProcAddress(GLibrary.Load(Library.Gtk), "gtk_tree_selection_set_select_function"));

		public Gtk.TreeSelectionFunc SelectFunction { 
			get {
				GtkSharp.TreeSelectionFuncNative raw_ret = gtk_tree_selection_get_select_function(Handle);
				Gtk.TreeSelectionFunc ret = GtkSharp.TreeSelectionFuncWrapper.GetManagedDelegate (raw_ret);
				return ret;
			}
			set {
				GtkSharp.TreeSelectionFuncWrapper value_wrapper = new GtkSharp.TreeSelectionFuncWrapper (value);
				IntPtr data;
				GLib.DestroyNotify destroy;
				if (value == null) {
					data = IntPtr.Zero;
					destroy = null;
				} else {
					data = (IntPtr) GCHandle.Alloc (value_wrapper);
					destroy = GLib.DestroyHelper.NotifyHandler;
				}
				gtk_tree_selection_set_select_function(Handle, value_wrapper.NativeDelegate, data, destroy);
			}
		}

		[UnmanagedFunctionPointer (CallingConvention.Cdecl)]
		delegate bool d_gtk_tree_selection_get_selected(IntPtr raw, out IntPtr model, IntPtr iter);
		static d_gtk_tree_selection_get_selected gtk_tree_selection_get_selected = FuncLoader.LoadFunction<d_gtk_tree_selection_get_selected>(FuncLoader.GetProcAddress(GLibrary.Load(Library.Gtk), "gtk_tree_selection_get_selected"));

		public bool GetSelected(out Gtk.ITreeModel model, out Gtk.TreeIter iter) {
			IntPtr native_model;
			IntPtr native_iter = Marshal.AllocHGlobal (Marshal.SizeOf<Gtk.TreeIter>());
			bool raw_ret = gtk_tree_selection_get_selected(Handle, out native_model, native_iter);
			bool ret = raw_ret;
			model = Gtk.TreeModelAdapter.GetObject (native_model, false);
			iter = Gtk.TreeIter.New (native_iter);
			Marshal.FreeHGlobal (native_iter);
			return ret;
		}

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

		public Gtk.TreePath[] GetSelectedRows(out Gtk.ITreeModel model) {
			IntPtr native_model;
			IntPtr raw_ret = gtk_tree_selection_get_selected_rows(Handle, out native_model);
			Gtk.TreePath[] ret = GLib.Marshaller.ListPtrToArray<Gtk.TreePath, Gtk.TreePath> (raw_ret, true, true);
			model = Gtk.TreeModelAdapter.GetObject (native_model, false);
			return ret;
		}

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

		public Gtk.TreeView TreeView { 
			get {
				IntPtr raw_ret = gtk_tree_selection_get_tree_view(Handle);
				Gtk.TreeView ret = GLib.Object.GetObject(raw_ret) as Gtk.TreeView;
				return ret;
			}
		}

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

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

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

		public IntPtr UserData { 
			get {
				IntPtr raw_ret = gtk_tree_selection_get_user_data(Handle);
				IntPtr ret = raw_ret;
				return ret;
			}
		}

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

		public bool IterIsSelected(Gtk.TreeIter iter) {
			IntPtr native_iter = GLib.Marshaller.StructureToPtrAlloc (iter);
			bool raw_ret = gtk_tree_selection_iter_is_selected(Handle, native_iter);
			bool ret = raw_ret;
			Marshal.FreeHGlobal (native_iter);
			return ret;
		}

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

		public bool PathIsSelected(Gtk.TreePath path) {
			bool raw_ret = gtk_tree_selection_path_is_selected(Handle, path == null ? IntPtr.Zero : path.Handle);
			bool ret = raw_ret;
			return ret;
		}

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

		public void SelectAll() {
			gtk_tree_selection_select_all(Handle);
		}

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

		public void SelectIter(Gtk.TreeIter iter) {
			IntPtr native_iter = GLib.Marshaller.StructureToPtrAlloc (iter);
			gtk_tree_selection_select_iter(Handle, native_iter);
			Marshal.FreeHGlobal (native_iter);
		}

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

		public void SelectPath(Gtk.TreePath path) {
			gtk_tree_selection_select_path(Handle, path == null ? IntPtr.Zero : path.Handle);
		}

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

		public void SelectRange(Gtk.TreePath start_path, Gtk.TreePath end_path) {
			gtk_tree_selection_select_range(Handle, start_path == null ? IntPtr.Zero : start_path.Handle, end_path == null ? IntPtr.Zero : end_path.Handle);
		}

		[UnmanagedFunctionPointer (CallingConvention.Cdecl)]
		delegate void d_gtk_tree_selection_selected_foreach(IntPtr raw, GtkSharp.TreeSelectionForeachFuncNative func, IntPtr data);
		static d_gtk_tree_selection_selected_foreach gtk_tree_selection_selected_foreach = FuncLoader.LoadFunction<d_gtk_tree_selection_selected_foreach>(FuncLoader.GetProcAddress(GLibrary.Load(Library.Gtk), "gtk_tree_selection_selected_foreach"));

		public void SelectedForeach(Gtk.TreeSelectionForeachFunc func) {
			GtkSharp.TreeSelectionForeachFuncWrapper func_wrapper = new GtkSharp.TreeSelectionForeachFuncWrapper (func);
			gtk_tree_selection_selected_foreach(Handle, func_wrapper.NativeDelegate, IntPtr.Zero);
		}

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

		public void UnselectAll() {
			gtk_tree_selection_unselect_all(Handle);
		}

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

		public void UnselectIter(Gtk.TreeIter iter) {
			IntPtr native_iter = GLib.Marshaller.StructureToPtrAlloc (iter);
			gtk_tree_selection_unselect_iter(Handle, native_iter);
			Marshal.FreeHGlobal (native_iter);
		}

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

		public void UnselectPath(Gtk.TreePath path) {
			gtk_tree_selection_unselect_path(Handle, path == null ? IntPtr.Zero : path.Handle);
		}

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

		public void UnselectRange(Gtk.TreePath start_path, Gtk.TreePath end_path) {
			gtk_tree_selection_unselect_range(Handle, start_path == null ? IntPtr.Zero : start_path.Handle, end_path == null ? IntPtr.Zero : end_path.Handle);
		}


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