blob: b83d27603bdd2c236c3763ae307914e2702ef21f (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
|
// This is a simple example
package main
import (
"os"
"fmt"
"log"
"git.wit.org/wit/gui"
)
var title string = "Cloudflare DNS Control Panel"
var outfile string = "/tmp/guilogfile"
var myGui *gui.Node
var buttonCounter int = 5
var gridW int = 5
var gridH int = 3
var mainWindow, more, more2 *gui.Node
func main() {
myGui = gui.New().Default()
buttonWindow()
// This is just a optional goroutine to watch that things are alive
gui.Watchdog()
gui.StandardExit()
}
// This creates a window
func buttonWindow() {
var t, g *gui.Node
log.Println("buttonWindow() START")
mainWindow = myGui.NewWindow(title).SetText(title)
t = mainWindow.NewTab("Cloudflare")
g = t.NewGroup("buttons")
g1 := t.NewGroup("buttonGroup 2")
more = g1.NewGroup("more")
showCloudflareCredentials(more)
// more2 = g1.NewGrid("gridnuts", gridW, gridH)
var domain string = os.Getenv("CLOUDFLARE_DOMAIN")
if (domain == "") {
domain = "example.org"
}
g.NewButton("Load " + domain + " DNS", func () {
loadDNS(domain)
})
g.NewButton("Load 'gocui'", func () {
// this set the xterm and mate-terminal window title. maybe works generally?
fmt.Println("\033]0;" + title + "blah \007")
myGui.LoadToolkit("gocui")
})
g.NewButton("Load 'andlabs'", func () {
myGui.LoadToolkit("andlabs")
})
g.NewButton("gui.DebugWindow()", func () {
gui.DebugWindow()
})
}
func showCloudflareCredentials(box *gui.Node) {
grid := box.NewGrid("credsGrid", 2, 4) // width = 2
grid.NewLabel("Domain")
grid.NewLabel(os.Getenv("CLOUDFLARE_DOMAIN"))
grid.NewLabel("Auth Key")
grid.NewLabel(os.Getenv("CLOUDFLARE_AUTHKEY"))
grid.NewLabel("Email")
grid.NewLabel(os.Getenv("CLOUDFLARE_EMAIL"))
grid.NewLabel("URL")
grid.NewLabel(os.Getenv("CLOUDFLARE_URL"))
}
|