submit-patchset/globalDisplayOptions.go

136 lines
2.6 KiB
Go
Raw Normal View History

package main
import (
"go.wit.com/gui"
"go.wit.com/lib/debugger"
"go.wit.com/lib/gui/gowit"
"go.wit.com/lib/gui/logsettings"
2024-02-17 08:38:44 -06:00
"go.wit.com/lib/gui/repolist"
2024-02-16 17:55:53 -06:00
"go.wit.com/log"
)
func globalDisplaySetRepoState() {
2024-02-17 08:38:44 -06:00
for _, repo := range repolist.AllRepos() {
2024-02-17 15:47:46 -06:00
if repo.Status.IsDirty() {
2024-02-16 20:37:23 -06:00
repo.Show()
continue
}
if me.autoHideReadOnly.Checked() {
2024-02-17 15:47:46 -06:00
if repo.Status.ReadOnly() {
repo.Hide()
continue
}
}
if me.autoHidePerfect.Checked() {
2024-02-17 08:38:44 -06:00
if repo.IsPerfect() {
repo.Hide()
continue
}
}
repo.Show()
}
}
func globalDisplayShow() {
2024-02-17 08:38:44 -06:00
for _, repo := range repolist.AllRepos() {
if me.autoHideReadOnly.Checked() {
2024-02-17 15:47:46 -06:00
if repo.Status.ReadOnly() {
continue
}
}
if me.autoHidePerfect.Checked() {
2024-02-17 08:38:44 -06:00
if repo.IsPerfect() {
continue
}
}
repo.Show()
}
}
func globalDisplayOptions(vbox *gui.Node) {
group1 := vbox.NewGroup("Global Display Options")
group1.NewButton("Show Repository Window", func() {
globalDisplaySetRepoState()
2024-02-17 14:20:37 -06:00
if me.repos.Hidden() {
me.repos.Show()
2024-02-17 08:38:44 -06:00
} else {
2024-02-17 14:20:37 -06:00
me.repos.Hide()
2024-02-17 08:38:44 -06:00
}
})
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(true)
me.autoHidePerfect.Custom = func() {
if me.autoHidePerfect.Checked() {
globalDisplaySetRepoState()
} else {
globalDisplayShow()
}
}
2024-02-16 17:55:53 -06:00
scanbox := group1.Box().Horizontal()
me.autoScanReposCB = scanbox.NewCheckbox("auto scan").SetChecked(true)
2024-02-17 14:20:37 -06:00
me.autoScanReposCB.Custom = func() {
me.repos.View.SetAutoScan(me.autoScanReposCB.Checked())
}
2024-02-16 17:55:53 -06:00
scanbox.NewButton("scan now", func() {
log.Info("re-scanning repos now")
2024-02-17 14:20:37 -06:00
me.repos.View.ScanRepositories()
2024-02-16 17:55:53 -06:00
})
me.duration = scanbox.NewLabel("")
var tagsW *tagWindow
group1.NewButton("git tags Window", func() {
if tagsW == nil {
tagsW = makeTagWindow()
} else {
tagsW.win.Toggle()
}
})
var listallB *gui.Node
listallB = group1.NewButton("go.wit.com", func() {
listallB.Disable()
if me.lw == nil {
me.lw = gowit.ListWindow()
}
if me.lw.Hidden() {
me.lw.Show()
} else {
me.lw.Hide()
}
listallB.Enable()
})
}
func debuggerBox(vbox *gui.Node) {
group2 := vbox.NewGroup("Debugger")
group2.NewButton("logging Window", func() {
logsettings.LogWindow()
})
group2.NewButton("Debugger Window", func() {
debugger.DebugWindow()
})
}
func hidePerfect() {
2024-02-17 08:38:44 -06:00
for _, repo := range repolist.AllRepos() {
if repo.IsPerfect() {
if repo.Hidden() {
continue
}
repo.Hide()
// return
}
}
}