----------------- namespace file -- used by main.ex ----------------- include GtkEngine.e ifdef WINDOWS then add(builder,"file.glade") elsedef add(builder,"~/demos/glade/file.glade") end ifdef set("file:chooser","do overwrite confirmation",TRUE) object working_file = canonical_path("~/demos/test0.ex") ----------------------------------------------------------------------- export function new(atom ctl, atom data) ----------------------------------------------------------------------- set("file:chooser",{ {"action",GTK_FILE_CHOOSER_ACTION_SAVE}, {"current name","MyNewFile"}, {"run"}, {"visible",FALSE}}) return 0 end function ----------------------------------------------------------------------- export function open(atom ctl, atom data) ----------------------------------------------------------------------- set("file:chooser",{ {"action",GTK_FILE_CHOOSER_ACTION_OPEN}, {"filename",working_file}, {"run"}, {"visible",FALSE}}) return 0 end function ----------------------------------------------------------------------- export function save(atom ctl, atom data) ----------------------------------------------------------------------- set("file:chooser",{ {"action",GTK_FILE_CHOOSER_ACTION_SAVE}, {"filename",working_file}, {"run"}, {"visible",FALSE}}) return 1 end function ----------------------------------------------------------------------- export function saveas(atom ctl, atom data) ----------------------------------------------------------------------- object newname set("file:chooser",{ {"action",GTK_FILE_CHOOSER_ACTION_SAVE}, {"current name",""}, {"run"}, {"visible",FALSE}}) return 1 end function -- following routines handle file-chooser dialog buttons; ----------------------------------------------------------------------- export function cancel(atom ctl, atom data) ----------------------------------------------------------------------- set("file:chooser","visible",FALSE) return 1 end function ----------------------------------------------------------------------- export function ok(atom ctl, atom data) ----------------------------------------------------------------------- object fs = get("file:chooser","filename") display(fs) if atom(fs) then return 0 -- no filename entered end if integer act = get("file:chooser","action") switch act do case GTK_FILE_CHOOSER_ACTION_SAVE then case GTK_FILE_CHOOSER_ACTION_OPEN then end switch set("file:chooser","visible",FALSE) return 1 end function