zenity/entry_darwin.go

31 lines
691 B
Go
Raw Permalink Normal View History

2021-03-04 21:01:59 -05:00
package zenity
import (
2022-05-06 08:48:31 -04:00
"os"
2021-03-04 21:01:59 -05:00
"github.com/ncruces/zenity/internal/zenutil"
)
2021-04-29 11:05:28 -04:00
func entry(text string, opts options) (string, error) {
2021-03-04 21:01:59 -05:00
var data zenutil.Dialog
data.Text = text
data.Operation = "displayDialog"
data.Options.Title = opts.title
data.Options.Answer = &opts.entryText
data.Options.Hidden = opts.hideText
data.Options.Timeout = zenutil.Timeout
2022-05-05 08:21:00 -04:00
if opts.customIcon != "" {
2022-05-06 08:48:31 -04:00
_, err := os.Stat(opts.customIcon)
if err != nil {
return "", err
}
2022-05-05 08:21:00 -04:00
data.IconPath = opts.customIcon
} else {
data.Options.Icon = opts.icon.String()
}
2021-04-06 07:35:22 -04:00
data.SetButtons(getButtons(true, true, opts))
2021-03-04 21:01:59 -05:00
out, err := zenutil.Run(opts.ctx, "dialog", data)
2021-04-08 11:43:14 -04:00
return strResult(opts, out, err)
2021-03-05 21:07:00 -05:00
}