plugin related cleanups
This commit is contained in:
parent
0a60272440
commit
552bdeb1e6
27
init.go
27
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()
|
||||
|
|
14
plugin.go
14
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
|
||||
|
|
|
@ -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")
|
||||
}
|
|
@ -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
|
||||
}
|
Loading…
Reference in New Issue