zenity/zenity.go

60 lines
1.3 KiB
Go
Raw Normal View History

2020-01-23 06:44:28 -05:00
// Package zenity provides cross-platform access to simple dialogs that interact
// graphically with the user.
//
// It is inspired by, and closely follows the API of, the zenity program, which
// it uses to provide the functionality on various Unixes. See:
//
// https://help.gnome.org/users/zenity/
//
// This package does not require cgo, and it does not impose any threading or
// initialization requirements.
2020-01-04 22:21:39 -05:00
package zenity
2020-01-18 07:40:16 -05:00
import "image/color"
2020-01-06 07:01:51 -05:00
type constError string
func (e constError) Error() string { return string(e) }
2020-01-04 22:21:39 -05:00
type options struct {
// General options
title string
// File selection options
filename string
2020-01-09 20:46:53 -05:00
directory bool
2020-01-04 22:21:39 -05:00
overwrite bool
create bool
hidden bool
2020-01-04 22:21:39 -05:00
filters []FileFilter
2020-01-18 07:40:16 -05:00
// Color selection options
color color.Color
palette bool
2020-01-04 22:21:39 -05:00
// Message options
icon MessageIcon
ok string
cancel string
extra string
nowrap bool
ellipsize bool
defcancel bool
}
2020-01-23 06:44:28 -05:00
// An Option is an argument passed to dialog functions to customize their
// behavior.
2020-01-04 22:21:39 -05:00
type Option func(*options)
func optsParse(options []Option) (res options) {
for _, o := range options {
o(&res)
}
return
}
2020-01-23 06:44:28 -05:00
// Title returns an Option to set the dialog title.
2020-01-04 22:21:39 -05:00
func Title(title string) Option {
return func(o *options) { o.title = title }
2020-01-04 22:21:39 -05:00
}