summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--addAccount.go8
-rw-r--r--debug.go14
-rw-r--r--gui.go45
-rw-r--r--mainCloudBox.go18
-rw-r--r--splash.go2
-rw-r--r--structs.go9
-rw-r--r--tableCallbacks.go10
-rw-r--r--vmWindow.go26
8 files changed, 52 insertions, 80 deletions
diff --git a/addAccount.go b/addAccount.go
index 6324ed8..23fd0ac 100644
--- a/addAccount.go
+++ b/addAccount.go
@@ -9,12 +9,12 @@ func AddAccountQuestionBox(junk *ui.Box, custom func(*ButtonMap)) *ui.Box {
newbox := ui.NewVerticalBox()
newbox.SetPadded(true)
- newButton := CreateButton("Create New Account", "DONE", custom)
+ newButton := CreateButton(nil, nil, "Create New Account", "DONE", custom)
newbox.Append(newButton, false)
newbox.Append(ui.NewHorizontalSeparator(), false)
- okButton := CreateButton("I Have an Account", "DONE", custom)
+ okButton := CreateButton(nil, nil, "I Have an Account", "DONE", custom)
newbox.Append(okButton, false)
return newbox
@@ -119,10 +119,10 @@ func AddAccountBox(custom func(*ButtonMap)) *ui.Box {
hboxButtons.SetPadded(true)
vbox.Append(hboxButtons, false)
- okButton := CreateButton("Add Account", "ADD", custom)
+ okButton := CreateButton(nil, nil, "Add Account", "ADD", custom)
hboxButtons.Append(okButton, false)
- backButton := CreateButton("Back", "BACK", custom)
+ backButton := CreateButton(nil, nil, "Back", "BACK", custom)
hboxButtons.Append(backButton, false)
return vbox
diff --git a/debug.go b/debug.go
index 0b4efe6..5d8f0aa 100644
--- a/debug.go
+++ b/debug.go
@@ -51,15 +51,15 @@ func addTableTab() {
log.Println("Sleep for 2 seconds, then try to add new tabs")
time.Sleep(1 * 1000 * 1000 * 1000)
- AddTableTab(Data.cloudTab, 1, "test seven", 7, parts)
+ AddTableTab(Data.cloudTab, 1, "test seven", 7, parts, nil)
}
func addDebuggingButtons(vbox *ui.Box, custom func(*ButtonMap)) {
vbox.Append(ui.NewLabel("Debugging:"), false)
vbox.Append(ui.NewColorButton(), false)
- vbox.Append(CreateButton("Add Account", "ADD", custom), false)
- vbox.Append(CreateButton("Quit", "QUIT", custom), false)
+ vbox.Append(CreateButton(nil, nil, "Add Account", "ADD", custom), false)
+ vbox.Append(CreateButton(nil, nil, "Quit", "QUIT", custom), false)
// ATTEMPT TO ADD THE TABLE HERE
add2button := ui.NewButton("Add a Test Table")
@@ -70,11 +70,11 @@ func addDebuggingButtons(vbox *ui.Box, custom func(*ButtonMap)) {
vbox.Append(add2button, false)
// ATTEMPT TO ADD THE TABLE HERE END
- vbox.Append(CreateButton("Close GUI", "QUIT", custom), false)
- vbox.Append(CreateButton("DEBUG goroutines", "DEBUG", custom), false)
+ vbox.Append(CreateButton(nil, nil, "Close GUI", "QUIT", custom), false)
+ vbox.Append(CreateButton(nil, nil, "DEBUG goroutines", "DEBUG", custom), false)
// vbox.Append(CreateButton("ping", "PING", runPingClick), false)
- vbox.Append(CreateButton("xterm", "XTERM", runTestExecClick), false)
- vbox.Append(CreateButton("Load test.json config file", "CONFIG", custom), false)
+ vbox.Append(CreateButton(nil, nil, "xterm", "XTERM", runTestExecClick), false)
+ vbox.Append(CreateButton(nil, nil, "Load test.json config file", "CONFIG", custom), false)
}
func runPingClick(b *ButtonMap) {
diff --git a/gui.go b/gui.go
index 532e35a..e30ae96 100644
--- a/gui.go
+++ b/gui.go
@@ -41,7 +41,7 @@ func InitColumns(mh *TableData, parts []TableColumnData) {
}
}
-func AddTableTab(mytab *ui.Tab, mytabcount int, name string, rowcount int, parts []TableColumnData) *TableData {
+func AddTableTab(mytab *ui.Tab, mytabcount int, name string, rowcount int, parts []TableColumnData, account *pb.Config_Account) *TableData {
mh := new(TableData)
mh.RowCount = rowcount
@@ -90,8 +90,8 @@ func AddTableTab(mytab *ui.Tab, mytabcount int, name string, rowcount int, parts
hbox := ui.NewHorizontalBox()
hbox.SetPadded(true)
- hbox.Append(CreateButton("Add Virtual Machine", "createAddVmBox", mouseClick), false)
- hbox.Append(CreateButton("Close", "CLOSE", mouseClick), false)
+ hbox.Append(CreateButton(account, nil, "Add Virtual Machine", "createAddVmBox", mouseClick), false)
+ hbox.Append(CreateButton(account, nil, "Close", "CLOSE", mouseClick), false)
vbox.Append(hbox, false)
@@ -193,48 +193,15 @@ func defaultFontButtonClick(button *ui.FontButton) {
}
}
-func CreateButton(name string, note string, custom func(*ButtonMap)) *ui.Button {
+func CreateButton(a *pb.Config_Account, vm *pb.Event_VM,
+ name string, note string, custom func(*ButtonMap)) *ui.Button {
newB := ui.NewButton(name)
newB.OnClicked(defaultButtonClick)
var newmap ButtonMap
newmap.B = newB
+ newmap.Account = a
newmap.Action = note
- // newmap.Name = name
- newmap.custom = custom
- Data.AllButtons = append(Data.AllButtons, newmap)
-
- return newB
-}
-
-func CreateAccountButton(pbC *pb.Config_Account, custom func(*ButtonMap)) *ui.Button {
- name := "Show " + pbC.Nick
- newB := ui.NewButton(name)
- newB.OnClicked(defaultButtonClick)
-
- var newmap ButtonMap
- newmap.B = newB
- newmap.Account = pbC
- newmap.Action = "SHOW"
-// newmap.Name = name
-// newmap.AccNick = account
- newmap.custom = custom
- Data.AllButtons = append(Data.AllButtons, newmap)
-
- return newB
-}
-
-func CreateLoginButton(pbC *pb.Config_Account, custom func(*ButtonMap)) *ui.Button {
- name := "Login " + pbC.Nick
- newB := ui.NewButton(name)
- newB.OnClicked(defaultButtonClick)
-
- var newmap ButtonMap
- newmap.B = newB
- newmap.Account = pbC
- newmap.Action = "LOGIN"
-// newmap.Name = name
-// newmap.AccNick = account
newmap.custom = custom
Data.AllButtons = append(Data.AllButtons, newmap)
diff --git a/mainCloudBox.go b/mainCloudBox.go
index 76a5ba8..98931ed 100644
--- a/mainCloudBox.go
+++ b/mainCloudBox.go
@@ -7,7 +7,7 @@ import "log"
import "github.com/andlabs/ui"
import _ "github.com/andlabs/ui/winmanifest"
-// import pb "git.wit.com/wit/witProtobuf"
+import pb "git.wit.com/wit/witProtobuf"
// import "github.com/davecgh/go-spew/spew"
func makeCloudInfoBox(custom func(*ButtonMap)) *ui.Box {
@@ -48,7 +48,7 @@ func makeCloudInfoBox(custom func(*ButtonMap)) *ui.Box {
hostnameEntry.SetText(tmp)
hostnameEntry.SetReadOnly(true)
- hostnamebox.Append(CreateButton("Edit", "EDIT", custom), false)
+ hostnamebox.Append(CreateButton(nil, nil, "Edit", "EDIT", custom), false)
vbox.Append(ui.NewHorizontalSeparator(), false)
@@ -72,10 +72,12 @@ func makeCloudInfoBox(custom func(*ButtonMap)) *ui.Box {
agrid.Append(ui.NewLabel(Data.Config.Accounts[key].Username), 2, row, 1, 1, true, ui.AlignFill, false, ui.AlignFill)
agrid.Append(ui.NewLabel(Data.Config.Accounts[key].Domainname), 3, row, 1, 1, true, ui.AlignFill, false, ui.AlignFill)
- l := CreateLoginButton(Data.Config.Accounts[key], custom)
+ name := "Login " + Data.Config.Accounts[key].Nick
+ l := CreateButton(Data.Config.Accounts[key], nil, name, "LOGIN", custom)
agrid.Append(l, 4, row, 1, 1, true, ui.AlignFill, false, ui.AlignFill)
- b := CreateAccountButton(Data.Config.Accounts[key], custom)
+ name = "Show " + Data.Config.Accounts[key].Nick
+ b := CreateButton(Data.Config.Accounts[key], nil, name, "SHOW", custom)
agrid.Append(b, 5, row, 1, 1, true, ui.AlignFill, false, ui.AlignFill)
row += 1
@@ -84,16 +86,16 @@ func makeCloudInfoBox(custom func(*ButtonMap)) *ui.Box {
row += 1
agrid.Append(ui.NewLabel(""), 1, row, 1, 1, true, ui.AlignFill, false, ui.AlignFill)
row += 1
- a := CreateButton("Add Account", "ADD", custom)
+ a := CreateButton(nil, nil, "Add Account", "ADD", custom)
agrid.Append(a, 4, row, 1, 1, true, ui.AlignFill, false, ui.AlignFill)
- q := CreateButton("Quit", "QUIT", custom)
+ q := CreateButton(nil, nil, "Quit", "QUIT", custom)
agrid.Append(q, 5, row, 1, 1, true, ui.AlignFill, false, ui.AlignFill)
vbox.Append(agrid, false)
return hbox
}
-func AddVmsTab(name string, count int) *TableData {
+func AddVmsTab(name string, count int, a *pb.Config_Account) *TableData {
var parts []TableColumnData
human := 0
@@ -147,6 +149,6 @@ func AddVmsTab(name string, count int) *TableData {
parts = append(parts, tmp)
human += 1
- mh := AddTableTab(Data.cloudTab, 1, name, count, parts)
+ mh := AddTableTab(Data.cloudTab, 1, name, count, parts, a)
return mh
}
diff --git a/splash.go b/splash.go
index b60445c..c4ed9c9 100644
--- a/splash.go
+++ b/splash.go
@@ -45,7 +45,7 @@ func ShowSplashBox(vbox *ui.Box, atest chan int, custom func(*ButtonMap)) *ui.Bo
}
}
- okButton := CreateButton("OK", "DONE", custom)
+ okButton := CreateButton(nil, nil, "OK", "DONE", custom)
newbox.Append(okButton, false)
if (vbox != nil) {
diff --git a/structs.go b/structs.go
index 19a0119..e3c353e 100644
--- a/structs.go
+++ b/structs.go
@@ -64,8 +64,8 @@ type GuiDataStructure struct {
// a tab (maybe the one the user is playing with?)
CurrentTab *GuiTabStructure
// a VM (maybe the one the user is playing with?)
- CurrentVM string
- CurrentPbVM *pb.Event_VM
+// CurrentVM string
+ CurrentVM *pb.Event_VM
// All the tabs
Tabs []GuiTabStructure
@@ -99,6 +99,7 @@ type ButtonMap struct {
B *ui.Button
FB *ui.FontButton
Account *pb.Config_Account
+ VM *pb.Event_VM
Action string // what type of button
custom func (*ButtonMap)
@@ -126,7 +127,7 @@ type RowData struct {
HumanData [20]HumanCellData
// The VM from the protobuf
- PbVM *pb.Event_VM
+ VM *pb.Event_VM
}
//
@@ -171,6 +172,8 @@ type TableData struct {
Cells [20]CellData
Human [20]HumanMap
+ Account *pb.Config_Account // what account this table is for
+
lastRow int
lastColumn int
parentTab *ui.Tab
diff --git a/tableCallbacks.go b/tableCallbacks.go
index a7479f6..8a61f6b 100644
--- a/tableCallbacks.go
+++ b/tableCallbacks.go
@@ -7,7 +7,7 @@ package gui
//
import "log"
-import "fmt"
+// import "fmt"
import "image/color"
import "runtime"
@@ -100,15 +100,15 @@ func defaultSetCellValue(mh *TableData, row int, column int) {
vmname := mh.Rows[row].HumanData[humanID].Text
log.Println("vmname =", vmname)
log.Println("defaultSetCellValue() FOUND THE BUTTON!!!!!!! Button was pressed START", row, column)
- Data.CurrentVM = fmt.Sprintf("%s",vmname)
- Data.CurrentPbVM = mh.Rows[row].PbVM
- log.Println("User last clicked on Data.CurrentVM =", Data.CurrentVM)
+ // Data.CurrentVM = fmt.Sprintf("%s",vmname)
+ Data.CurrentVM = mh.Rows[row].VM
+ log.Println("User last clicked on Data.CurrentVM =", mh.Rows[row].VM)
if (Data.Debug) {
go ui.Main(ShowVM)
} else {
// AddVmConfigureTab(vmname, mh.Rows[row].PbVM)
// createVmBox(Data.cloudTab, buttonVmClick, mh.Rows[row].PbVM)
- createVmBox(Data.cloudTab, mouseClick, mh.Rows[row].PbVM)
+ createVmBox(Data.cloudTab, mouseClick, mh.Rows[row].VM)
}
}
}
diff --git a/vmWindow.go b/vmWindow.go
index 280ccf6..2dc8d81 100644
--- a/vmWindow.go
+++ b/vmWindow.go
@@ -11,7 +11,7 @@ import "github.com/davecgh/go-spew/spew"
import pb "git.wit.com/wit/witProtobuf"
func ShowVM() {
- name := Data.CurrentVM
+ name := Data.CurrentVM.Name
log.Println("ShowVM() START Data.CurrentVM=", Data.CurrentVM)
VMwin := ui.NewWindow("VM " + name, 500, 300, false)
VMwin.OnClosing(func(*ui.Window) bool {
@@ -27,12 +27,12 @@ func ShowVM() {
VMwin.SetChild(VMtab)
VMwin.SetMargined(true)
- createVmBox(VMtab, mouseClick, Data.CurrentPbVM)
+ createVmBox(VMtab, mouseClick, Data.CurrentVM)
VMwin.Show()
}
func AddVmConfigureTab(name string, pbVM *pb.Event_VM) {
- createVmBox(Data.cloudTab, mouseClick, Data.CurrentPbVM)
+ createVmBox(Data.cloudTab, mouseClick, Data.CurrentVM)
}
// makeEntryBox(box, "hostname:", "blah.foo.org") {
@@ -108,15 +108,15 @@ func createVmBox(tab *ui.Tab, custom func(*ButtonMap), pbVM *pb.Event_VM) {
hboxButtons.SetPadded(true)
vbox.Append(hboxButtons, false)
- hboxButtons.Append(CreateButton("Power On", "POWERON", custom), false)
- hboxButtons.Append(CreateButton("Power Off", "POWEROFF", custom), false)
- hboxButtons.Append(CreateButton("Destroy", "DESTROY", custom), false)
- hboxButtons.Append(CreateButton("ping", "PING", runPingClick), false)
- hboxButtons.Append(CreateButton("Console", "XTERM", runTestExecClick), false)
- hboxButtons.Append(CreateButton("Save", "SAVE", custom), false)
- hboxButtons.Append(CreateButton("Done", "DONE", custom), false)
+ hboxButtons.Append(CreateButton(nil, pbVM, "Power On", "POWERON", custom), false)
+ hboxButtons.Append(CreateButton(nil, pbVM, "Power Off", "POWEROFF", custom), false)
+ hboxButtons.Append(CreateButton(nil, pbVM, "Destroy", "DESTROY", custom), false)
+ hboxButtons.Append(CreateButton(nil, pbVM, "ping", "PING", runPingClick), false)
+ hboxButtons.Append(CreateButton(nil, pbVM, "Console", "XTERM", runTestExecClick), false)
+ hboxButtons.Append(CreateButton(nil, pbVM, "Save", "SAVE", custom), false)
+ hboxButtons.Append(CreateButton(nil, pbVM, "Done", "DONE", custom), false)
- tab.Append(Data.CurrentVM, vbox)
+ tab.Append(Data.CurrentVM.Name, vbox)
tab.SetMargined(0, true)
}
@@ -138,8 +138,8 @@ func createAddVmBox(tab *ui.Tab, name string, custom func(*ButtonMap)) {
hboxButtons.SetPadded(true)
vbox.Append(hboxButtons, false)
- hboxButtons.Append(CreateButton("Add Virtual Machine", "CREATE", custom), false)
- hboxButtons.Append(CreateButton("Cancel", "DONE", custom), false)
+ hboxButtons.Append(CreateButton(nil, nil, "Add Virtual Machine", "CREATE", custom), false)
+ hboxButtons.Append(CreateButton(nil, nil, "Cancel", "DONE", custom), false)
tab.Append(name, vbox)
tab.SetMargined(0, true)