start a window for errors to fix

Signed-off-by: Jeff Carr <jcarr@wit.com>
This commit is contained in:
Jeff Carr 2024-01-07 09:52:20 -06:00
parent 9b4d2d9a08
commit 16767ac97f
6 changed files with 59 additions and 43 deletions

17
fix.go
View File

@ -9,6 +9,21 @@ import (
func fix() bool { func fix() bool {
log.Log(CHANGE, "") log.Log(CHANGE, "")
// make and toggle the fixWindow display
if me.fixWindow == nil {
me.fixWindow = smartwindow.New()
me.fixWindow.SetParent(me.myGui)
me.fixWindow.Title("fix window")
me.fixWindow.SetDraw(drawFixWindow)
me.fixWindow.Make()
me.fixWindow.Draw()
me.fixWindow.Hide()
// me.fixWindow.Draw2()
return false
}
me.fixWindow.Toggle()
if ! me.statusDNS.Ready() { if ! me.statusDNS.Ready() {
log.Log(CHANGE, "The IPv6 Control Panel is not Ready() yet") log.Log(CHANGE, "The IPv6 Control Panel is not Ready() yet")
return false return false
@ -148,4 +163,6 @@ func addToFixWindow(t string, ip string) {
func drawFixWindow(sw *smartwindow.SmartWindow) { func drawFixWindow(sw *smartwindow.SmartWindow) {
log.Log(WARN, "drawFixWindow() START") log.Log(WARN, "drawFixWindow() START")
box := sw.Box()
box.NewLabel("test")
} }

View File

@ -8,17 +8,15 @@ import (
) )
func (sw *SmartWindow) Ready() bool { func (sw *SmartWindow) Ready() bool {
log.Log(WARN, "Ready() maybe not ready? sw =", sw) log.Log(INFO, "Ready() START")
if sw == nil {return false}
if sw == nil {return false} if sw == nil {return false}
if sw.window == nil {return false} if sw.window == nil {return false}
log.Log(INFO, "Ready() END sw.ready =", sw.ready)
return sw.ready return sw.ready
} }
func (sw *SmartWindow) Initialized() bool { func (sw *SmartWindow) Initialized() bool {
log.Log(WARN, "checking Initialized()") log.Log(INFO, "checking Initialized()")
if sw == nil {return false} if sw == nil {return false}
if sw == nil {return false}
if sw.parent == nil {return false}
return true return true
} }

View File

@ -2,8 +2,6 @@ package smartwindow
import ( import (
"go.wit.com/log" "go.wit.com/log"
"go.wit.com/gui/gadgets"
) )
func New() *SmartWindow { func New() *SmartWindow {
@ -25,8 +23,4 @@ func (sw *SmartWindow) InitWindow() {
sw.ready = true sw.ready = true
return return
} }
log.Log(WARN, "Creating the Window")
sw.window = gadgets.NewBasicWindow(sw.parent, sw.title)
sw.ready = true
} }

View File

@ -55,5 +55,24 @@ func (sw *SmartWindow) Toggle() {
func (sw *SmartWindow) Box() *gui.Node { func (sw *SmartWindow) Box() *gui.Node {
if ! sw.Ready() {return nil} if ! sw.Ready() {return nil}
return sw.window.Box() return sw.box
}
func (sw *SmartWindow) Draw() {
if ! sw.Ready() {return}
log.Log(WARN, "Draw() window ready")
sw.window.Draw()
if sw.vertical {
sw.box = sw.window.NewBox("bw vbox", false)
log.Log(WARN, "BasicWindow.Custom() made vbox")
} else {
sw.box = sw.window.NewBox("bw hbox", true)
log.Log(WARN, "BasicWindow.Custom() made hbox")
}
if (sw.populate != nil) {
log.Log(WARN, "Make() trying to run Custom sw.populate() here")
sw.populate(sw)
}
} }

View File

@ -36,49 +36,37 @@ func (sw *SmartWindow) SetParent(p *gui.Node) {
} }
func (sw *SmartWindow) SetDraw(f func(*SmartWindow)) { func (sw *SmartWindow) SetDraw(f func(*SmartWindow)) {
if ! sw.Initialized() {return} log.Log(WARN, "SetDraw() START")
if sw.Ready() {return} if ! sw.Initialized() {
log.Log(WARN, "SetDraw() Failed. sw.Initialized == false")
return
}
if sw.Ready() {
log.Log(WARN, "SetDraw() Failed. sw.Ready() == true")
return
}
sw.populate = f sw.populate = f
log.Log(WARN, "SetDraw() END sw.populate is set")
} }
func (sw *SmartWindow) Make() { func (sw *SmartWindow) Make() {
if ! sw.Initialized() {return} if ! sw.Initialized() {return}
if sw.Ready() {return} if sw.Ready() {return}
log.Log(WARN, "Make() START")
log.Log(WARN, "Make() window ready =", sw.ready) sw.window = sw.parent.RawWindow(sw.title)
sw.window.Make() sw.window.Custom = func() {
if (sw.populate != nil) { log.Warn("BasicWindow.Custom() closed. TODO: handle this", sw.title)
log.Log(WARN, "Make() trying to run Custom sw.populate() here")
sw.populate(sw)
} }
log.Log(WARN, "Make() END sw.window = RawWindow() (not sent to toolkits)")
sw.ready = true sw.ready = true
} }
func (sw *SmartWindow) Draw() {
if ! sw.Initialized() {return}
if sw.Ready() {return}
log.Log(WARN, "Draw() window ready =", sw.ready)
sw.window.Draw()
if (sw.populate != nil) {
log.Log(WARN, "Make() trying to run Custom sw.populate() here")
sw.populate(sw)
}
sw.ready = true
}
func (sw *SmartWindow) Vertical() { func (sw *SmartWindow) Vertical() {
if ! sw.Initialized() {return} if ! sw.Initialized() {return}
if sw.Ready() {return} if sw.Ready() {return}
log.Log(WARN, "Draw() window ready =", sw.ready) log.Log(WARN, "Vertical() setting vertical = true")
sw.window.Draw() sw.vertical = true
if (sw.populate != nil) {
log.Log(WARN, "Make() trying to run Custom sw.populate() here")
sw.populate(sw)
}
sw.ready = true
} }

View File

@ -2,19 +2,19 @@ package smartwindow
import ( import (
"go.wit.com/gui/gui" "go.wit.com/gui/gui"
"go.wit.com/gui/gadgets"
) )
type SmartWindow struct { type SmartWindow struct {
ready bool // track if the window is ready ready bool // track if the window is ready
hidden bool // track if the window is hidden from the toolkits hidden bool // track if the window is hidden from the toolkits
changed bool // track if something changed in the window changed bool // track if something changed in the window
vertical bool
title string // what the user sees as the name title string // what the user sees as the name
name string // the programatic name aka: "CALANDAR" name string // the programatic name aka: "CALANDAR"
parent *gui.Node // where to place the window if you try to draw it parent *gui.Node // where to place the window if you try to draw it
window *gadgets.BasicWindow // the underlying BasicWindow window *gui.Node // the underlying window
box *gui.Node // the box inside the window // get this from BasicWindow() ? box *gui.Node // the box inside the window // get this from BasicWindow() ?
populate func(*SmartWindow) // the function to generate the widgets populate func(*SmartWindow) // the function to generate the widgets