summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJeff Carr <[email protected]>2023-04-23 14:18:34 -0500
committerJeff Carr <[email protected]>2023-04-23 14:18:34 -0500
commit890fe6740e7810e7eadd5cad21fefe2e99fd2d76 (patch)
treefdc556520d48b4864656516be38f815b3ca339ec
parent36894c8b38c6ef3a722ef00fa5d3aeddcef5724e (diff)
andlabs: artificial delay. queue() all add's
Signed-off-by: Jeff Carr <[email protected]>
-rw-r--r--cmds/buttonplugin/main.go3
-rw-r--r--tab.go12
-rw-r--r--toolkit/andlabs/plugin.go51
3 files changed, 22 insertions, 44 deletions
diff --git a/cmds/buttonplugin/main.go b/cmds/buttonplugin/main.go
index 7c62b21..d206591 100644
--- a/cmds/buttonplugin/main.go
+++ b/cmds/buttonplugin/main.go
@@ -19,7 +19,8 @@ func main() {
// gui.SetDebug(true)
// myGui = gui.New().LoadToolkit("gocui")
- myGui = gui.New().LoadToolkit("andlabs")
+ // myGui = gui.New().LoadToolkit("andlabs")
+ myGui = gui.New().Default()
buttonWindow()
// This is just a optional goroutine to watch that things are alive
diff --git a/tab.go b/tab.go
index 41013bd..c19ecb5 100644
--- a/tab.go
+++ b/tab.go
@@ -8,6 +8,18 @@ import (
// the 'tab' as a child
func (n *Node) NewTab(text string) *Node {
+ // check to make sure n is actually a window
+
+ if (n.WidgetType != toolkit.Window) {
+ // figure out what the actual window is
+ log(logError, "NewTab() is being requested on something that isn't a Window")
+ if (n.parent.WidgetType == toolkit.Window) {
+ return n.parent.NewTab(text)
+ } else {
+ // TODO: find a window. any window. never give up. never die.
+ panic("NewTab did not get passed a window")
+ }
+ }
newNode := n.newNode(text, toolkit.Tab, nil)
var a toolkit.Action
diff --git a/toolkit/andlabs/plugin.go b/toolkit/andlabs/plugin.go
index a7205fb..96a73ac 100644
--- a/toolkit/andlabs/plugin.go
+++ b/toolkit/andlabs/plugin.go
@@ -1,47 +1,9 @@
package main
-// if you include more than just this import
-// then your plugin might be doing something un-ideal (just a guess from 2023/02/27)
-import "git.wit.org/wit/gui/toolkit"
-
-// import "github.com/andlabs/ui"
-// import _ "github.com/andlabs/ui/winmanifest"
-
-//
-// This should be called ?
-// Pass() ?
-// This handles all interaction between the wit/gui package (what golang knows about)
-// and this plugin that talks to the OS and does scary and crazy things to make
-// a GUI on whatever OS or whatever GUI toolkit you might have (GTK, QT, WASM, libcurses)
-//
-// Once you are here, you should be in a protected goroutine created by the golang wit/gui package
-//
-// TODO: make sure you can't escape this goroutine
-//
-/*
-func Send(p *toolkit.Widget, c *toolkit.Widget) {
- log(debugPlugin, "Send() goodbye. not used anymore")
-}
-*/
-
-/*
-func oldAction2(a *toolkit.Action) {
- log(logNow, "Action() START")
- if (a == nil) {
- log(debugPlugin, "Action = nil")
- return
- }
- pluginChan <- *a
-
- f := func() {
- rawAction(a)
- }
-
- // f()
- Queue(f)
- log(logNow, "Action() END")
-}
-*/
+import (
+ "github.com/andlabs/ui"
+ "git.wit.org/wit/gui/toolkit"
+)
func rawAction(a toolkit.Action) {
log(debugAction, "rawAction() START a.ActionType =", a.ActionType)
@@ -66,7 +28,10 @@ func rawAction(a toolkit.Action) {
switch a.ActionType {
case toolkit.Add:
- add(a)
+ ui.QueueMain(func() {
+ add(a)
+ })
+ sleep(.1)
case toolkit.Show:
a.B = true
show(&a)