zenity/pwd_darwin.go

42 lines
870 B
Go
Raw Normal View History

2022-05-11 12:49:15 -04:00
package zenity
import (
"os"
2024-07-10 00:06:01 -04:00
"git.bigun.dev/evan/zenity/internal/zenutil"
2022-05-11 12:49:15 -04:00
)
func password(opts options) (string, string, error) {
if !opts.username {
2022-05-13 12:32:23 -04:00
opts.entryText = ""
2022-05-11 12:49:15 -04:00
opts.hideText = true
str, err := entry("Password:", opts)
return "", str, err
}
var data zenutil.Password
data.Separator = zenutil.Separator
data.Options.Title = opts.title
data.Options.Timeout = zenutil.Timeout
2022-06-02 07:49:31 -04:00
if opts.attach != nil {
data.Application = opts.attach
2022-06-08 18:52:44 -04:00
}
if i, ok := opts.windowIcon.(string); ok {
2022-06-01 19:00:08 -04:00
data.WindowIcon = i
}
2022-05-17 11:18:12 -04:00
switch i := opts.icon.(type) {
case string:
_, err := os.Stat(i)
2022-05-11 12:49:15 -04:00
if err != nil {
return "", "", err
}
2022-05-17 11:18:12 -04:00
data.IconPath = i
case DialogIcon:
data.Options.Icon = i.String()
2022-05-11 12:49:15 -04:00
}
data.SetButtons(getButtons(true, true, opts))
out, err := zenutil.Run(opts.ctx, "pwd", data)
return pwdResult(zenutil.Separator, opts, out, err)
}