#include ONCE "window9.bi"

sub GetItemSubItemListView(listview as any ptr )
	
		dim as integer iSubIndex
		
		dim as GtkTreePath ptr path
		
		dim as GtkTreeViewColumn ptr focus_column
		
		dim as GtkTreeSelection ptr selection
		
		dim as GtkListStore ptr liststore
		
		dim as GtkTreeIter iter
		
		dim as Long ptr piIndex
		
		dim as Long iIndex		
		
		gtk_tree_view_get_cursor (listview , @path , @focus_column)

		if focus_column then
			
			iSubIndex = cast ( integer , g_object_get_data (cast(any ptr,focus_column), "IndexColumn"))
			
		EndIf
		
		gtk_tree_path_free(path)
		
		liststore = cast(any ptr , gtk_tree_view_get_model(listview))	
		
		selection = gtk_tree_view_get_selection (listview)	
		
		if gtk_tree_selection_get_mode(selection) = GTK_SELECTION_BROWSE then
	
			gtk_tree_selection_get_selected(selection , cast(any ptr,@liststore) , @iter)
			
			if iter.stamp <> 0 then
				
				path = gtk_tree_model_get_path ( cast(any ptr,liststore) , @iter )
				
				piIndex = gtk_tree_path_get_indices ( path )
				
				if piIndex then 
					
					iIndex = *piIndex

				else
					
					iIndex = -1
					
				EndIf	
				
				gtk_tree_path_free(path)	
				
			EndIf	
			
		else
		
			dim as Glist ptr list = gtk_tree_selection_get_selected_rows (selection , cast(any ptr,@liststore))
			
			dim as Glist ptr listtemp = g_list_last(list)
			
			if listtemp then
	
				path = cast(any ptr , listtemp->Data)
				
				piIndex = gtk_tree_path_get_indices ( path )
				
				if piIndex then 
					
					iIndex = *piIndex

				else
					
					iIndex = -1
					
				EndIf	
				
				gtk_tree_path_free(path)				

			EndIf
			
			g_list_free(list)

		EndIf
		
		pGlobalTypeWindow9->iSubItemListView = iSubIndex

		pGlobalTypeWindow9->iItemListView = iIndex	

End Sub