summaryrefslogtreecommitdiff
path: root/cmds/buttonplugin/main.go
blob: 64500bb145426f17d04e47350ed66e47792b31d7 (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
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
// This is a simple example
package main

import 	(
	"fmt"
	"log"
	"time"
	"strconv"
	"git.wit.org/wit/gui"
)

var title string = "Demo Plugin Window"
var outfile string = "/tmp/guilogfile"
var myGui *gui.Node

var buttonCounter int = 5

func main() {
	// time.Sleep(5 * time.Second)
	// var w *gui.Node

	// this doesn't seem to work
	// captureSTDOUT()

	// gui.LoadToolkit("default")
	// panic("WTF gocui not happening")
	// gui.LoadToolkit("gocui")
//	gui.Init()

	// buttonWindow()
	gui.SetDebug(true)
	myGui = gui.Start()
	time.Sleep(1 * time.Second)
	buttonWindow()
	log.Println("Main() END")
	time.Sleep(1 * time.Second)
	// gui.StartS("gocui")
	// gui.Redraw("gocui")
	gui.Watchdog()
	gui.StandardExit()
}

// This creates a window
func buttonWindow() {
	var w, t, g, more, more2 *gui.Node

	log.Println("buttonWindow()")
	log.Println("buttonWindow()")
	log.Println("buttonWindow()")

	w = myGui.NewWindow2(title).SetText("Nueva Ventana de Botones")
	t = w.NewTab("buttonTab")
	g = t.NewGroup("buttonGroup")
	g1 := t.NewGroup("buttonGroup 2")
	more = g1.NewGroup("more")
	g1.NewButton("hello2", func () {
		log.Println("world2")
	})
	more2 = g1.NewGrid("gridnuts", 3, 3)

	more2.NewLabel("more2")

	g.NewButton("this app is useful for plugin debuggin", func () {
	})
	g.NewLabel("STDOUT is set to: " + outfile)

	g.NewButton("hello", func () {
		log.Println("world")
	})

	g.NewButton("Load 'gocui'", func () {
		// this set the xterm and mate-terminal window title. maybe works generally?
		fmt.Println("\033]0;" + title + "blah \007")
		gui.StartS("gocui")
		gui.Redraw("gocui")
	})

	g.NewButton("Load 'andlabs'", func () {
		gui.StartS("andlabs")
	})

	g.NewButton("NewButton(more)", func () {
		log.Println("new foobar 2. Adding button 'foobar 3'")
		name := "foobar " + strconv.Itoa(buttonCounter)
		buttonCounter += 1
		more.NewButton(name, func () {
			log.Println("Got all the way to main() name =", name)
		})
	})

	g.NewButton("NewButton(more2)", func () {
		log.Println("new foobar 2. Adding button 'foobar 3'")
		name := "foobar " + strconv.Itoa(buttonCounter)
		buttonCounter += 1
		more2.NewButton(name, func () {
			log.Println("Got all the way to main() name =", name)
		})
	})

	g.NewButton("NewButton(more2 d)", func () {
		log.Println("new foobar 2. Adding button 'foobar 3'")
		name := "d" + strconv.Itoa(buttonCounter)
		buttonCounter += 1
		more2.NewButton(name, func () {
			log.Println("Got all the way to main() name =", name)
		})
	})

	g.NewButton("NewGroup()", func () {
		log.Println("new foobar 2. Adding button 'foobar 3'")
		name := "neat " + strconv.Itoa(buttonCounter)
		buttonCounter += 1
		more.NewGroup(name)
	})

	g.NewButton("gui.DebugWindow()", func () {
		gui.DebugWindow()
	})
}