summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--doGui.go9
-rw-r--r--windowNewPatchsets.go127
2 files changed, 136 insertions, 0 deletions
diff --git a/doGui.go b/doGui.go
index 943dd62..a42ef61 100644
--- a/doGui.go
+++ b/doGui.go
@@ -228,6 +228,15 @@ func drawWindow(win *gadgets.GenericWindow) {
reposWin = makeReposWin()
})
+ var patches *stdPatchsetTableWin
+ gridM.NewButton("New Patch Window", func() {
+ if patches != nil {
+ patches.Toggle()
+ return
+ }
+ patches = makePatchsetsWin()
+ })
+
// set the initial button state based on the last
// forge mode the user saved in the config file
switch me.forge.Config.Mode {
diff --git a/windowNewPatchsets.go b/windowNewPatchsets.go
new file mode 100644
index 0000000..fecdf5d
--- /dev/null
+++ b/windowNewPatchsets.go
@@ -0,0 +1,127 @@
+// Copyright 2017-2025 WIT.COM Inc. All rights reserved.
+// Use of this source code is governed by the GPL 3.0
+
+package main
+
+import (
+ "fmt"
+ "sync"
+
+ "go.wit.com/gui"
+ "go.wit.com/lib/gadgets"
+ "go.wit.com/lib/protobuf/forgepb"
+ "go.wit.com/log"
+)
+
+type stdPatchsetTableWin struct {
+ sync.Mutex
+ win *gadgets.GenericWindow // the machines gui window
+ box *gui.Node // the machines gui parent box widget
+ TB *forgepb.PatchsetsTable // the gui table buffer
+ update bool // if the window should be updated
+}
+
+func (w *stdPatchsetTableWin) Toggle() {
+ if w == nil {
+ return
+ }
+ if w.win == nil {
+ return
+ }
+ w.win.Toggle()
+}
+
+func makePatchsetsWin() *stdPatchsetTableWin {
+ dwin := new(stdPatchsetTableWin)
+ 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("update patchsets", func() {
+ psets, err := openPatchsets()
+ if err != nil {
+ log.Info("Open Patchsets failed", err)
+ return
+ }
+ dwin.doPatchsetsTable(psets)
+ })
+
+ // make a box at the bottom of the window for the protobuf table
+ dwin.box = dwin.win.Bottom.Box().SetProgName("TBOX")
+
+ // load and show the current patch sets
+ psets, err := openPatchsets()
+ if err != nil {
+ log.Info("Open Patchsets failed", err)
+ return dwin
+ }
+ dwin.doPatchsetsTable(psets)
+
+ return dwin
+}
+
+func (dwin *stdPatchsetTableWin) doPatchsetsTable(currentPatchsets *forgepb.Patchsets) {
+ dwin.Lock()
+ defer dwin.Unlock()
+ if dwin.TB != nil {
+ dwin.TB.Delete()
+ dwin.TB = nil
+ }
+
+ // display the protobuf
+ dwin.TB = AddPatchsetsPB(dwin.box, currentPatchsets)
+ f := func(pset *forgepb.Patchset) {
+ log.Info("Triggered. do something here", pset.Name)
+ // m.Enabled = true
+ win := makePatchWindow(pset)
+ win.Show()
+ }
+ dwin.TB.Custom(f)
+}
+
+func AddPatchsetsPB(tbox *gui.Node, pb *forgepb.Patchsets) *forgepb.PatchsetsTable {
+ t := pb.NewTable("PatchsetsPB")
+ t.NewUuid()
+ t.SetParent(tbox)
+
+ butf := func(p *forgepb.Patchset) string {
+ ctime := p.Ctime.AsTime()
+ s := ctime.Format("2006/01/02 15:04")
+ log.Info("Found", s, p.Name)
+ return "view"
+ }
+ t.AddButtonFunc("view", butf)
+
+ t.AddName()
+ t.AddComment()
+
+ ctimef := func(p *forgepb.Patchset) string {
+ ctime := p.Ctime.AsTime()
+ return ctime.Format("2006/01/02 15:04")
+ }
+ t.AddStringFunc("ctime", ctimef)
+
+ /*
+ etimef := func(e *forgepb.Patchset) string {
+ etime := e.Etime.AsTime()
+ s := etime.Format("2006/01/02 15:04")
+ if strings.HasPrefix(s, "1970/") {
+ // just show a blank if it's not set
+ return ""
+ }
+ return s
+ }
+ t.AddStringFunc("etime", etimef)
+ */
+
+ t.AddStringFunc("Author", func(p *forgepb.Patchset) string {
+ return fmt.Sprintf("%s <%s>", p.GitAuthorName, p.GitAuthorEmail)
+ })
+
+ t.AddUuid()
+
+ t.ShowTable()
+ return t
+}