make custom buttons for the account sockets

Signed-off-by: Jeff Carr <jcarr@wit.com>
This commit is contained in:
Jeff Carr 2019-05-23 17:44:00 -07:00
parent cdf7ee0962
commit e00e6670ed
2 changed files with 24 additions and 6 deletions

21
gui.go
View File

@ -66,6 +66,7 @@ type ButtonMap struct {
custom func (int, string) custom func (int, string)
Name string // the text on the button Name string // the text on the button
Note string // what type of button Note string // what type of button
AccNick string // what account this button is for
} }
/* /*
@ -182,8 +183,10 @@ func defaultButtonClick(button *ui.Button) {
} else if Data.allButtons[key].custom != nil { } else if Data.allButtons[key].custom != nil {
Data.allButtons[key].custom(42, "BUTTON DOES NOTHING") Data.allButtons[key].custom(42, "BUTTON DOES NOTHING")
} }
return
} }
} }
log.Println("\tBUTTON NOT FOUND")
} }
func defaultFontButtonClick(button *ui.FontButton) { func defaultFontButtonClick(button *ui.FontButton) {
@ -208,6 +211,23 @@ func CreateButton(name string, note string, custom func(int, string)) *ui.Button
return newB return newB
} }
func CreateAccountButton(account string, custom func(int, string)) *ui.Button {
name := "Show " + account
newB := ui.NewButton(name)
newB.OnClicked(defaultButtonClick)
var newmap ButtonMap
newmap.B = newB
newmap.Note = "SHOW"
newmap.Name = name
newmap.AccNick = account
newmap.custom = custom
Data.allButtons = append(Data.allButtons, newmap)
return newB
}
func CreateFontButton(name string, note string, custom func(int, string)) *ui.FontButton { func CreateFontButton(name string, note string, custom func(int, string)) *ui.FontButton {
newB := ui.NewFontButton() newB := ui.NewFontButton()
@ -216,7 +236,6 @@ func CreateFontButton(name string, note string, custom func(int, string)) *ui.Fo
var newmap ButtonMap var newmap ButtonMap
newmap.FB = newB newmap.FB = newB
newmap.Note = note newmap.Note = note
newmap.Name = name
newmap.custom = custom newmap.custom = custom
Data.allButtons = append(Data.allButtons, newmap) Data.allButtons = append(Data.allButtons, newmap)

View File

@ -83,11 +83,10 @@ func makeCloudInfoBox(custom func(int, string)) *ui.Box {
agrid.Append(ui.NewLabel(account), 1, row, 1, 1, true, ui.AlignFill, false, ui.AlignFill) agrid.Append(ui.NewLabel(account), 1, row, 1, 1, true, ui.AlignFill, false, ui.AlignFill)
agrid.Append(ui.NewLabel(username), 2, row, 1, 1, true, ui.AlignFill, false, ui.AlignFill) agrid.Append(ui.NewLabel(username), 2, row, 1, 1, true, ui.AlignFill, false, ui.AlignFill)
agrid.Append(ui.NewLabel(domainname), 3, row, 1, 1, true, ui.AlignFill, false, ui.AlignFill) agrid.Append(ui.NewLabel(domainname), 3, row, 1, 1, true, ui.AlignFill, false, ui.AlignFill)
bname := "Open " + account
b := CreateButton(bname, "SHOW", custom) b := CreateAccountButton(account, custom)
agrid.Append(b, 4, row, 1, 1, true, ui.AlignFill, false, ui.AlignFill) agrid.Append(b, 4, row, 1, 1, true, ui.AlignFill, false, ui.AlignFill)
// vbox.Append(ui.NewLabel(a), false)
row += 1 row += 1
} }
@ -135,7 +134,7 @@ func addTableTab() {
AddTableTab(Data.cloudTab, 1, "test seven", 7, parts) AddTableTab(Data.cloudTab, 1, "test seven", 7, parts)
} }
func AddVmsTab(count int) *TableData { func AddVmsTab(name string, count int) *TableData {
var parts []TableColumnData var parts []TableColumnData
human := 0 human := 0
@ -189,7 +188,7 @@ func AddVmsTab(count int) *TableData {
parts = append(parts, tmp) parts = append(parts, tmp)
human += 1 human += 1
mh := AddTableTab(Data.cloudTab, 1, "Virtual Machines", count, parts) mh := AddTableTab(Data.cloudTab, 1, name, count, parts)
return mh return mh
} }