diff options
| author | Jeff Carr <[email protected]> | 2025-01-20 05:06:08 -0600 |
|---|---|---|
| committer | Jeff Carr <[email protected]> | 2025-01-20 05:06:08 -0600 |
| commit | 5005edc9e37cb207f6c6035ea6fe3c3d98d94caa (patch) | |
| tree | 2ef2a0ba9fa27a2ced91572261170a93fdb5c3c6 | |
| parent | 250f1c756881c04720b277bbe1e56ece4988c88f (diff) | |
add a 'app' defined default plugin variablev0.22.22
| -rw-r--r-- | Makefile | 13 | ||||
| -rw-r--r-- | init.go | 12 | ||||
| -rw-r--r-- | plugin.go | 40 | ||||
| -rw-r--r-- | structs.go | 5 |
4 files changed, 42 insertions, 28 deletions
@@ -1,14 +1,17 @@ -all: goimports vet +all: @echo - @echo This is the core gui package 'go.wit.com/gui/gui' + @echo This is the core GUI package 'go.wit.com/gui' @echo - @echo It creates a binary tree of widgets - @echo The widgets are things like Windows, Buttons, Labels, etc + @echo "It creates a binary tree of widgets (Windows, Buttons, etc)" + @echo "This is the interface to the GUI GO plugin (ncurses, GTK, etc)" @echo + @echo "todo: rewrite this using protobufs" + @echo + @make goimports vet vet: @GO111MODULE=off go vet - @echo go vet: this go library package builds okay + @echo go vet: this go library should build okay goimports: goimports -w *.go @@ -280,6 +280,12 @@ func (n *Node) Default() *Node { log.Log(WARN, "LoadToolkit() failed for =", argGui.GuiPlugin) return nil } + if me.appPlugin != "" { + if n, err = n.LoadToolkit(me.appPlugin); err == nil { + return n + } + } + // if DISPLAY isn't set, return since gtk can't load // TODO: figure out how to check what to do in macos and mswindows if os.Getenv("DISPLAY") == "" { @@ -393,3 +399,9 @@ func trapStdout() { // defer guioutf.Close() } + +// sets the applications requested plugin +// the command line arguements override this +func (n *Node) SetAppDefaultPlugin(plugname string) { + me.appPlugin = plugname +} @@ -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 { @@ -56,9 +56,8 @@ type guiConfig struct { // option to pass in compiled plugins as embedded files resFS embed.FS - // used to beautify logging to Stdout - // depth int - // prefix string + // what the application would like the default GUI plugin to be + appPlugin string } /* |
