#include Once "window9.bi"

Function GetParentItemTreeView(iGadget As Long , iItem As Integer) As Integer

	Dim As Any Ptr treeview = Gadgetid(iGadget)
	
	Dim As Any Ptr treestore = Cast(Any Ptr , gtk_tree_view_get_model(treeview))
	
	Dim As GtkTreeIter iterChild , iterfirst , iterParent
	
	If gtk_tree_model_get_iter_first(treestore , @iterfirst) Then
		
		iterChild.stamp =  iterfirst.stamp
		
		iterChild.user_data = Cast(Any Ptr,iItem)
		
		gtk_tree_model_iter_parent(treestore, @iterParent , @iterChild )
		
		If iterParent.stamp Then
			
			Return Cast(Integer , iterParent.user_data)
			
		Endif
		
	Endif
	
End Function