Initial Commit

This commit is contained in:
Jeff Carr 2023-02-08 11:04:04 -06:00
commit 00082af773
10 changed files with 188 additions and 0 deletions

1
.gitignore vendored Normal file
View File

@ -0,0 +1 @@
control-panel-dns

13
Makefile Normal file
View File

@ -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 .

19
README.md Normal file
View File

@ -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)

19
args.go Normal file
View File

@ -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
}

47
debian/Makefile vendored Normal file
View File

@ -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

1
debian/compat vendored Normal file
View File

@ -0,0 +1 @@
10

9
debian/control vendored Normal file
View File

@ -0,0 +1,9 @@
Source: go-wit-gui
Build-Depends: golang
Package: go-wit-gui
Maintainer: Jeff Carr <jcarr@wit.com>
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.

1
debian/postinst vendored Executable file
View File

@ -0,0 +1 @@
#!/bin/sh

61
gui.go Normal file
View File

@ -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)
}

17
main.go Normal file
View File

@ -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)
}