error window v0.1
error box starts doing something start a window for errors to fix more status cleanups & housecleaning Signed-off-by: Jeff Carr <jcarr@wit.com> Signed-off-by: Jeff Carr <jcarr@wit.com>
This commit is contained in:
parent
259b4bdb40
commit
ef6eb7a96a
|
@ -16,7 +16,6 @@ import (
|
||||||
"os"
|
"os"
|
||||||
"fmt"
|
"fmt"
|
||||||
"time"
|
"time"
|
||||||
"strings"
|
|
||||||
"reflect"
|
"reflect"
|
||||||
"errors"
|
"errors"
|
||||||
|
|
||||||
|
@ -153,6 +152,7 @@ func (ds *digStatus) setIPv6status(s string) {
|
||||||
me.digStatus.set(ds.statusAAAA, s)
|
me.digStatus.set(ds.statusAAAA, s)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
func (ds *digStatus) SetIPv6(s string) {
|
func (ds *digStatus) SetIPv6(s string) {
|
||||||
if ! ds.Ready() {return}
|
if ! ds.Ready() {return}
|
||||||
log.Warn("Should SetIPv6() here to", s)
|
log.Warn("Should SetIPv6() here to", s)
|
||||||
|
@ -162,6 +162,7 @@ func (ds *digStatus) SetIPv6(s string) {
|
||||||
me.DnsAAAA.Set(s)
|
me.DnsAAAA.Set(s)
|
||||||
// me.digStatus.set(ds.httpGoWitCom, addr)
|
// me.digStatus.set(ds.httpGoWitCom, addr)
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
func (ds *digStatus) set(a any, s string) {
|
func (ds *digStatus) set(a any, s string) {
|
||||||
if ! ds.Ready() {return}
|
if ! ds.Ready() {return}
|
||||||
|
@ -301,7 +302,7 @@ func (ds *digStatus) checkLookupDoH(hostname string) bool {
|
||||||
s = append(s, addr)
|
s = append(s, addr)
|
||||||
status = true
|
status = true
|
||||||
}
|
}
|
||||||
me.digStatus.SetIPv6(strings.Join(s, "\n"))
|
// me.digStatus.SetIPv6(strings.Join(s, "\n"))
|
||||||
return status
|
return status
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
56
errorBox.go
56
errorBox.go
|
@ -20,25 +20,65 @@ type errorBox struct {
|
||||||
l *gui.Node
|
l *gui.Node
|
||||||
b *gui.Node
|
b *gui.Node
|
||||||
|
|
||||||
|
fixes map[string]*anError
|
||||||
|
|
||||||
something *gadgets.OneLiner
|
something *gadgets.OneLiner
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewErrorBox(p *gui.Node, name string) *errorBox {
|
type anError struct {
|
||||||
|
kind string // what kind of error is it?
|
||||||
|
ip string
|
||||||
|
status string
|
||||||
|
|
||||||
|
kindLabel *gui.Node
|
||||||
|
ipLabel *gui.Node
|
||||||
|
statusLabel *gui.Node
|
||||||
|
button *gui.Node
|
||||||
|
}
|
||||||
|
|
||||||
|
func NewErrorBox(p *gui.Node, name string, ip string) *errorBox {
|
||||||
var eb *errorBox
|
var eb *errorBox
|
||||||
eb = new(errorBox)
|
eb = new(errorBox)
|
||||||
eb.parent = p
|
eb.parent = p
|
||||||
// eb.group = p.NewGroup("eg")
|
eb.group = p.NewGroup(name)
|
||||||
// eb.grid = eb.group.NewGrid("labels", 2, 1)
|
eb.grid = eb.group.NewGrid("stuff", 4, 1)
|
||||||
|
|
||||||
eb.l = p.NewLabel("click to fix")
|
eb.grid.NewLabel("Type")
|
||||||
eb.b = p.NewButton("fix", func() {
|
eb.grid.NewLabel("IP")
|
||||||
log.Log(WARN, "should try to fix here")
|
eb.grid.NewLabel("Status")
|
||||||
})
|
eb.grid.NewLabel("")
|
||||||
eb.something = gadgets.NewOneLiner(eb.grid, "something")
|
|
||||||
|
|
||||||
|
eb.fixes = make(map[string]*anError)
|
||||||
return eb
|
return eb
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
func (eb *errorBox) add(kind string, ip string) bool {
|
||||||
|
tmp := kind + " " + ip
|
||||||
|
if eb.fixes[tmp] != nil {
|
||||||
|
log.Log(WARN, "Error is already here", kind, ip)
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
|
anErr := new(anError)
|
||||||
|
anErr.kind = kind
|
||||||
|
|
||||||
|
anErr.kindLabel = eb.grid.NewLabel(kind)
|
||||||
|
anErr.ipLabel = eb.grid.NewLabel(ip)
|
||||||
|
anErr.statusLabel = eb.grid.NewLabel("")
|
||||||
|
anErr.button = eb.grid.NewButton(kind, func() {
|
||||||
|
log.Log(WARN, "got", kind, "here. IP =", ip)
|
||||||
|
eb.fix(kind, ip)
|
||||||
|
})
|
||||||
|
eb.fixes[tmp] = anErr
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
|
func (eb *errorBox) fix(name string, ip string) bool {
|
||||||
|
log.Log(WARN, "should try to fix", name, "here. IP =", ip)
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
func (eb *errorBox) update() bool {
|
func (eb *errorBox) update() bool {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
41
fix.go
41
fix.go
|
@ -9,6 +9,22 @@ 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.Vertical()
|
||||||
|
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
|
||||||
|
@ -65,7 +81,9 @@ func fixIPv6dns() bool {
|
||||||
|
|
||||||
// remove old DNS entries first
|
// remove old DNS entries first
|
||||||
for aaaa, _ := range dnsAAAA {
|
for aaaa, _ := range dnsAAAA {
|
||||||
if osAAAA[aaaa] == "dns" {
|
if osAAAA[aaaa] == "os" {
|
||||||
|
log.Log(INFO, "DNS AAAA is in OS", aaaa)
|
||||||
|
} else {
|
||||||
broken = true
|
broken = true
|
||||||
log.Log(INFO, "DNS AAAA is not in OS", aaaa)
|
log.Log(INFO, "DNS AAAA is not in OS", aaaa)
|
||||||
addToFixWindow("DELETE", aaaa)
|
addToFixWindow("DELETE", aaaa)
|
||||||
|
@ -76,8 +94,6 @@ func fixIPv6dns() bool {
|
||||||
log.Log(INFO, "Delete AAAA", aaaa, "Failed")
|
log.Log(INFO, "Delete AAAA", aaaa, "Failed")
|
||||||
}
|
}
|
||||||
*/
|
*/
|
||||||
} else {
|
|
||||||
log.Log(INFO, "DNS AAAA is in OS", aaaa)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -127,17 +143,24 @@ func exists(m map[string]bool, s string) bool {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var myErrorBox *errorBox
|
||||||
|
|
||||||
func addToFixWindow(t string, ip string) {
|
func addToFixWindow(t string, ip string) {
|
||||||
|
log.Log(INFO, "addToFixWindow() START")
|
||||||
if me.fixWindow == nil {
|
if me.fixWindow == nil {
|
||||||
me.fixWindow = smartwindow.New()
|
log.Log(WARN, "addToFixWindow() fixWindow == nil. Can't add the error", t, ip)
|
||||||
me.fixWindow.SetParent(me.myGui)
|
return
|
||||||
me.fixWindow.InitWindow()
|
|
||||||
me.fixWindow.Title("fix window")
|
|
||||||
me.fixWindow.SetDraw(drawFixWindow)
|
|
||||||
me.fixWindow.Make()
|
|
||||||
}
|
}
|
||||||
|
if myErrorBox == nil {
|
||||||
|
box := me.fixWindow.Box()
|
||||||
|
myErrorBox = NewErrorBox(box, t, ip)
|
||||||
|
}
|
||||||
|
myErrorBox.add(t, ip)
|
||||||
|
log.Log(INFO, "addToFixWindow() END")
|
||||||
}
|
}
|
||||||
|
|
||||||
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")
|
||||||
}
|
}
|
||||||
|
|
86
gui.go
86
gui.go
|
@ -4,8 +4,6 @@ package main
|
||||||
import (
|
import (
|
||||||
"time"
|
"time"
|
||||||
"os"
|
"os"
|
||||||
"strings"
|
|
||||||
"sort"
|
|
||||||
|
|
||||||
"go.wit.com/log"
|
"go.wit.com/log"
|
||||||
|
|
||||||
|
@ -60,42 +58,6 @@ func debugTab(title string) {
|
||||||
me.debug.Hide()
|
me.debug.Hide()
|
||||||
}
|
}
|
||||||
|
|
||||||
// doesn't actually do any network traffic
|
|
||||||
// it just updates the GUI
|
|
||||||
func displayDNS() string {
|
|
||||||
var aaaa []string
|
|
||||||
aaaa = append(aaaa, "blah", "more")
|
|
||||||
// h := me.hostname
|
|
||||||
var all string
|
|
||||||
var broken string = "unknown"
|
|
||||||
for _, s := range aaaa {
|
|
||||||
log.Log(STATUS, "host", "fixme", "DNS AAAA =", s, "ipmap[s] =", me.ipmap[s])
|
|
||||||
all += s + "\n"
|
|
||||||
if ( me.ipmap[s] == nil) {
|
|
||||||
log.Warn("THIS IS THE WRONG AAAA DNS ENTRY: host", "fixme", "DNS AAAA =", s)
|
|
||||||
broken = "wrong AAAA entry"
|
|
||||||
} else {
|
|
||||||
if (broken == "unknown") {
|
|
||||||
broken = "needs update"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
var a []string
|
|
||||||
a = append(a, "fixme")
|
|
||||||
sort.Strings(a)
|
|
||||||
all = strings.Join(a, "\n")
|
|
||||||
if (all == "") {
|
|
||||||
log.Log(NOW, "THERE IS NOT a real A DNS ENTRY")
|
|
||||||
all = "CNAME ipv6.wit.com"
|
|
||||||
}
|
|
||||||
if (me.DnsA.S != all) {
|
|
||||||
log.Log(NOW, "DnsA.SetText() to:", all)
|
|
||||||
me.DnsA.SetText(all)
|
|
||||||
}
|
|
||||||
return broken
|
|
||||||
}
|
|
||||||
|
|
||||||
func myDefaultExit(n *gui.Node) {
|
func myDefaultExit(n *gui.Node) {
|
||||||
log.Println("You can Do exit() things here")
|
log.Println("You can Do exit() things here")
|
||||||
os.Exit(0)
|
os.Exit(0)
|
||||||
|
@ -105,15 +67,6 @@ func mainWindow(title string) {
|
||||||
me.window = gadgets.NewBasicWindow(me.myGui, title)
|
me.window = gadgets.NewBasicWindow(me.myGui, title)
|
||||||
|
|
||||||
gr := me.window.Box().NewGroup("dns update")
|
gr := me.window.Box().NewGroup("dns update")
|
||||||
grid := gr.NewGrid("gridnuts", 2, 2)
|
|
||||||
|
|
||||||
grid.SetNext(1,1)
|
|
||||||
|
|
||||||
me.hostname = gadgets.NewOneLiner(grid, "hostname =").Set("unknown")
|
|
||||||
me.DnsAAAA = gadgets.NewOneLiner(grid, "DNS AAAA =").Set("unknown")
|
|
||||||
|
|
||||||
grid.NewLabel("DNS A =")
|
|
||||||
me.DnsA = grid.NewLabel("?")
|
|
||||||
|
|
||||||
// This is where you figure out what to do next to fix the problems
|
// This is where you figure out what to do next to fix the problems
|
||||||
me.fixButton = gr.NewButton("fix", func () {
|
me.fixButton = gr.NewButton("fix", func () {
|
||||||
|
@ -123,16 +76,13 @@ func mainWindow(title string) {
|
||||||
}
|
}
|
||||||
log.Log(CHANGE, "IPv6 WORKED")
|
log.Log(CHANGE, "IPv6 WORKED")
|
||||||
// update everything here visually for the user
|
// update everything here visually for the user
|
||||||
hostname := me.statusOS.GetHostname()
|
// hostname := me.statusOS.GetHostname()
|
||||||
me.hostname.Set(hostname)
|
// me.hostname.Set(hostname)
|
||||||
me.hostnameStatus.Set("WORKING")
|
me.hostnameStatus.Set("WORKING")
|
||||||
me.DnsStatus.Set("WORKING")
|
me.DnsStatus.Set("WORKING")
|
||||||
me.fixButton.Disable()
|
// me.fixButton.Disable()
|
||||||
})
|
})
|
||||||
|
|
||||||
grid.Margin()
|
|
||||||
grid.Pad()
|
|
||||||
|
|
||||||
statusGrid(me.window.Box())
|
statusGrid(me.window.Box())
|
||||||
|
|
||||||
gr = me.window.Box().NewGroup("debugging")
|
gr = me.window.Box().NewGroup("debugging")
|
||||||
|
@ -207,6 +157,7 @@ func updateDNS() {
|
||||||
|
|
||||||
// log.Println("digAAAA()")
|
// log.Println("digAAAA()")
|
||||||
|
|
||||||
|
/*
|
||||||
if me.statusOS.ValidHostname() {
|
if me.statusOS.ValidHostname() {
|
||||||
var aaaa []string
|
var aaaa []string
|
||||||
h := me.statusOS.GetHostname()
|
h := me.statusOS.GetHostname()
|
||||||
|
@ -216,7 +167,7 @@ func updateDNS() {
|
||||||
// log.Println(SPEW, me)
|
// log.Println(SPEW, me)
|
||||||
if (aaaa == nil) {
|
if (aaaa == nil) {
|
||||||
log.Warn("There are no DNS AAAA records for hostname: ", h)
|
log.Warn("There are no DNS AAAA records for hostname: ", h)
|
||||||
me.DnsAAAA.Set("(none)")
|
// me.DnsAAAA.Set("(none)")
|
||||||
if (cloudflare.CFdialog.TypeNode != nil) {
|
if (cloudflare.CFdialog.TypeNode != nil) {
|
||||||
cloudflare.CFdialog.TypeNode.SetText("AAAA new")
|
cloudflare.CFdialog.TypeNode.SetText("AAAA new")
|
||||||
}
|
}
|
||||||
|
@ -225,34 +176,11 @@ func updateDNS() {
|
||||||
cloudflare.CFdialog.NameNode.SetText(h)
|
cloudflare.CFdialog.NameNode.SetText(h)
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
d := deleteAAA()
|
|
||||||
if (d != "") {
|
|
||||||
if (cloudflare.CFdialog.ValueNode != nil) {
|
|
||||||
cloudflare.CFdialog.ValueNode.SetText(d)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
*/
|
*/
|
||||||
// m := missingAAAA()
|
// status := displayDNS() // update the GUI based on dig results
|
||||||
// if (m != "") {
|
// me.DnsStatus.SetText(status)
|
||||||
// if (cloudflare.CFdialog.ValueNode != nil) {
|
|
||||||
// cloudflare.CFdialog.ValueNode.SetText(m)
|
|
||||||
// }
|
|
||||||
// /*
|
|
||||||
// rr := &cloudflare.RRT{
|
|
||||||
// Type: "AAAA",
|
|
||||||
// Name: me.hostname,
|
|
||||||
// Ttl: "Auto",
|
|
||||||
// Proxied: false,
|
|
||||||
// Content: m,
|
|
||||||
// }
|
|
||||||
// cloudflare.Update(rr)
|
|
||||||
// */
|
|
||||||
// }
|
|
||||||
}
|
|
||||||
}
|
|
||||||
status := displayDNS() // update the GUI based on dig results
|
|
||||||
me.DnsStatus.SetText(status)
|
|
||||||
|
|
||||||
if me.digStatus.Ready() {
|
if me.digStatus.Ready() {
|
||||||
if me.digStatus.IPv6() {
|
if me.digStatus.IPv6() {
|
||||||
|
|
|
@ -18,11 +18,11 @@ func (ls *LinuxStatus) Update() {
|
||||||
duration := timeFunction(func () {
|
duration := timeFunction(func () {
|
||||||
linuxLoop()
|
linuxLoop()
|
||||||
})
|
})
|
||||||
ls.SetSpeed(duration)
|
ls.setSpeed(duration)
|
||||||
log.Log(INFO, "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.Log(WARN, "can't actually warn")
|
log.Log(WARN, "can't actually warn")
|
||||||
|
|
8
main.go
8
main.go
|
@ -157,9 +157,17 @@ func dnsTTL() {
|
||||||
}
|
}
|
||||||
|
|
||||||
// run update on the LinuxStatus() window
|
// run update on the LinuxStatus() window
|
||||||
|
// also update a few things on the main window
|
||||||
func linuxLoop() {
|
func linuxLoop() {
|
||||||
me.statusOS.Update()
|
me.statusOS.Update()
|
||||||
|
|
||||||
|
if me.statusOS.ValidHostname() {
|
||||||
|
if me.hostnameStatus.GetText() != "VALID" {
|
||||||
|
me.hostnameStatus.Set("VALID")
|
||||||
|
me.changed = true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (me.statusOS.Changed()) {
|
if (me.statusOS.Changed()) {
|
||||||
stamp := time.Now().Format("2006/01/02 15:04:05")
|
stamp := time.Now().Format("2006/01/02 15:04:05")
|
||||||
log.Log(CHANGE, "Network things changed on", stamp)
|
log.Log(CHANGE, "Network things changed on", stamp)
|
||||||
|
|
|
@ -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
|
||||||
}
|
}
|
||||||
|
|
|
@ -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
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -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)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -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
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
|
@ -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
|
||||||
|
|
|
@ -27,7 +27,7 @@ type Host struct {
|
||||||
digStatus *digStatus // window of the results of DNS lookups
|
digStatus *digStatus // window of the results of DNS lookups
|
||||||
|
|
||||||
hostnameStatus *gui.Node // a summary for the user of where things are
|
hostnameStatus *gui.Node // a summary for the user of where things are
|
||||||
hostname *gadgets.OneLiner // the hostname grabbed from gadget.linuxStatus
|
// hostname *gadgets.OneLiner // the hostname grabbed from gadget.linuxStatus
|
||||||
|
|
||||||
artificialSleep float64 `default:"0.7"` // artificial sleep on startup
|
artificialSleep float64 `default:"0.7"` // artificial sleep on startup
|
||||||
artificialS string `default:"abc"` // artificial sleep on startup
|
artificialS string `default:"abc"` // artificial sleep on startup
|
||||||
|
@ -50,8 +50,6 @@ type Host struct {
|
||||||
|
|
||||||
// DNS stuff
|
// DNS stuff
|
||||||
DnsAPI *gui.Node // what DNS API to use?
|
DnsAPI *gui.Node // what DNS API to use?
|
||||||
DnsAAAA *gadgets.OneLiner // the actual DNS AAAA results
|
|
||||||
DnsA *gui.Node // the actual DNS A results (ignore for status since mostly never happens?)
|
|
||||||
DnsStatus *gui.Node // the current state of DNS
|
DnsStatus *gui.Node // the current state of DNS
|
||||||
DnsSpeed *gui.Node // 'FAST', 'OK', 'SLOW', etc
|
DnsSpeed *gui.Node // 'FAST', 'OK', 'SLOW', etc
|
||||||
DnsSpeedActual *gui.Node // the last actual duration
|
DnsSpeedActual *gui.Node // the last actual duration
|
||||||
|
|
Loading…
Reference in New Issue