diff --git a/init.go b/init.go index 8eba6c6..0c649a5 100644 --- a/init.go +++ b/init.go @@ -16,19 +16,16 @@ import ( "github.com/awesome-gocui/gocui" "go.wit.com/log" - "go.wit.com/toolkits/tree" ) // sent via -ldflags var VERSION string var BUILDTIME string -func queueToolkitClose() { - me.baseGui.Close() -} +var PLUGIN string = "gocui" -func queueSetChecked(n *tree.Node, b bool) { - setChecked(n, b) +func toolkitClose() { + me.baseGui.Close() } // sets defaults and establishes communication @@ -62,8 +59,10 @@ func init() { me.mouse.clicktime = time.Millisecond * 200 me.mouse.doubletime = time.Millisecond * 400 - me.myTree = tree.New() - me.myTree.PluginName = "gocui" + me.myTree = initTree() + + me.newWindowTrigger = make(chan *guiWidget, 1) + go newWindowTrigger() go refreshGocui() // read in defaults from config protobuf @@ -86,18 +85,6 @@ func init() { } } - me.myTree.NodeAction = newaction - me.myTree.Add = newAdd - me.myTree.SetTitle = newSetTitle - me.myTree.SetLabel = newSetLabel - me.myTree.SetText = newSetText - me.myTree.AddText = newAddText - me.myTree.SetChecked = queueSetChecked - me.myTree.ToolkitClose = queueToolkitClose - - me.newWindowTrigger = make(chan *guiWidget, 1) - go newWindowTrigger() - log.Log(NOW, "Init() start pluginChan") // log.Sleep(.1) // probably not needed, but in here for now under development go mainGogui() diff --git a/plugin.go b/plugin.go index 30509ca..19af06f 100644 --- a/plugin.go +++ b/plugin.go @@ -42,18 +42,18 @@ func newAdd(n *tree.Node) { } // for gocui as a GUI plugin, SetTitle & SetLabel are identical to SetText -func newSetTitle(n *tree.Node, s string) { - newSetText(n, s) +func setTitle(n *tree.Node, s string) { + setText(n, s) } -func newSetLabel(n *tree.Node, s string) { - newSetText(n, s) +func setLabel(n *tree.Node, s string) { + setText(n, s) } -// newSetText() and newAddText() are simple. They take the event sent +// setText() and addText() are simple. They take the event sent // to the GO plugin from the application and lookup the plugin structure // then pass that event to gocui. This is the transfer point -func newSetText(n *tree.Node, s string) { +func setText(n *tree.Node, s string) { if n == nil { log.Warn("Tree Error: Add() sent n == nil") return @@ -66,7 +66,7 @@ func newSetText(n *tree.Node, s string) { w.SetText(s) } -func newAddText(n *tree.Node, s string) { +func addText(n *tree.Node, s string) { if n == nil { log.Warn("Tree Error: Add() sent n == nil") return diff --git a/table.go b/table.go new file mode 100644 index 0000000..e69c593 --- /dev/null +++ b/table.go @@ -0,0 +1,13 @@ +// Copyright 2017-2025 WIT.COM Inc. All rights reserved. +// Use of this source code is governed by the GPL 3.0 + +package main + +import ( + log "go.wit.com/log" + "go.wit.com/toolkits/tree" +) + +func showTable(t *tree.Node) { + log.Info("should show table here") +} diff --git a/treeCallback.go b/treeInit.go similarity index 71% rename from treeCallback.go rename to treeInit.go index 1ead288..55faaa6 100644 --- a/treeCallback.go +++ b/treeInit.go @@ -13,6 +13,7 @@ package main */ import ( + "go.wit.com/toolkits/tree" "go.wit.com/widget" ) @@ -30,3 +31,19 @@ func Callback(guiCallback chan widget.Action) { func PluginChannel() chan widget.Action { return me.myTree.PluginChannel() } + +func initTree() *tree.TreeInfo { + t := tree.New() + t.PluginName = PLUGIN + t.NodeAction = newaction + t.Add = newAdd + t.SetTitle = setTitle + t.SetLabel = setLabel + t.SetText = setText + t.AddText = addText + t.SetChecked = setChecked + t.ToolkitClose = toolkitClose + t.ShowTable = showTable + + return t +}