submit-patchset/globalDisplayOptions.go

167 lines
3.6 KiB
Go
Raw Normal View History

// This is a simple example
package main
import (
"fmt"
"os"
"path/filepath"
"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()
})
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()
}
}
me.scanEveryMinute = group1.NewCheckbox("Scan every minute").SetChecked(false)
group1.NewButton("make go.work file", func() {
me.autotypistWindow.Disable()
defer me.autotypistWindow.Enable()
goSrcDir := me.goSrcPwd.String()
filename := filepath.Join(goSrcDir, "go.work")
f, err := os.OpenFile(filename, os.O_WRONLY|os.O_CREATE, 0600)
if err != nil {
return
}
defer f.Close()
fmt.Fprintln(f, "go 1.21.4")
fmt.Fprintln(f, "")
fmt.Fprintln(f, "use (")
for _, repo := range me.allrepos {
if repo.status.Exists("go.mod") {
fmt.Fprintln(f, "\t"+repo.String())
} else {
log.Info("missing go.mod for", repo.String())
repo.status.MakeRedomod()
}
}
fmt.Fprintln(f, ")")
})
group1.NewButton("list all tags", func() {
me.autotypistWindow.Disable()
defer me.autotypistWindow.Enable()
for _, repo := range me.allrepos {
tagsW := repo.status.TagsW
if tagsW == nil {
repo.status.TagWindow()
tagsW = repo.status.TagsW
// tagsW.Prune()
continue
}
allTags := tagsW.ListAll()
for _, t := range allTags {
log.Info("found tag:", t.TagString(), "from", repo.status.String())
}
}
})
group1.NewButton("delete all dup tags", func() {
me.autotypistWindow.Disable()
defer me.autotypistWindow.Enable()
for _, repo := range me.allrepos {
tagsW := repo.status.TagsW
if tagsW == nil {
repo.status.TagWindow()
tagsW = repo.status.TagsW
tagsW.PruneSmart()
continue
}
deleteTags := tagsW.List()
for _, t := range deleteTags {
if me.autoDryRun.Checked() {
log.Info("delete tag --dry-run:", t.TagString(), "from", repo.status.String())
} else {
log.Info("Deleting tag:", t.TagString(), "from", repo.status.String())
// tagsW.Delete(t)
}
}
}
})
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
}
}
}