1
0
mirror of https://github.com/garraflavatra/rolens.git synced 2025-07-19 22:18:03 +00:00

First commit in a long time

This commit is contained in:
2023-05-26 17:21:39 +02:00
parent b15fde11db
commit a84b1498a3
17 changed files with 321 additions and 87 deletions

View File

@ -1,28 +1,33 @@
package ui
import "github.com/ncruces/zenity"
import (
"time"
func (u *UI) StartProgressBar(title string) {
if u.progress != nil {
// already loading
return
}
"github.com/ncruces/zenity"
)
func (u *UI) StartProgressBar(id uint, title string) {
if title == "" {
// default title
title = "Loading"
title = "Loading"
}
p, err := zenity.Progress(zenity.Title(title), zenity.Pulsate(), zenity.NoCancel(), zenity.Modal())
p, err := zenity.Progress(zenity.Title(title), zenity.Pulsate(), zenity.Modal())
if err != nil {
return
}
u.progress = p
u.progressBars[id] = p
}
func (u *UI) StopProgressBar() {
if u.progress == nil {
return
func (u *UI) StopProgressBar(id uint) {
for try := 0; try < 10; try++ {
p := u.progressBars[id]
if p != nil {
p.Complete()
p.Close()
p = nil
return
}
println("Progress dialog not found:", id, try)
time.Sleep(100 * time.Millisecond)
}
u.progress.Complete()
u.progress.Close()
u.progress = nil
}

View File

@ -9,12 +9,14 @@ import (
)
type UI struct {
ctx context.Context
progress zenity.ProgressDialog
ctx context.Context
progressBars map[uint]zenity.ProgressDialog
}
func New() *UI {
return &UI{}
return &UI{
progressBars: make(map[uint]zenity.ProgressDialog),
}
}
func (u *UI) Startup(ctx context.Context) {