Make backend and frontend independent

This commit is contained in:
Xpl0itU 2023-08-29 20:55:43 +02:00
parent 08505c9eec
commit 99597834ce
8 changed files with 148 additions and 123 deletions

View file

@ -18,7 +18,6 @@ import (
"time"
"unsafe"
"github.com/gotk3/gotk3/glib"
"golang.org/x/sync/errgroup"
)
@ -29,7 +28,7 @@ func callProgressCallback(progress C.int) {
var progressChan chan int
func DecryptContents(path string, progress *ProgressWindow, deleteEncryptedContents bool) error {
func DecryptContents(path string, progress ProgressReporter, deleteEncryptedContents bool) error {
progressChan = make(chan int)
errGroup := errgroup.Group{}
@ -38,16 +37,9 @@ func DecryptContents(path string, progress *ProgressWindow, deleteEncryptedConte
return runDecryption(path, deleteEncryptedContents)
})
glib.IdleAdd(func() {
progress.bar.SetText("Decrypting...")
})
for progressInt := range progressChan {
if progressInt > 0 {
glib.IdleAdd(func() {
progress.bar.SetFraction(float64(progressInt) / 100)
})
forceUpdateUI()
progress.UpdateDecryptionProgress(float64(progressInt) / 100)
}
time.Sleep(time.Millisecond * 10)
}