remove more duplicate code
Signed-off-by: Jeff Carr <jcarr@wit.com>
This commit is contained in:
parent
898b9e27c4
commit
3a204732cd
35
box.go
35
box.go
|
@ -43,7 +43,7 @@ func add(box *GuiBox, newbox *GuiBox) {
|
|||
log.Println("gui.add() END")
|
||||
return
|
||||
}
|
||||
log.Println("gui.add() adding", newbox.Name, "to", box.Name)
|
||||
log.Println("\tgui.add() adding", newbox.Name, "to", box.Name)
|
||||
// copy the box settings over
|
||||
newbox.Window = box.Window
|
||||
box.UiBox.Append(newbox.UiBox, false)
|
||||
|
@ -151,7 +151,8 @@ func AddGenericBox(gw *GuiWindow, name string) *GuiBox {
|
|||
return newbox
|
||||
}
|
||||
|
||||
func CreateGenericBox(gw *GuiWindow, b *GuiButton, name string) *GuiBox{
|
||||
/*
|
||||
func CreateGenericBox(gw *GuiWindow, name string) *GuiBox {
|
||||
log.Println("CreateAddVmBox() START name =", name)
|
||||
|
||||
var box *GuiBox
|
||||
|
@ -171,32 +172,4 @@ func CreateGenericBox(gw *GuiWindow, b *GuiButton, name string) *GuiBox{
|
|||
gw.UiTab.SetMargined(0, true)
|
||||
return box
|
||||
}
|
||||
|
||||
func CreateBox(gw *GuiWindow, name string) *GuiBox {
|
||||
log.Println("CreateVmBox() START")
|
||||
log.Println("CreateVmBox() vm.Name =", name)
|
||||
log.Println("CreateVmBox() gw =", gw)
|
||||
|
||||
var box *GuiBox
|
||||
box = new(GuiBox)
|
||||
|
||||
vbox := ui.NewVerticalBox()
|
||||
vbox.SetPadded(true)
|
||||
log.Println("CreateVmBox() vbox =", vbox)
|
||||
log.Println("CreateVmBox() box.UiBox =", box.UiBox)
|
||||
box.UiBox = vbox
|
||||
log.Println("CreateVmBox() box.Window =", box.Window)
|
||||
box.Window = gw
|
||||
log.Println("CreateVmBox() gw.BoxMap =", gw.BoxMap)
|
||||
gw.BoxMap[name] = box
|
||||
|
||||
hboxAccount := ui.NewHorizontalBox()
|
||||
hboxAccount.SetPadded(true)
|
||||
vbox.Append(hboxAccount, false)
|
||||
|
||||
box.UiBox = hboxAccount
|
||||
|
||||
gw.UiTab.Append(name, vbox)
|
||||
gw.UiTab.SetMargined(0, true)
|
||||
return box
|
||||
}
|
||||
*/
|
||||
|
|
25
misc.go
25
misc.go
|
@ -33,15 +33,16 @@ func ShowMainTabShowBox(gw *GuiWindow, box *GuiBox) {
|
|||
gw.UiTab.SetMargined(0, true)
|
||||
}
|
||||
|
||||
func InitGuiWindow(c *pb.Config, action string, maketab func(*GuiWindow) *GuiBox, uiW *ui.Window, uiT *ui.Tab) *GuiWindow {
|
||||
// func InitGuiWindow(c *pb.Config, action string, maketab func(*GuiWindow) *GuiBox, uiW *ui.Window, uiT *ui.Tab) *GuiWindow {
|
||||
func InitGuiWindow(c *pb.Config, action string, gw *GuiWindow) *GuiWindow {
|
||||
log.Println("InitGuiWindow() START")
|
||||
var newGuiWindow GuiWindow
|
||||
newGuiWindow.Width = int(c.Width)
|
||||
newGuiWindow.Height = int(c.Height)
|
||||
newGuiWindow.Action = action
|
||||
newGuiWindow.MakeWindow = maketab
|
||||
newGuiWindow.UiWindow = uiW
|
||||
newGuiWindow.UiTab = uiT
|
||||
newGuiWindow.MakeWindow = gw.MakeWindow
|
||||
newGuiWindow.UiWindow = gw.UiWindow
|
||||
newGuiWindow.UiTab = gw.UiTab
|
||||
newGuiWindow.BoxMap = make(map[string]*GuiBox)
|
||||
newGuiWindow.EntryMap = make(map[string]*GuiEntry)
|
||||
newGuiWindow.EntryMap["test"] = nil
|
||||
|
@ -52,18 +53,22 @@ func InitGuiWindow(c *pb.Config, action string, maketab func(*GuiWindow) *GuiBox
|
|||
}
|
||||
|
||||
|
||||
func StartNewWindow(c *pb.Config, bg bool, action string, maketab func(*GuiWindow) *GuiBox) {
|
||||
log.Println("InitNewWindow() Create a new window")
|
||||
window := InitGuiWindow(c, action, maketab, nil, nil)
|
||||
func StartNewWindow(c *pb.Config, bg bool, action string, callback func(*GuiWindow) *GuiBox) {
|
||||
log.Println("StartNewWindow() Create a new window")
|
||||
var junk GuiWindow
|
||||
junk.MakeWindow = callback
|
||||
window := InitGuiWindow(c, action, &junk)
|
||||
if (bg) {
|
||||
log.Println("ShowWindow() IN NEW GOROUTINE")
|
||||
log.Println("StartNewWindow() START NEW GOROUTINE for ui.Main()")
|
||||
go ui.Main(func() {
|
||||
log.Println("gui.StartNewWindow() inside ui.Main()")
|
||||
InitTabWindow(window)
|
||||
})
|
||||
time.Sleep(2000 * time.Millisecond)
|
||||
time.Sleep(2000 * time.Millisecond) // this might make it more stable on windows?
|
||||
} else {
|
||||
log.Println("ShowWindow() WAITING for ui.Main()")
|
||||
log.Println("StartNewWindow() WAITING for ui.Main()")
|
||||
ui.Main(func() {
|
||||
log.Println("gui.StartNewWindow() inside ui.Main()")
|
||||
InitTabWindow(window)
|
||||
})
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue