submit-patchset/globalDisplayOptions.go

82 lines
1.8 KiB
Go
Raw Normal View History

package main
import (
"go.wit.com/gui"
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"
)
2024-02-19 19:41:48 -06:00
func hideFunction(r *repolist.Repo) {
if r.Status.IsDirty() {
r.Show()
return
}
if me.autoHideReadOnly.Checked() {
if r.Status.ReadOnly() {
r.Hide()
return
}
2024-02-19 19:41:48 -06:00
}
if me.autoHidePerfect.Checked() {
if r.IsPerfect() {
r.Hide()
return
}
}
2024-02-19 19:41:48 -06:00
r.Show()
}
2024-02-19 19:41:48 -06:00
func hideFunction2(repo *repolist.Repo) {
if me.autoHideReadOnly.Checked() {
if repo.Status.ReadOnly() {
return
}
2024-02-19 19:41:48 -06:00
}
if me.autoHidePerfect.Checked() {
if repo.IsPerfect() {
return
}
}
2024-02-19 19:41:48 -06:00
repo.Show()
}
func globalDisplayOptions(vbox *gui.Node) {
group1 := vbox.NewGroup("Global Display Options")
group1.NewButton("Show Repository Window", func() {
2024-02-19 19:41:48 -06:00
// 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() {
2024-02-19 19:41:48 -06:00
me.repos.View.RegisterHideFunction(hideFunction)
me.repos.View.ScanRepositories()
}
me.autoHidePerfect = group1.NewCheckbox("Hide Perfectly clean repos").SetChecked(true)
me.autoHidePerfect.Custom = func() {
if me.autoHidePerfect.Checked() {
2024-02-19 19:41:48 -06:00
me.repos.View.RegisterHideFunction(hideFunction)
me.repos.View.ScanRepositories()
} else {
2024-02-19 19:41:48 -06:00
me.repos.View.RegisterHideFunction(hideFunction2)
me.repos.View.ScanRepositories()
}
}
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-18 07:24:56 -06:00
i, s := me.repos.View.ScanRepositories()
log.Info("re-scanning repos done", i, s)
2024-02-16 17:55:53 -06:00
})
}