diff --git a/internal/zenutil/run_darwin.go b/internal/zenutil/run_darwin.go index 403cde1..d3d71b3 100644 --- a/internal/zenutil/run_darwin.go +++ b/internal/zenutil/run_darwin.go @@ -130,7 +130,7 @@ type Dialog struct { Text string Extra *string Options DialogOptions - IconPath *string + IconPath string } // DialogOptions is internal. diff --git a/msg_darwin.go b/msg_darwin.go index 3f2e836..61f54d7 100644 --- a/msg_darwin.go +++ b/msg_darwin.go @@ -11,7 +11,7 @@ func message(kind messageKind, text string, opts options) error { // dialog is more flexible, alert prettier var dialog bool - if opts.icon != 0 || opts.iconPath != nil { // use if we want to show a specific icon + if opts.icon != 0 || opts.customIcon != "" { // use if we want to show a specific icon dialog = true } else if kind == questionKind && opts.cancelLabel == nil { // use for questions with default buttons dialog = true @@ -20,8 +20,8 @@ func message(kind messageKind, text string, opts options) error { if dialog { data.Operation = "displayDialog" data.Options.Title = opts.title - if opts.iconPath != nil { - data.IconPath = opts.iconPath + if opts.customIcon != "" { + data.IconPath = opts.customIcon } else { data.Options.Icon = opts.icon.String() } diff --git a/zenity.go b/zenity.go index 4364254..f737c62 100644 --- a/zenity.go +++ b/zenity.go @@ -39,7 +39,7 @@ type options struct { cancelLabel *string extraButton *string icon DialogIcon - iconPath *string + customIcon string defaultCancel bool // Message options @@ -133,7 +133,10 @@ func ExtraButton(extra string) Option { // DialogIcon is an Option that sets the dialog icon. type DialogIcon int -func (i DialogIcon) apply(o *options) { o.icon = i } +func (i DialogIcon) apply(o *options) { + o.customIcon = "" + o.icon = i +} // The stock dialog icons. const ( @@ -148,12 +151,15 @@ const ( // Icon returns an Option to set the dialog icon. // -// Deprecated: use DialogIcon directly. +// Tip: use DialogIcon directly. func Icon(icon DialogIcon) Option { return icon } -// Icon returns an Option to set an icon loaded from a file. +// Icon returns an Option to set a custom dialog icon, loaded from a file. func CustomIcon(path string) Option { - return funcOption(func(o *options) { o.iconPath = &path }) + return funcOption(func(o *options) { + o.icon = unspecifiedIcon + o.customIcon = path + }) } // Context returns an Option to set a Context that can dismiss the dialog.