summaryrefslogtreecommitdiff
path: root/windowRepo.go
blob: c934f5570cc1c5b60cbb0cd34985169ad640bee2 (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
package repostatus

import (
	"go.wit.com/lib/gadgets"
	"go.wit.com/lib/protobuf/gitpb"

	"go.wit.com/gui"
)

type repoWindow struct {
	repo  *gitpb.Repo          // the repo protobuf
	win   *gadgets.BasicWindow // the patches window
	stack *gui.Node            // the top box set as vertical
	//shelf   *gui.Node            // the first box in the stack, set as horizontal
	//grid    *gui.Node            // the list of available patches
	//setgrid *gui.Node            // the list of each patchset
}

// todo: autogenerate these or make them standared 'gui' package functions
// make this an go interface somehow

// is the window hidden right now?
func (w *repoWindow) Hidden() bool {
	return w.win.Hidden()
}

// switches between the window being visable or hidden on the desktop
func (w *repoWindow) Toggle() {
	if w.Hidden() {
		w.Show()
	} else {
		w.Hide()
	}
}

// hides the window completely
func (w *repoWindow) Show() {
	w.win.Show()
}

func (w *repoWindow) Hide() {
	w.win.Hide()
}

// should be the first box/widget in the window
// greys out the window to the user
func (w *repoWindow) Disable() {
	w.stack.Disable()
}

func (w *repoWindow) Enable() {
	w.stack.Enable()
}

// you can only have one of these
func MakeRepoWindow(repo *gitpb.Repo) *repoWindow {
	pw := new(repoWindow)

	// sync.Once()
	pw.win = gadgets.RawBasicWindow("Patcheset for " + repo.GetGoPath())
	pw.win.Make()

	pw.stack = pw.win.Box().NewBox("bw vbox", false)
	// me.reposwin.Draw()
	pw.win.Custom = func() {
		// sets the hidden flag to false so Toggle() works
		pw.win.Hide()
	}

	// grid := pw.stack.NewGrid("", 0, 0)

	return pw
}