From 34d081f85678010f68620508bdeef8d01db4965e Mon Sep 17 00:00:00 2001 From: Jeff Carr Date: Sun, 26 May 2019 17:28:34 -0700 Subject: [PATCH] experiement with 'show vm' as a window or a tab Signed-off-by: Jeff Carr --- gui.go | 17 ++++++++++------- mainCloudBox.go | 45 ++++++++++++++++++++++++--------------------- structs.go | 1 + 3 files changed, 35 insertions(+), 28 deletions(-) diff --git a/gui.go b/gui.go index 9199eca..8b3b1e0 100644 --- a/gui.go +++ b/gui.go @@ -134,14 +134,16 @@ func mouseClick(b *ButtonMap) { createAddVmBox(Data.cloudTab, "Create New Virtual Machine") return } + /* if (b.Action == "SHOW VM") { Data.CurrentVM = b.VM if (Data.Debug) { go ui.Main(ShowVM) } else { - createVmBox(Data.cloudTab, b.VM) + CreateVmBox(Data.cloudTab, b.VM) } } + */ if (b.Action == "WINDOW CLOSE") { b.W.Hide() // TODO: fix this (seems to crash? maybe because we are in the button here?) @@ -203,12 +205,13 @@ func CreateButton(a *pb.Account, vm *pb.Event_VM, newB.OnClicked(defaultButtonClick) var newmap ButtonMap - newmap.B = newB - newmap.Account = a - newmap.VM = vm - newmap.Action = action - newmap.custom = custom - Data.AllButtons = append(Data.AllButtons, newmap) + newmap.B = newB + newmap.T = Data.cloudTab + newmap.Account = a + newmap.VM = vm + newmap.Action = action + newmap.custom = custom + Data.AllButtons = append(Data.AllButtons, newmap) return newB } diff --git a/mainCloudBox.go b/mainCloudBox.go index 973d510..f474f83 100644 --- a/mainCloudBox.go +++ b/mainCloudBox.go @@ -235,6 +235,10 @@ func makeCloudWindow() { Data.State = "splash" } +func GoShowVM() { + ui.Main(ShowVM) +} + func ShowVM() { name := Data.CurrentVM.Name log.Println("ShowVM() START Data.CurrentVM=", Data.CurrentVM) @@ -259,12 +263,12 @@ func ShowVM() { VMwin.SetChild(VMtab) VMwin.SetMargined(true) - createVmBox(VMtab, Data.CurrentVM) + CreateVmBox(VMtab, Data.CurrentVM) VMwin.Show() } func AddVmConfigureTab(name string, pbVM *pb.Event_VM) { - createVmBox(Data.cloudTab, Data.CurrentVM) + CreateVmBox(Data.cloudTab, Data.CurrentVM) } // makeEntryBox(box, "hostname:", "blah.foo.org") { @@ -312,12 +316,12 @@ func makeEntryHbox(hbox *ui.Box, a string, b string, edit bool) { // End 'Nickname' vertical box } -func createVmBox(tab *ui.Tab, pbVM *pb.Event_VM) { - log.Println("createVmBox() START") - log.Println("createVmBox() pbVM.Name", pbVM.Name) - spew.Dump(pbVM) +func CreateVmBox(tab *ui.Tab, vm *pb.Event_VM) { + log.Println("CreateVmBox() START") + log.Println("CreateVmBox() vm.Name", vm.Name) + spew.Dump(vm) if (Data.Debug) { - spew.Dump(pbVM) + spew.Dump(vm) } vbox := ui.NewVerticalBox() vbox.SetPadded(true) @@ -327,12 +331,12 @@ func createVmBox(tab *ui.Tab, pbVM *pb.Event_VM) { vbox.Append(hboxAccount, false) // Add hostname entry box - makeEntryVbox(hboxAccount, "hostname:", pbVM.Hostname, true) - makeEntryVbox(hboxAccount, "IPv6:", pbVM.IPv6, true) - makeEntryVbox(hboxAccount, "RAM:", fmt.Sprintf("%d",pbVM.Memory), true) - makeEntryVbox(hboxAccount, "CPU:", fmt.Sprintf("%d",pbVM.Cpus), true) - makeEntryVbox(hboxAccount, "Disk (GB):", fmt.Sprintf("%d",pbVM.Disk), true) - makeEntryVbox(hboxAccount, "OS Image:", pbVM.BaseImage, true) + makeEntryVbox(hboxAccount, "hostname:", vm.Hostname, true) + makeEntryVbox(hboxAccount, "IPv6:", vm.IPv6, true) + makeEntryVbox(hboxAccount, "RAM:", fmt.Sprintf("%d",vm.Memory), true) + makeEntryVbox(hboxAccount, "CPU:", fmt.Sprintf("%d",vm.Cpus), true) + makeEntryVbox(hboxAccount, "Disk (GB):", fmt.Sprintf("%d",vm.Disk), true) + makeEntryVbox(hboxAccount, "OS Image:", vm.BaseImage, true) vbox.Append(ui.NewHorizontalSeparator(), false) @@ -340,14 +344,13 @@ func createVmBox(tab *ui.Tab, pbVM *pb.Event_VM) { hboxButtons.SetPadded(true) vbox.Append(hboxButtons, false) - log.Println("pbVM =", pbVM) - hboxButtons.Append(CreateButton(nil, pbVM, "Power On", "POWERON", nil), false) - hboxButtons.Append(CreateButton(nil, pbVM, "Power Off", "POWEROFF", nil), false) - hboxButtons.Append(CreateButton(nil, pbVM, "Destroy", "DESTROY", nil), 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", nil), false) - hboxButtons.Append(CreateButton(nil, pbVM, "Done", "DONE", nil), false) + hboxButtons.Append(CreateButton(nil, vm, "Power On", "POWERON", nil), false) + hboxButtons.Append(CreateButton(nil, vm, "Power Off", "POWEROFF", nil), false) + hboxButtons.Append(CreateButton(nil, vm, "Destroy", "DESTROY", nil), false) + hboxButtons.Append(CreateButton(nil, vm, "ping", "PING", runPingClick), false) + hboxButtons.Append(CreateButton(nil, vm, "Console", "XTERM", runTestExecClick), false) + hboxButtons.Append(CreateButton(nil, vm, "Save", "SAVE", nil), false) + hboxButtons.Append(CreateButton(nil, vm, "Done", "DONE", nil), false) tab.Append(Data.CurrentVM.Name, vbox) tab.SetMargined(0, true) diff --git a/structs.go b/structs.go index b5377ee..d28d3c9 100644 --- a/structs.go +++ b/structs.go @@ -102,6 +102,7 @@ type ButtonMap struct { FB *ui.FontButton A *ui.Area W *ui.Window + T *ui.Tab Account *pb.Account VM *pb.Event_VM