works in sierpinski carpet mode

Signed-off-by: Jeff Carr <jcarr@wit.com>
This commit is contained in:
Jeff Carr 2024-01-06 13:55:46 -06:00
parent f6f5bdba4e
commit a8f4ba1b05
4 changed files with 36 additions and 17 deletions

View File

@ -6,10 +6,17 @@ import (
"go.wit.com/gui/gui" "go.wit.com/gui/gui"
) )
func (ls *LinuxStatus) Draw() { func (ls *LinuxStatus) Make() {
log.Log(CHANGE, "linuxStatus.Draw() window") log.Log(CHANGE, "Draw() window")
if ! ls.Ready() {return} if ! ls.Ready() {return}
log.Log(CHANGE, "linuxStatus.Draw() window ready =", ls.ready) log.Log(CHANGE, "Draw() window ready =", ls.ready)
ls.window.Make()
ls.ready = true
}
func (ls *LinuxStatus) Draw() {
log.Log(CHANGE, "Draw() window")
if ! ls.Ready() {return}
log.Log(CHANGE, "Draw() window ready =", ls.ready)
ls.window.Draw() ls.window.Draw()
ls.ready = true ls.ready = true
} }
@ -21,25 +28,25 @@ func (ls *LinuxStatus) Draw2() {
} }
func (ls *LinuxStatus) Show() { func (ls *LinuxStatus) Show() {
log.Log(CHANGE, "linuxStatus.Show() window") log.Log(CHANGE, "Show() window")
if ! ls.Ready() {return} if ! ls.Ready() {return}
log.Log(CHANGE, "linuxStatus.Show() window ready =", ls.ready) log.Log(CHANGE, "Show() window ready =", ls.ready)
ls.window.Show() ls.window.Show()
ls.hidden = false ls.hidden = false
} }
func (ls *LinuxStatus) Hide() { func (ls *LinuxStatus) Hide() {
log.Log(CHANGE, "linuxStatus.Hide() window") log.Log(CHANGE, "Hide() window")
if ! ls.Ready() {return} if ! ls.Ready() {return}
log.Log(CHANGE, "linuxStatus.Hide() window ready =", ls.ready) log.Log(CHANGE, "Hide() window ready =", ls.ready)
ls.window.Hide() ls.window.Hide()
ls.hidden = true ls.hidden = true
} }
func (ls *LinuxStatus) Toggle() { func (ls *LinuxStatus) Toggle() {
log.Log(CHANGE, "linuxStatus.Toggle() window") log.Log(CHANGE, "Toggle() window")
if ! ls.Ready() {return} if ! ls.Ready() {return}
log.Log(CHANGE, "linuxStatus.Toggle() window ready =", ls.ready) log.Log(CHANGE, "Toggle() window ready =", ls.ready)
if ls.hidden { if ls.hidden {
ls.Show() ls.Show()
} else { } else {
@ -48,7 +55,7 @@ func (ls *LinuxStatus) Toggle() {
} }
func (ls *LinuxStatus) Ready() bool { func (ls *LinuxStatus) Ready() bool {
log.Log(CHANGE, "Ready() ls =", ls) log.Log(CHANGE, "Ready()")
if me == nil {return false} if me == nil {return false}
if ls == nil {return false} if ls == nil {return false}
if ls.window == nil {return false} if ls.window == nil {return false}
@ -56,7 +63,7 @@ func (ls *LinuxStatus) Ready() bool {
} }
func (ls *LinuxStatus) Initialized() bool { func (ls *LinuxStatus) Initialized() bool {
log.Log(CHANGE, "checking Initialized() ls =", ls) log.Log(CHANGE, "checking Initialized()")
if me == nil {return false} if me == nil {return false}
if ls == nil {return false} if ls == nil {return false}
if ls.parent == nil {return false} if ls.parent == nil {return false}
@ -64,7 +71,7 @@ func (ls *LinuxStatus) Initialized() bool {
} }
func (ls *LinuxStatus) SetParent(p *gui.Node) { func (ls *LinuxStatus) SetParent(p *gui.Node) {
log.Log(CHANGE, "Attempting SetParent =", p) log.Log(CHANGE, "Attempting SetParent")
if me == nil {return} if me == nil {return}
if ls == nil {return} if ls == nil {return}
if ls.parent == nil { if ls.parent == nil {

View File

@ -14,6 +14,11 @@ import (
func (ls *LinuxStatus) GetDomainName() string { func (ls *LinuxStatus) GetDomainName() string {
if ! me.Ready() {return ""} if ! me.Ready() {return ""}
if me.window == nil {
log.Log(NOW, "me.window == nil")
} else {
log.Log(NOW, "me.window exists, but has not been drawn")
}
return me.domainname.Get() return me.domainname.Get()
} }
@ -22,7 +27,8 @@ func (ls *LinuxStatus) setDomainName(dn string) {
me.domainname.Set(dn) me.domainname.Set(dn)
} }
func getHostname() { func lookupHostname() {
if ! me.Ready() {return}
var err error var err error
var s string = "gui.Label == nil" var s string = "gui.Label == nil"
s, err = fqdn.FqdnHostname() s, err = fqdn.FqdnHostname()
@ -33,6 +39,12 @@ func getHostname() {
log.Error(errors.New("full hostname should be: " + s)) log.Error(errors.New("full hostname should be: " + s))
dn := run("domainname") dn := run("domainname")
if me.window == nil {
log.Log(NOW, "me.window == nil")
} else {
log.Log(NOW, "me.window exists, but has not been drawn")
log.Log(NOW, "me.window.Draw() =")
}
if (me.domainname.Get() != dn) { if (me.domainname.Get() != dn) {
log.Log(CHANGE, "domainname has changed from", me.GetDomainName(), "to", dn) log.Log(CHANGE, "domainname has changed from", me.GetDomainName(), "to", dn)
me.setDomainName(dn) me.setDomainName(dn)

View File

@ -14,7 +14,7 @@ import (
func linuxLoop() { func linuxLoop() {
me.changed = false me.changed = false
duration := timeFunction(getHostname) duration := timeFunction(lookupHostname)
log.Log(INFO, "getHostname() execution Time: ", duration, "me.changed =", me.changed) log.Log(INFO, "getHostname() execution Time: ", duration, "me.changed =", me.changed)
duration = timeFunction(scanInterfaces) duration = timeFunction(scanInterfaces)

View File

@ -10,7 +10,7 @@ import (
func (ls *LinuxStatus) Update() { func (ls *LinuxStatus) Update() {
if ! ls.Ready() { if ! ls.Ready() {
log.Warn("can't update yet. ready is false") log.Log(WARN, "can't update yet. ready is false")
log.Error(errors.New("Update() is not ready yet")) log.Error(errors.New("Update() is not ready yet"))
return return
} }
@ -19,13 +19,13 @@ func (ls *LinuxStatus) Update() {
linuxLoop() linuxLoop()
}) })
ls.SetSpeed(duration) ls.SetSpeed(duration)
log.Info("linuxStatus() Update() END") log.Log(INFO, "Update() END")
} }
func (ls *LinuxStatus) SetSpeed(duration time.Duration) { func (ls *LinuxStatus) SetSpeed(duration time.Duration) {
s := fmt.Sprint(duration) s := fmt.Sprint(duration)
if ls.speedActual == nil { if ls.speedActual == nil {
log.Warn("can't actually warn") log.Log(WARN, "can't actually warn")
return return
} }
ls.speedActual.Set(s) ls.speedActual.Set(s)