summaryrefslogtreecommitdiff
path: root/windowViewPatch.go
diff options
context:
space:
mode:
authorJeff Carr <[email protected]>2025-01-29 09:06:19 -0600
committerJeff Carr <[email protected]>2025-01-29 12:18:16 -0600
commitf2281a2102d5821d337029a9f36395b955f3ec80 (patch)
treeeca9f11c59c8c3ca7dda42eee2d73b4a529a3c66 /windowViewPatch.go
parentb047d706795074a63cbbfd771bdd6787fa80a9ab (diff)
start a 'view patch' window
Diffstat (limited to 'windowViewPatch.go')
-rw-r--r--windowViewPatch.go114
1 files changed, 114 insertions, 0 deletions
diff --git a/windowViewPatch.go b/windowViewPatch.go
new file mode 100644
index 0000000..a59baa7
--- /dev/null
+++ b/windowViewPatch.go
@@ -0,0 +1,114 @@
+package main
+
+import (
+ "strings"
+ "sync"
+
+ "go.wit.com/lib/gadgets"
+ "go.wit.com/lib/protobuf/forgepb"
+
+ "go.wit.com/gui"
+)
+
+type patchWindow struct {
+ once sync.Once // only init() the window once
+ 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
+ summary *patchSummary // summary of current patches
+ setgrid *gui.Node // the list of each patchset
+ pset *forgepb.Patchset // the patchset in question
+}
+
+// todo: autogenerate these or make them standared 'gui' package functions
+// make this an go interface somehow
+
+// is the window hidden right now?
+func (w *patchWindow) Hidden() bool {
+ return w.win.Hidden()
+}
+
+// switches between the window being visable or hidden on the desktop
+func (w *patchWindow) Toggle() {
+ if w.Hidden() {
+ w.Show()
+ } else {
+ w.Hide()
+ }
+}
+
+// hides the window completely
+func (w *patchWindow) Show() {
+ w.win.Show()
+}
+
+func (w *patchWindow) Hide() {
+ w.win.Hide()
+}
+
+// should be the first box/widget in the window
+// greys out the window to the user
+func (w *patchWindow) Disable() {
+ w.stack.Disable()
+}
+
+func (w *patchWindow) Enable() {
+ w.stack.Enable()
+}
+
+// you can only have one of these
+func makePatchWindow(pset *forgepb.Patchset) *patchWindow {
+ pw := new(patchWindow)
+
+ // sync.Once()
+ pw.win = gadgets.RawBasicWindow("Patcheset for")
+ 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)
+
+ grid.NewLabel(pset.GitAuthorName)
+
+ /*
+ r.shelf = r.initGroup()
+ group1 := r.stack.NewGroup("stuff")
+ vbox := group1.Box()
+ vbox.Vertical()
+ */
+
+ g := pw.stack.NewGroup("PatchSet List")
+
+ // add the patch grid
+ g.NewGrid("", 0, 0)
+
+ /*
+ for i, line := range lines {
+ log.Info(i, line)
+ r.addFile(line)
+ }
+ */
+ return pw
+}
+
+func (r *patchWindow) addPatchset(line string) {
+ parts := strings.Split(line, "Author:")
+ author := parts[1]
+ parts = strings.Fields(parts[0])
+ name := parts[0]
+ subject := strings.Join(parts[1:], " ")
+ r.setgrid.NewLabel(name)
+ r.setgrid.NewLabel(subject)
+ r.setgrid.NewLabel(author)
+ r.setgrid.NewButton("Download", func() {
+ })
+ r.setgrid.NewButton("Apply", func() {
+ })
+ r.setgrid.NextRow()
+}