Re: EuGTK-3.0 File Dialogue question

new topic     » goto parent     » topic index » view thread      » older message » newer message

I suggest you try this.

I don't understand why select_file() has to return 1 to get the dialog to close, however. Is select_file() being called elsewhere?

include GtkEngine.e 
include std/io.e 
include std/text.e 
include std/console.e 
include std/sequence.e 
 
constant filter1 = create(GtkFileFilter) 
	set(filter1,"name","Euphoria files") 
	set(filter1,"add pattern","*.ex") 
	set(filter1,"add pattern","*.e") 
 
constant filter2 = create(GtkFileFilter) 
	set(filter2,"name","all text files") 
	set(filter2,"add mime type","text/plain") 
object filename 
 
export function select_file() 
atom dlg = create(GtkFileChooserDialog) 
	set(dlg,"action",GTK_FILE_CHOOSER_ACTION_OPEN) 
	set(dlg,"add filter",filter1) 
	set(dlg,"add filter",filter2) 
	set(dlg,"add button","gtk-cancel",GTK_RESPONSE_CANCEL) 
	set(dlg,"add button","gtk-ok",GTK_RESPONSE_APPLY) 
 
    if get(dlg,"run") = GTK_RESPONSE_APPLY then 
	filename = get(dlg,"filename") 
	if not atom(filename) then  
	    display(filename) 
	end if 
    else 
        filename = 0 
    end if 
     
    set(dlg,"hide") 
    return 1 
end function 
export function select_file_get_answer() 
    return filename 
end function 
 
procedure new_file() 
    sequence answer 
    object res 
	 
	if modified and last_use() then 
		while TRUE do 
		    set_top_line("") 
		    printf(SCREEN, "save changes to %s? ", {file_name}) 
		    answer = key_gets("yn", {}) 
		    if find('y', answer) then 
			save_file(file_name) 
			exit 
		    elsif find('n', answer) then 
			exit 
		    end if 
		end while 
	end if 
	save_state() 
--          set_top_line("new file name: ") 
--          answer = delete_trailing_white(key_gets("", file_history)) 
	 
 
            res = select_file() 
	    if res = 1 then 
                if sequence(select_file_get_answer()) then 
		answer = select_file_get_answer() 
		else 
		answer = "" 
		end if 
	    else 
	    answer = "" 
	    end if 
	 
            if length(answer) != 0 then 
	    file_name = answer 
	    stop = TRUE 
	end if 
end procedure 
new topic     » goto parent     » topic index » view thread      » older message » newer message

Search



Quick Links

User menu

Not signed in.

Misc Menu