zenity/progress.go

49 lines
1.4 KiB
Go
Raw Normal View History

2021-04-22 10:03:08 -04:00
package zenity
2021-04-25 13:34:56 -04:00
// Progress displays the progress indication dialog.
//
// Valid options: Title, Width, Height, OKLabel, CancelLabel, ExtraButton,
// Icon, MaxValue, Pulsate, NoCancel, TimeRemaining.
func Progress(options ...Option) (ProgressDialog, error) {
return progress(applyOptions(options))
}
2021-04-25 19:36:15 -04:00
// ProgressDialog allows you to interact with the progress indication dialog.
2021-04-25 13:34:56 -04:00
type ProgressDialog interface {
2021-04-25 19:36:15 -04:00
// Text sets the dialog text.
2021-04-25 13:34:56 -04:00
Text(string) error
2021-04-25 19:36:15 -04:00
// Value sets how much of the task has been completed.
2021-04-25 13:34:56 -04:00
Value(int) error
2021-04-25 19:36:15 -04:00
// MaxValue gets how much work the task requires in total.
MaxValue() int
// Close closes the dialog.
2021-04-22 10:03:08 -04:00
Close() error
2021-04-25 19:36:15 -04:00
// Done returns a channel that's closed when the dialog is closed.
Done() <-chan struct{}
2021-04-22 10:03:08 -04:00
}
2021-04-25 13:34:56 -04:00
// MaxValue returns an Option to set the maximum value (macOS only).
2021-04-25 19:36:15 -04:00
// The default maximum value is 100.
2021-04-25 13:34:56 -04:00
func MaxValue(value int) Option {
return funcOption(func(o *options) { o.maxValue = value })
}
// Pulsate returns an Option to pulsate the progress bar.
func Pulsate() Option {
return funcOption(func(o *options) { o.maxValue = -1 })
}
// NoCancel returns an Option to hide the Cancel button (Unix only).
func NoCancel() Option {
return funcOption(func(o *options) { o.noCancel = true })
}
// TimeRemaining returns an Option to estimate when progress will reach 100% (Unix only).
func TimeRemaining() Option {
return funcOption(func(o *options) { o.timeRemaining = true })
}