zenity/progress_unix.go

30 lines
729 B
Go
Raw Permalink Normal View History

2022-03-24 10:37:37 -04:00
//go:build !windows && !darwin
2021-04-25 19:36:15 -04:00
package zenity
2022-05-11 12:49:15 -04:00
import "github.com/ncruces/zenity/internal/zenutil"
2021-04-25 19:36:15 -04:00
func progress(opts options) (ProgressDialog, error) {
args := []string{"--progress"}
2022-06-02 07:24:24 -04:00
args = appendGeneral(args, opts)
2021-04-25 19:36:15 -04:00
args = appendButtons(args, opts)
args = appendWidthHeight(args, opts)
2022-05-18 09:48:09 -04:00
args = appendWindowIcon(args, opts)
2021-04-25 19:36:15 -04:00
if opts.maxValue == 0 {
opts.maxValue = 100
}
if opts.maxValue < 0 {
args = append(args, "--pulsate")
}
if opts.noCancel {
args = append(args, "--no-cancel")
}
2023-08-03 07:55:59 -04:00
if opts.autoClose {
args = append(args, "--auto-close")
}
2021-04-25 19:36:15 -04:00
if opts.timeRemaining {
args = append(args, "--time-remaining")
}
2023-08-03 07:55:59 -04:00
return zenutil.RunProgress(opts.ctx, opts.maxValue, opts.autoClose, opts.extraButton, args)
2021-04-25 19:36:15 -04:00
}