From 7779d0185462c94e3330b79ae05ff3996992fb4f Mon Sep 17 00:00:00 2001 From: Jeff Carr Date: Thu, 30 Jan 2025 09:16:39 -0600 Subject: [PATCH] removing "patch summary" struct --- windowPatches.go | 84 +++++++++++++++++++++++------------------------- 1 file changed, 41 insertions(+), 43 deletions(-) diff --git a/windowPatches.go b/windowPatches.go index 69cb2d8..48f854e 100644 --- a/windowPatches.go +++ b/windowPatches.go @@ -12,15 +12,11 @@ import ( ) type patchesWindow struct { - win *gadgets.BasicWindow // the patches window - stack *gui.Node // the top box set as vertical - grid *gui.Node // the list of available patches - summary *patchSummary // summary of current patches - setgrid *gui.Node // the list of each patchset -} - -type patchSummary struct { - grid *gui.Node + win *gadgets.BasicWindow // the patches window + stack *gui.Node // the top box set as vertical + grid *gui.Node // the list of available patches + summary *patchSummary // summary of current patches + setgrid *gui.Node // the list of each patchset checkB *gui.Node totalOL *gadgets.OneLiner dirtyOL *gadgets.OneLiner @@ -30,6 +26,9 @@ type patchSummary struct { submitB *gui.Node } +type patchSummary struct { +} + func (r *patchesWindow) Hidden() bool { return r.win.Hidden() } @@ -64,10 +63,10 @@ func (r *patchesWindow) initWindow() { } r.grid = r.stack.NewGrid("", 0, 0) - r.summary = r.submitPatchesBox(r.stack) + r.submitPatchesBox() // update the stats about the repos and patches - r.summary.Update() + r.Update() g := r.stack.NewGroup("Patchset List") @@ -75,27 +74,27 @@ func (r *patchesWindow) initWindow() { r.setgrid = g.NewGrid("", 0, 0) } -func (r *patchesWindow) submitPatchesBox(box *gui.Node) *patchSummary { - s := new(patchSummary) - group1 := box.NewGroup("Repo Summary") - s.grid = group1.RawGrid() +func (r *patchesWindow) submitPatchesBox() { + // s := new(patchSummary) + group1 := r.stack.NewGroup("Repo Summary") + grid := group1.RawGrid() // make the header table for repo stats - s.totalOL = gadgets.NewOneLiner(s.grid, "Total") - s.grid.NextRow() - s.dirtyOL = gadgets.NewOneLiner(s.grid, "dirty") - s.grid.NextRow() - s.readonlyOL = gadgets.NewOneLiner(s.grid, "read-only") - s.grid.NextRow() - s.rw = gadgets.NewOneLiner(s.grid, "r/w") - s.grid.NextRow() + r.totalOL = gadgets.NewOneLiner(grid, "Total") + grid.NextRow() + r.dirtyOL = gadgets.NewOneLiner(grid, "dirty") + grid.NextRow() + r.readonlyOL = gadgets.NewOneLiner(grid, "read-only") + grid.NextRow() + r.rw = gadgets.NewOneLiner(grid, "r/w") + grid.NextRow() // make the 'widget group' for the buttons at the bottom of the window - group1 = box.NewGroup("Patchset Create") - s.grid = group1.RawGrid() + group1 = r.stack.NewGroup("Patchset Create") + grid = group1.RawGrid() - s.grid.NewButton("current patch summary", func() { - s.Update() + grid.NewButton("current patch summary", func() { + r.Update() pset, err := me.forge.MakeDevelPatchSet("current patches") if err != nil { log.Info("patchset creation failed", err) @@ -109,16 +108,16 @@ func (r *patchesWindow) submitPatchesBox(box *gui.Node) *patchSummary { win.Show() }) - s.reason = gadgets.NewBasicEntry(s.grid, "Patchset name:") - s.reason.Custom = func() { - if s.reason.String() != "" { - s.submitB.Enable() + r.reason = gadgets.NewBasicEntry(grid, "Patchset name:") + r.reason.Custom = func() { + if r.reason.String() != "" { + r.submitB.Enable() } else { - s.submitB.Disable() + r.submitB.Disable() } } - s.submitB = s.grid.NewButton("Submit", func() { - pset, err := me.forge.SubmitDevelPatchSet(s.reason.String()) + r.submitB = grid.NewButton("Submit", func() { + pset, err := me.forge.SubmitDevelPatchSet(r.reason.String()) if err != nil { log.Info(err) return @@ -126,7 +125,7 @@ func (r *patchesWindow) submitPatchesBox(box *gui.Node) *patchSummary { // line := "somedate " + s.reason.String() + " Author: me" + pset.GitAuthorEmail r.addPatchsetNew(pset) }) - s.grid.NewButton("Get Patchset List", func() { + grid.NewButton("Get Patchset List", func() { if psets, err := me.forge.GetPatchesets(); err != nil { log.Info("Get Patchsets failed", err) return @@ -141,9 +140,8 @@ func (r *patchesWindow) submitPatchesBox(box *gui.Node) *patchSummary { } }) - s.submitB.Disable() - s.grid.NextRow() - return s + r.submitB.Disable() + grid.NextRow() } func (r *patchesWindow) addPatchsetNew(pset *forgepb.Patchset) { @@ -168,7 +166,7 @@ func (r *patchesWindow) addPatchsetNew(pset *forgepb.Patchset) { } // will update this from the current state of the protobuf -func (s *patchSummary) Update() { +func (r *patchesWindow) Update() { var total, dirty, readonly, rw int // figure out the totals @@ -187,8 +185,8 @@ func (s *patchSummary) Update() { } // send the values to the GUI toolkit - s.totalOL.SetText(strconv.Itoa(total) + " repos") - s.dirtyOL.SetText(strconv.Itoa(dirty) + " repos") - s.readonlyOL.SetText(strconv.Itoa(readonly) + " repos") - s.rw.SetText(fmt.Sprintf("%d repos", rw)) + r.totalOL.SetText(strconv.Itoa(total) + " repos") + r.dirtyOL.SetText(strconv.Itoa(dirty) + " repos") + r.readonlyOL.SetText(strconv.Itoa(readonly) + " repos") + r.rw.SetText(fmt.Sprintf("%d repos", rw)) }