mirror of
https://github.com/garraflavatra/rolens.git
synced 2025-06-28 05:25:11 +00:00
Zenity progress bar
This commit is contained in:
@ -2,6 +2,7 @@ package app
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"time"
|
||||
|
||||
"github.com/ncruces/zenity"
|
||||
"github.com/wailsapp/wails/v2/pkg/runtime"
|
||||
@ -23,6 +24,7 @@ type QueryResult struct {
|
||||
}
|
||||
|
||||
func (a *App) FindItems(hostKey, dbKey, collKey, formJson string) QueryResult {
|
||||
time.Sleep(2 * time.Second)
|
||||
var out QueryResult
|
||||
var form Query
|
||||
|
||||
|
@ -7,7 +7,7 @@ func (u *UI) OpenDirectory(id, title string) string {
|
||||
title = "Choose a directory"
|
||||
}
|
||||
|
||||
dir, err := zenity.SelectFile(zenity.Title(title), zenity.Directory())
|
||||
dir, err := zenity.SelectFile(zenity.Title(title), zenity.Directory(), zenity.Modal())
|
||||
|
||||
if err != nil && err != zenity.ErrCanceled {
|
||||
zenity.Error("Error while opening directory", zenity.ErrorIcon)
|
||||
@ -17,7 +17,7 @@ func (u *UI) OpenDirectory(id, title string) string {
|
||||
}
|
||||
|
||||
func (u *UI) EnterText(title, info, defaultEntry string) string {
|
||||
input, err := zenity.Entry(info, zenity.Title(title), zenity.EntryText(defaultEntry))
|
||||
input, err := zenity.Entry(info, zenity.Title(title), zenity.EntryText(defaultEntry), zenity.Modal())
|
||||
|
||||
if err == zenity.ErrCanceled {
|
||||
return ""
|
||||
|
28
internal/ui/progress.go
Normal file
28
internal/ui/progress.go
Normal file
@ -0,0 +1,28 @@
|
||||
package ui
|
||||
|
||||
import "github.com/ncruces/zenity"
|
||||
|
||||
func (u *UI) StartProgressBar(title string) {
|
||||
if u.progress != nil {
|
||||
// already loading
|
||||
return
|
||||
}
|
||||
if title == "" {
|
||||
// default title
|
||||
title = "Loading"
|
||||
}
|
||||
p, err := zenity.Progress(zenity.Title(title), zenity.Pulsate(), zenity.NoCancel(), zenity.Modal())
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
u.progress = p
|
||||
}
|
||||
|
||||
func (u *UI) StopProgressBar() {
|
||||
if u.progress == nil {
|
||||
return
|
||||
}
|
||||
u.progress.Complete()
|
||||
u.progress.Close()
|
||||
u.progress = nil
|
||||
}
|
@ -5,10 +5,12 @@ import (
|
||||
"runtime"
|
||||
|
||||
"github.com/gen2brain/beeep"
|
||||
"github.com/ncruces/zenity"
|
||||
)
|
||||
|
||||
type UI struct {
|
||||
ctx context.Context
|
||||
ctx context.Context
|
||||
progress zenity.ProgressDialog
|
||||
}
|
||||
|
||||
func New() *UI {
|
||||
|
Reference in New Issue
Block a user