zenity/progress.go

59 lines
1.7 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,
2022-06-02 07:24:24 -04:00
// Icon, WindowIcon, Attach, Modal, MaxValue, Pulsate, NoCancel, TimeRemaining.
2022-03-25 20:58:27 -04:00
//
2022-05-02 06:22:53 -04:00
// May return: ErrUnsupported.
2021-04-25 13:34:56 -04:00
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
2022-05-02 06:22:53 -04:00
// Done returns a channel that is closed when the dialog is closed.
2021-04-25 19:36:15 -04:00
Done() <-chan struct{}
2021-04-22 10:03:08 -04:00
}
2021-04-25 13:34:56 -04:00
2022-11-22 13:08:35 -05:00
// MaxValue returns an Option to set the maximum value.
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 })
}
2023-08-03 07:55:59 -04:00
// AutoClose returns an Option to dismiss the dialog when 100% has been reached.
func AutoClose() Option {
return funcOption(func(o *options) { o.autoClose = true })
}
2021-04-25 13:34:56 -04:00
// TimeRemaining returns an Option to estimate when progress will reach 100% (Unix only).
func TimeRemaining() Option {
return funcOption(func(o *options) { o.timeRemaining = true })
}