From 68f23a5866f2901f459c5b28d618579aa7dc1b54 Mon Sep 17 00:00:00 2001 From: Jeff Carr Date: Thu, 15 Feb 2024 03:28:16 -0600 Subject: [PATCH] gui API updates Signed-off-by: Jeff Carr --- .gitignore | 1 + Makefile | 5 +++-- apt.go | 4 +++- args.go | 28 ---------------------------- debugger.go | 26 ++++++++++++++++++++++++++ go.mod | 22 ---------------------- go.sum | 26 -------------------------- gui.go | 9 ++------- main.go | 8 +------- setup.go | 4 ++-- 10 files changed, 38 insertions(+), 95 deletions(-) delete mode 100644 args.go create mode 100644 debugger.go delete mode 100644 go.mod delete mode 100644 go.sum diff --git a/.gitignore b/.gitignore index 1a68be7..23d21c9 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,5 @@ *.swp +go.* wit-new-machine /files/* /*.deb diff --git a/Makefile b/Makefile index e57f164..c32ead8 100644 --- a/Makefile +++ b/Makefile @@ -6,9 +6,10 @@ VERSION = $(shell cat resources/VERSION) # export GO111MODULE="off" build: - -cp ~/go/src/go.wit.com/gui/toolkits/*.so plugins/ + -mkdir plugins + -cp ~/go/src/go.wit.com/toolkits/*.so plugins/ go build -v - ./wit-new-machine --debugging + ./wit-new-machine goimports: goimports -w *.go diff --git a/apt.go b/apt.go index 45c3442..b1d6817 100644 --- a/apt.go +++ b/apt.go @@ -3,10 +3,12 @@ package main import ( "log" "os" + + "go.wit.com/gui" ) func aptTab() { - aptTab := mainWindow.NewTab("apt") + aptTab := gui.RawWindow("apt") box := aptTab.NewBox("aptBox", false) box.NewButton("apt sources", func() { diff --git a/args.go b/args.go deleted file mode 100644 index 4010b45..0000000 --- a/args.go +++ /dev/null @@ -1,28 +0,0 @@ -package main - -/* - this enables command line options from other packages like 'gui' and 'log' -*/ - -import ( - "go.wit.com/dev/alexflint/arg" - "go.wit.com/lib/debugger" - "go.wit.com/log" -) - -var argGui ArgsGui - -// This struct can be used with the go-arg package -type ArgsGui struct { - Test bool `arg:"--test" help:"enable all logging"` -} - -func init() { - arg.MustParse(&argGui) - - if debugger.ArgDebug() { - log.Log(true, "INIT() gui debug == true") - } else { - log.Log(true, "INIT() gui debug == false") - } -} diff --git a/debugger.go b/debugger.go new file mode 100644 index 0000000..116d549 --- /dev/null +++ b/debugger.go @@ -0,0 +1,26 @@ +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/go.mod b/go.mod deleted file mode 100644 index f083e2d..0000000 --- a/go.mod +++ /dev/null @@ -1,22 +0,0 @@ -module git.wit.org/jcarr/wit-new-machine - -go 1.21.4 - -require ( - go.wit.com/dev/alexflint/arg v1.4.5 - go.wit.com/gui v0.13.11 - go.wit.com/lib/debugger v0.13.0 - go.wit.com/log v0.5.6 - golang.org/x/mobile v0.0.0-20240112133503-c713f31d574b -) - -require ( - go.wit.com/dev/alexflint/scalar v1.2.1 // indirect - go.wit.com/dev/davecgh/spew v1.1.4 // indirect - go.wit.com/lib/gadgets v0.13.0 // indirect - go.wit.com/lib/gui/logsettings v0.13.0 // indirect - go.wit.com/widget v1.1.6 // indirect - golang.org/x/exp/shiny v0.0.0-20230817173708-d852ddb80c63 // indirect - golang.org/x/image v0.15.0 // indirect - golang.org/x/sys v0.16.0 // indirect -) diff --git a/go.sum b/go.sum deleted file mode 100644 index a38c373..0000000 --- a/go.sum +++ /dev/null @@ -1,26 +0,0 @@ -go.wit.com/dev/alexflint/arg v1.4.5 h1:asDx5f9IlfpknKjPBqqb2qndE91Pbo7ZDkWUgddfMhY= -go.wit.com/dev/alexflint/arg v1.4.5/go.mod h1:wnWc+c6z8kSdDKYriMf6RpM+FiXmo5RYp/t4FNi0MU0= -go.wit.com/dev/alexflint/scalar v1.2.1 h1:loXOcbVnd+8YeJRLey+XXidecBiedMDO00zQ26TvKNs= -go.wit.com/dev/alexflint/scalar v1.2.1/go.mod h1:+rYsfxqdI2cwA8kJ7GCMwWbNJvfvWUurOCXLiwdTtSs= -go.wit.com/dev/davecgh/spew v1.1.4 h1:C9hj/rjlUpdK+E6aroyLjCbS5MFcyNUOuP1ICLWdNek= -go.wit.com/dev/davecgh/spew v1.1.4/go.mod h1:sihvWmnQ/09FWplnEmozt90CCVqBtGuPXM811tgfhFA= -go.wit.com/gui v0.13.11 h1:d74Ko/XFZYR25P/AZfCQaVO2CuGh1BSjdUp1wjktdDg= -go.wit.com/gui v0.13.11/go.mod h1:v2VgnOL3dlZ13KclYeedZ1cd20nQdvwjyJTNKvFX3DA= -go.wit.com/lib/debugger v0.13.0 h1:k5XCa7BZFYA37rFf20iTAm5L4Ch+3eRuxCbHIhorYZI= -go.wit.com/lib/debugger v0.13.0/go.mod h1:b3gykobdR+lcMjWAHJUa3GRsMYbnaHNwA/upfjpSA28= -go.wit.com/lib/gadgets v0.13.0 h1:jtsEnf4DHqAxBxuYsaDlHti73rgaxYf/ffAXNB1PJAk= -go.wit.com/lib/gadgets v0.13.0/go.mod h1:xidaHAL6Nk9+M9FkySVU1AG5i39v7T3PuFphUos6LxE= -go.wit.com/lib/gui/logsettings v0.13.0 h1:iphACMcfdc5GoCcxZkShcWn9A/SwvnPmLXCSYSL+eJU= -go.wit.com/lib/gui/logsettings v0.13.0/go.mod h1:h+skqrtQ3muJ1TzMQ7M568xAwqT7nZCGS32c5jYCrqc= -go.wit.com/log v0.5.6 h1:rDC3ju95zfEads4f1Zm+QMkqjZ39CsYAT/UmQQs7VP4= -go.wit.com/log v0.5.6/go.mod h1:BaJBfHFqcJSJLXGQ9RHi3XVhPgsStxSMZRlaRxW4kAo= -go.wit.com/widget v1.1.6 h1:av2miF5vlohMfARA/QGPTPfgW/ADup1c+oeAOKgroPY= -go.wit.com/widget v1.1.6/go.mod h1:I8tnD3x3ECbB/CRNnLCdC+uoyk7rK0AEkzK1bQYSqoQ= -golang.org/x/exp/shiny v0.0.0-20230817173708-d852ddb80c63 h1:3AGKexOYqL+ztdWdkB1bDwXgPBuTS/S8A4WzuTvJ8Cg= -golang.org/x/exp/shiny v0.0.0-20230817173708-d852ddb80c63/go.mod h1:UH99kUObWAZkDnWqppdQe5ZhPYESUw8I0zVV1uWBR+0= -golang.org/x/image v0.15.0 h1:kOELfmgrmJlw4Cdb7g/QGuB3CvDrXbqEIww/pNtNBm8= -golang.org/x/image v0.15.0/go.mod h1:HUYqC05R2ZcZ3ejNQsIHQDQiwWM4JBqmm6MKANTp4LE= -golang.org/x/mobile v0.0.0-20240112133503-c713f31d574b h1:kfWLZgb8iUBHdE9WydD5V5dHIS/F6HjlBZNyJfn2bs4= -golang.org/x/mobile v0.0.0-20240112133503-c713f31d574b/go.mod h1:4efzQnuA1nICq6h4kmZRMGzbPiP06lZvgADUu1VpJCE= -golang.org/x/sys v0.16.0 h1:xWw16ngr6ZMtmxDyKyIgsE93KNKz5HKmMa3b8ALHidU= -golang.org/x/sys v0.16.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= diff --git a/gui.go b/gui.go index f6c4c71..4079e4b 100644 --- a/gui.go +++ b/gui.go @@ -5,7 +5,6 @@ import ( "os" "time" - "go.wit.com/lib/debugger" "go.wit.com/gui" "go.wit.com/log" ) @@ -41,7 +40,7 @@ func drawWindow() { mainWindow = myGui.NewWindow("wit new machine setup").SetText("wit new machine setup") mainWindow.Custom = customExit - newTab := mainWindow.NewTab("mainTab") + newTab := gui.NewWindow("mainTab") //////////////////// General GUI debugging ///////////////////////// g = newTab.NewGroup("Debug") @@ -97,14 +96,10 @@ func drawWindow() { os.Exit(0) }) - rn.NewButton("DebugWindow()", func() { - debugger.DebugWindow(myGui) - }) - rn.NewLabel("Not yet working stuff") rn.NewButton("resolv.conf", func() { - s := resolv.GetText() + s := resolv.String() log.Println("supposed to make the resolv.conf window\n\n", s) }) diff --git a/main.go b/main.go index 188be67..798b478 100644 --- a/main.go +++ b/main.go @@ -8,7 +8,6 @@ import ( "strings" "go.wit.com/dev/alexflint/arg" - "go.wit.com/lib/debugger" "go.wit.com/gui" "go.wit.com/log" ) @@ -54,15 +53,10 @@ func main() { myGui = gui.New().Default() drawWindow() - if debugger.ArgDebug() { - log.Sleep(2) - debugger.DebugWindow(myGui) - } - gui.Watchdog() } func closeWindow(n *gui.Node) { - log.Println("Just closing the window and nothing else.", n.Name) + log.Println("Just closing the window and nothing else.", n.String()) // os.Exit(0) } diff --git a/setup.go b/setup.go index 949f071..553450f 100644 --- a/setup.go +++ b/setup.go @@ -12,7 +12,7 @@ var commandEntry *gui.Node func setupNewMachine(cur *gui.Node) { var w, g *gui.Node - w = cur.NewTab("Setup Machine") + w = myGui.NewWindow("Setup Machine") g = w.NewGroup("ssh things") g.NewButton("ssh localhost", func() { @@ -37,7 +37,7 @@ func setupNewMachine(cur *gui.Node) { g.NewLabel("install go 1.19") g.NewButton("wget 1.19", func() { command = "ssh -t " + "jcarr" + "@" + hostname + " 'wget https://go.dev/dl/go1.19.linux-amd64.tar.gz' " - xtermHold.Set(true) + xtermHold.SetChecked(true) xterm(command) })