zenity/file.go

51 lines
706 B
Go
Raw Normal View History

2019-12-29 20:00:50 -05:00
package zenity
2019-12-11 06:29:32 -05:00
2020-01-02 20:44:23 -05:00
type opts struct {
title string
}
type Option func(*opts)
func (o *opts) Title(title string) {
o.title = title
}
type fileopts struct {
opts
filename string
overwrite bool
filters []FileFilter
}
type FileOption func(*fileopts)
func Filename(filename string) FileOption {
return func(o *fileopts) {
o.filename = filename
}
}
func ConfirmOverwrite(o *fileopts) {
o.overwrite = true
}
2019-12-11 06:29:32 -05:00
type FileFilter struct {
Name string
Exts []string
}
2020-01-02 20:44:23 -05:00
type FileFilters []FileFilter
func (f FileFilters) New() FileOption {
return func(o *fileopts) {
o.filters = f
}
}
func fileoptsParse(options []FileOption) (res fileopts) {
for _, o := range options {
o(&res)
}
return
}