summaryrefslogtreecommitdiff
path: root/main.go
diff options
context:
space:
mode:
Diffstat (limited to 'main.go')
-rw-r--r--main.go100
1 files changed, 50 insertions, 50 deletions
diff --git a/main.go b/main.go
index 29eedc7..19aea2e 100644
--- a/main.go
+++ b/main.go
@@ -3,8 +3,8 @@ package gui
import (
"os"
+ "go.wit.com/lib/widget"
"go.wit.com/log"
- "go.wit.com/gui/widget"
)
// TODO: make a fake 'plugin' channel of communication to andlabs for mswindows
@@ -39,18 +39,18 @@ func init() {
}
// lookup the widget by the id sent from the toolkit
-func (n *Node) findId(i int) (*Node) {
- if (n == nil) {
+func (n *Node) findId(i int) *Node {
+ if n == nil {
return nil
}
- if (n.id == i) {
+ if n.id == i {
return n
}
for _, child := range n.children {
newN := child.findId(i)
- if (newN != nil) {
+ if newN != nil {
return newN
}
}
@@ -61,20 +61,20 @@ func watchCallback() {
log.Info("guiChan() START")
for {
log.Info("guiChan() select restarted")
- select {
+ select {
case a := <-me.guiChan:
- if (a.ActionType == widget.UserQuit) {
+ 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) {
+ if a.ActionType == widget.CloseWindow {
log.Warn("guiChan() Close Window")
StandardExit()
break
}
- if (a.ActionType == widget.ToolkitPanic) {
+ 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()
@@ -95,12 +95,12 @@ func watchCallback() {
me.rootNode.LoadToolkit("nocui")
break
}
- if (a.ActionType == widget.ToolkitLoad) {
+ 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) {
+ if a.ActionType == widget.EnableDebug {
log.Warn("guiChan() Enable Debugging Window")
log.Warn("guiChan() TODO: not implemented")
log.Warn("guiChan() Listing Toolkits:")
@@ -120,7 +120,7 @@ func watchCallback() {
}
n := me.rootNode.findId(a.WidgetId)
- if (n == nil) {
+ if n == nil {
log.Warn("guiChan() UNKNOWN widget id")
log.Warn("id =", a.WidgetId, a.ProgName)
} else {
@@ -136,7 +136,7 @@ func watchCallback() {
func (n *Node) doCustom() {
log.Info("doUserEvent() widget =", n.id, n.progname, n.WidgetType)
- if (n.Custom == nil) {
+ if n.Custom == nil {
log.Warn("Custom() = nil. SKIPPING")
return
}
@@ -153,39 +153,39 @@ func (n *Node) doUserEvent(a widget.Action) {
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)
- }
+ 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)
+ }
*/
}
@@ -199,19 +199,19 @@ func New() *Node {
// try to load andlabs, if that doesn't work, fall back to the console
func (n *Node) Default() *Node {
- if (argGui.GuiPlugin != "") {
+ if argGui.GuiPlugin != "" {
log.Warn("New.Default() try toolkit =", argGui.GuiPlugin)
return n.LoadToolkit(argGui.GuiPlugin)
}
// if DISPLAY isn't set, return since gtk can't load
// TODO: figure out how to check what to do in macos and mswindows
- if (os.Getenv("DISPLAY") == "") {
- if (n.LoadToolkit("gocui") == nil) {
+ if os.Getenv("DISPLAY") == "" {
+ if n.LoadToolkit("gocui") == nil {
log.Warn("New() failed to load gocui")
}
return n
}
- if (n.LoadToolkit("andlabs") != nil) {
+ if n.LoadToolkit("andlabs") != nil {
return n
}
n.LoadToolkit("gocui")