From bd24754c82f77d06dba31c32c3acdd0ed1adebe9 Mon Sep 17 00:00:00 2001 From: Jeff Carr Date: Fri, 9 Feb 2024 03:43:55 -0600 Subject: [PATCH] more node State repairs Signed-off-by: Jeff Carr --- addNode.go | 8 +++++++- common.go | 4 ++++ event.go | 17 ++++++++--------- init.go | 2 ++ structs.go | 2 +- 5 files changed, 22 insertions(+), 11 deletions(-) diff --git a/addNode.go b/addNode.go index 5a17a25..43e4d20 100644 --- a/addNode.go +++ b/addNode.go @@ -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") diff --git a/common.go b/common.go index 70a5d14..cdc560d 100644 --- a/common.go +++ b/common.go @@ -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: diff --git a/event.go b/event.go index e5d0c1f..b20729b 100644 --- a/event.go +++ b/event.go @@ -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 diff --git a/init.go b/init.go index 453d162..9a9101b 100644 --- a/init.go +++ b/init.go @@ -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()) diff --git a/structs.go b/structs.go index cfd21db..679bdb2 100644 --- a/structs.go +++ b/structs.go @@ -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