diff options
Diffstat (limited to 'listWindow.go')
| -rw-r--r-- | listWindow.go | 39 |
1 files changed, 30 insertions, 9 deletions
diff --git a/listWindow.go b/listWindow.go index 5bcb9d7..3f87050 100644 --- a/listWindow.go +++ b/listWindow.go @@ -4,6 +4,7 @@ package main import ( "io/ioutil" "net/http" + "os" "strings" "go.wit.com/gui" @@ -15,13 +16,20 @@ import ( var lw *gadgets.BasicWindow var allsections []*section +type witRepo struct { + sec *section + path *gui.Node + downloadB *gui.Node +} + type section struct { name string parent *gui.Node box *gui.Node group *gui.Node - checkbox *gui.Node - repos []*gui.Node + grid *gui.Node // where the repos are listed + hideCB *gui.Node + witRepos []*witRepo } func listWindow() { @@ -66,8 +74,19 @@ func (s *section) add(path string) { if s == nil { return } - tmp := s.parent.NewLabel(path) - s.repos = append(s.repos, tmp) + tmp := new(witRepo) + tmp.sec = s + tmp.path = s.grid.NewLabel(path) + tmp.downloadB = s.grid.NewButton("download", func() { + lw.Disable() + log.Info("downloading", tmp.path.String(), "here") + os.Setenv("GO111MODULE", "off") + fullpath := "/home/jcarr/go/src/go.wit.com/" + quickCmd(fullpath, []string{"go", "get", "-v", tmp.path.String()}) + lw.Enable() + }) + + s.witRepos = append(s.witRepos, tmp) } func NewSection(parent *gui.Node, path string) *section { @@ -75,19 +94,21 @@ func NewSection(parent *gui.Node, path string) *section { news.parent = parent news.box = news.parent.NewBox("bw vbox", true) news.group = news.box.NewGroup(path) - news.checkbox = news.box.NewCheckbox("hide") - news.checkbox.Custom = func() { + news.hideCB = news.box.NewCheckbox("hide") + news.hideCB.Custom = func() { news.toggle() } + news.grid = news.parent.NewGrid("sections", 2, 1) allsections = append(allsections, news) return news } func (s *section) toggle() { log.Warn(s.name) - for i, n := range s.repos { - log.Warn(i, n.String()) - n.Hide() + for i, wrepo := range s.witRepos { + log.Warn(i, wrepo.path.String()) + wrepo.path.Hide() + wrepo.downloadB.Hide() } } |
