andlabs: my logic for new window is still wrong
Signed-off-by: Jeff Carr <jcarr@wit.com>
This commit is contained in:
parent
85c2fb8d70
commit
e34ec5efbf
4
main.go
4
main.go
|
@ -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 {
|
||||
|
|
27
plugin.go
27
plugin.go
|
@ -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)
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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")
|
||||
}
|
||||
|
||||
|
|
|
@ -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)
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue