2014-08-18 18:01:56 -05:00
|
|
|
// 18 august 2014
|
|
|
|
|
|
|
|
package ui
|
|
|
|
|
2014-08-26 11:52:32 -05:00
|
|
|
type windowDialog interface {
|
|
|
|
openFile(f func(filename string))
|
|
|
|
}
|
|
|
|
|
2014-08-18 18:01:56 -05:00
|
|
|
// OpenFile opens a dialog box that asks the user to choose a file.
|
2014-08-26 11:52:32 -05:00
|
|
|
// The dialog box is modal to win, which mut not be nil.
|
|
|
|
// Some time after the dialog box is closed, OpenFile runs f on the main thread, passing filename.
|
|
|
|
// filename is the selected filename, or an empty string if no file was chosen.
|
|
|
|
// OpenFile does not ensure that f remains alive; the programmer is responsible for this.
|
2014-08-25 15:23:00 -05:00
|
|
|
// If possible on a given system, OpenFile() will not dereference links; it will return the link file itself.
|
2014-08-26 12:58:39 -05:00
|
|
|
// Hidden files will not be hidden by OpenFile().
|
2014-08-26 11:52:32 -05:00
|
|
|
func OpenFile(win Window, f func(filename string)) {
|
|
|
|
if win == nil {
|
|
|
|
panic("Window passed to OpenFile() cannot be nil")
|
|
|
|
}
|
|
|
|
win.openFile(f)
|
2014-08-18 18:01:56 -05:00
|
|
|
}
|