diff --git a/cmd/zenity/main.go b/cmd/zenity/main.go index a3bb851..3b35d9b 100644 --- a/cmd/zenity/main.go +++ b/cmd/zenity/main.go @@ -376,7 +376,7 @@ func loadFlags() []zenity.Option { case "": ico = zenity.NoIcon } - opts = append(opts, zenity.Icon(ico)) + opts = append(opts, ico) // Message options diff --git a/cmd/zenity/notify.go b/cmd/zenity/notify.go index 005b5ef..18ca6d3 100644 --- a/cmd/zenity/notify.go +++ b/cmd/zenity/notify.go @@ -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:] diff --git a/msg_test.go b/msg_test.go index ea649ce..0d70191 100644 --- a/msg_test.go +++ b/msg_test.go @@ -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: } diff --git a/notify_test.go b/notify_test.go index 015ae61..45e02f8 100644 --- a/notify_test.go +++ b/notify_test.go @@ -12,7 +12,7 @@ import ( func ExampleNotify() { zenity.Notify("There are system updates necessary!", zenity.Title("Warning"), - zenity.Icon(zenity.InfoIcon)) + zenity.InfoIcon) // Output: } diff --git a/zenity.go b/zenity.go index 90ac710..84b9529 100644 --- a/zenity.go +++ b/zenity.go @@ -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. //