diff options
| author | Jeff Carr <[email protected]> | 2025-01-29 09:06:19 -0600 |
|---|---|---|
| committer | Jeff Carr <[email protected]> | 2025-01-29 12:18:16 -0600 |
| commit | f2281a2102d5821d337029a9f36395b955f3ec80 (patch) | |
| tree | eca9f11c59c8c3ca7dda42eee2d73b4a529a3c66 /windowPatches.go | |
| parent | b047d706795074a63cbbfd771bdd6787fa80a9ab (diff) | |
start a 'view patch' window
Diffstat (limited to 'windowPatches.go')
| -rw-r--r-- | windowPatches.go | 28 |
1 files changed, 24 insertions, 4 deletions
diff --git a/windowPatches.go b/windowPatches.go index ad14e7f..4839f3d 100644 --- a/windowPatches.go +++ b/windowPatches.go @@ -13,14 +13,15 @@ import ( ) type patchesWindow 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 + 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 setlist map[string]*forgepb.Patchset // a map of the patch names to the protobuf + setwin map[string]*patchWindow // a map of the patch names to the protobuf } func (r *patchesWindow) Hidden() bool { @@ -84,6 +85,7 @@ func (r *patchesWindow) initWindow() { // add the grid r.setgrid = g.NewGrid("", 0, 0) r.setlist = make(map[string]*forgepb.Patchset) + r.setwin = make(map[string]*patchWindow) // query for current patchsets lines, err := listPatches() @@ -108,12 +110,30 @@ func (r *patchesWindow) addPatchset(line string) { r.setgrid.NewLabel(subject) r.setgrid.NewLabel(author) r.setgrid.NewButton("Download", func() { + pset, err := savePatch(name) + if err != nil { + log.Info(name, "failed to download", err) + return + } + r.setlist[name] = pset + }) + r.setgrid.NewButton("View", func() { + // has the window already been created? + win := r.setwin[name] + if win != nil { + win.Toggle() + log.Info("TRYING TO TOGGLE WINDOW") + return + } + + // get the patch and make the window pset, err := getPatch(name) if err != nil { log.Info(name, "failed to download", err) return } r.setlist[name] = pset + r.setwin[name] = makePatchWindow(pset) }) r.setgrid.NewButton("Dump", func() { pset := r.setlist[name] |
