#include Once "window9.bi"

Sub Replaceimageitemtreeview( iGadget As Long , iItem As Integer , IDImage As HBITMAP = 0, IDImageSelect As HBITMAP = 0 ) Export
	
	Dim As Any Ptr treeview = Gadgetid(iGadget)
	
	If treeview = 0 Then Exit Sub
	
	Dim As Any Ptr model
	
	Dim As GtkTreeIter iter , iterfirst		
	
	model =  gtk_tree_view_get_model(treeview)	
	
	Dim As ListT Ptr pListTemp
	
	Dim As LinList Ptr imglist = Cast(Any Ptr, g_object_get_data (Cast(Any Ptr,model), "tree_img_list"))
	
	If iItem <> 0 Andalso iItem <> -1 Andalso imglist <> 0 Then
		
		pListTemp = Cast(ListT Ptr,imglist->findNodeFunc(iItem))
		
	Endif	
	
	If pListTemp <> 0 Then
		
		If IDImage = 0 Andalso  IDImageSelect = 0 Then
			
			Exit Sub
			
		Elseif IDImage = 0 Then	
			
			pListTemp->anyFourData = Cast(Integer,IDImageSelect)
			
		Elseif IDImageSelect = 0 Then
			
			pListTemp->anyThreeData	= Cast(Integer,IDImage)
			
		Else
			
			pListTemp->anyFourData = Cast(Integer, IDImageSelect)
			
			pListTemp->anyThreeData	= Cast(Integer, IDImage)
			
		Endif		
		
		If gtk_tree_model_get_iter_first(model , @iterfirst) Then
			
			iter.stamp =  iterfirst.stamp
			
			iter.user_data = Cast(Any Ptr,iItem)			
			
		Endif
		
		Dim As Any Ptr path = gtk_tree_model_get_path(model , @iter)
		
		If gtk_tree_view_row_expanded (treeview , path) Then
			
			gtk_tree_store_set(model, @iter, 0 , pListTemp->anyFourData ,  -1)
			
		Else
			
			gtk_tree_store_set(model, @iter, 0 , pListTemp->anyThreeData ,  -1)
			
		Endif
		
		gtk_tree_path_free(path)
		
	Endif	
	
End Sub