2
2
3
3
package zenity
4
4
5
- import "github.com/ncruces/zenity/internal/zenutil"
5
+ import (
6
+ "slices"
7
+
8
+ "github.com/ncruces/zenity/internal/zenutil"
9
+ )
6
10
7
11
func list (text string , items []string , opts options ) (string , error ) {
8
12
args := []string {"--list" , "--hide-header" , "--text" , text }
@@ -27,15 +31,6 @@ func list(text string, items []string, opts options) (string, error) {
27
31
return strResult (opts , out , err )
28
32
}
29
33
30
- func isSelected (defaults []string , value string ) string {
31
- for _ , d := range defaults {
32
- if d == value {
33
- return "TRUE"
34
- }
35
- }
36
- return "FALSE"
37
- }
38
-
39
34
func listMultiple (text string , items []string , opts options ) ([]string , error ) {
40
35
args := []string {"--list" , "--hide-header" , "--text" , text , "--multiple" , "--separator" , zenutil .Separator }
41
36
args = appendGeneral (args , opts )
@@ -48,7 +43,11 @@ func listMultiple(text string, items []string, opts options) ([]string, error) {
48
43
if opts .listKind == checkListKind || len (opts .defaultItems ) > 0 {
49
44
args = append (args , "--checklist" , "--column=" , "--column=" )
50
45
for _ , i := range items {
51
- args = append (args , isSelected (opts .defaultItems , i ), i )
46
+ selected := ""
47
+ if slices .Contains (opts .defaultItems , i ) {
48
+ selected = "true"
49
+ }
50
+ args = append (args , selected , i )
52
51
}
53
52
} else {
54
53
args = append (args , "--column=" )
0 commit comments