summaryrefslogtreecommitdiff
path: root/main.go
blob: e3e6609c26338fdf7022bb7cd68b3cb929c7e541 (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
package gui

import (
	"log"
	"os"
)

import toolkit "git.wit.org/wit/gui/toolkit/andlabs"

const Xaxis = 0 // stack things horizontally
const Yaxis = 1 // stack things vertically

func init() {
	log.Println("gui.init() has been run")

	Config.counter = 0
	Config.prefix = "wit"

	// Config.Options.Debug = true
	// Config.Options.DebugNode = true
	// Config.Options.DebugTabs = true

	title := "guiBinaryTree"
	w     := 640
	h     := 480

	// Populates the top of the binary tree
	Config.master = addNode(title, w, h)
	if (Config.Options.Debug) {
		Config.master.Dump()
	}

	// load the gocli plugin
	PlugGocli = LoadPlugin("../../toolkit/gocli.so")
}

func Main(f func()) {
	if (Config.Options.Debug) {
		log.Println("Starting gui.Main() (using gtk via andlabs/ui)")
	}
	toolkit.Main(f)
}

// Other goroutines must use this to access the GUI
//
// You can not acess / process the GUI thread directly from
// other goroutines. This is due to the nature of how
// Linux, MacOS and Windows work (they all work differently. suprise. surprise.)
// For example: gui.Queue(NewWindow())
func Queue(f func()) {
	log.Println("Sending function to gui.Main() (using gtk via andlabs/ui)")
	toolkit.Queue(f)
}

// The window is destroyed but the application does not quit
func StandardClose(n *Node) {
	if (Config.Options.Debug) {
		log.Println("wit/gui Standard Window Close. name =", n.Name)
	}
}


// The window is destroyed but the application does not quit
func StandardExit(n *Node) {
	if (Config.Options.Debug) {
		log.Println("wit/gui Standard Window Exit. running os.Exit()")
	}
	os.Exit(0)
}