From 8034921c7d63df9b2c402d7a4053c29f97d80761 Mon Sep 17 00:00:00 2001 From: Jeff Carr Date: Sat, 27 Jan 2024 15:09:51 -0600 Subject: [PATCH] download all button Signed-off-by: Jeff Carr --- listWindow.go | 44 ++++++++++++++++++++++++++++++++++---------- 1 file changed, 34 insertions(+), 10 deletions(-) diff --git a/listWindow.go b/listWindow.go index 943dde8..bc2f5d9 100644 --- a/listWindow.go +++ b/listWindow.go @@ -34,6 +34,7 @@ type section struct { group *gui.Node grid *gui.Node // where the repos are listed hideCB *gui.Node + downloadAllB *gui.Node witRepos []*witRepo } @@ -106,6 +107,27 @@ func downloadRepo(path string) bool { return true } +func (r *witRepo) doDownload() bool { + if me.autoDryRun.Checked() { + r.downloadB.SetLabel("uncheck --dry-run") + return false + } + if r.downloadB.String() == "downloaded" { + log.Info("skipping already downloaded", r.path.String()) + return true + } + if downloadRepo(r.path.String()) { + log.Info("download", r.path.String(), "worked") + r.downloadB.SetLabel("downloaded") + r.downloadB.Disable() + } else { + r.downloadB.SetLabel("failed") + log.Info("download", r.path.String(), "failed") + return false + } + return true +} + func (s *section) add(path string) { if s == nil { return @@ -115,16 +137,7 @@ func (s *section) add(path string) { tmp.path = s.grid.NewLabel(path) tmp.downloadB = s.grid.NewButton("download", func() { lw.Disable() - if me.autoDryRun.Checked() { - tmp.downloadB.SetLabel("uncheck --dry-run") - } - if downloadRepo(tmp.path.String()) { - log.Info("download", tmp.path.String(), "worked") - tmp.downloadB.SetLabel("downloaded") - tmp.downloadB.Disable() - } else { - log.Info("download", tmp.path.String(), "failed") - } + tmp.doDownload() lw.Enable() }) if repostatus.VerifyLocalGoRepo(path) { @@ -146,6 +159,17 @@ func NewSection(parent *gui.Node, desc string) *section { news.hideCB.Custom = func() { news.toggle() } + news.downloadAllB = news.box.NewButton("download all", func() { + lw.Disable() + log.Warn("Download all here") + for i, wrepo := range news.witRepos { + log.Warn("download:", i, wrepo.path.String()) + wrepo.doDownload() + //wrepo.path.Show() + //wrepo.downloadB.Show() + } + lw.Enable() + }) news.grid = news.parent.NewGrid("sections", 2, 1) allsections = append(allsections, news) return news