generic table protobuf buttons work

This commit is contained in:
Jeff Carr 2025-03-05 19:39:30 -06:00
parent b6b0cadde5
commit 0c4bf8e9bb
1 changed files with 50 additions and 0 deletions

View File

@ -10,6 +10,8 @@
package gitpb
import "go.wit.com/log"
/*
func (mt *ReposTable) Delete() {
if mt == nil {
@ -24,3 +26,51 @@ func (mt *ReposTable) Delete() {
func (mt *ReposTable) UpdateTable(pb *Repos) {
// mt.parent.UpdateTable(pb)
}
func (mt *ReposTable) lookupByWidgetId(id int) *Repo {
log.Info("no shit. got to lookupWidgdetId() id =", id, "on mt", mt.GetUuid())
for _, r := range mt.pb.StringRows {
for _, w := range r.Widgets {
if int(w.Id) == id {
log.Info("lookupByWidgetId() found id", id, w.Location)
return mt.x.Repos[w.Location.Y - 1]
}
}
}
for _, r := range mt.pb.ButtonRows {
for _, w := range r.Widgets {
if int(w.Id) == id {
log.Info("lookupByWidgetId() found id", id, w.Location)
if w.Location == nil {
log.Info("lookupByWidgetId() location was nil", id, w.Location)
return nil
}
return mt.x.Repos[w.Location.Y - 1]
}
}
}
return nil
}
func (mt *ReposTable) reposCustom(id int) {
repo := mt.lookupByWidgetId(id)
mt.CustomFunc(repo)
}
func (mt *ReposTable) Custom(f func(*Repo)) {
mt.pb.RegisterCustom(mt.reposCustom)
mt.CustomFunc = f
}
//func (mt *ReposTable) CustomRegister(f func(int)) {
// mt.pb.RegisterCustom(mt.reposCustom)
//}
func (mt *ReposTable) GetUuid() string {
return mt.pb.Uuid
}
// END GUI