#include ONCE "window9.bi"

sub SetFilterRequester(sInFilter as string , chooser as GtkFileChooser ptr )
	
	dim as Long iPos , iOldPos , iFlag
	
	dim as GtkFileFilter ptr filter
	
	do
	
		if iPos+1 < len(sInFilter) then
	
			iOldPos = iPos+1
			
			iPos = Instr (iPos + 1 , sInFilter , chr(0))
			
			if iPos <> 0 andalso iFlag  = 0 then
	
				filter = gtk_file_filter_new ()
				
				gtk_file_filter_set_name (filter, mid(sInFilter , iOldPos , iPos - iOldPos))	
				
				iFlag  = 1	
				
			elseif iPos <> 0 andalso iFlag  = 1 then
			
				dim as string sFind = mid(sInFilter , iOldPos , iPos - iOldPos)
				
				dim as Long iOldPos2 , iPos2 
				
				do	
					iOldPos2 = iPos2 + 1
					
					iPos2 = Instr (iPos2 + 1 , sFind , ";")
					
					if iPos2 <> 0 then
						
						gtk_file_filter_add_pattern (filter, mid(sFind , iOldPos2 , iPos2 - iOldPos2))						
					
					else
						
						gtk_file_filter_add_pattern (filter, mid(sFind , iOldPos2))
						
						gtk_file_chooser_add_filter (chooser, filter)	
						
						exit do		

					EndIf
				
				loop
				
				iFlag  = 0	
				
			else
			
				exit do	

			EndIf
			
		else
		
			exit do

		EndIf	

	Loop

End Sub