summaryrefslogtreecommitdiff
path: root/main.go
diff options
context:
space:
mode:
Diffstat (limited to 'main.go')
-rw-r--r--main.go107
1 files changed, 30 insertions, 77 deletions
diff --git a/main.go b/main.go
index 7c834ca..a3471a7 100644
--- a/main.go
+++ b/main.go
@@ -63,17 +63,20 @@ func watchCallback() {
log.Info("guiChan() select restarted")
select {
case a := <-me.guiChan:
+ // 99.9% of events are just widget changes
+ n := me.rootNode.findId(a.WidgetId)
+ if n != nil {
+ log.Verbose("guiChan() FOUND widget id =", n.id, n.progname)
+ n.goUserEvent(a)
+ break
+ }
+
+ // if not a widget change, something more bizare
if a.ActionType == widget.UserQuit {
log.Warn("guiChan() User sent Quit()")
- me.rootNode.doCustom()
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)
@@ -107,88 +110,38 @@ func watchCallback() {
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:]
+ /*
+ 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
}
-
- n := me.rootNode.findId(a.WidgetId)
- if n == nil {
- log.Warn("guiChan() UNKNOWN widget id")
- log.Warn("id =", a.WidgetId, a.ProgName)
- } else {
- log.Verbose("guiChan() FOUND widget id =", n.id, n.progname)
- n.doUserEvent(a)
- }
- // this maybe a good idea?
- // TODO: Throttle user events somehow
- // sleep(.01) // hack that throttles user events
+ log.Warn("guiChan() Action could not be found or handled", a.ActionType, a)
}
}
}
-func (n *Node) doCustom() {
- log.Info("doUserEvent() widget =", n.id, n.progname, n.WidgetType)
+// stores the value returned then
+// spawns the user defined custom routine
+// hopefully everything is designed smart enough
+// that it doesn't matter what happens outside of here
+// TODO: implement throttling someday
+func (n *Node) goUserEvent(a widget.Action) {
+ log.Info("goUserEvent() node =", n.id, n.progname)
+ n.value = a.Value
if n.Custom == nil {
- log.Warn("Custom() = nil. SKIPPING")
+ log.Info("a Custom() function was not set for this widget")
return
}
go n.Custom()
}
-func (n *Node) doUserEvent(a widget.Action) {
- log.Info("doUserEvent() node =", n.id, n.progname)
- if a.Value == nil {
- log.Warn("doUserEvent() a.A == nil", n.id, n.progname)
- return
- }
- n.value = a.Value
- n.doCustom()
- return
- /*
- switch n.WidgetType {
- case widget.Checkbox:
- log.Info("doUserEvent() node =", n.id, n.progname, "set to:", n.value)
- n.doCustom()
- case widget.Button:
- log.Info("doUserEvent() node =", n.id, n.progname, "button clicked")
- n.doCustom()
- case widget.Combobox:
- n.S = a.S
- log.Info("doUserEvent() node =", n.id, n.progname, "set to:", n.S)
- n.doCustom()
- case widget.Dropdown:
- n.S = a.S
- log.Info("doUserEvent() node =", n.id, n.progname, "set to:", n.S)
- n.doCustom()
- case widget.Textbox:
- n.S = a.S
- log.Info("doUserEvent() node =", n.id, n.progname, "set to:", n.S)
- n.doCustom()
- case widget.Spinner:
- n.I = a.I
- log.Info("doUserEvent() node =", n.id, n.progname, "set to:", n.I)
- n.doCustom()
- case widget.Slider:
- n.I = a.I
- log.Info("doUserEvent() node =", n.id, n.progname, "set to:", n.I)
- n.doCustom()
- case widget.Window:
- log.Info("doUserEvent() node =", n.id, n.progname, "window closed")
- n.doCustom()
- default:
- log.Info("doUserEvent() type =", n.WidgetType)
- }
- */
-}
-
// There should only be one of these per application
// This is due to restrictions by being cross platform
// some toolkit's on some operating systems don't support more than one
@@ -220,8 +173,8 @@ func (n *Node) Default() *Node {
// The window is destroyed but the application does not quit
func (n *Node) StandardClose() {
- log.Log(GUI, "wit/gui Standard Window Close. name =", n.progname)
- log.Log(GUI, "wit/gui Standard Window Close. n.Custom exit =", n.Custom)
+ log.Log(NOW, "wit/gui Standard Window Close. name =", n.progname)
+ log.Log(NOW, "wit/gui Standard Window Close. n.Custom exit =", n.Custom)
}
// The window is destroyed and the application exits