2022-03-24 10:37:37 -04:00
|
|
|
//go:build !windows && !darwin
|
2021-04-07 09:16:35 -04:00
|
|
|
|
|
|
|
package zenity
|
|
|
|
|
2022-05-11 12:49:15 -04:00
|
|
|
import "github.com/ncruces/zenity/internal/zenutil"
|
2021-04-08 11:43:14 -04:00
|
|
|
|
2021-04-29 11:05:28 -04:00
|
|
|
func list(text string, items []string, opts options) (string, error) {
|
2022-07-28 20:16:15 -04:00
|
|
|
args := []string{"--list", "--hide-header", "--text", text}
|
2022-06-02 07:24:24 -04:00
|
|
|
args = appendGeneral(args, opts)
|
2021-04-08 11:43:14 -04:00
|
|
|
args = appendButtons(args, opts)
|
|
|
|
args = appendWidthHeight(args, opts)
|
2022-05-18 09:48:09 -04:00
|
|
|
args = appendWindowIcon(args, opts)
|
2022-07-28 20:16:15 -04:00
|
|
|
if opts.listKind == radioListKind {
|
|
|
|
args = append(args, "--radiolist", "--column=", "--column=")
|
|
|
|
for _, i := range items {
|
2022-11-22 13:08:35 -05:00
|
|
|
args = append(args, "", i)
|
2022-07-28 20:16:15 -04:00
|
|
|
}
|
|
|
|
} else {
|
|
|
|
args = append(args, "--column=")
|
|
|
|
args = append(args, items...)
|
|
|
|
}
|
2021-04-08 11:43:14 -04:00
|
|
|
|
|
|
|
out, err := zenutil.Run(opts.ctx, args)
|
|
|
|
return strResult(opts, out, err)
|
2021-04-07 09:16:35 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
func listMultiple(text string, items []string, opts options) ([]string, error) {
|
2022-07-28 20:16:15 -04:00
|
|
|
args := []string{"--list", "--hide-header", "--text", text, "--multiple", "--separator", zenutil.Separator}
|
2022-06-02 07:24:24 -04:00
|
|
|
args = appendGeneral(args, opts)
|
2021-04-08 11:43:14 -04:00
|
|
|
args = appendButtons(args, opts)
|
|
|
|
args = appendWidthHeight(args, opts)
|
2022-05-18 09:48:09 -04:00
|
|
|
args = appendWindowIcon(args, opts)
|
2022-07-28 20:16:15 -04:00
|
|
|
if opts.listKind == checkListKind {
|
|
|
|
args = append(args, "--checklist", "--column=", "--column=")
|
|
|
|
for _, i := range items {
|
2022-11-22 13:08:35 -05:00
|
|
|
args = append(args, "", i)
|
2022-07-28 20:16:15 -04:00
|
|
|
}
|
|
|
|
} else {
|
|
|
|
args = append(args, "--column=")
|
|
|
|
args = append(args, items...)
|
|
|
|
}
|
2021-04-08 11:43:14 -04:00
|
|
|
|
|
|
|
out, err := zenutil.Run(opts.ctx, args)
|
|
|
|
return lstResult(opts, out, err)
|
2021-04-07 09:16:35 -04:00
|
|
|
}
|