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")
|
log.Println("gui.add() END")
|
||||||
return
|
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
|
// copy the box settings over
|
||||||
newbox.Window = box.Window
|
newbox.Window = box.Window
|
||||||
box.UiBox.Append(newbox.UiBox, false)
|
box.UiBox.Append(newbox.UiBox, false)
|
||||||
|
@ -151,7 +151,8 @@ func AddGenericBox(gw *GuiWindow, name string) *GuiBox {
|
||||||
return newbox
|
return newbox
|
||||||
}
|
}
|
||||||
|
|
||||||
func CreateGenericBox(gw *GuiWindow, b *GuiButton, name string) *GuiBox{
|
/*
|
||||||
|
func CreateGenericBox(gw *GuiWindow, name string) *GuiBox {
|
||||||
log.Println("CreateAddVmBox() START name =", name)
|
log.Println("CreateAddVmBox() START name =", name)
|
||||||
|
|
||||||
var box *GuiBox
|
var box *GuiBox
|
||||||
|
@ -171,32 +172,4 @@ func CreateGenericBox(gw *GuiWindow, b *GuiButton, name string) *GuiBox{
|
||||||
gw.UiTab.SetMargined(0, true)
|
gw.UiTab.SetMargined(0, true)
|
||||||
return box
|
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)
|
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")
|
log.Println("InitGuiWindow() START")
|
||||||
var newGuiWindow GuiWindow
|
var newGuiWindow GuiWindow
|
||||||
newGuiWindow.Width = int(c.Width)
|
newGuiWindow.Width = int(c.Width)
|
||||||
newGuiWindow.Height = int(c.Height)
|
newGuiWindow.Height = int(c.Height)
|
||||||
newGuiWindow.Action = action
|
newGuiWindow.Action = action
|
||||||
newGuiWindow.MakeWindow = maketab
|
newGuiWindow.MakeWindow = gw.MakeWindow
|
||||||
newGuiWindow.UiWindow = uiW
|
newGuiWindow.UiWindow = gw.UiWindow
|
||||||
newGuiWindow.UiTab = uiT
|
newGuiWindow.UiTab = gw.UiTab
|
||||||
newGuiWindow.BoxMap = make(map[string]*GuiBox)
|
newGuiWindow.BoxMap = make(map[string]*GuiBox)
|
||||||
newGuiWindow.EntryMap = make(map[string]*GuiEntry)
|
newGuiWindow.EntryMap = make(map[string]*GuiEntry)
|
||||||
newGuiWindow.EntryMap["test"] = nil
|
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) {
|
func StartNewWindow(c *pb.Config, bg bool, action string, callback func(*GuiWindow) *GuiBox) {
|
||||||
log.Println("InitNewWindow() Create a new window")
|
log.Println("StartNewWindow() Create a new window")
|
||||||
window := InitGuiWindow(c, action, maketab, nil, nil)
|
var junk GuiWindow
|
||||||
|
junk.MakeWindow = callback
|
||||||
|
window := InitGuiWindow(c, action, &junk)
|
||||||
if (bg) {
|
if (bg) {
|
||||||
log.Println("ShowWindow() IN NEW GOROUTINE")
|
log.Println("StartNewWindow() START NEW GOROUTINE for ui.Main()")
|
||||||
go ui.Main(func() {
|
go ui.Main(func() {
|
||||||
|
log.Println("gui.StartNewWindow() inside ui.Main()")
|
||||||
InitTabWindow(window)
|
InitTabWindow(window)
|
||||||
})
|
})
|
||||||
time.Sleep(2000 * time.Millisecond)
|
time.Sleep(2000 * time.Millisecond) // this might make it more stable on windows?
|
||||||
} else {
|
} else {
|
||||||
log.Println("ShowWindow() WAITING for ui.Main()")
|
log.Println("StartNewWindow() WAITING for ui.Main()")
|
||||||
ui.Main(func() {
|
ui.Main(func() {
|
||||||
|
log.Println("gui.StartNewWindow() inside ui.Main()")
|
||||||
InitTabWindow(window)
|
InitTabWindow(window)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue