diff options
| author | Jeff Carr <[email protected]> | 2024-01-17 21:31:49 -0600 |
|---|---|---|
| committer | Jeff Carr <[email protected]> | 2024-01-17 21:31:49 -0600 |
| commit | 841e6252c95244f0ee7faf2c01d33f69a8ab483a (patch) | |
| tree | ef400228622b87611168db2227269ba7fd56625d /common/plugin.go | |
| parent | ba95c13799740b5f55541fc5e8ab9f1d34f7e421 (diff) | |
common tree package for toolkitsv0.12.4
This update provides *lots* of toolkit updates. This will allow
the next step of debugging the gocui toolkit to make it work
again. There are new common routines for handling the plugin
channel communication
Signed-off-by: Jeff Carr <[email protected]>
Diffstat (limited to 'common/plugin.go')
| -rw-r--r-- | common/plugin.go | 69 |
1 files changed, 0 insertions, 69 deletions
diff --git a/common/plugin.go b/common/plugin.go deleted file mode 100644 index bfc9a68..0000000 --- a/common/plugin.go +++ /dev/null @@ -1,69 +0,0 @@ -package main - -/* - These code should be common to all gui plugins - - There are some helper functions that are probably going to be - the same everywhere. Mostly due to handling the binary tree structure - and the channel communication - - For now, it's just a symlink to the 'master' version in - ./toolkit/nocui/common.go -*/ - -import ( - "reflect" - "strconv" - - "go.wit.com/log" - "go.wit.com/gui/widget" -) - -// searches the binary tree for a WidgetId -func (n *node) findWidgetId(id int) *node { - if (n == nil) { - return nil - } - - if n.WidgetId == id { - return n - } - - for _, child := range n.children { - newN := child.findWidgetId(id) - if (newN != nil) { - return newN - } - } - return nil -} - -func (n *node) doUserEvent() { - if (callback == nil) { - log.Log(ERROR, "doUserEvent() callback == nil", n.WidgetId) - return - } - var a widget.Action - a.WidgetId = n.WidgetId - a.Value = n.value - a.ActionType = widget.User - log.Log(INFO, "doUserEvent() START: send a user event to the callback channel") - callback <- a - log.Log(INFO, "doUserEvent() END: sent a user event to the callback channel") - return -} - -// Other goroutines must use this to access the GUI -// -// You can not acess / process the GUI thread directly from -// other goroutines. This is due to the nature of how -// Linux, MacOS and Windows work (they all work differently. suprise. surprise.) -// -// this sets the channel to send user events back from the plugin -func Callback(guiCallback chan widget.Action) { - callback = guiCallback -} - -func PluginChannel() chan widget.Action { - return pluginChan -} |
