summaryrefslogtreecommitdiff
path: root/plugin.go
diff options
context:
space:
mode:
authorJeff Carr <[email protected]>2023-03-01 11:35:36 -0600
committerJeff Carr <[email protected]>2023-03-01 11:35:36 -0600
commit8dbf5a09097b7868e9218bf98716c57eac998a10 (patch)
treeab3bdfeaf5a59a55de9d2a6661d2d824090491e5 /plugin.go
parentf3bb68396afa7452ecf1c8d4744c825a9d81057c (diff)
lots cleaner code between the pluginv0.6.1
Queue() around SetText is helping userspace crashing merge forceDump(bool) into Dump() debugging output configuration is pretty clean keep cutting down duplicate things --gui-verbose flag works make label "standard" code add debug.FreeOSMemory() move the GO language internals to display in the GUI update push to do tags and go to github.com/wit-go/ remove the other license file it might be confusing golang.org and github proper WidgetType added a Quit() button Signed-off-by: Jeff Carr <[email protected]>
Diffstat (limited to 'plugin.go')
-rw-r--r--plugin.go54
1 files changed, 35 insertions, 19 deletions
diff --git a/plugin.go b/plugin.go
index a4e007a..3b558f5 100644
--- a/plugin.go
+++ b/plugin.go
@@ -26,21 +26,24 @@ type aplug struct {
MainOk bool
Init func()
- Main func(func ())
- Queue func(func ())
+ // TODO: make Main() main() and never allow the user to call it
+ // run plugin.Main() when the plugin is loaded
+ Main func(func ()) // this never returns. Each plugin must have it's own goroutine
+ Queue func(func ()) // Should this return right away? Should it wait (can it wait?)
Quit func()
- NewWindow func(*toolkit.Widget)
+ // NewWindow func(*toolkit.Widget)
+
+ // simplifies passing to the plugin
+ Send func(*toolkit.Widget, *toolkit.Widget)
+
NewButton func(*toolkit.Widget, *toolkit.Widget)
NewGroup func(*toolkit.Widget, *toolkit.Widget)
NewCheckbox func(*toolkit.Widget, *toolkit.Widget)
NewTab func(*toolkit.Widget, *toolkit.Widget)
- NewLabel func(*toolkit.Widget, *toolkit.Widget)
- NewTextbox func(*toolkit.Widget, *toolkit.Widget)
- NewSlider func(*toolkit.Widget, *toolkit.Widget)
- NewSpinner func(*toolkit.Widget, *toolkit.Widget)
NewDropdown func(*toolkit.Widget, *toolkit.Widget)
AddDropdownName func(*toolkit.Widget, string)
+ SetDropdownName func(*toolkit.Widget, string)
SetDebugToolkit func(bool)
SetDebugChange func(bool)
@@ -73,27 +76,27 @@ func LoadToolkit(name string) bool {
// newPlug.Ok = true
newPlug.name = name
- // map all the functions
+ // deprecate Init(?)
newPlug.Init = loadFuncE(&newPlug, "Init")
- newPlug.Quit = loadFuncE(&newPlug, "Quit")
- // this should be laodFuncE()
+ // should make a goroutine that never exits
newPlug.Main = loadFuncF(&newPlug, "Main")
+
+ // should send things to the goroutine above
newPlug.Queue = loadFuncF(&newPlug, "Queue")
- newPlug.NewWindow = loadFunc1(&newPlug, "NewWindow")
+ // unload the plugin and restore state
+ newPlug.Quit = loadFuncE(&newPlug, "Quit")
+
+ // Sends a widget (button, checkbox, etc) and it's parent widget
+ // This includes instructions like "Add", "Delete", "Disable", etc
+ newPlug.Send = loadFunc2(&newPlug, "Send")
- newPlug.NewButton = loadFunc2(&newPlug, "NewButton")
- newPlug.NewGroup = loadFunc2(&newPlug, "NewGroup")
- newPlug.NewCheckbox = loadFunc2(&newPlug, "NewCheckbox")
- newPlug.NewTab = loadFunc2(&newPlug, "NewTab")
- newPlug.NewLabel = loadFunc2(&newPlug, "NewLabel")
- newPlug.NewTextbox = loadFunc2(&newPlug, "NewTextbox")
- newPlug.NewSlider = loadFunc2(&newPlug, "NewSlider")
- newPlug.NewSpinner = loadFunc2(&newPlug, "NewSpinner")
+ // newPlug.NewGroup = loadFunc2(&newPlug, "NewGroup")
newPlug.NewDropdown = loadFunc2(&newPlug, "NewDropdown")
newPlug.AddDropdownName = loadFuncS(&newPlug, "AddDropdownName")
+ newPlug.SetDropdownName = loadFuncS(&newPlug, "SetDropdownName")
newPlug.SetDebugToolkit = loadFuncB(&newPlug, "SetDebugToolkit")
newPlug.SetDebugChange = loadFuncB(&newPlug, "SetDebugChange")
@@ -275,3 +278,16 @@ func loadfile(filename string) *plugin.Plugin {
log(debugGui, "plugin WORKED =", filename)
return plug
}
+
+// Sends a widget and what to do with it to the plugin
+// parent = n, child = c
+func send(p *Node, c *Node) {
+ for _, aplug := range allPlugins {
+ log(debugPlugin, "Send() aplug =", aplug.name, "name =", c.widget.Name)
+ if (aplug.Send == nil) {
+ log(debugPlugin, "\tSend() failed (aplug.Selete = nil) for", aplug.name)
+ continue
+ }
+ aplug.Send(&c.parent.widget, &c.widget)
+ }
+}