mirror of
https://github.com/Xpl0itU/WiiUDownloader.git
synced 2025-05-12 22:26:15 -04:00
Fix GTK warnings
This commit is contained in:
parent
40d174fd4e
commit
2d7d23fc68
4 changed files with 25 additions and 31 deletions
|
@ -44,6 +44,7 @@ func main() {
|
|||
win.ShowAll()
|
||||
app.AddWindow(win.window)
|
||||
app.GetActiveWindow().Show()
|
||||
gtk.Main()
|
||||
})
|
||||
app.Run(nil)
|
||||
app.Quit()
|
||||
|
|
|
@ -285,7 +285,7 @@ func (mw *MainWindow) ShowAll() {
|
|||
mw.logger.Fatal("Unable to create box:", err)
|
||||
}
|
||||
|
||||
mw.categoryButtons = make([]*gtk.ToggleButton, 5)
|
||||
mw.categoryButtons = make([]*gtk.ToggleButton, 0)
|
||||
for _, cat := range []string{"Game", "Update", "DLC", "Demo", "All"} {
|
||||
button, err := gtk.ToggleButtonNewWithLabel(cat)
|
||||
if err != nil {
|
||||
|
|
|
@ -19,7 +19,6 @@ import (
|
|||
"unsafe"
|
||||
|
||||
"github.com/gotk3/gotk3/glib"
|
||||
"github.com/gotk3/gotk3/gtk"
|
||||
"golang.org/x/sync/errgroup"
|
||||
)
|
||||
|
||||
|
@ -48,9 +47,7 @@ func DecryptContents(path string, progress *ProgressWindow, deleteEncryptedConte
|
|||
glib.IdleAdd(func() {
|
||||
progress.bar.SetFraction(float64(progressInt) / 100)
|
||||
})
|
||||
for gtk.EventsPending() {
|
||||
gtk.MainIteration()
|
||||
}
|
||||
forceUpdateUI()
|
||||
}
|
||||
time.Sleep(time.Millisecond * 10)
|
||||
}
|
||||
|
|
|
@ -98,13 +98,7 @@ func downloadFile(progressWindow *ProgressWindow, client *grab.Client, downloadU
|
|||
req.BufferSize = bufferSize
|
||||
|
||||
resp := client.Do(req)
|
||||
glib.IdleAdd(func() {
|
||||
progressWindow.bar.SetFraction(resp.Progress())
|
||||
progressWindow.bar.SetText(fmt.Sprintf("Downloading %s (%s/%s) (%s/s)", filePath, humanize.Bytes(uint64(resp.BytesComplete())), humanize.Bytes(uint64(resp.Size())), humanize.Bytes(uint64(resp.BytesPerSecond()))))
|
||||
})
|
||||
for gtk.EventsPending() {
|
||||
gtk.MainIteration()
|
||||
}
|
||||
updateProgressWindow(progressWindow, resp, filePath)
|
||||
|
||||
t := time.NewTicker(500 * time.Millisecond)
|
||||
defer t.Stop()
|
||||
|
@ -113,21 +107,13 @@ func downloadFile(progressWindow *ProgressWindow, client *grab.Client, downloadU
|
|||
for {
|
||||
select {
|
||||
case <-t.C:
|
||||
glib.IdleAdd(func() {
|
||||
progressWindow.bar.SetFraction(resp.Progress())
|
||||
progressWindow.bar.SetText(fmt.Sprintf("Downloading %s (%s/%s) (%s/s)", filePath, humanize.Bytes(uint64(resp.BytesComplete())), humanize.Bytes(uint64(resp.Size())), humanize.Bytes(uint64(resp.BytesPerSecond()))))
|
||||
})
|
||||
for gtk.EventsPending() {
|
||||
gtk.MainIteration()
|
||||
}
|
||||
updateProgressWindow(progressWindow, resp, filePath)
|
||||
if progressWindow.cancelled {
|
||||
resp.Cancel()
|
||||
break Loop
|
||||
}
|
||||
case <-resp.Done:
|
||||
for gtk.EventsPending() {
|
||||
gtk.MainIteration()
|
||||
}
|
||||
forceUpdateUI()
|
||||
if err := resp.Err(); err != nil {
|
||||
if doRetries && attempt < maxRetries {
|
||||
time.Sleep(retryDelay)
|
||||
|
@ -143,6 +129,20 @@ func downloadFile(progressWindow *ProgressWindow, client *grab.Client, downloadU
|
|||
return nil
|
||||
}
|
||||
|
||||
func forceUpdateUI() {
|
||||
for gtk.EventsPending() {
|
||||
gtk.MainIteration()
|
||||
}
|
||||
}
|
||||
|
||||
func updateProgressWindow(progressWindow *ProgressWindow, resp *grab.Response, filePath string) {
|
||||
glib.IdleAdd(func() {
|
||||
progressWindow.bar.SetFraction(resp.Progress())
|
||||
progressWindow.bar.SetText(fmt.Sprintf("Downloading %s (%s/%s) (%s/s)", filePath, humanize.Bytes(uint64(resp.BytesComplete())), humanize.Bytes(uint64(resp.Size())), humanize.Bytes(uint64(resp.BytesPerSecond()))))
|
||||
})
|
||||
forceUpdateUI()
|
||||
}
|
||||
|
||||
func DownloadTitle(titleID string, outputDirectory string, doDecryption bool, progressWindow *ProgressWindow, deleteEncryptedContents bool, logger *Logger) error {
|
||||
progressWindow.cancelButton.Connect("clicked", func() {
|
||||
progressWindow.cancelled = true
|
||||
|
@ -166,9 +166,8 @@ func DownloadTitle(titleID string, outputDirectory string, doDecryption bool, pr
|
|||
|
||||
client := grab.NewClient()
|
||||
client.BufferSize = bufferSize
|
||||
downloadURL := fmt.Sprintf("%s/%s", baseURL, "tmd")
|
||||
tmdPath := filepath.Join(outputDir, "title.tmd")
|
||||
if err := downloadFile(progressWindow, client, downloadURL, tmdPath, true); err != nil {
|
||||
if err := downloadFile(progressWindow, client, fmt.Sprintf("%s/%s", baseURL, "tmd"), tmdPath, true); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
|
@ -183,8 +182,7 @@ func DownloadTitle(titleID string, outputDirectory string, doDecryption bool, pr
|
|||
}
|
||||
|
||||
tikPath := filepath.Join(outputDir, "title.tik")
|
||||
downloadURL = fmt.Sprintf("%s/%s", baseURL, "cetk")
|
||||
if err := downloadFile(progressWindow, client, downloadURL, tikPath, false); err != nil {
|
||||
if err := downloadFile(progressWindow, client, fmt.Sprintf("%s/%s", baseURL, "cetk"), tikPath, false); err != nil {
|
||||
titleKey, err := GenerateKey(titleID)
|
||||
if err != nil {
|
||||
return err
|
||||
|
@ -235,6 +233,7 @@ func DownloadTitle(titleID string, outputDirectory string, doDecryption bool, pr
|
|||
}
|
||||
|
||||
var id uint32
|
||||
var content contentInfo
|
||||
tmdDataReader := bytes.NewReader(tmdData)
|
||||
|
||||
for i := 0; i < int(contentCount); i++ {
|
||||
|
@ -244,18 +243,15 @@ func DownloadTitle(titleID string, outputDirectory string, doDecryption bool, pr
|
|||
return err
|
||||
}
|
||||
filePath := filepath.Join(outputDir, fmt.Sprintf("%08X.app", id))
|
||||
downloadURL = fmt.Sprintf("%s/%08X", baseURL, id)
|
||||
if err := downloadFile(progressWindow, client, downloadURL, filePath, true); err != nil {
|
||||
if err := downloadFile(progressWindow, client, fmt.Sprintf("%s/%08X", baseURL, id), filePath, true); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
if tmdData[offset+7]&0x2 == 2 {
|
||||
filePath = filepath.Join(outputDir, fmt.Sprintf("%08X.h3", id))
|
||||
downloadURL = fmt.Sprintf("%s/%08X.h3", baseURL, id)
|
||||
if err := downloadFile(progressWindow, client, downloadURL, filePath, true); err != nil {
|
||||
if err := downloadFile(progressWindow, client, fmt.Sprintf("%s/%08X.h3", baseURL, id), filePath, true); err != nil {
|
||||
return err
|
||||
}
|
||||
var content contentInfo
|
||||
content.Hash = tmdData[offset+16 : offset+0x14]
|
||||
content.ID = fmt.Sprintf("%08X", id)
|
||||
tmdDataReader.Seek(int64(offset+8), 0)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue