diff options
| author | Jeff Carr <[email protected]> | 2025-01-28 13:20:10 -0600 |
|---|---|---|
| committer | Jeff Carr <[email protected]> | 2025-01-28 13:20:10 -0600 |
| commit | 91c28de514b1a41e2355714f5352f5438dbe34a2 (patch) | |
| tree | fbf0c71cecc509195501be13a26dd07c0d026706 /windowPatches.go | |
| parent | 3b6e84abdfdff7181c1eb9553a6c6589d6ba027a (diff) | |
make a patchset grid widget
Diffstat (limited to 'windowPatches.go')
| -rw-r--r-- | windowPatches.go | 78 |
1 files changed, 60 insertions, 18 deletions
diff --git a/windowPatches.go b/windowPatches.go index 5a164b4..aaf1c4f 100644 --- a/windowPatches.go +++ b/windowPatches.go @@ -1,21 +1,25 @@ package main import ( + "strings" "sync" "go.wit.com/lib/gadgets" + "go.wit.com/lib/protobuf/forgepb" "go.wit.com/log" "go.wit.com/gui" ) 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 - grid *gui.Node // the list of available patches - summary *patchSummary // summary of current patches + 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 } func (r *patchesWindow) Hidden() bool { @@ -63,20 +67,17 @@ func (r *patchesWindow) initWindow() { r.grid = r.stack.NewGrid("", 0, 0) r.shelf = r.initGroup() - r.summary = submitPatchesBox(r.stack) + r.summary = r.submitPatchesBox(r.stack) + r.initSetList() } func (r *patchesWindow) initGroup() *gui.Node { - // reposbox.SetExpand(false) group1 := r.stack.NewGroup("stuff") vbox := group1.Box() - // hbox.Horizontal() vbox.Vertical() hbox := vbox.Box().Horizontal() - /* - */ dirty := hbox.NewCheckbox("dirty") dirty.Custom = func() { @@ -91,7 +92,6 @@ func (r *patchesWindow) initGroup() *gui.Node { }) hbox.NewButton("Get Patchsets", func() { - // if psets, err := me.forge.GetPatchesets(); err != nil { psets, err := me.forge.GetPatchesets() if err != nil { log.Info(err) @@ -102,12 +102,54 @@ func (r *patchesWindow) initGroup() *gui.Node { pset := all.Next() log.Info(pset) } - /* - if err := listPatches(); err != nil { - log.Info(err) - } - */ }) - return vbox } + +func (r *patchesWindow) initSetList() *gui.Node { + r.setgrid = r.stack.NewGrid("", 0, 0) + r.setlist = make(map[string]*forgepb.Patchset) + return nil +} + +func (r *patchesWindow) addPatchset(line string) { + parts := strings.Split(line, "Author:") + author := parts[1] + parts = strings.Fields(parts[0]) + name := parts[0] + subject := strings.Join(parts[1:], " ") + r.setgrid.NewLabel(name) + r.setgrid.NewLabel(subject) + r.setgrid.NewLabel(author) + r.setgrid.NewButton("Download", func() { + pset, err := getPatch(name) + if err != nil { + log.Info(name, "failed to download", err) + return + } + r.setlist[name] = pset + }) + r.setgrid.NewButton("Dump", func() { + pset := r.setlist[name] + if pset == nil { + log.Info(name, "was nil") + return + } + if !dumpPatchset(pset) { + log.Info("Dump: some patches are bad", name) + return + } + }) + r.setgrid.NewButton("Save", func() { + pset := r.setlist[name] + if pset == nil { + log.Info(name, "was nil") + return + } + if !savePatchset(pset) { + log.Info("Save: some patches are bad", name) + return + } + }) + r.setgrid.NextRow() +} |
