diff options
| author | Jeff Carr <[email protected]> | 2023-04-08 11:43:58 -0500 |
|---|---|---|
| committer | Jeff Carr <[email protected]> | 2023-04-08 11:43:58 -0500 |
| commit | e582e4cfb0fa0a3a679d031b1f157b274f0d4075 (patch) | |
| tree | 7a41e27309d2adde0f057dd2f291b724247380bf | |
| parent | da6a4363226f14aa893be02cb4a73cbf34fd77e7 (diff) | |
andlabs: my logic for new window is still wrong
Signed-off-by: Jeff Carr <[email protected]>
| -rw-r--r-- | main.go | 4 | ||||
| -rw-r--r-- | plugin.go | 27 | ||||
| -rw-r--r-- | redraw.go | 7 | ||||
| -rw-r--r-- | toolkit/andlabs/add.go | 4 | ||||
| -rw-r--r-- | toolkit/andlabs/main.go | 41 | ||||
| -rw-r--r-- | toolkit/andlabs/window.go | 6 |
6 files changed, 32 insertions, 57 deletions
@@ -203,8 +203,8 @@ func Main(f func()) { if (os.Getenv("DISPLAY") == "") { InitPlugins([]string{"gocui"}) } else { - //InitPlugins([]string{"andlabs", "gocui"}) - InitPlugins([]string{"gocui", "andlabs"}) + InitPlugins([]string{"andlabs", "gocui"}) + // InitPlugins([]string{"gocui", "andlabs"}) } for _, aplug := range allPlugins { @@ -59,7 +59,7 @@ type aplug struct { // simplifies passing to the plugin // Send func(*toolkit.Widget, *toolkit.Widget) // should replace Send() - Action func(*toolkit.Action) + // Action func(*toolkit.Action) } var allPlugins []*aplug @@ -104,7 +104,7 @@ func LoadToolkit(name string) *aplug { // Sends instructions like "Add", "Delete", "Disable", etc // Sends a widget (button, checkbox, etc) and it's parent widget - newPlug.Action = loadFuncA(newPlug, "Action") + // newPlug.Action = loadFuncA(newPlug, "Action") // this tells the toolkit plugin how to send user events back to us // for things like: the user clicked on the 'Check IPv6' @@ -332,24 +332,15 @@ func newaction(a *toolkit.Action, n *Node, where *Node) { for _, aplug := range allPlugins { log(debugPlugin, "Action() aplug =", aplug.name, "Action type=", a.ActionType) if (aplug.pluginChan == nil) { - log(debugNow, "Action() SEND old way", aplug.name) - log(debugNow, "Action() SEND old way", aplug.name) - log(debugNow, "Action() SEND old way", aplug.name) - if (aplug.Action == nil) { - log(debugPlugin, "Failed Action() == nil for", aplug.name) - continue - } - aplug.Action(a) - log(debugNow, "Action() SEND trying aplug.PluginChannel()", aplug.name) + log(debugNow, "Action() retrieving the aplug.PluginChannel()", aplug.name) aplug.pluginChan = aplug.PluginChannel() - log(debugNow, "Action() SEND trying aplug.PluginChannel()", aplug.pluginChan) - } else { - log(debugNow, "Action() SEND pluginChan", aplug.name) - log(debugNow, "Action() SEND pluginChan", aplug.name) - log(debugNow, "Action() SEND pluginChan", aplug.name) - aplug.pluginChan <- *a + log(debugNow, "Action() retrieved", aplug.pluginChan) } - sleep(.5) + log(debugNow, "Action() SEND pluginChan", aplug.name) + log(debugNow, "Action() SEND pluginChan", aplug.name) + log(debugNow, "Action() SEND pluginChan", aplug.name) + aplug.pluginChan <- *a + sleep(.2) } // increment where to put the next widget in a grid or table if (where != nil) { @@ -76,12 +76,7 @@ func (n *Node) redo(plug *aplug) { // plug.Action(a) if (plug.pluginChan == nil) { - log(debugNow, "Action() SEND old way", plug.name) - log(debugNow, "Action() SEND old way", plug.name) - log(debugNow, "Action() SEND old way", plug.name) - plug.Action(a) - log(debugNow, "Action() SEND trying plug.PluginChannel()", plug.name) - log(debugNow, "Action() SEND trying plug.PluginChannel()", plug.pluginChan) + log(debugNow, "Action() ERRRRRRROR pluginChan == nil", plug.name) } else { log(debugNow, "Action() SEND pluginChan", plug.name) log(debugNow, "Action() SEND pluginChan", plug.name) diff --git a/toolkit/andlabs/add.go b/toolkit/andlabs/add.go index e6f3305..2f35e99 100644 --- a/toolkit/andlabs/add.go +++ b/toolkit/andlabs/add.go @@ -29,7 +29,7 @@ func add(a *toolkit.Action) { // for now, window gets handled without checking where == nil) if (a.WidgetType == toolkit.Window) { - doWindow(a) + newWindow(*a) return } @@ -44,7 +44,7 @@ func add(a *toolkit.Action) { switch a.WidgetType { case toolkit.Window: - doWindow(a) + newWindow(*a) return case toolkit.Tab: log(debugError, "add() CAME AT THIS FROM add() =", a.Name) diff --git a/toolkit/andlabs/main.go b/toolkit/andlabs/main.go index c107038..8466abf 100644 --- a/toolkit/andlabs/main.go +++ b/toolkit/andlabs/main.go @@ -15,6 +15,8 @@ var res embed.FS // this is the channel we get requests to make widgets var pluginChan chan toolkit.Action +var uiMain bool = false + func catchActionChannel() { log(logNow, "makeCallback() START") for { @@ -25,11 +27,19 @@ func catchActionChannel() { // go Action(a) if (a.WidgetType == toolkit.Window) { log(logNow, "makeCallback() WINDOW START") - go ui.Main( func() { - log(logNow, "ui.Main() WINDOW START DOING NOTHING") - newWindow(&a) - log(logNow, "ui.Main() WINDOW END") - }) + // this is a hack for now + // if uiMain == true, ui.Main() has already started + if (uiMain) { + log(logNow, "WINDOW START newWindow(&a)") + newWindow(a) + } else { + go ui.Main( func() { + log(logNow, "ui.Main() WINDOW START DOING NOTHING") + newWindow(a) + log(logNow, "ui.Main() WINDOW END") + }) + uiMain = true + } sleep(.5) log(logNow, "makeCallback() WINDOW END") } else { @@ -43,7 +53,7 @@ func catchActionChannel() { } func Main(f func()) { - log(debugNow, "gui.Main() START (using gtk via andlabs/ui)") + log(debugNow, "Main() START (using gtk via andlabs/ui)") f() // support the old way. deprecate this } @@ -79,28 +89,11 @@ func Init() { // log(debugToolkit, "gui/toolkit init() Setting defaultBehavior = true") setDefaultBehavior(true) - // mapWidgets = make(map[*andlabsT]*toolkit.Widget) - // mapToolkits = make(map[*toolkit.Widget]*andlabsT) - andlabs = make(map[int]*andlabsT) pluginChan = make(chan toolkit.Action) - log(logNow, "Init() ui.Main() start") + log(logNow, "Init() start channel reciever") go catchActionChannel() - /* - ui.Main( func() { - log(logNow, "gui.Main() IN (using gtk via andlabs/ui)") - var a toolkit.Action - a.Name = "jcarr" - a.Width = 640 - a.Height = 480 - a.WidgetId = 0 - newWindow(&a) - // time.Sleep(1 * time.Second) - // NewWindow2("helloworld2", 200, 100) - log(logNow, "gui.Main() EXIT (using gtk via andlabs/ui)") - }) - */ log(logNow, "Init() END") } diff --git a/toolkit/andlabs/window.go b/toolkit/andlabs/window.go index 9e2e950..34245d8 100644 --- a/toolkit/andlabs/window.go +++ b/toolkit/andlabs/window.go @@ -15,7 +15,7 @@ func (t *andlabsT) ErrorWindow(msg1 string, msg2 string) { ui.MsgBoxError(t.uiWindow, msg1, msg2) } -func newWindow(a *toolkit.Action) { +func newWindow(a toolkit.Action) { var newt *andlabsT newt = new(andlabsT) @@ -49,7 +49,3 @@ func (t *andlabsT) SetWindowTitle(title string) { log(debugToolkit, "Setting the window title", title) } } - -func doWindow(a *toolkit.Action) { - newWindow(a) -} |
