start converting over to using a direct pb grid

This commit is contained in:
Jeff Carr 2025-02-21 16:10:33 -06:00
parent efd0373c21
commit ce938cc73b
2 changed files with 56 additions and 26 deletions

View File

@ -370,6 +370,29 @@ func drawWindow(win *gadgets.BasicWindow) {
*/
}
// this is the magic that generates a window directly from the protocol buffer
func makeStandardReposGrid(pb *gitpb.Repos) *gitpb.ReposTable {
t := pb.NewTable("testDirty")
sf := t.AddStringFunc("repo", func(r *gitpb.Repo) string {
return r.GetGoPath()
})
// t.Custom = func() {
// log.Info("close grid?")
// }
sf.Custom = func(r *gitpb.Repo) {
log.Info("do button click on", r.GetGoPath())
}
t.AddTimeFunc("age", func(repo *gitpb.Repo) time.Time {
return repo.NewestTime()
})
t.AddMasterVersion()
t.AddDevelVersion()
t.AddUserVersion()
t.AddCurrentBranchName()
t.AddState()
return t
}
// this is the magic that generates a window directly from the protocol buffer
func makeStandardReposWindow(pb *gitpb.Repos) {
t := pb.NewTable("testDirty")

View File

@ -6,7 +6,6 @@ package main
import (
"fmt"
"sync"
"time"
"go.wit.com/lib/gadgets"
"go.wit.com/lib/protobuf/forgepb"
@ -86,46 +85,54 @@ func makeRepoProblemsWindow() *repoProblemsWindow {
found = develBehindMasterProblem()
txt = fmt.Sprintf("devel is behind master (%d)", found.Len())
grid.NewButton(txt, func() {
found := develBehindMasterProblem()
win := gadgets.RawBasicWindow("pbgrid in window")
win := gadgets.RawBasicWindow("devel branches that are out of sync with master")
win.Make()
win.Show()
box := win.Box().NewBox("bw vbox", false)
win.Custom = func() {
// sets the hidden flag to false so Toggle() works
win.Hide()
}
box := win.Box().NewBox("bw vbox", false)
t := found.NewTable("testDirty")
found := develBehindMasterProblem()
group := box.NewGroup("test buttons")
group.NewButton("hello", func() {
log.Info("world")
})
group.NewButton("list", func() {
log.Info("world")
})
t := makeStandardReposGrid(found)
t.SetParent(box)
sf := t.AddStringFunc("repo", func(r *gitpb.Repo) string {
return r.GetGoPath()
})
// t.Custom = func() {
// log.Info("close grid?")
// }
sf.Custom = func(r *gitpb.Repo) {
log.Info("do button click on", r.GetGoPath())
}
t.AddTimeFunc("age", func(repo *gitpb.Repo) time.Time {
return repo.NewestTime()
})
t.AddMasterVersion()
t.AddDevelVersion()
t.AddUserVersion()
t.AddCurrentBranchName()
t.AddState()
t.ShowTable()
// makeStandardReposWindow(found, box)
})
found = remoteUserBranchProblem()
txt = fmt.Sprintf("user branch is remote (%d)", found.Len())
grid.NewButton(txt, func() {
win := gadgets.RawBasicWindow("repos that seem to have remote user branches")
win.Make()
win.Show()
win.Custom = func() {
// sets the hidden flag to false so Toggle() works
win.Hide()
}
box := win.Box().NewBox("bw vbox", false)
found := remoteUserBranchProblem()
makeStandardReposWindow(found)
group := box.NewGroup("test buttons")
group.NewButton("git branch delete", func() {
all := found.SortByFullPath()
for all.Scan() {
repo := all.Next()
log.Info("git branch -D jcarr", repo.GetGoPath())
}
})
t := makeStandardReposGrid(found)
t.SetParent(box)
t.ShowTable()
})
grid.NewButton("unknown branches", func() {