zenity/progress.go

52 lines
1.5 KiB
Go
Raw Permalink 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
2021-04-30 14:05:49 -04:00
// Complete marks the task completed.
Complete() error
2021-04-25 19:36:15 -04:00
// 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
2021-04-30 14:19:14 -04:00
// MaxValue returns an Option to set the maximum value (Windows and 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 })
}
2021-04-30 14:19:14 -04:00
// NoCancel returns an Option to hide the Cancel button (Windows and Unix only).
2021-04-25 13:34:56 -04:00
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 })
}