1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
|
package gui
import "log"
import "github.com/andlabs/ui"
import _ "github.com/andlabs/ui/winmanifest"
func ShowVM() {
name := Data.CurrentVM
log.Println("ShowVM() START Data.CurrentVM=", Data.CurrentVM)
VMwin := ui.NewWindow("VM " + name, 500, 300, false)
VMwin.OnClosing(func(*ui.Window) bool {
return true
})
ui.OnShouldQuit(func() bool {
VMwin.Destroy()
VMwin = nil
return true
})
VMtab := ui.NewTab()
VMwin.SetChild(VMtab)
VMwin.SetMargined(true)
createVmBox(VMtab, buttonVmClick)
// vmBox := createVmBox(buttonVmClick)
// VMtab.Append(Data.CurrentVM, vmBox)
// VMtab.SetMargined(0, true)
VMwin.Show()
}
func AddVmConfigureTab(name string) {
createVmBox(Data.cloudTab, buttonVmClick)
// vmBox := createVmBox(Data.cloudTab, buttonVmClick)
// Data.cloudTab.Append(name, vmBox)
// Data.cloudTab.SetMargined(0, true)
}
func createVmBox(tab *ui.Tab, custom func(b *ButtonMap,s string)) {
vbox := ui.NewVerticalBox()
vbox.SetPadded(true)
hboxAccount := ui.NewHorizontalBox()
hboxAccount.SetPadded(true)
vbox.Append(hboxAccount, false)
// Start 'Provider' vertical box
vboxC := ui.NewVerticalBox()
vboxC.SetPadded(true)
vboxC.Append(ui.NewLabel("Cloud Provider:"), false)
cbox := ui.NewCombobox()
cbox.Append("WIT")
cbox.Append("Evocative")
vboxC.Append(cbox, false)
cbox.SetSelected(0)
cbox.OnSelected(func(*ui.Combobox) {
log.Println("OK. Selected Cloud Provider =", cbox.Selected())
})
hboxAccount.Append(vboxC, false)
// End 'Cloud Provider' vertical box
// Start 'Region' vertical box
vboxR := ui.NewVerticalBox()
vboxR.SetPadded(true)
vboxR.Append(ui.NewLabel("Region:"), false)
regbox := ui.NewCombobox()
regbox.Append("Any")
regbox.Append("SF")
vboxR.Append(regbox, false)
regbox.SetSelected(0)
regbox.OnSelected(func(*ui.Combobox) {
log.Println("OK. Selected something =", regbox.Selected())
})
hboxAccount.Append(vboxR, false)
// End 'Region' vertical box
// Start 'Nickname' vertical box
vboxN := ui.NewVerticalBox()
vboxN.SetPadded(true)
vboxN.Append(ui.NewLabel("Account Nickname:"), false)
entryNick := ui.NewEntry()
entryNick.SetReadOnly(false)
vboxN.Append(entryNick, false)
entryNick.OnChanged(func(*ui.Entry) {
log.Println("OK. nickname =", entryNick.Text())
Data.AccNick = entryNick.Text()
})
hboxAccount.Append(vboxN, false)
// End 'Nickname' vertical box
// Start 'Username' vertical box
vboxU := ui.NewVerticalBox()
vboxU.SetPadded(true)
vboxU.Append(ui.NewLabel("Account Username:"), false)
entryUser := ui.NewEntry()
entryUser.SetReadOnly(false)
vboxU.Append(entryUser, false)
entryUser.OnChanged(func(*ui.Entry) {
log.Println("OK. username =", entryUser.Text())
Data.AccUser = entryUser.Text()
})
hboxAccount.Append(vboxU, false)
// End 'Username' vertical box
// Start 'Password' vertical box
vboxP := ui.NewVerticalBox()
vboxP.SetPadded(true)
vboxP.Append(ui.NewLabel("Account Password:"), false)
entryPass := ui.NewEntry()
entryPass.SetReadOnly(false)
vboxP.Append(entryPass, false)
entryPass.OnChanged(func(*ui.Entry) {
log.Println("OK. password =", entryPass.Text())
Data.AccPass = entryPass.Text()
})
hboxAccount.Append(vboxP, false)
// End 'Password' vertical box
vbox.Append(ui.NewHorizontalSeparator(), false)
hboxButtons := ui.NewHorizontalBox()
hboxButtons.SetPadded(true)
vbox.Append(hboxButtons, false)
okButton := CreateButton("Add Account", "ADD", custom)
hboxButtons.Append(okButton, false)
backButton := CreateButton("Back", "BACK", custom)
hboxButtons.Append(backButton, false)
hboxButtons.Append(CreateButton("Power On", "POWERON", custom), false)
hboxButtons.Append(CreateButton("Power Off", "POWEROFF", custom), false)
hboxButtons.Append(CreateButton("Destroy", "DESTROY", custom), false)
tab.Append(Data.CurrentVM, vbox)
tab.SetMargined(0, true)
}
func buttonVmClick(b *ButtonMap, s string) {
log.Println("gui.buttonVmClick() START")
if (Data.MouseClick != nil) {
log.Println("Data.ButtonClick() START")
Data.MouseClick(nil)
}
}
|