commit 00082af773b80948418bc9eb471ab22498e80c75 Author: Jeff Carr Date: Wed Feb 8 11:04:04 2023 -0600 Initial Commit diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..1bfd4de --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +control-panel-dns diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..926ed4e --- /dev/null +++ b/Makefile @@ -0,0 +1,13 @@ +run: build + ./control-panel-dns + +build-release: + go get -v -u -x . + go build + +build: + GO111MODULE="off" go get -v -x . + GO111MODULE="off" go build + +update: + GO111MODULE="off" go get -v -u -x . diff --git a/README.md b/README.md new file mode 100644 index 0000000..fc69d97 --- /dev/null +++ b/README.md @@ -0,0 +1,19 @@ +# control-panel-dns + +A Control Panel to monitor DNS settings + +Goals: + +* Correctly care and handle IPv6 (IPv4 is dead) +* Update your hostname DNS when your IP address changes +* Run as a daemon +* When run in GUI, add status via systray + +## References + +Useful links and other +external things which might be useful + +* [WIT GO projects](http://go.wit.org/) +* [GOLANG GUI](https://github.com/wit-go/gui) +* [GO Style Guide](https://google.github.io/styleguide/go/index) diff --git a/args.go b/args.go new file mode 100644 index 0000000..aa8d224 --- /dev/null +++ b/args.go @@ -0,0 +1,19 @@ +// This creates a simple hello world window +package main + +import ( + "git.wit.org/wit/gui" +) + +type LogOptions struct { + LogFile string + Verbose bool + // GuiDebug bool `help:"open up the wit/gui Debugging Window"` + // GuiDemo bool `help:"open the wit/gui Demo Window"` + User string `arg:"env:USER"` +} + +var args struct { + LogOptions + gui.GuiArgs +} diff --git a/debian/Makefile b/debian/Makefile new file mode 100644 index 0000000..d0fdeab --- /dev/null +++ b/debian/Makefile @@ -0,0 +1,47 @@ +# GITVERSION=$(shell git rev-parse FETCH_HEAD) +VERSION=$(shell git describe --tags $(git rev-list --tags --max-count=1) | sed 's/^v//') + +BASENAME=control-panel-dns + +all: help deb + +help: + @echo + @echo "make deb # attempt to build the .deb package using dpkg" + @echo + +deb: clean extract DEBIAN build + +clean: + rm -rf ../files + rm -f ../*.deb + rm -f ../*.tar.xz data.tar.xz + rm -rf DEBIAN + +extract: + mkdir -p ../files/usr/bin + cp ../control-panel-dns ../files/usr/bin/ + +# makes the DEBIAN/ directory +DEBIAN: + mkdir -p DEBIAN + + # make the md5sum file + cd ../files/ && find -type f -exec md5sum '{}' \; |sort -k2 >../md5sums + mv ../md5sums DEBIAN/ + + # make the control there + mkdir -p DEBIAN + cp control DEBIAN/ + echo Version: ${VERSION} >>DEBIAN/control + + cp postinst DEBIAN + +build: + mv DEBIAN ../files/ + cd .. && dpkg-deb --build files ${BASENAME}_${VERSION}_amd64.deb + @echo + @echo '#######################' + cd .. && dpkg-deb --info ${BASENAME}_${VERSION}_amd64.deb + @echo '#######################' + @echo diff --git a/debian/compat b/debian/compat new file mode 100644 index 0000000..f599e28 --- /dev/null +++ b/debian/compat @@ -0,0 +1 @@ +10 diff --git a/debian/control b/debian/control new file mode 100644 index 0000000..906f089 --- /dev/null +++ b/debian/control @@ -0,0 +1,9 @@ +Source: go-wit-gui +Build-Depends: golang +Package: go-wit-gui +Maintainer: Jeff Carr +Architecture: amd64 +Depends: +Recommends: libgtk-3-0 +Description: a abstraction layer for Go visual elements (GTK, QT, etc) + Package gui implements a abstraction layer for Go visual elements. diff --git a/debian/postinst b/debian/postinst new file mode 100755 index 0000000..1a24852 --- /dev/null +++ b/debian/postinst @@ -0,0 +1 @@ +#!/bin/sh diff --git a/gui.go b/gui.go new file mode 100644 index 0000000..6f1a7f3 --- /dev/null +++ b/gui.go @@ -0,0 +1,61 @@ +// This creates a simple hello world window +package main + +import ( + "os" + "log" + "git.wit.org/wit/gui" +) + +// This initializes the first window +func initGUI() { + var w *gui.Node + gui.Config.Title = "Hello World golang wit/gui Window" + gui.Config.Width = 640 + gui.Config.Height = 480 + gui.Config.Exit = myDefaultExit + + w = gui.NewWindow() + w.Dump() + addDemoTab(w, "A Simple Tab Demo") + + // TODO: add these back + if (args.GuiDemo) { + gui.DemoWindow() + } + + if (args.GuiDebug) { + gui.DebugWindow() + } +} + +func addDemoTab(window *gui.Node, title string) { + var newNode, g, g2, tb *gui.Node + + newNode = window.NewTab(title) + log.Println("addDemoTab() newNode.Dump") + newNode.Dump() + + g = newNode.NewGroup("group 1") + dd := g.NewDropdown("demoCombo2") + dd.AddDropdownName("more 1") + dd.AddDropdownName("more 2") + dd.AddDropdownName("more 3") + dd.OnChanged = func(*gui.Node) { + s := dd.GetText() + tb.SetText("hello world " + args.User + "\n" + s) + } + + g2 = newNode.NewGroup("group 2") + tb = g2.NewTextbox("tb") + log.Println("tb =", tb.GetText()) + tb.OnChanged = func(*gui.Node) { + s := tb.GetText() + log.Println("text =", s) + } +} + +func myDefaultExit(n *gui.Node) { + log.Println("You can Do exit() things here") + os.Exit(0) +} diff --git a/main.go b/main.go new file mode 100644 index 0000000..c248501 --- /dev/null +++ b/main.go @@ -0,0 +1,17 @@ +// This creates a simple hello world window +package main + +import ( + "log" + "git.wit.org/wit/gui" + arg "github.com/alexflint/go-arg" +) + +func main() { + arg.MustParse(&args) + // fmt.Println(args.Foo, args.Bar, args.User) + log.Println("Toolkit = ", args.Toolkit) + + // gui.InitPlugins([]string{"andlabs"}) + gui.Main(initGUI) +}