correctly show/hide() repo

This commit is contained in:
Jeff Carr 2024-03-01 18:02:44 -06:00
parent cbac752e60
commit 316c1b8cc2
2 changed files with 28 additions and 16 deletions

View File

@ -1,5 +1,5 @@
all:
@GO111MODULE=off go build
@GO111MODULE=off go vet
@echo this is a go library with buildable code
goimports:

View File

@ -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()
}
}