mirror of
https://github.com/garraflavatra/rolens.git
synced 2024-11-22 10:25:48 +01:00
35 lines
622 B
Go
35 lines
622 B
Go
package ui
|
|
|
|
import (
|
|
"time"
|
|
|
|
"github.com/ncruces/zenity"
|
|
)
|
|
|
|
// @todo: this takes ~0.5 seconds. Improve?
|
|
func (u *UI) StartProgressBar(id uint, title string) {
|
|
if title == "" {
|
|
// default title
|
|
title = "Loading…"
|
|
}
|
|
p, err := zenity.Progress(zenity.Title(title), zenity.Pulsate(), zenity.Modal())
|
|
if err != nil {
|
|
return
|
|
}
|
|
u.progressBars[id] = p
|
|
}
|
|
|
|
func (u *UI) StopProgressBar(id uint) {
|
|
for try := 0; try < 10; try++ {
|
|
if p := u.progressBars[id]; p != nil {
|
|
p.Complete()
|
|
p.Close()
|
|
p = nil
|
|
return
|
|
}
|
|
|
|
println("Progress dialog not found:", id, try)
|
|
time.Sleep(100 * time.Millisecond)
|
|
}
|
|
}
|