more node State repairs

Signed-off-by: Jeff Carr <jcarr@wit.com>
This commit is contained in:
Jeff Carr 2024-02-09 03:43:55 -06:00
parent b029617e7d
commit bd24754c82
5 changed files with 22 additions and 11 deletions

View File

@ -13,7 +13,13 @@ func (me *TreeInfo) AddNode(a *widget.Action) *Node {
n.ParentId = a.ParentId
n.State = a.State
n.Strings = make(map[string]int)
// n.Strings = make(map[string]int)
// slices.Reverse(lines)
// dropdown strings
n.ddStrings = make([]string, 0)
for _, s := range a.State.Strings {
n.ddStrings = append(n.ddStrings, s)
}
if a.WidgetType == widget.Root {
log.Log(TREE, "AddNode() Root")

View File

@ -23,6 +23,10 @@ func (n *Node) CurrentS() string {
return n.State.CurrentS
}
func (n *Node) Strings() []string {
return n.ddStrings
}
func (n *Node) String() string {
switch n.WidgetType {
case widget.Button:

View File

@ -33,11 +33,11 @@ func (me *TreeInfo) SendToolkitLoad(s string) {
log.Log(TREEWARN, "SendToolkitLoad() callback == nil")
return
}
log.Log(TREEWARN, "SendToolkitLoad() START: toolkit load", s)
var a widget.Action
a.ActionType = widget.ToolkitLoad
a.ProgName = me.PluginName
a.Value = s
log.Log(TREEWARN, "SendToolkitLoad() START: toolkit load", s)
a.ProgName = me.PluginName
me.callback <- a
log.Log(TREEWARN, "SendToolkitLoad() END: toolkit load", s)
return
@ -48,12 +48,12 @@ func (me *TreeInfo) SendToolkitPanic() {
log.Log(TREEWARN, "SendToolkitPanic() callback == nil")
return
}
log.Log(TREEWARN, "SendToolkitPanic() START")
var a widget.Action
a.ActionType = widget.ToolkitPanic
a.ProgName = me.PluginName
log.Log(TREE, "SendToolkitPanic() START")
me.callback <- a
log.Log(TREE, "SendToolkitPanic() END")
log.Log(TREEWARN, "SendToolkitPanic() END")
return
}
@ -62,10 +62,11 @@ func (me *TreeInfo) SendWindowCloseEvent(n *Node) {
log.Log(TREEWARN, "SendWindowClose() callback == nil", n.WidgetId)
return
}
log.Log(TREE, "SendWindowClose() START: user closed the window", n.GetProgName())
var a widget.Action
a.WidgetId = n.WidgetId
a.ActionType = widget.CloseWindow
log.Log(TREE, "SendWindowClose() START: user closed the window", n.GetProgName())
a.ProgName = me.PluginName
me.callback <- a
log.Log(TREE, "SendWindowClose() END: user closed the window", n.GetProgName())
return
@ -91,14 +92,12 @@ func (me *TreeInfo) SendUserEvent(n *Node) {
log.Log(TREEWARN, "SendUserEvent() callback == nil", n.WidgetId)
return
}
log.Log(TREE, "SendUserEvent() START: send a user event to the callback channel")
var a widget.Action
a.WidgetId = n.WidgetId
a.State = n.State
a.ActionType = widget.User
if n.WidgetType == widget.Checkbox {
log.Log(TREE, "SendUserEvent() checkbox going to send:", a.Value)
}
log.Log(TREE, "SendUserEvent() START: send a user event to the callback channel")
a.ProgName = me.PluginName
me.callback <- a
log.Log(TREE, "SendUserEvent() END: sent a user event to the callback channel")
return

View File

@ -40,8 +40,10 @@ func (me *TreeInfo) newAction(a widget.Action) {
case widget.AddText:
switch n.WidgetType {
case widget.Dropdown:
n.ddStrings = append(n.ddStrings, a.State.NewString)
me.AddText(n, a.State.NewString)
case widget.Combobox:
n.ddStrings = append(n.ddStrings, a.State.NewString)
me.AddText(n, a.State.NewString)
default:
log.Log(TREEWARN, "AddText() not supported on widget", n.WidgetType, n.String())

View File

@ -44,7 +44,7 @@ type Node struct {
State widget.State
Strings map[string]int
ddStrings []string
// the internal plugin toolkit structure
// in the gtk plugin, it has gtk things like margin & border settings