autotypist/globalDisplayOptions.go

156 lines
3.2 KiB
Go

// This is a simple example
package main
import (
"go.wit.com/gui"
"go.wit.com/lib/debugger"
"go.wit.com/lib/gui/logsettings"
"go.wit.com/log"
// "go.wit.com/gui/gadgets"
)
func globalDisplaySetRepoState() {
for _, repo := range me.allrepos {
if me.autoHideReadOnly.Checked() {
if repo.status.ReadOnly() {
repo.Hide()
continue
}
}
if me.autoHidePerfect.Checked() {
if repo.dirtyLabel.String() == "PERFECT" {
repo.Hide()
continue
}
}
repo.Show()
}
}
func globalDisplayShow() {
for _, repo := range me.allrepos {
if me.autoHideReadOnly.Checked() {
if repo.status.ReadOnly() {
continue
}
}
if me.autoHidePerfect.Checked() {
if repo.dirtyLabel.String() == "PERFECT" {
continue
}
}
repo.Show()
}
}
func globalDisplayOptions(box *gui.Node) {
vbox := box.NewVerticalBox("DISPLAYVBOX")
group1 := vbox.NewGroup("Global Display Options")
group1.NewButton("Show Repository Window", func() {
globalDisplaySetRepoState()
reposwin.Toggle()
})
group1.NewButton("Create Release Window", func() {
if release.win == nil {
log.Info("Creating the Release Window")
createReleaseWindow()
log.Info("Toggling the Release Window")
release.win.Toggle()
}
log.Info("Toggling the Release Window")
release.openrepo.Disable()
for _, repo := range me.allrepos {
repo.newScan()
}
reposwin.Toggle()
release.win.Toggle()
})
group1.NewButton("Create Release Window (fullscan)", func() {
if release.win == nil {
log.Info("Creating the Release Window")
createReleaseWindow()
for _, repo := range me.allrepos {
repo.status.Update()
repo.newScan()
}
globalDisplaySetRepoState()
// open the repo window
reposwin.Toggle()
log.Info("Toggling the Release Window")
release.win.Toggle()
}
log.Info("Toggling the Release Window")
release.win.Toggle()
release.openrepo.Disable()
for _, repo := range me.allrepos {
repo.newScan()
}
})
/*
group1.NewButton("hide all", func() {
for _, repo := range me.allrepos {
repo.Hide()
}
})
group1.NewButton("show all", func() {
for repo := range me.allrepos {
repo.Show()
}
})
*/
me.autoHideReadOnly = group1.NewCheckbox("Hide read-only repos").SetChecked(true)
me.autoHideReadOnly.Custom = func() {
if me.autoHideReadOnly.Checked() {
globalDisplaySetRepoState()
} else {
globalDisplayShow()
}
}
me.autoHidePerfect = group1.NewCheckbox("Hide Perfectly clean repos").SetChecked(false)
me.autoHidePerfect.Custom = func() {
if me.autoHidePerfect.Checked() {
globalDisplaySetRepoState()
} else {
globalDisplayShow()
}
}
me.scanEveryMinute = group1.NewCheckbox("Scan every minute").SetChecked(false)
group1.NewButton("status.Update() all", func() {
for _, repo := range me.allrepos {
repo.status.Update()
}
})
group1.NewButton("rescan all", func() {
for _, repo := range me.allrepos {
repo.newScan()
}
})
group2 := vbox.NewGroup("Debugger")
group2.NewButton("logging Window", func() {
logsettings.LogWindow()
})
group2.NewButton("Debugger Window", func() {
debugger.DebugWindow()
})
}
func hidePerfect() {
for _, repo := range me.allrepos {
if repo.dirtyLabel.String() == "PERFECT" {
if repo.hidden {
continue
}
repo.Hide()
// return
}
}
}