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