From 7b4eb41de7e1c65c07dfc8f04f1263b3f258b268 Mon Sep 17 00:00:00 2001 From: Jeff Carr Date: Sun, 25 Feb 2024 18:37:44 -0600 Subject: better names with Init() vs New() --- argv.go | 27 +++++++++++++++++++++++++++ controlPanelWindow.go | 6 +++++- debugger.go | 26 -------------------------- digStatusWindow.go | 2 +- errorBox.go | 2 +- hostnameStatusWindow.go | 2 +- main.go | 10 +++++----- 7 files changed, 40 insertions(+), 35 deletions(-) create mode 100644 argv.go delete mode 100644 debugger.go diff --git a/argv.go b/argv.go new file mode 100644 index 0000000..324e7d7 --- /dev/null +++ b/argv.go @@ -0,0 +1,27 @@ +package main + +/* + enables GUI options and the debugger in your application +*/ + +import ( + "go.wit.com/dev/alexflint/arg" + "go.wit.com/lib/debugger" + "go.wit.com/log" +) + +var args struct { + Daemon bool `arg:"--daemon" help:"run without a gui"` +} + +func init() { + arg.MustParse(&args) + + if debugger.ArgDebug() { + log.Info("cmd line --debugger == true") + go func() { + log.Sleep(2) + debugger.DebugWindow() + }() + } +} diff --git a/controlPanelWindow.go b/controlPanelWindow.go index 827e6c3..c9e1917 100644 --- a/controlPanelWindow.go +++ b/controlPanelWindow.go @@ -46,13 +46,14 @@ func makeMainWindow() { func statusGrid(n *gui.Node) { problems := n.NewGroup("status") - grid := problems.NewGrid("nuts", 3, 1) + grid := problems.RawGrid() grid.NewLabel("hostname =") me.hostnameStatus = grid.NewLabel("invalid") grid.NewButton("Linux Status", func() { me.statusOS.Toggle() }) + grid.NextRow() me.statusIPv6 = gadgets.NewOneLiner(grid, "DNS Lookup") me.statusIPv6.SetText("known") @@ -62,6 +63,7 @@ func statusGrid(n *gui.Node) { } me.digStatus.window.Toggle() }) + grid.NextRow() grid.NewLabel("DNS Status") me.DnsStatus = grid.NewLabel("unknown") @@ -71,6 +73,7 @@ func statusGrid(n *gui.Node) { } me.statusDNS.window.Toggle() }) + grid.NextRow() grid.NewLabel("DNS API") me.DnsAPIstatus = grid.NewLabel("unknown") @@ -85,6 +88,7 @@ func statusGrid(n *gui.Node) { } } }) + grid.NextRow() } func myDefaultExit(n *gui.Node) { diff --git a/debugger.go b/debugger.go deleted file mode 100644 index 116d549..0000000 --- a/debugger.go +++ /dev/null @@ -1,26 +0,0 @@ -package main - -/* - enables GUI options and the debugger in your application -*/ - -import ( - "go.wit.com/dev/alexflint/arg" - "go.wit.com/lib/debugger" - "go.wit.com/log" -) - -var args struct { -} - -func init() { - arg.MustParse(&args) - - if debugger.ArgDebug() { - log.Info("cmd line --debugger == true") - go func() { - log.Sleep(2) - debugger.DebugWindow() - }() - } -} diff --git a/digStatusWindow.go b/digStatusWindow.go index a0917f5..e62be77 100644 --- a/digStatusWindow.go +++ b/digStatusWindow.go @@ -55,7 +55,7 @@ type digStatus struct { statusHTTP *gadgets.OneLiner } -func NewDigStatusWindow() *digStatus { +func InitDigStatus() *digStatus { var ds *digStatus ds = new(digStatus) diff --git a/errorBox.go b/errorBox.go index 0a16631..b2605e5 100644 --- a/errorBox.go +++ b/errorBox.go @@ -43,7 +43,7 @@ type anError struct { problem *Problem } -func NewErrorBox(p *gui.Node, name string, ip string) *errorBox { +func InitErrorBox(p *gui.Node, name string, ip string) *errorBox { var eb *errorBox eb = new(errorBox) eb.parent = p diff --git a/hostnameStatusWindow.go b/hostnameStatusWindow.go index 6a88fae..5ce8ae9 100644 --- a/hostnameStatusWindow.go +++ b/hostnameStatusWindow.go @@ -56,7 +56,7 @@ type hostnameStatus struct { // dnsAction *gui.Node } -func NewHostnameStatusWindow() *hostnameStatus { +func InitHostnameStatus() *hostnameStatus { var hs *hostnameStatus hs = new(hostnameStatus) diff --git a/main.go b/main.go index c220754..5e4d7e2 100644 --- a/main.go +++ b/main.go @@ -46,17 +46,17 @@ func main() { makeMainWindow() // These are your problems - me.problems = NewErrorBox(me.window.Box(), "Errors", "has problems?") + me.problems = InitErrorBox(me.window.Box(), "Errors", "has problems?") me.problems.addIPerror(RR, USER, "1:1:1:1") me.window.Show() me.debug = debugWindow("Debugging") - me.digStatus = NewDigStatusWindow() - me.statusDNS = NewHostnameStatusWindow() - - me.statusOS = linuxstatus.NewLinuxStatus(me.myGui) + // 3 external windows that should be seperate go packages + me.digStatus = InitDigStatus() + me.statusDNS = InitHostnameStatus() + me.statusOS = linuxstatus.InitLinuxStatus() digLoop() -- cgit v1.2.3