zenity/progress_darwin.go

28 lines
544 B
Go
Raw Permalink Normal View History

2021-04-25 13:34:56 -04:00
package zenity
import (
2022-05-03 09:20:22 -04:00
"fmt"
2021-04-25 13:34:56 -04:00
"github.com/ncruces/zenity/internal/zenutil"
)
func progress(opts options) (ProgressDialog, error) {
2021-04-30 14:19:14 -04:00
if opts.extraButton != nil {
2022-05-03 09:20:22 -04:00
return nil, fmt.Errorf("%w: extra button", ErrUnsupported)
2021-04-25 13:34:56 -04:00
}
2021-04-30 14:19:14 -04:00
var data zenutil.Progress
data.Description = opts.title
2021-04-25 13:34:56 -04:00
if opts.maxValue == 0 {
opts.maxValue = 100
}
if opts.maxValue >= 0 {
2021-04-30 14:19:14 -04:00
data.Total = &opts.maxValue
2021-04-25 13:34:56 -04:00
}
2022-06-01 19:00:08 -04:00
if i, ok := opts.windowIcon.(string); ok {
data.WindowIcon = i
}
2021-04-30 14:19:14 -04:00
2023-08-03 07:55:59 -04:00
return zenutil.RunProgress(opts.ctx, opts.maxValue, opts.autoClose, data)
2021-04-25 13:34:56 -04:00
}