-
-
Notifications
You must be signed in to change notification settings - Fork 37
/
msg_unix.go
53 lines (49 loc) · 1.34 KB
/
msg_unix.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
//go:build !windows && !darwin
package zenity
import "github.com/ncruces/zenity/internal/zenutil"
func message(kind messageKind, text string, opts options) error {
args := []string{"--text", text, "--no-markup"}
switch kind {
case questionKind:
args = append(args, "--question")
case infoKind:
args = append(args, "--info")
case warningKind:
args = append(args, "--warning")
case errorKind:
args = append(args, "--error")
}
args = appendGeneral(args, opts)
args = appendButtons(args, opts)
args = appendWidthHeight(args, opts)
args = appendWindowIcon(args, opts)
if opts.noWrap {
args = append(args, "--no-wrap")
}
if opts.ellipsize {
args = append(args, "--ellipsize")
}
if opts.defaultCancel {
args = append(args, "--default-cancel")
}
switch opts.icon {
case ErrorIcon:
args = append(args, "--icon-name=dialog-error")
case WarningIcon:
args = append(args, "--icon-name=dialog-warning")
case InfoIcon:
args = append(args, "--icon-name=dialog-information")
case QuestionIcon:
args = append(args, "--icon-name=dialog-question")
case PasswordIcon:
args = append(args, "--icon-name=dialog-password")
case NoIcon:
args = append(args, "--icon-name=")
}
if i, ok := opts.icon.(string); ok {
args = append(args, "--icon-name", i)
}
out, err := zenutil.Run(opts.ctx, args)
_, err = strResult(opts, out, err)
return err
}