make a buttonMap
Signed-off-by: Jeff Carr <jcarr@wit.com>
This commit is contained in:
parent
1abf8279f2
commit
26bcac9b85
|
@ -39,7 +39,7 @@ func processEvents() {
|
|||
log.Println("processEvents() do Event DEMO")
|
||||
} else {
|
||||
log.Println("processEvents() NEW PROTOBUF")
|
||||
gui.Data.State = "NEW PROTOBUF"
|
||||
State = "NEW PROTOBUF"
|
||||
}
|
||||
log.Println("processEvents() END on channel")
|
||||
}
|
||||
|
|
|
@ -51,7 +51,7 @@ func mainMouseClick(b *gui.GuiButton) {
|
|||
log.Println("\tTRY TO ADD A NEW VIRTUAL MACHINE")
|
||||
/*
|
||||
log.Println("\tTRIGGER CREATE VM")
|
||||
gui.Data.State = "CREATE"
|
||||
State = "CREATE"
|
||||
event := pb.MakeAddVmEvent()
|
||||
for key, entry := range gui.Data.AllEntries {
|
||||
log.Println("\tdefaultEntryChange() Data.AllEntries =", key, entry)
|
||||
|
@ -76,7 +76,7 @@ func mainMouseClick(b *gui.GuiButton) {
|
|||
} else if (values.Action == "CONFIG") {
|
||||
newConfig := loadDefaultConfig()
|
||||
config.Accounts = newConfig.Accounts
|
||||
gui.Data.State = "done"
|
||||
State = "done"
|
||||
} else if (values.Action == "DEBUG") {
|
||||
log.Println("\tdebug.PrintStack() (SHOULD BE JUST THIS goroutine)")
|
||||
debug.PrintStack()
|
||||
|
@ -98,7 +98,7 @@ func mainMouseClick(b *gui.GuiButton) {
|
|||
*/
|
||||
} else if (values.Action == "SHOW") {
|
||||
log.Println("\tTRIGGER DISPLAY ACCOUNT")
|
||||
gui.Data.State = "SEND WEBSOCKET"
|
||||
State = "SEND WEBSOCKET"
|
||||
|
||||
event := pb.MakeGetEvent()
|
||||
event.Account = values.Account
|
||||
|
@ -106,14 +106,14 @@ func mainMouseClick(b *gui.GuiButton) {
|
|||
|
||||
count := 0
|
||||
for {
|
||||
log.Println("\tSleep() in buttonClick() gui.Data.State =", gui.Data.State)
|
||||
log.Println("\tSleep() in buttonClick() State =", State)
|
||||
time.Sleep(200 * time.Millisecond)
|
||||
if (gui.Data.State == "NEW PROTOBUF") {
|
||||
if (State == "NEW PROTOBUF") {
|
||||
if (currentMessage == nil) {
|
||||
gui.ErrorWindow(gw,
|
||||
"There was a socket error",
|
||||
"More detailed information can be shown here.")
|
||||
gui.Data.State = "done"
|
||||
State = "done"
|
||||
} else {
|
||||
count := countVMS(currentMessage)
|
||||
log.Println("\tSHOW VMS currentMessage =", currentMessage)
|
||||
|
@ -125,7 +125,7 @@ func mainMouseClick(b *gui.GuiButton) {
|
|||
ReadReceivedData(currentMessage, mh, b.Box)
|
||||
// }
|
||||
currentMessage = nil
|
||||
gui.Data.State = "done"
|
||||
State = "done"
|
||||
}
|
||||
return
|
||||
}
|
||||
|
@ -133,7 +133,7 @@ func mainMouseClick(b *gui.GuiButton) {
|
|||
if (count > 10) {
|
||||
log.Println("\tERROR: waited too long for a resposne")
|
||||
currentMessage = nil
|
||||
gui.Data.State = "done"
|
||||
State = "done"
|
||||
return
|
||||
}
|
||||
}
|
||||
|
@ -159,5 +159,5 @@ func makeGuiButtonValues(box *gui.GuiBox, a *pb.Account, vm *pb.Event_VM,
|
|||
func makeButton(box *gui.GuiBox, a *pb.Account, vm *pb.Event_VM,
|
||||
name string, action string, custom func(*gui.GuiButton)) *gui.GuiButton {
|
||||
val := makeGuiButtonValues(box, a, vm, name, action, custom)
|
||||
return gui.NewCreateButton(box, custom, name, val)
|
||||
return gui.CreateButton(box, custom, name, val)
|
||||
}
|
||||
|
|
|
@ -107,7 +107,7 @@ func addSubdomainButton(b *gui.GuiButton) {
|
|||
config.Accounts = append(config.Accounts, acc)
|
||||
|
||||
makeCloudInfoBox(b.Box.Window)
|
||||
gui.Data.State = "done"
|
||||
State = "done"
|
||||
log.Println("addSubdomainButton() END")
|
||||
}
|
||||
|
||||
|
|
12
login.go
12
login.go
|
@ -13,7 +13,7 @@ import pb "git.wit.com/wit/witProtobuf"
|
|||
|
||||
func login(b *gui.GuiButton) {
|
||||
log.Println("login() START")
|
||||
gui.Data.State = "SEND LOGIN"
|
||||
State = "SEND LOGIN"
|
||||
|
||||
// TODO: move this into a seperate goroutine
|
||||
// note: this may never be possible because of cross platform
|
||||
|
@ -28,14 +28,14 @@ func login(b *gui.GuiButton) {
|
|||
|
||||
count := 0
|
||||
for {
|
||||
log.Println("\tSleep() in buttonClick() gui.Data.State =", gui.Data.State)
|
||||
log.Println("\tSleep() in buttonClick() State =", State)
|
||||
time.Sleep(200 * time.Millisecond)
|
||||
if (gui.Data.State == "NEW PROTOBUF") {
|
||||
if (State == "NEW PROTOBUF") {
|
||||
if (currentMessage == nil) {
|
||||
gui.ErrorWindow(b.Box.Window,
|
||||
"There was a socket error",
|
||||
"More detailed information can be shown here.")
|
||||
gui.Data.State = "done"
|
||||
State = "done"
|
||||
} else {
|
||||
log.Println("LOGIN currentMessage =", currentMessage)
|
||||
if (currentMessage.Type == pb.Event_OK) {
|
||||
|
@ -64,7 +64,7 @@ func login(b *gui.GuiButton) {
|
|||
gui.ErrorWindow(b.Box.Window, "Login Failed", msg)
|
||||
}
|
||||
currentMessage = nil
|
||||
gui.Data.State = "done"
|
||||
State = "done"
|
||||
}
|
||||
return
|
||||
}
|
||||
|
@ -73,7 +73,7 @@ func login(b *gui.GuiButton) {
|
|||
if (count > 10) {
|
||||
log.Println("\tERROR: waited too long for a resposne")
|
||||
currentMessage = nil
|
||||
gui.Data.State = "done"
|
||||
State = "done"
|
||||
return
|
||||
}
|
||||
}
|
||||
|
|
2
main.go
2
main.go
|
@ -20,6 +20,8 @@ var GOVERSION string // this is passed in as an ldflag
|
|||
var BUILDTIME string // this is passed in as an ldflag
|
||||
var VERSION string // this is passed in as an ldflag
|
||||
|
||||
var State string // used as a State machine
|
||||
|
||||
type myButtonInfo struct {
|
||||
Account *pb.Account // associated with what account?
|
||||
Accounts []*pb.Account // associated with what account?
|
||||
|
|
Loading…
Reference in New Issue