summaryrefslogtreecommitdiff
path: root/windowNewPatches.go
blob: 3e7e435189d85d839cde3d1c2784db969b05a096 (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
// Copyright 2017-2025 WIT.COM Inc. All rights reserved.
// Use of this source code is governed by the GPL 3.0

package main

import (
	"sync"

	"go.wit.com/gui"
	"go.wit.com/lib/gadgets"
	"go.wit.com/lib/protobuf/forgepb"
	"go.wit.com/log"
)

type stdPatchTableWin struct {
	sync.Mutex
	win    *gadgets.GenericWindow // the machines gui window
	box    *gui.Node              // the machines gui parent box widget
	TB     *forgepb.PatchesTable  // the gui table buffer
	update bool                   // if the window should be updated
}

func (w *stdPatchTableWin) Toggle() {
	if w == nil {
		return
	}
	if w.win == nil {
		return
	}
	w.win.Toggle()
}

func makePatchesWin() *stdPatchTableWin {
	dwin := new(stdPatchTableWin)
	dwin.win = gadgets.NewGenericWindow("forge current patchsets", "who is squirreling around?")
	dwin.win.Custom = func() {
		log.Info("test delete window here")
	}
	grid := dwin.win.Group.RawGrid()

	grid.NewButton("reload", func() {
	})

	// make a box at the bottom of the window for the protobuf table
	dwin.box = dwin.win.Bottom.Box().SetProgName("TBOX")

	return dwin
}

func (dwin *stdPatchTableWin) doPatchesTable(currentPatches *forgepb.Patches) {
	dwin.Lock()
	defer dwin.Unlock()
	if dwin.TB != nil {
		dwin.TB.Delete()
		dwin.TB = nil
	}
}

// define what rows to have in the protobuf table
func AddPatchesPB(tbox *gui.Node, pb *forgepb.Patches) *forgepb.PatchesTable {
	t := pb.NewTable("PatchesPB")
	t.NewUuid()
	t.SetParent(tbox)

	t.AddRepoNamespace()
	t.AddFilename()
	t.AddCommitHash()

	t.ShowTable()
	return t
}