summaryrefslogtreecommitdiff
path: root/new.go
blob: 5da1fc1753fc725354819f0d5670b680d53786a6 (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
package repostatus

import (
	"go.wit.com/gui"
	"go.wit.com/lib/gadgets"
	"go.wit.com/log"
)

var windowMap map[string]*RepoStatus

func ListAll() {
	for path, rs := range windowMap {
		log.Warn(rs.GetMasterVersion(), path)
	}
}

func NewRepoStatusWindow(path string) *RepoStatus {
	if windowMap[path] == nil {
		log.Warn("This doesn't exist yet for path", path)
	} else {
		log.Warn("This already exists yet for path", path)
		log.Warn("should return windowMap[path] here")
	}
	rs := New(gui.TreeRoot(), path)
	windowMap[path] = rs

	// todo check if a window already exists for this path
	return rs
}

func New(p *gui.Node, path string) *RepoStatus {
	rs := &RepoStatus{
		hidden:   true,
		ready:    false,
		parent:   p,
		repopath: path,
	}
	rs.tags = make(map[string]string)
	rs.window = gadgets.NewBasicWindow(p, "GO Repo Details "+path)
	rs.window.Horizontal()
	rs.window.Make()
	rs.ready = true
	rs.draw()
	rs.window.Custom = func() {
		// rs.hidden = true
		rs.Hide()
		log.Warn("repostatus user closed the window()")
	}
	windowMap[path] = rs
	return rs
}

func init() {
	windowMap = make(map[string]*RepoStatus)
}