From 5005edc9e37cb207f6c6035ea6fe3c3d98d94caa Mon Sep 17 00:00:00 2001 From: Jeff Carr Date: Mon, 20 Jan 2025 05:06:08 -0600 Subject: add a 'app' defined default plugin variable --- plugin.go | 40 ++++++++++++++++++++-------------------- 1 file changed, 20 insertions(+), 20 deletions(-) (limited to 'plugin.go') diff --git a/plugin.go b/plugin.go index 72b3112..7e8ad3c 100644 --- a/plugin.go +++ b/plugin.go @@ -56,6 +56,26 @@ type aplug struct { var allPlugins []*aplug +func (n *Node) LoadToolkit(name string) (*Node, error) { + log.Log(PLUG, "LoadToolkit() START for name =", name) + plug := initPlugin(name) + if plug == nil { + return n, errors.New("initPlugin(" + name + ") failed") + } + plug.dead = false + + log.Log(PLUG, "LoadToolkit() sending Toolkit Init action to the plugin channel") + var a widget.Action + a.ActionType = widget.ToolkitInit + plug.pluginChan <- a + // sleep(.5) // temp hack until chan communication is setup + + // TODO: find a new way to do this that is locking, safe and accurate + me.rootNode.redraw(plug) + log.Log(PLUG, "LoadToolkit() END for name =", name) + return n, nil +} + // loads and initializes a toolkit (andlabs/ui, gocui, etc) // attempts to locate the .so file func initPlugin(name string) *aplug { @@ -281,26 +301,6 @@ func (n *Node) ListToolkits() { } } -func (n *Node) LoadToolkit(name string) (*Node, error) { - log.Log(PLUG, "LoadToolkit() START for name =", name) - plug := initPlugin(name) - if plug == nil { - return n, errors.New("initPlugin(" + name + ") failed") - } - plug.dead = false - - log.Log(PLUG, "LoadToolkit() sending Toolkit Init action to the plugin channel") - var a widget.Action - a.ActionType = widget.ToolkitInit - plug.pluginChan <- a - // sleep(.5) // temp hack until chan communication is setup - - // TODO: find a new way to do this that is locking, safe and accurate - me.rootNode.redraw(plug) - log.Log(PLUG, "LoadToolkit() END for name =", name) - return n, nil -} - func (n *Node) CloseToolkit(name string) bool { log.Log(PLUG, "CloseToolkit() for name =", name) for i, plug := range allPlugins { -- cgit v1.2.3