more work on protobuf tables
This commit is contained in:
parent
1418d4652e
commit
1068eb5aad
31
action.go
31
action.go
|
@ -5,6 +5,8 @@
|
||||||
package tree
|
package tree
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"os"
|
||||||
|
|
||||||
"go.wit.com/lib/protobuf/guipb"
|
"go.wit.com/lib/protobuf/guipb"
|
||||||
"go.wit.com/log"
|
"go.wit.com/log"
|
||||||
"go.wit.com/widget"
|
"go.wit.com/widget"
|
||||||
|
@ -27,6 +29,35 @@ func (me *TreeInfo) doAction(a widget.Action) {
|
||||||
me.ToolkitInit()
|
me.ToolkitInit()
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
if a.WidgetPB != nil {
|
||||||
|
log.Log(TREEWARN, "tree: got a WidgetPB")
|
||||||
|
widgetpb := new(guipb.Widgets)
|
||||||
|
err := widgetpb.Unmarshal(a.WidgetPB)
|
||||||
|
if err != nil {
|
||||||
|
log.Log(TREEWARN, "WidgetPB unmarshal err", err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
log.Log(TREEWARN, "tree: unmarshal worked!")
|
||||||
|
var wind *Node
|
||||||
|
newa := new(widget.Action)
|
||||||
|
newa.WidgetType = widget.Window
|
||||||
|
newa.WidgetId = -234
|
||||||
|
newa.ParentId = -1234
|
||||||
|
newa.State.Enable = true
|
||||||
|
wind = addNode(newa)
|
||||||
|
if wind == nil {
|
||||||
|
log.Log(TREEWARN, "tree: addNode() failed to add win")
|
||||||
|
return
|
||||||
|
}
|
||||||
|
wind.State.ProgName = "WinPB"
|
||||||
|
wind.State.Label = "WinPB"
|
||||||
|
me.Add(wind)
|
||||||
|
me.doWidgetsPB(widgetpb.Tree)
|
||||||
|
me.ToolkitClose()
|
||||||
|
os.Exit(0)
|
||||||
|
// me.doTable(a)
|
||||||
|
return
|
||||||
|
}
|
||||||
if a.TablePB != nil {
|
if a.TablePB != nil {
|
||||||
log.Log(TREE, "tree: got a TablePB")
|
log.Log(TREE, "tree: got a TablePB")
|
||||||
me.doTable(a)
|
me.doTable(a)
|
||||||
|
|
8
table.go
8
table.go
|
@ -18,6 +18,14 @@ import (
|
||||||
"google.golang.org/protobuf/types/known/wrapperspb"
|
"google.golang.org/protobuf/types/known/wrapperspb"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
func (me *TreeInfo) doWidgetsPB(w *guipb.Widget) {
|
||||||
|
log.Log(TREEWARN, "tree:", w.Id, w.Name)
|
||||||
|
|
||||||
|
for _, child := range w.Children {
|
||||||
|
me.doWidgetsPB(child)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
func (me *TreeInfo) doTable(a widget.Action) {
|
func (me *TreeInfo) doTable(a widget.Action) {
|
||||||
if a.TablePB == nil {
|
if a.TablePB == nil {
|
||||||
log.Log(TREE, "tree: action didn't have a Table PB")
|
log.Log(TREE, "tree: action didn't have a Table PB")
|
||||||
|
|
Loading…
Reference in New Issue