zenity/list.go

46 lines
1.5 KiB
Go
Raw Permalink Normal View History

2021-04-07 09:16:35 -04:00
package zenity
// List displays the list dialog.
//
// Returns false on cancel, or ErrExtraButton.
//
// Valid options: Title, Width, Height, OKLabel, CancelLabel, ExtraButton,
// Icon, DefaultItems, DisallowEmpty.
func List(text string, items []string, options ...Option) (string, bool, error) {
return list(text, items, applyOptions(options))
}
// ListItems displays the list dialog.
//
// Returns false on cancel, or ErrExtraButton.
func ListItems(text string, items ...string) (string, bool, error) {
return List(text, items)
}
2021-04-08 11:43:14 -04:00
// ListMultiple displays the list dialog, allowing multiple items to be selected.
2021-04-07 09:16:35 -04:00
//
// Returns a nil slice on cancel, or ErrExtraButton.
//
// Valid options: Title, Width, Height, OKLabel, CancelLabel, ExtraButton,
// Icon, DefaultItems, DisallowEmpty.
func ListMultiple(text string, items []string, options ...Option) ([]string, error) {
return listMultiple(text, items, applyOptions(options))
}
2021-04-09 10:28:17 -04:00
// ListMultipleItems displays the list dialog, allowing multiple items to be selected.
2021-04-07 09:16:35 -04:00
//
// Returns a nil slice on cancel, or ErrExtraButton.
func ListMultipleItems(text string, items ...string) ([]string, error) {
return ListMultiple(text, items)
}
2021-04-09 10:28:17 -04:00
// DefaultItems returns an Option to set the items to initially select (macOS only).
2021-04-07 09:16:35 -04:00
func DefaultItems(items ...string) Option {
return funcOption(func(o *options) { o.defaultItems = items })
}
2021-04-09 08:39:15 -04:00
// DisallowEmpty returns an Option to not allow zero items to be selected (macOS only).
2021-04-07 09:16:35 -04:00
func DisallowEmpty() Option {
return funcOption(func(o *options) { o.disallowEmpty = true })
}