#include Once "window9.bi"

Sub Settopindexlistbox( iGadget As Long , iItem As Long ) Export
	
	Dim As GtkWidget Ptr listbox = Gadgetid(iGadget)
	
	Dim As Long iCountItems = Countitemlistbox(iGadget)
		
	Dim As Any Ptr pVertAdj
	
	Dim As Long iAdjValue , iUpper , iPageSize , hSingleLine , hRest , iNewPosition
	
	pVertAdj = gtk_scrolled_window_get_vadjustment(GTK_SCROLLED_WINDOW(gtk_widget_get_parent(listbox)))
	
	iAdjValue = gtk_adjustment_get_value(pVertAdj)
	
	iUpper = gtk_adjustment_get_upper(pVertAdj)
	
	iPageSize = gtk_adjustment_get_page_size(pVertAdj)
	
	hSingleLine = iUpper/iCountItems
	
	'hRest = iPageSize\hSingleLine
	
	'iNewPosition = hSingleLine * iItem + hRest
	
	iNewPosition = hSingleLine * iItem
	
	gtk_adjustment_set_value (pVertAdj, iNewPosition)			
	
End Sub