summaryrefslogtreecommitdiff
path: root/gui.go
diff options
context:
space:
mode:
authorJeff Carr <[email protected]>2025-09-09 04:38:09 -0500
committerJeff Carr <[email protected]>2025-09-09 04:38:09 -0500
commit656a1e15d434d1a0cc5bc89f42f273de1678dce1 (patch)
tree765faa153f84770758240e29a90580cd5743b841 /gui.go
parent3e4383e1316f0e9c824aea8a9e38465721477350 (diff)
cleaner common gui code
Diffstat (limited to 'gui.go')
-rw-r--r--gui.go39
1 files changed, 35 insertions, 4 deletions
diff --git a/gui.go b/gui.go
index fe44f30..f9803cc 100644
--- a/gui.go
+++ b/gui.go
@@ -7,6 +7,8 @@ import (
"go.wit.com/dev/alexflint/arg"
"go.wit.com/gui"
+ "go.wit.com/lib/fhelp"
+ "go.wit.com/log"
)
var argGui ArgsGui
@@ -16,8 +18,7 @@ This struct can be used with the go-arg package. These
are the generic default command line arguments for the 'GUI' package
*/
type ArgsGui struct {
- GuiPluginHack string `arg:"--gui-check-plugin" help:"hack to verify GO plugins load"`
- GuiVerbose bool `arg:"--gui-verbose" help:"enable all logging"`
+ GuiVerbose bool `arg:"--gui-verbose" help:"enable all logging"`
}
/*
@@ -54,6 +55,8 @@ func postMustParse(s string) string {
return "true"
}
return "false"
+ case "DEFAULT":
+ return "gocui"
case "FILE":
return "someplugin"
default:
@@ -62,7 +65,15 @@ func postMustParse(s string) string {
return "unknown"
}
-func Gui() *gui.Node {
+var prepGui *GuiPrep
+
+type GuiPrep struct {
+ rootn *gui.Node
+ hidden bool // don't update the toolkits when it's hidden
+ Auto func([]string)
+}
+
+func Gui() *GuiPrep {
if len(os.Args) > 1 && os.Args[1] == "--gui-check-plugin" {
gui.TestPluginAndExitNew(os.Args[2])
os.Exit(0)
@@ -70,5 +81,25 @@ func Gui() *gui.Node {
arg.Register(&argGui)
gui.InitArg()
- return gui.PreInit(postMustParse)
+ prepGui = new(GuiPrep)
+ prepGui.rootn = gui.PreInit(postMustParse)
+
+ return prepGui
+}
+
+func (g *GuiPrep) Start() error {
+ // me.myGui.InitEmbed(resources)
+ if pname, err := g.rootn.Default(); err != nil {
+ if !fhelp.BuildPlugin("gocui") {
+ log.Info("You can't run the forge GUI since the plugins did not build", pname)
+ return nil
+ }
+ if err := g.rootn.LoadToolkitNew("gocui"); err != nil {
+ log.Info("The plugins built, but still failed to load", pname)
+ return err
+ }
+ } else {
+ log.Info("The plugins built and loaded!", pname)
+ }
+ return nil
}