more isolation of Update() pieces

Signed-off-by: Jeff Carr <jcarr@wit.com>
This commit is contained in:
Jeff Carr 2024-01-06 14:23:19 -06:00
parent 398d9fe3c4
commit ba3d5a3cb2
3 changed files with 42 additions and 27 deletions

12
gui.go
View File

@ -44,7 +44,7 @@ func detailsTab(title string) {
// me.domainname = grid.NewLabel("domainname") // me.domainname = grid.NewLabel("domainname")
grid.NewLabel("hostname -s =") grid.NewLabel("hostname -s =")
me.hostshort = grid.NewLabel("hostname -s") grid.NewLabel("DEPRECATED")
grid.NewLabel("NS records =") grid.NewLabel("NS records =")
me.NSrr = grid.NewLabel("NS RR's") me.NSrr = grid.NewLabel("NS RR's")
@ -227,17 +227,17 @@ func mainWindow(title string) {
me.details.Toggle() me.details.Toggle()
}) })
gr.NewButton("linuxstatus.New()", func () { gr.NewButton("linuxstatus.New()", func () {
me.statusOS = linuxstatus.New() if (me.statusOS == nil) {
me.statusOS = linuxstatus.New()
}
me.statusOS.SetParent(me.myGui) me.statusOS.SetParent(me.myGui)
me.statusOS.InitWindow() me.statusOS.InitWindow()
me.statusOS.Make()
me.statusOS.Draw2()
}) })
gr.NewButton("statusOS.Ready()", func () { gr.NewButton("statusOS.Ready()", func () {
me.statusOS.Ready() me.statusOS.Ready()
}) })
gr.NewButton("statusOS.Make()", func () {
me.statusOS.Make()
me.statusOS.Draw2()
})
gr.NewButton("statusOS.Draw()", func () { gr.NewButton("statusOS.Draw()", func () {
me.statusOS.Draw() me.statusOS.Draw()
me.statusOS.Draw2() me.statusOS.Draw2()

View File

@ -296,7 +296,7 @@ func (hs *hostnameStatus) updateStatus() {
var vals []string var vals []string
log.Log(STATUS, "updateStatus() START") log.Log(STATUS, "updateStatus() START")
hs.hostShort.Set(me.hostshort.S) hs.hostShort.Set(me.statusOS.GetHostShort())
hs.domainname.Set(me.statusOS.GetDomainName()) hs.domainname.Set(me.statusOS.GetDomainName())
if hs.ValidHostname() { if hs.ValidHostname() {

View File

@ -22,9 +22,41 @@ func (ls *LinuxStatus) GetDomainName() string {
return me.domainname.Get() return me.domainname.Get()
} }
func (ls *LinuxStatus) setDomainName(dn string) { func (ls *LinuxStatus) setDomainName() {
if ! me.Ready() {return} if ! me.Ready() {return}
me.domainname.Set(dn)
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) {
log.Log(CHANGE, "domainname has changed from", me.GetDomainName(), "to", dn)
me.domainname.Set(dn)
me.changed = true
}
}
func (ls *LinuxStatus) GetHostShort() string {
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.hostshort.Get()
}
func (ls *LinuxStatus) setHostShort() {
if ! me.Ready() {return ""}
hshort := run("hostname -s")
if (me.hostshort.Get() != hshort) {
log.Log(CHANGE, "hostname -s has changed from", me.hostshort.Get(), "to", hshort)
me.hostshort.Set(hshort)
me.changed = true
}
} }
func lookupHostname() { func lookupHostname() {
@ -38,25 +70,8 @@ func lookupHostname() {
} }
log.Error(errors.New("full hostname should be: " + s)) log.Error(errors.New("full hostname should be: " + s))
dn := run("domainname") me.setDomainName()
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) {
log.Log(CHANGE, "domainname has changed from", me.GetDomainName(), "to", dn)
me.setDomainName(dn)
me.changed = true
}
hshort := run("hostname -s")
if (me.hostshort.Get() != hshort) {
log.Log(CHANGE, "hostname -s has changed from", me.hostshort.Get(), "to", hshort)
me.hostshort.Set(hshort)
me.changed = true
}
/* /*
var test string var test string