From 3d4e297db93544fe1380178ec4cb7fc286b2dc4c Mon Sep 17 00:00:00 2001 From: Jeff Carr Date: Wed, 7 Feb 2024 13:04:25 -0600 Subject: [PATCH] reorg buttons Signed-off-by: Jeff Carr --- globalDisplayOptions.go | 51 +++++++--------------- globalResetOptions.go | 42 +++++++----------- listWindow.go | 5 ++- tagWindow.go | 94 +++++++++++++++++++++++++++++++++++++++++ 4 files changed, 129 insertions(+), 63 deletions(-) create mode 100644 tagWindow.go diff --git a/globalDisplayOptions.go b/globalDisplayOptions.go index 6efb287..448f742 100644 --- a/globalDisplayOptions.go +++ b/globalDisplayOptions.go @@ -8,6 +8,7 @@ import ( "go.wit.com/gui" "go.wit.com/lib/debugger" + "go.wit.com/lib/gadgets" "go.wit.com/lib/gui/logsettings" "go.wit.com/log" // "go.wit.com/gui/gadgets" @@ -102,45 +103,25 @@ func globalDisplayOptions(box *gui.Node) { fmt.Fprintln(f, ")") }) - group1.NewButton("list all tags", func() { - me.autotypistWindow.Disable() - defer me.autotypistWindow.Enable() - for _, repo := range me.allrepos { - tagsW := repo.status.TagsW - if tagsW == nil { - repo.status.TagWindow() - tagsW = repo.status.TagsW - // tagsW.Prune() - continue - } - allTags := tagsW.ListAll() - for _, t := range allTags { - log.Info("found tag:", t.TagString(), "from", repo.status.String()) - } + var tagsW *tagWindow + group1.NewButton("tag Window", func() { + if tagsW == nil { + tagsW = makeTagWindow() + } else { + tagsW.win.Toggle() } }) - group1.NewButton("delete all dup tags", func() { - me.autotypistWindow.Disable() - defer me.autotypistWindow.Enable() - for _, repo := range me.allrepos { - tagsW := repo.status.TagsW - if tagsW == nil { - repo.status.TagWindow() - tagsW = repo.status.TagsW - tagsW.PruneSmart() - continue - } - deleteTags := tagsW.List() - for _, t := range deleteTags { - if me.autoDryRun.Checked() { - log.Info("delete tag --dry-run:", t.TagString(), "from", repo.status.String()) - } else { - log.Info("Deleting tag:", t.TagString(), "from", repo.status.String()) - // tagsW.Delete(t) - } - } + var listallB *gui.Node + var listW *gadgets.BasicWindow + listallB = group1.NewButton("go.wit.com Window", func() { + listallB.Disable() + if listW == nil { + listW = listWindow() + } else { + listW.Toggle() } + listallB.Enable() }) group2 := vbox.NewGroup("Debugger") diff --git a/globalResetOptions.go b/globalResetOptions.go index 1654c77..5f7f347 100644 --- a/globalResetOptions.go +++ b/globalResetOptions.go @@ -10,7 +10,22 @@ import ( func globalResetOptions(box *gui.Node) { group2 := box.NewGroup("Global Destructive Options") - globalTestingOptions(group2) + + me.autoRebuildButton = group2.NewButton("rebuild autotypist", func() { + me.autoRebuildButton.Disable() + me.autoRebuildButton.SetLabel("running....") + attemptAutoRebuild() + me.autoRebuildButton.Enable() + me.autoRebuildButton.SetLabel("rebuild autotypist") + }) + + me.stopOnErrors = group2.NewCheckbox("Stop on errors") + me.stopOnErrors.SetChecked(true) + + me.autoDryRun = group2.NewCheckbox("autotypist --dry-run") + me.autoDryRun.SetChecked(true) + + buildOptions := group2.NewGrid("buildOptions", 2, 1) buildOptions.NewLabel("start over") @@ -38,31 +53,6 @@ func globalResetOptions(box *gui.Node) { }) } -// things being testing -func globalTestingOptions(box *gui.Node) { - - var listallB *gui.Node - listallB = box.NewButton("go.wit.com/list", func() { - listallB.Disable() - listWindow() - listallB.Enable() - }) - - me.autoRebuildButton = box.NewButton("rebuild autotypist", func() { - me.autoRebuildButton.Disable() - me.autoRebuildButton.SetLabel("running....") - attemptAutoRebuild() - me.autoRebuildButton.Enable() - me.autoRebuildButton.SetLabel("rebuild autotypist") - }) - - me.stopOnErrors = box.NewCheckbox("Stop on errors") - me.stopOnErrors.SetChecked(true) - - me.autoDryRun = box.NewCheckbox("autotypist --dry-run") - me.autoDryRun.SetChecked(true) -} - func attemptAutoRebuild() { os.Setenv("GO111MODULE", "off") diff --git a/listWindow.go b/listWindow.go index 7aba7d7..091c9fa 100644 --- a/listWindow.go +++ b/listWindow.go @@ -41,10 +41,10 @@ type section struct { witRepos []*witRepo } -func listWindow() { +func listWindow() *gadgets.BasicWindow { if lw != nil { lw.Toggle() - return + return lw } lw = gadgets.NewBasicWindow(me.myGui, "go.wit.com repositories") lw.Custom = func() { @@ -89,6 +89,7 @@ func listWindow() { } } // lw.Toggle() + return lw } func downloadRepo(path string) bool { diff --git a/tagWindow.go b/tagWindow.go new file mode 100644 index 0000000..122f2d6 --- /dev/null +++ b/tagWindow.go @@ -0,0 +1,94 @@ +// This is a simple example +package main + +import ( + "go.wit.com/gui" + "go.wit.com/log" + + "go.wit.com/lib/gadgets" + "go.wit.com/lib/gui/repostatus" +) + +var tagW *tagWindow + +type tagWindow struct { + win *gadgets.BasicWindow + box *gui.Node + grid *gui.Node + group *gui.Node + allTags []*gitTag +} + +type gitTag struct { + rs *repostatus.RepoStatus + hidden bool +} + +func makeTagWindow() *tagWindow { + if tagW != nil { + tagW.win.Toggle() + return tagW + } + tagW = new(tagWindow) + tagW.win = gadgets.NewBasicWindow(me.myGui, "git tag tasks") + tagW.win.Custom = func() { + log.Warn("got to close") + } + + tagW.win.Make() + tagW.win.StandardClose() + tagW.win.Draw() + + tagW.box = tagW.win.Box() + tagW.group = tagW.box.NewGroup("tags") + tagW.group.NewButton("list tags", func() { + // dumpVersions() + }) + + tagW.group.NewButton("list all tags", func() { + me.autotypistWindow.Disable() + defer me.autotypistWindow.Enable() + for _, repo := range me.allrepos { + tagsW := repo.status.TagsW + if tagsW == nil { + repo.status.TagWindow() + tagsW = repo.status.TagsW + // tagsW.Prune() + continue + } + allTags := tagsW.ListAll() + for _, t := range allTags { + log.Info("found tag:", t.TagString(), "from", repo.status.String()) + } + } + }) + + tagW.group.NewButton("delete all dup tags", func() { + me.autotypistWindow.Disable() + defer me.autotypistWindow.Enable() + for _, repo := range me.allrepos { + tagsW := repo.status.TagsW + if tagsW == nil { + repo.status.TagWindow() + tagsW = repo.status.TagsW + tagsW.PruneSmart() + continue + } + deleteTags := tagsW.List() + for _, t := range deleteTags { + if me.autoDryRun.Checked() { + log.Info("delete tag --dry-run:", t.TagString(), "from", repo.status.String()) + } else { + log.Info("Deleting tag:", t.TagString(), "from", repo.status.String()) + // tagsW.Delete(t) + } + } + } + }) + + return tagW +} + +func (t *gitTag) Hide() { + t.hidden = true +}