diff options
| author | Jeff Carr <[email protected]> | 2025-03-10 17:14:59 -0500 |
|---|---|---|
| committer | Jeff Carr <[email protected]> | 2025-03-10 17:14:59 -0500 |
| commit | 1b145d1f04e4cd0e83f1c603af13803f0027fabb (patch) | |
| tree | 461464affe90941f8d4d647570085e7144fbfaf6 /windowPatches.go | |
| parent | 391a988e5f638f5c4b33b78f1f0ac9df7e670518 (diff) | |
rm old code
Diffstat (limited to 'windowPatches.go')
| -rw-r--r-- | windowPatches.go | 95 |
1 files changed, 95 insertions, 0 deletions
diff --git a/windowPatches.go b/windowPatches.go new file mode 100644 index 0000000..5735872 --- /dev/null +++ b/windowPatches.go @@ -0,0 +1,95 @@ +// 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(p *forgepb.Patches) *stdPatchTableWin { + dwin := new(stdPatchTableWin) + dwin.win = gadgets.NewGenericWindow("current patches", "patching options") + dwin.win.Custom = func() { + log.Info("test delete window here") + // dwin = nil + } + grid := dwin.win.Group.RawGrid() + + grid.NewLabel(fmt.Sprintf("%d", p.Len()) + grid.NewLabel(fmt.Sprintf("total patches") + grid.NextRow() + + all := p.All() + for all.Scan() { + repo := all.Next() + } + grid.NewLabel(fmt.Sprintf("%d", p.Len()) + grid.NewLabel(fmt.Sprintf("total repos") + grid.NextRow() + + 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") + + if p != nil { + dwin.doPatchesTable(p) + } + + return dwin +} + +func (dwin *stdPatchTableWin) doPatchesTable(currentPatches *forgepb.Patches) { + dwin.Lock() + defer dwin.Unlock() + if dwin.TB != nil { + dwin.TB.Delete() + dwin.TB = nil + } + + // display the protobuf + dwin.TB = AddPatchesPB(dwin.box, currentPatches) + f := func(p *forgepb.Patch) { + log.Info("do something with patch", p.Filename) + } + dwin.TB.Custom(f) +} + +// 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 +} |
