diff options
Diffstat (limited to 'main.go')
| -rw-r--r-- | main.go | 56 |
1 files changed, 55 insertions, 1 deletions
@@ -60,7 +60,7 @@ func (n *Node) findId(i int) (*Node) { func watchCallback() { log.Info("guiChan() START") for { - log.Info("guiChan() restarted") + log.Info("guiChan() select restarted") select { case a := <-me.guiChan: if (a.ActionType == widget.UserQuit) { @@ -69,9 +69,52 @@ func watchCallback() { log.Exit("wit/gui toolkit.UserQuit") break } + if (a.ActionType == widget.CloseWindow) { + log.Warn("guiChan() Close Window") + StandardExit() + break + } + if (a.ActionType == widget.ToolkitPanic) { + log.Warn("guiChan() Toolkit panic() in", a.ProgName) + log.Warn("guiChan() unload toolkit plugin here", a.ProgName) + me.rootNode.ListToolkits() + for _, aplug := range allPlugins { + log.Warn("ListToolkits() already loaded toolkit plugin =", aplug.name) + if aplug.name == a.ProgName { + log.Warn("FOUND PLUGIN =", aplug.name) + log.Warn("unload here") + log.Warn("panic on purpose") + me.rootNode.CloseToolkit(aplug.name) + // panic("panic trapped!") + // log.Sleep(.5) + // me.rootNode.LoadToolkit("gocui") + break + } + } + // StandardExit() + me.rootNode.LoadToolkit("nocui") + break + } + if (a.ActionType == widget.ToolkitLoad) { + newPlug := widget.GetString(a.Value) + log.Warn("Attempt to load a new toolkit", newPlug, "here") + me.rootNode.LoadToolkit(newPlug) + } if (a.ActionType == widget.EnableDebug) { log.Warn("guiChan() Enable Debugging Window") log.Warn("guiChan() TODO: not implemented") + log.Warn("guiChan() Listing Toolkits:") + PLUG.Set(true) + me.rootNode.ListToolkits() + me.rootNode.ListChildren(true) + for i, aplug := range allPlugins { + log.Warn("plug =", i, aplug.name) + if aplug.name == "andlabs" { + log.Warn("Found plug =", i, aplug.name) + //closePlugin(aplug) + allPlugins = allPlugins[1:] + } + } // DebugWindow() break } @@ -191,3 +234,14 @@ func StandardExit() { } log.Exit(0) } + +// The window is destroyed and the application exits +// TODO: properly exit the plugin since Quit() doesn't do it +func (n *Node) StandardExit() { + log.Log(NOW, "wit/gui Standard Window Exit. running os.Exit()") + log.Log(NOW, "StandardExit() attempt to exit each toolkit plugin") + for i, plug := range allPlugins { + log.Log(NOW, "NewButton()", i, plug) + } + log.Exit(0) +} |
