#include ONCE "window9.bi"

function GetItemTreeView(iGadget as Long) as integer export
	
	dim as any ptr treeview = GadgetID(iGadget)
	
	if treeview = 0 then return -1
	
	dim as GtkTreeSelection ptr selection
	
	dim as GtkTreeStore ptr treestore
	
	dim as GtkTreeIter iter		
	
	treestore = cast(any ptr , gtk_tree_view_get_model(treeview))	
	
	selection = gtk_tree_view_get_selection (treeview)	
	
	gtk_tree_selection_get_selected(selection , cast(any ptr,@treestore) , @iter)
	
	if iter.stamp then
		
		return cast(integer,iter.user_data)
		
	else
		
		return -1	
		
	EndIf
	
End Function