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
|
|
|
}
|
2021-04-30 14:19:14 -04:00
|
|
|
|
|
|
|
return zenutil.RunProgress(opts.ctx, opts.maxValue, data)
|
2021-04-25 13:34:56 -04:00
|
|
|
}
|