diff --git a/gui.go b/gui.go index ec5688f..45b61f3 100644 --- a/gui.go +++ b/gui.go @@ -10,6 +10,8 @@ import pb "git.wit.com/wit/witProtobuf" import "github.com/davecgh/go-spew/spew" +// THIS IS CLEAN (all that is left is the 'createAddVmBox') + func InitColumns(mh *TableData, parts []TableColumnData) { tmpBTindex := 0 humanID := 0 @@ -284,3 +286,34 @@ func SetText(box *GuiBox, name string, value string) error { log.Println("gui.SetText() END") return nil } + +// makeEntryBox(box, "hostname:", "blah.foo.org") { +func MakeEntryVbox(box *GuiBox, a string, startValue string, edit bool, action string) *GuiEntry { + // Start 'Nickname' vertical box + vboxN := ui.NewVerticalBox() + vboxN.SetPadded(true) + vboxN.Append(ui.NewLabel(a), false) + + e := defaultMakeEntry(startValue, edit, action) + + vboxN.Append(e.UiEntry, false) + box.UiBox.Append(vboxN, false) + // End 'Nickname' vertical box + + return e +} + +func MakeEntryHbox(box *GuiBox, a string, startValue string, edit bool, action string) *GuiEntry { + // Start 'Nickname' vertical box + hboxN := ui.NewHorizontalBox() + hboxN.SetPadded(true) + hboxN.Append(ui.NewLabel(a), false) + + e := defaultMakeEntry(startValue, edit, action) + hboxN.Append(e.UiEntry, false) + + box.UiBox.Append(hboxN, false) + // End 'Nickname' vertical box + + return e +} diff --git a/mainCloudBox.go b/mainCloudBox.go index 6f5d971..86a04cd 100644 --- a/mainCloudBox.go +++ b/mainCloudBox.go @@ -249,20 +249,9 @@ func InitWindow(gw *GuiWindow) { gw.UiWindow.Show() } -// makeEntryBox(box, "hostname:", "blah.foo.org") { -func makeEntryVbox(hbox *ui.Box, a string, startValue string, edit bool, action string) *GuiEntry { - // Start 'Nickname' vertical box - vboxN := ui.NewVerticalBox() - vboxN.SetPadded(true) - vboxN.Append(ui.NewLabel(a), false) - - e := defaultMakeEntry(startValue, edit, action) - - vboxN.Append(e.UiEntry, false) - hbox.Append(vboxN, false) - // End 'Nickname' vertical box - - return e +func AddBoxToTab(name string, tab *ui.Tab, box *ui.Box) { + tab.Append(name, box) + tab.SetMargined(0, true) } /* @@ -341,7 +330,24 @@ func defaultMakeEntry(startValue string, edit bool, action string) *GuiEntry { return &newEntry } -func makeEntryHbox(hbox *ui.Box, a string, startValue string, edit bool, action string) *GuiEntry { +/* +// makeEntryBox(box, "hostname:", "blah.foo.org") { +func makeEntryVbox(box *GuiBox, a string, startValue string, edit bool, action string) *GuiEntry { + // Start 'Nickname' vertical box + vboxN := ui.NewVerticalBox() + vboxN.SetPadded(true) + vboxN.Append(ui.NewLabel(a), false) + + e := defaultMakeEntry(startValue, edit, action) + + vboxN.Append(e.UiEntry, false) + box.UiBox.Append(vboxN, false) + // End 'Nickname' vertical box + + return e +} + +func makeEntryHbox(box *GuiBox, a string, startValue string, edit bool, action string) *GuiEntry { // Start 'Nickname' vertical box hboxN := ui.NewHorizontalBox() hboxN.SetPadded(true) @@ -350,13 +356,9 @@ func makeEntryHbox(hbox *ui.Box, a string, startValue string, edit bool, action e := defaultMakeEntry(startValue, edit, action) hboxN.Append(e.UiEntry, false) - hbox.Append(hboxN, false) + box.UiBox.Append(hboxN, false) // End 'Nickname' vertical box return e } - -func AddBoxToTab(name string, tab *ui.Tab, box *ui.Box) { - tab.Append(name, box) - tab.SetMargined(0, true) -} +*/ diff --git a/vmBox.go b/vmBox.go index 6e6b960..bb5bd69 100644 --- a/vmBox.go +++ b/vmBox.go @@ -36,13 +36,15 @@ func CreateVmBox(gw *GuiWindow, vm *pb.Event_VM) { hboxAccount.SetPadded(true) vbox.Append(hboxAccount, false) + box.UiBox = hboxAccount + // Add hostname entry box - makeEntryVbox(hboxAccount, "hostname:", vm.Hostname, true, "Hostname") - makeEntryVbox(hboxAccount, "IPv6:", vm.IPv6, true, "IPv6") - makeEntryVbox(hboxAccount, "RAM:", fmt.Sprintf("%d",vm.Memory), true, "Memory") - makeEntryVbox(hboxAccount, "CPU:", fmt.Sprintf("%d",vm.Cpus), true, "Cpus") - makeEntryVbox(hboxAccount, "Disk (GB):",fmt.Sprintf("%d",vm.Disk), true, "Disk") - makeEntryVbox(hboxAccount, "OS Image:", vm.BaseImage, true, "BaseImage") + MakeEntryVbox(box, "hostname:", vm.Hostname, true, "Hostname") + MakeEntryVbox(box, "IPv6:", vm.IPv6, true, "IPv6") + MakeEntryVbox(box, "RAM:", fmt.Sprintf("%d",vm.Memory), true, "Memory") + MakeEntryVbox(box, "CPU:", fmt.Sprintf("%d",vm.Cpus), true, "Cpus") + MakeEntryVbox(box, "Disk (GB):",fmt.Sprintf("%d",vm.Disk), true, "Disk") + MakeEntryVbox(box, "OS Image:", vm.BaseImage, true, "BaseImage") vbox.Append(ui.NewHorizontalSeparator(), false) @@ -86,9 +88,9 @@ func createAddVmBox(gw *GuiWindow, b *GuiButton) { vbox.Append(hbox, false) // Add hostname entry box - hostname := makeEntryHbox(vbox, "Hostname:", "testhost", true, "Hostname") - memory := makeEntryHbox(vbox, "Memory:", "512", true, "Memory") - disk := makeEntryHbox(vbox, "Disk:", "20", true, "Disk") + hostname := MakeEntryHbox(box, "Hostname:", "testhost", true, "Hostname") + memory := MakeEntryHbox(box, "Memory:", "512", true, "Memory") + disk := MakeEntryHbox(box, "Disk:", "20", true, "Disk") log.Println("createAddVmBox() hostname, memory, disk =", hostname, memory, disk)