
//-- load  file and show the window
//gins_glade("GBdialog-multifilechooser.glade")

// globals
fc = ""
mode = 0
chooser = {"filechooserdialog1" , "filechooserdialog2" , "filechooserdialog3" , "filechooserdialog4"}


function file_chooser(title , folder , filemask , mode , multi)

mode = val(mode)
fc=chooser[mode]
gins_set(fc , "visible" , "1" , "<boolean>")
 //-------------------------------------------------------------
//-- this filter allows to show only ".au" files in the dialog

'gtk_createobject("GtkFileFilter" , "Filefilter" ,0,0)
'gtk("gtk_file_filter_add_pattern"  , ":Filefilter" , filemask ,0,0,0,0)
'gtk("gtk_file_chooser_set_filter"  , chooser[mode] , ":Filefilter" ,0,0,0,0)

 //-------------------------------------------------------------
//-- set current path for the dialog



'gtk("gtk_file_chooser_set_current_folder" , fc , folder ,0,0,0,0)
'gins_set(fc , "title" , title , "<str>")
if mode < 3 then
//gins_set(chooser[mode] , "select_multiple" , multi , "<boolean>")
gtk("gtk_file_chooser_set_select_multiple" , fc, multi ,0,0,0,0)
end if
//gins_set(fc , "visible" , "True" , "<boolean>")


end function

function file_chooser_event(widget)

      if left(widget , 15 ) = "fc_buttoncancel" then
        return ("MESSAGE: cancelled")
      end if

      if left(widget , 11 ) = "fc_buttonok" then


        if mode = 3 then
	        myresult = gtk("gtk_file_chooser_get_current_folder" , fc , 0,0,0,0,0)
		return myresult
        else
		mylist = gtk("gtk_file_chooser_get_filenames" , fc , 0,0,0,0,0)
		return mylist
	end if

       return

      end if


  
end function
