plugin related cleanups

This commit is contained in:
Jeff Carr 2025-02-12 15:26:24 -06:00
parent 0a60272440
commit 552bdeb1e6
4 changed files with 44 additions and 27 deletions

27
init.go
View File

@ -16,19 +16,16 @@ import (
"github.com/awesome-gocui/gocui" "github.com/awesome-gocui/gocui"
"go.wit.com/log" "go.wit.com/log"
"go.wit.com/toolkits/tree"
) )
// sent via -ldflags // sent via -ldflags
var VERSION string var VERSION string
var BUILDTIME string var BUILDTIME string
func queueToolkitClose() { var PLUGIN string = "gocui"
me.baseGui.Close()
}
func queueSetChecked(n *tree.Node, b bool) { func toolkitClose() {
setChecked(n, b) me.baseGui.Close()
} }
// sets defaults and establishes communication // sets defaults and establishes communication
@ -62,8 +59,10 @@ func init() {
me.mouse.clicktime = time.Millisecond * 200 me.mouse.clicktime = time.Millisecond * 200
me.mouse.doubletime = time.Millisecond * 400 me.mouse.doubletime = time.Millisecond * 400
me.myTree = tree.New() me.myTree = initTree()
me.myTree.PluginName = "gocui"
me.newWindowTrigger = make(chan *guiWidget, 1)
go newWindowTrigger()
go refreshGocui() go refreshGocui()
// read in defaults from config protobuf // 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.Log(NOW, "Init() start pluginChan")
// log.Sleep(.1) // probably not needed, but in here for now under development // log.Sleep(.1) // probably not needed, but in here for now under development
go mainGogui() go mainGogui()

View File

@ -42,18 +42,18 @@ func newAdd(n *tree.Node) {
} }
// for gocui as a GUI plugin, SetTitle & SetLabel are identical to SetText // for gocui as a GUI plugin, SetTitle & SetLabel are identical to SetText
func newSetTitle(n *tree.Node, s string) { func setTitle(n *tree.Node, s string) {
newSetText(n, s) setText(n, s)
} }
func newSetLabel(n *tree.Node, s string) { func setLabel(n *tree.Node, s string) {
newSetText(n, s) 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 // to the GO plugin from the application and lookup the plugin structure
// then pass that event to gocui. This is the transfer point // 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 { if n == nil {
log.Warn("Tree Error: Add() sent n == nil") log.Warn("Tree Error: Add() sent n == nil")
return return
@ -66,7 +66,7 @@ func newSetText(n *tree.Node, s string) {
w.SetText(s) w.SetText(s)
} }
func newAddText(n *tree.Node, s string) { func addText(n *tree.Node, s string) {
if n == nil { if n == nil {
log.Warn("Tree Error: Add() sent n == nil") log.Warn("Tree Error: Add() sent n == nil")
return return

13
table.go Normal file
View File

@ -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")
}

View File

@ -13,6 +13,7 @@ package main
*/ */
import ( import (
"go.wit.com/toolkits/tree"
"go.wit.com/widget" "go.wit.com/widget"
) )
@ -30,3 +31,19 @@ func Callback(guiCallback chan widget.Action) {
func PluginChannel() chan widget.Action { func PluginChannel() chan widget.Action {
return me.myTree.PluginChannel() 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
}