convert to gadget.BasicWindow()

Signed-off-by: Jeff Carr <jcarr@wit.com>
This commit is contained in:
Jeff Carr 2024-01-05 00:07:13 -06:00
parent 3baa63dadf
commit ff21dba712
4 changed files with 28 additions and 41 deletions

54
gui.go
View File

@ -20,14 +20,11 @@ import (
// This setups up the dns control panel window
func setupControlPanelWindow() {
me.window = myGui.NewWindow("DNS and IPv6 Control Panel")
// me.window.Dump() // will dump out some info
log.Info("artificial sleep of:", me.artificialSleep)
log.Sleep(me.artificialSleep)
// setup the main tab
dnsTab("DNS")
mainWindow("DNS and IPv6 Control Panel")
detailsTab("Details")
debugTab("Debug")
@ -37,9 +34,8 @@ func setupControlPanelWindow() {
func detailsTab(title string) {
var g2 *gui.Node
tab := me.window.NewWindow(title)
g2 = tab.NewGroup("Real Stuff")
me.details = gadgets.NewBasicWindow(me.myGui, title)
g2 = me.details.Box().NewGroup("Real Stuff")
grid := g2.NewGrid("gridnuts", 2, 2)
@ -72,9 +68,6 @@ func detailsTab(title string) {
grid.NewLabel("refresh speed")
me.LocalSpeedActual = grid.NewLabel("unknown")
tab.Margin()
tab.Pad()
grid.Margin()
grid.Pad()
}
@ -82,24 +75,12 @@ func detailsTab(title string) {
func debugTab(title string) {
var g2 *gui.Node
tab := me.window.NewWindow(title)
win := gadgets.NewBasicWindow(me.myGui, title)
g2 = tab.NewGroup("Real Stuff")
g2 = win.Box().NewGroup("Real Stuff")
var hidden bool = true
g2.NewButton("GO GUI Debug Window", func () {
if (me.myDebug == nil) {
me.myDebug = debugger.DebugWindow(me.window)
hidden = false
return
}
if hidden {
me.myDebug.Show()
hidden = false
} else {
me.myDebug.Hide()
hidden = true
}
debugger.DebugWindow(me.myGui)
})
g2.NewButton("getHostname() looks at the OS settings", func () {
@ -116,7 +97,7 @@ func debugTab(title string) {
log.Println(o)
})
g2 = tab.NewGroup("debugging options")
g2 = win.Box().NewGroup("debugging options")
// makes a slider widget
me.ttl = gadgets.NewDurationSlider(g2, "Loop Timeout", 10 * time.Millisecond, 5 * time.Second)
@ -199,12 +180,10 @@ func myDefaultExit(n *gui.Node) {
os.Exit(0)
}
func dnsTab(title string) {
win := me.window.NewWindow(title)
tab := win.NewBox("hBox", true)
me.mainStatus = tab.NewGroup("dns update")
func mainWindow(title string) {
me.window = gadgets.NewBasicWindow(me.myGui, title)
me.mainStatus = me.window.Box().NewGroup("dns update")
grid := me.mainStatus.NewGrid("gridnuts", 2, 2)
grid.SetNext(1,1)
@ -253,7 +232,7 @@ func dnsTab(title string) {
me.digStatusButton = me.mainStatus.NewButton("Resolver Status", func () {
if (me.digStatus == nil) {
log.Info("drawing the digStatus window START")
me.digStatus = NewDigStatusWindow(myGui)
me.digStatus = NewDigStatusWindow(me.myGui)
log.Info("drawing the digStatus window END")
me.digStatusButton.SetText("Hide DNS Lookup Status")
me.digStatus.Update()
@ -270,7 +249,7 @@ func dnsTab(title string) {
})
me.hostnameStatusButton = me.mainStatus.NewButton("Show hostname DNS Status", func () {
if (me.hostnameStatus == nil) {
me.hostnameStatus = NewHostnameStatusWindow(myGui)
me.hostnameStatus = NewHostnameStatusWindow(me.myGui)
me.hostnameStatusButton.SetText("Hide " + me.hostname + " DNS Status")
me.hostnameStatus.Update()
return
@ -288,8 +267,15 @@ func dnsTab(title string) {
grid.Margin()
grid.Pad()
statusGrid(tab)
statusGrid(me.window.Box())
gr := me.window.Box().NewGroup("debugging")
gr.NewButton("GO GUI Debugger", func () {
debugger.DebugWindow(me.myGui)
})
gr.NewButton("Details", func () {
me.details.Toggle()
})
}
func statusGrid(n *gui.Node) {

View File

@ -65,7 +65,7 @@ func getHostname() {
log.Log(CHANGE, "me.cloudflare == nil; me.DnsAPI.S =", me.DnsAPI.S)
if (me.DnsAPI.S == "cloudflare") {
me.cloudflareB = me.mainStatus.NewButton("cloudflare wit.com", func () {
cloudflare.CreateRR(myGui, "wit.com", "3777302ac4a78cd7fa4f6d3f72086d06")
cloudflare.CreateRR(me.myGui, "wit.com", "3777302ac4a78cd7fa4f6d3f72086d06")
})
}
}

View File

@ -20,8 +20,6 @@ import (
"github.com/miekg/dns"
)
var myGui *gui.Node
//go:embed plugins/*.so
var resToolkit embed.FS
@ -41,14 +39,14 @@ func main() {
// send all log() output to a file in /tmp
log.SetTmp()
myGui = gui.New().Default()
me.myGui = gui.New().Default()
log.Sleep(me.artificialSleep)
setupControlPanelWindow()
if debugger.ArgDebug() {
log.Sleep(2)
debugger.DebugWindow(myGui)
debugger.DebugWindow(me.myGui)
}
// forever monitor for network and dns changes

View File

@ -41,7 +41,9 @@ type Host struct {
ipv4s map[string]dns.RR
ipv6s map[string]dns.RR
window *gui.Node // the main window
window *gadgets.BasicWindow // the main window
details *gadgets.BasicWindow // more details of the DNS state
tab *gui.Node // the main dns tab
notes *gui.Node // using this to put notes here
@ -81,7 +83,8 @@ type Host struct {
hostnameStatus *hostnameStatus
hostnameStatusButton *gui.Node
myDebug *gui.Node
myDebug *gui.Node
myGui *gui.Node
}
type IPtype struct {