summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJeff Carr <[email protected]>2025-02-15 03:59:08 -0600
committerJeff Carr <[email protected]>2025-02-15 07:28:34 -0600
commit25bc18c55f58949e5765b73af8b61ede8ac5eb12 (patch)
tree820ce661f2a7c9263a108c8a17c8b52734036fe4
parent940d259bbf34dd643ac8a555dc003804fd036c43 (diff)
start a table window
-rw-r--r--doGui.go15
-rw-r--r--tableWindow.go133
2 files changed, 144 insertions, 4 deletions
diff --git a/doGui.go b/doGui.go
index 6719661..91b79a5 100644
--- a/doGui.go
+++ b/doGui.go
@@ -49,14 +49,21 @@ func drawWindow(win *gadgets.BasicWindow) {
group1 := vbox.NewGroup("Zookeeper Settings")
grid := group1.NewGrid("buildOptions", 0, 0)
- // select the branch you want to test, build and develop against
- // this lets you select your user branch, but, when you are happy
- // you can merge everything into the devel branch and make sure it actually
- // works. Then, when that is good, merge and version everything in master
+ var tbwin *tableWindow
grid.NewButton("show zoo", func() {
win.Disable()
defer win.Enable()
+ if tbwin != nil {
+ if tbwin.Hidden() {
+ tbwin.Show()
+ } else {
+ tbwin.Hide()
+ }
+ return
+ }
+
log.Info("show zoo here")
+ tbwin = makeTableWindow()
})
}
diff --git a/tableWindow.go b/tableWindow.go
new file mode 100644
index 0000000..8ec1439
--- /dev/null
+++ b/tableWindow.go
@@ -0,0 +1,133 @@
+// 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/lib/gadgets"
+
+ "go.wit.com/gui"
+)
+
+type tableWindow 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
+}
+
+// todo: autogenerate these or make them standared 'gui' package functions
+// make this an go interface somehow
+
+// is the window hidden right now?
+func (w *tableWindow) Hidden() bool {
+ return w.win.Hidden()
+}
+
+// switches between the window being visable or hidden on the desktop
+func (w *tableWindow) Toggle() {
+ if w.Hidden() {
+ w.Show()
+ } else {
+ w.Hide()
+ }
+}
+
+// hides the window completely
+func (w *tableWindow) Show() {
+ w.win.Show()
+}
+
+func (w *tableWindow) Hide() {
+ w.win.Hide()
+}
+
+// should be the first box/widget in the window
+// greys out the window to the user
+func (w *tableWindow) Disable() {
+ w.stack.Disable()
+}
+
+func (w *tableWindow) Enable() {
+ w.stack.Enable()
+}
+
+// you can only have one of these
+func makeTableWindow() *tableWindow {
+ pw := new(tableWindow)
+
+ // sync.Once()
+ pw.win = gadgets.RawBasicWindow("Table window 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("Patchset Details:")
+ grid.NextRow()
+
+ g := pw.stack.NewGroup("PatchSet List")
+
+ // make a grid to put the list of git repos that have patches
+ // in this particular patchset
+ grid = g.NewGrid("", 0, 0)
+ grid.NewLabel("repo")
+ grid.NewLabel("patch name")
+ grid.NewLabel("Applied in current branch?")
+ grid.NewLabel("start hash")
+ grid.NewLabel("")
+ grid.NextRow()
+
+ // add the patches to the grid
+ // pw.addPatchset(grid, pset)
+ return pw
+}
+
+/*
+func (r *tableWindow) addPatchset(grid *gui.Node, pset *forgepb.Patchset) {
+
+ all := pset.Patches.SortByFilename()
+ for all.Scan() {
+ p := all.Next()
+ // for repo, patches := range repomap {
+ rn := p.RepoNamespace
+ repo := me.forge.FindByGoPath(rn)
+ if repo == nil {
+ log.Info("Could not figure out repo path", rn)
+ rn += " bad repo"
+ }
+ log.Info("Adding patches for", rn)
+ grid.NewLabel(rn)
+
+ // hash := repohash[repo]
+ grid.NewLabel(p.StartHash)
+ grid.NewLabel(p.Filename)
+
+ if repo == nil {
+ continue
+ }
+ grid.NewButton("apply", func() {
+ filename, _ := savePatch(p)
+ if err := applyPatch(repo, filename); err != nil {
+ log.Info("warn user of git am error", err)
+ }
+ })
+ grid.NewCheckbox("").SetChecked(true)
+ grid.NewCheckbox("").SetChecked(true)
+ grid.NewButton("save patch to /tmp", func() {
+ })
+ grid.NextRow()
+ }
+}
+*/