Icon options.

This commit is contained in:
Nuno Cruces 2021-05-11 14:58:04 +01:00
parent a1e9ae327f
commit 6e3393bd4f
5 changed files with 11 additions and 11 deletions

View file

@ -376,7 +376,7 @@ func loadFlags() []zenity.Option {
case "":
ico = zenity.NoIcon
}
opts = append(opts, zenity.Icon(ico))
opts = append(opts, ico)
// Message options

View file

@ -16,7 +16,7 @@ func notify(opts ...zenity.Option) error {
}
zenutil.Command = false
var icon zenity.DialogIcon
icon := zenity.InfoIcon
for scanner := bufio.NewScanner(os.Stdin); scanner.Scan(); {
line := scanner.Text()
var cmd, msg string
@ -43,7 +43,7 @@ func notify(opts ...zenity.Option) error {
icon = zenity.NoIcon
}
case "message", "tooltip":
opts := []zenity.Option{zenity.Icon(icon)}
opts := []zenity.Option{icon}
if n := strings.IndexByte(msg, '\n'); n >= 0 {
opts = append(opts, zenity.Title(msg[:n]))
msg = msg[n+1:]

View file

@ -14,28 +14,28 @@ import (
func ExampleError() {
zenity.Error("An error has occurred.",
zenity.Title("Error"),
zenity.Icon(zenity.ErrorIcon))
zenity.ErrorIcon)
// Output:
}
func ExampleInfo() {
zenity.Info("All updates are complete.",
zenity.Title("Information"),
zenity.Icon(zenity.InfoIcon))
zenity.InfoIcon)
// Output:
}
func ExampleWarning() {
zenity.Warning("Are you sure you want to proceed?",
zenity.Title("Warning"),
zenity.Icon(zenity.WarningIcon))
zenity.WarningIcon)
// Output:
}
func ExampleQuestion() {
zenity.Question("Are you sure you want to proceed?",
zenity.Title("Question"),
zenity.Icon(zenity.QuestionIcon))
zenity.QuestionIcon)
// Output:
}

View file

@ -12,7 +12,7 @@ import (
func ExampleNotify() {
zenity.Notify("There are system updates necessary!",
zenity.Title("Warning"),
zenity.Icon(zenity.InfoIcon))
zenity.InfoIcon)
// Output:
}

View file

@ -128,6 +128,8 @@ func ExtraButton(extra string) Option {
// DialogIcon is the enumeration for dialog icons.
type DialogIcon int
func (i DialogIcon) apply(o *options) { o.icon = i }
// The stock dialog icons.
const (
ErrorIcon DialogIcon = iota + 1
@ -139,9 +141,7 @@ const (
)
// Icon returns an Option to set the dialog icon.
func Icon(icon DialogIcon) Option {
return funcOption(func(o *options) { o.icon = icon })
}
func Icon(icon DialogIcon) Option { return icon }
// Context returns an Option to set a Context that can dismiss the dialog.
//