summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJeff Carr <[email protected]>2024-01-05 00:07:13 -0600
committerJeff Carr <[email protected]>2024-01-05 00:07:13 -0600
commitff21dba712e5c63ec3dab1defe55c63c98eb3226 (patch)
tree3b76a4e86eaec1613346f59d903fb3d14af08cee
parent3baa63dadf31c9b30f364e19e3f2c514157bca36 (diff)
convert to gadget.BasicWindow()
Signed-off-by: Jeff Carr <[email protected]>
-rw-r--r--gui.go54
-rw-r--r--hostname.go2
-rw-r--r--main.go6
-rw-r--r--structs.go7
4 files changed, 28 insertions, 41 deletions
diff --git a/gui.go b/gui.go
index 2c2972c..4434a97 100644
--- a/gui.go
+++ b/gui.go
@@ -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) {
diff --git a/hostname.go b/hostname.go
index c3a2e1f..9eb1a65 100644
--- a/hostname.go
+++ b/hostname.go
@@ -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")
})
}
}
diff --git a/main.go b/main.go
index 0957d70..232204c 100644
--- a/main.go
+++ b/main.go
@@ -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
diff --git a/structs.go b/structs.go
index 4be9602..8b882e3 100644
--- a/structs.go
+++ b/structs.go
@@ -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 {