zenity/msg.go

58 lines
1.6 KiB
Go
Raw Normal View History

2020-01-23 06:44:28 -05:00
package zenity
// Question displays the question dialog.
//
2021-03-05 10:14:30 -05:00
// Valid options: Title, Width, Height, OKLabel, CancelLabel, ExtraButton,
// Icon, NoWrap, Ellipsize, DefaultCancel.
2021-04-29 11:05:28 -04:00
func Question(text string, options ...Option) error {
2021-03-04 07:42:30 -05:00
return message(questionKind, text, applyOptions(options))
2020-01-23 06:44:28 -05:00
}
// Info displays the info dialog.
//
2021-03-05 10:14:30 -05:00
// Valid options: Title, Width, Height, OKLabel, ExtraButton, Icon,
2021-02-12 09:24:13 -05:00
// NoWrap, Ellipsize.
2021-04-29 11:05:28 -04:00
func Info(text string, options ...Option) error {
2021-03-04 07:42:30 -05:00
return message(infoKind, text, applyOptions(options))
2020-01-23 06:44:28 -05:00
}
// Warning displays the warning dialog.
//
2021-03-05 10:14:30 -05:00
// Valid options: Title, Width, Height, OKLabel, ExtraButton, Icon,
2021-02-12 09:24:13 -05:00
// NoWrap, Ellipsize.
2021-04-29 11:05:28 -04:00
func Warning(text string, options ...Option) error {
2021-03-04 07:42:30 -05:00
return message(warningKind, text, applyOptions(options))
2020-01-23 06:44:28 -05:00
}
// Error displays the error dialog.
//
2021-03-05 10:14:30 -05:00
// Valid options: Title, Width, Height, OKLabel, ExtraButton, Icon,
2021-02-12 09:24:13 -05:00
// NoWrap, Ellipsize.
2021-04-29 11:05:28 -04:00
func Error(text string, options ...Option) error {
2021-03-04 07:42:30 -05:00
return message(errorKind, text, applyOptions(options))
2020-01-23 06:44:28 -05:00
}
type messageKind int
const (
questionKind messageKind = iota
infoKind
warningKind
errorKind
)
2021-03-03 21:52:05 -05:00
// NoWrap returns an Option to disable enable text wrapping (Unix only).
2020-01-23 06:44:28 -05:00
func NoWrap() Option {
2020-01-24 07:52:45 -05:00
return funcOption(func(o *options) { o.noWrap = true })
2020-01-23 06:44:28 -05:00
}
2021-03-03 21:52:05 -05:00
// Ellipsize returns an Option to enable ellipsizing in the dialog text (Unix only).
2020-01-23 06:44:28 -05:00
func Ellipsize() Option {
2020-01-24 07:52:45 -05:00
return funcOption(func(o *options) { o.ellipsize = true })
2020-01-23 06:44:28 -05:00
}
2021-03-03 21:52:05 -05:00
// DefaultCancel returns an Option to give the Cancel button focus by default.
2020-01-23 06:44:28 -05:00
func DefaultCancel() Option {
2020-01-24 07:52:45 -05:00
return funcOption(func(o *options) { o.defaultCancel = true })
2020-01-23 06:44:28 -05:00
}