Compare commits

...

3 Commits

Author SHA1 Message Date
Jeff Carr 1127b96570 hack to identify protobuf tables 2025-03-25 13:17:00 -05:00
Jeff Carr 308543c02c identify widgets in tables 2025-03-25 13:17:00 -05:00
Jeff Carr d141b4d308 save the toolkit config options 2025-03-25 13:17:00 -05:00
5 changed files with 50 additions and 6 deletions

View File

@ -38,9 +38,9 @@ func addNode(a *widget.Action) *Node {
}
if treeRoot.FindWidgetId(a.WidgetId) != nil {
log.Log(TREEWARN, "AddNode() WidgetId already exists", a.WidgetId)
log.Log(TREEWARN, "probably this is a Show() / Hide() issue")
log.Log(TREEWARN, "TODO: figure out what to do here")
// ignore these errors for now
log.Log(TREE, "AddNode() WidgetId already exists", a.WidgetId)
log.Log(TREE, "TODO: figure out what to do here probably this is a Show() / Hide() issue")
return treeRoot.FindWidgetId(a.WidgetId)
}

View File

@ -10,6 +10,10 @@ func FindWidgetId(id int) *Node {
return treeRoot.FindWidgetId(id)
}
func FindWidgetById(id int) *Node {
return treeRoot.FindWidgetId(id)
}
// searches the binary tree for a WidgetId
func (n *Node) FindWidgetId(id int) *Node {
if n == nil {

25
init.go
View File

@ -68,7 +68,30 @@ func (t *TreeInfo) ConfigFind(n string) (string, error) {
if n == r.Name {
return r.Value, nil
}
log.Info("toolkit config", r.Plugin, r.Name, r.Value, n)
// log.Info("toolkit config no-match on", r.Plugin, r.Name, r.Value, n)
}
return "", fmt.Errorf("toolkit config %s not found", n)
}
func (t *TreeInfo) ConfigSave(o *ToolkitConfig) {
t.configInsert(o)
t.config.configSave()
}
// update the config option value (or append if new record)
func (t *TreeInfo) configInsert(newr *ToolkitConfig) {
all := t.config.All() // get the list of repos
for all.Scan() {
r := all.Next()
if t.PluginName != r.Plugin {
// option isn't for this plugin
continue
}
if newr.Name == r.Name {
// found the record!
r.Value = newr.Value
return
}
}
t.config.Append(newr)
}

View File

@ -200,6 +200,7 @@ func (me *TreeInfo) makeTable(t *guipb.Table) {
return
}
me.Add(grid)
grid.State.ProgName = "TableGridPB"
// log.Info("tree: makeTable() finished add win & grid")
var h int = 0
var w int = 0
@ -307,6 +308,22 @@ func (me *TreeInfo) addTableRow(t *guipb.Table, grid *Node, name string, w int)
return false
}
// returns true if widget is in a table
func (n *Node) InTable() bool {
// log.Info("InTable() parent id =", n.ParentId)
grid := FindWidgetById(int(n.ParentId))
if grid != nil {
if grid.WidgetType == widget.Grid {
if grid.State.ProgName == "TableGridPB" {
// this is a protobuf table
return true
}
}
}
return false
}
func dumpTable(t *guipb.Table) {
for i, o := range t.Order {
log.Info("got order:", t.Title, i, o)

View File

@ -7,8 +7,8 @@ package forgepb;
import "google/protobuf/timestamp.proto"; // Import the well-known type for Timestamp
message ToolkitConfig { //
string plugin = 1; // 'gocui', 'andlabs', etc
string name = 2; // variable name 'fullscreen'
string plugin = 1; // 'gocui', 'andlabs', etc `autogenpb:unique`
string name = 2; // variable name 'fullscreen' `autogenpb:unique`
string value = 3; // value "true"
}