diff --git a/Makefile b/Makefile index 2ac7baf..5673e81 100644 --- a/Makefile +++ b/Makefile @@ -1,5 +1,5 @@ all: - @GO111MODULE=off go build + @GO111MODULE=off go vet @echo this is a go library with buildable code goimports: diff --git a/listWindow.go b/listWindow.go index 61239b3..87216ff 100644 --- a/listWindow.go +++ b/listWindow.go @@ -13,8 +13,8 @@ import ( "go.wit.com/log" "go.wit.com/lib/gadgets" - "go.wit.com/lib/gui/repostatus" "go.wit.com/lib/gui/repolist" + "go.wit.com/lib/gui/repostatus" "go.wit.com/lib/gui/shell" ) @@ -23,9 +23,25 @@ var lw *gadgets.BasicWindow var allsections []*section type witRepo struct { - sec *section - path *gui.Node - downloadB *gui.Node + hidden bool + sec *section + path *gui.Node + downloadB *gui.Node + configureB *gui.Node +} + +func (w *witRepo) Show() { + w.hidden = false + w.path.Show() + w.downloadB.Show() + w.configureB.Show() +} + +func (w *witRepo) Hide() { + w.hidden = true + w.path.Hide() + w.downloadB.Hide() + w.configureB.Hide() } type section struct { @@ -59,9 +75,9 @@ func CheckRegistered(rs *repostatus.RepoStatus) (bool, string) { return found, source } -func myrepolist() []string { +func myrepolist(cfgfile string) []string { homeDir, _ := os.UserHomeDir() - cfgfile := filepath.Join(homeDir, ".config/myrepolist") + cfgfile = filepath.Join(homeDir, cfgfile) content, _ := ioutil.ReadFile(cfgfile) out := string(content) out = strings.TrimSpace(out) @@ -92,8 +108,8 @@ func ListWindow(view *repolist.RepoList) *gadgets.BasicWindow { var lines []string var currents *section - currents = NewSection(group, "local (~/.config/myrepolist)") - for i, line := range myrepolist() { + currents = NewSection(group, "local " + view.Cfgfile()) + for i, line := range myrepolist(view.Cfgfile()) { line = strings.TrimSpace(line) if line == "" { // skip blank lines @@ -211,7 +227,7 @@ func (s *section) add(view *repolist.RepoList, path string) { log.Verbose("repo is already downloaded", path) tmp.downloadB.SetLabel("downloaded") tmp.downloadB.Disable() - s.grid.NewButton("Configure", func() { + tmp.configureB = s.grid.NewButton("Configure", func() { log.Log(WIT, "todo: open the repo window here") }) } @@ -236,8 +252,6 @@ func NewSection(parent *gui.Node, desc string) *section { for i, wrepo := range news.witRepos { log.Warn("download:", i, wrepo.path.String()) wrepo.doDownload() - //wrepo.path.Show() - //wrepo.downloadB.Show() } lw.Enable() }) @@ -252,8 +266,7 @@ func (s *section) toggle() { s.hidden = false for i, wrepo := range s.witRepos { log.Warn(i, wrepo.path.String()) - wrepo.path.Show() - wrepo.downloadB.Show() + wrepo.Show() } } else { s.Hide() @@ -265,8 +278,7 @@ func (s *section) Hide() { s.hideCB.SetChecked(true) for i, wrepo := range s.witRepos { log.Warn(i, wrepo.path.String()) - wrepo.path.Hide() - wrepo.downloadB.Hide() + wrepo.Hide() } }