zenity/list_darwin.go

44 lines
1.1 KiB
Go
Raw Normal View History

2021-04-07 09:16:35 -04:00
package zenity
import (
"github.com/ncruces/zenity/internal/zenutil"
)
2021-04-29 11:05:28 -04:00
func list(text string, items []string, opts options) (string, error) {
2022-05-02 10:51:21 -04:00
if len(items) == 0 || opts.extraButton != nil {
2021-04-30 14:19:14 -04:00
return "", ErrUnsupported
}
2021-04-07 09:16:35 -04:00
var data zenutil.List
data.Items = items
data.Options.Prompt = &text
data.Options.Title = opts.title
data.Options.OK = opts.okLabel
data.Options.Cancel = opts.cancelLabel
data.Options.Default = opts.defaultItems
data.Options.Empty = !opts.disallowEmpty
out, err := zenutil.Run(opts.ctx, "list", data)
2021-04-08 11:43:14 -04:00
return strResult(opts, out, err)
2021-04-07 09:16:35 -04:00
}
func listMultiple(text string, items []string, opts options) ([]string, error) {
2022-05-02 10:51:21 -04:00
if len(items) == 0 || opts.extraButton != nil {
2021-04-30 14:19:14 -04:00
return nil, ErrUnsupported
}
2021-04-07 09:16:35 -04:00
var data zenutil.List
data.Items = items
data.Options.Prompt = &text
data.Options.Title = opts.title
data.Options.OK = opts.okLabel
data.Options.Cancel = opts.cancelLabel
data.Options.Default = opts.defaultItems
data.Options.Empty = !opts.disallowEmpty
data.Options.Multiple = true
data.Separator = zenutil.Separator
out, err := zenutil.Run(opts.ctx, "list", data)
2021-04-08 11:43:14 -04:00
return lstResult(opts, out, err)
2021-04-07 09:16:35 -04:00
}