From 0dd8cd9deaf2e8b1ac2537dfcefd76ac484e35e8 Mon Sep 17 00:00:00 2001 From: Jeff Carr Date: Tue, 16 Jan 2024 11:14:30 -0600 Subject: [PATCH] add Global Display Options Signed-off-by: Jeff Carr --- globalBuildOptions.go | 36 ---------- globalDisplayOptions.go | 88 ++++++++++++++++++++++++ resetOptions.go => globalResetOptions.go | 0 main.go | 6 +- structs.go | 3 + 5 files changed, 96 insertions(+), 37 deletions(-) create mode 100644 globalDisplayOptions.go rename resetOptions.go => globalResetOptions.go (100%) diff --git a/globalBuildOptions.go b/globalBuildOptions.go index 9e03d75..5694a70 100644 --- a/globalBuildOptions.go +++ b/globalBuildOptions.go @@ -52,7 +52,6 @@ func globalBuildOptions(box *gui.Node) { setCurrentBranch.Set("set all branches to " + me.toMoveToBranch) me.mainBranch.Disable() } - setCurrentBranch = groupvbox.NewButton("set all branches to", func () { for _, repo := range allrepos { var changeBranch [][]string @@ -106,39 +105,4 @@ func globalBuildOptions(box *gui.Node) { }) groupvbox.NewButton("build all apps", func () { }) - - groupvbox.NewButton("status.Update() all", func () { - for _, repo := range allrepos { - repo.status.Update() - } - }) - - groupvbox.NewButton("rescan all", func () { - for _, repo := range allrepos { - repo.newScan() - } - }) - - groupvbox.NewButton("hide perfect", func () { - for _, repo := range allrepos { - if repo.dirtyLabel.GetText() == "PERFECT" { - repo.hide() - } - return - } - }) -} - -func (r *repo) hide() { - r.pLabel.Hide() - r.lastTag.Hide() - r.vLabel.Hide() - - r.masterName.Hide() - r.masterVersion.Hide() - r.develName.Hide() - r.develVersion.Hide() - r.userName.Hide() - r.userVersion.Hide() - r.dirtyLabel.Hide() } diff --git a/globalDisplayOptions.go b/globalDisplayOptions.go new file mode 100644 index 0000000..6674c83 --- /dev/null +++ b/globalDisplayOptions.go @@ -0,0 +1,88 @@ +// This is a simple example +package main + +import ( + // "go.wit.com/log" + + "go.wit.com/gui/gui" + // "go.wit.com/gui/gadgets" +) + +func globalDisplayOptions(box *gui.Node) { + group1 := box.NewGroup("Global Display Options") + groupvbox := group1.NewBox("bw vbox", false) + // grouphbox := groupvbox.NewBox("bw hbox", true) + + groupvbox.NewLabel("Display Perfectly clean repos") + me.autoHidePerfect = groupvbox.NewCheckbox("Hide repos") + + groupvbox.NewButton("show all", func () { + for _, repo := range allrepos { + if repo.dirtyLabel.GetText() == "PERFECT" { + if repo.hidden { + repo.show() + } + // return + } + } + }) + groupvbox.NewButton("hide perfect", func () { + hidePerfect() + }) + + groupvbox.NewButton("status.Update() all", func () { + for _, repo := range allrepos { + repo.status.Update() + } + }) + + groupvbox.NewButton("rescan all", func () { + for _, repo := range allrepos { + repo.newScan() + } + }) +} + +func hidePerfect() { + for _, repo := range allrepos { + if repo.dirtyLabel.GetText() == "PERFECT" { + if repo.hidden { + continue + } + repo.hide() + // return + } + } +} + +func (r *repo) hide() { + r.pLabel.Hide() + r.lastTag.Hide() + r.vLabel.Hide() + + r.masterName.Hide() + r.masterVersion.Hide() + r.develName.Hide() + r.develVersion.Hide() + r.userName.Hide() + r.userVersion.Hide() + r.dirtyLabel.Hide() + r.showButton.Hide() + r.hidden = true +} + +func (r *repo) show() { + r.pLabel.Show() + r.lastTag.Show() + r.vLabel.Show() + + r.masterName.Show() + r.masterVersion.Show() + r.develName.Show() + r.develVersion.Show() + r.userName.Show() + r.userVersion.Show() + r.dirtyLabel.Show() + r.showButton.Show() + r.hidden = false +} diff --git a/resetOptions.go b/globalResetOptions.go similarity index 100% rename from resetOptions.go rename to globalResetOptions.go diff --git a/main.go b/main.go index 9afca5d..429230b 100644 --- a/main.go +++ b/main.go @@ -21,6 +21,8 @@ func main() { myGui.Default() repoworld() + log.Sleep(.3) + hidePerfect() gui.Watchdog() } @@ -47,7 +49,7 @@ func addRepo(grid *gui.Node, path string, master string, devel string, user stri newRepo.userVersion = grid.NewLabel("").SetProgName("userVersion") newRepo.dirtyLabel = grid.NewLabel("") - grid.NewButton("Show()", func () { + newRepo.showButton = grid.NewButton("Show()", func () { if newRepo.status == nil { log.Warn("status window doesn't exist") return @@ -64,6 +66,7 @@ func addRepo(grid *gui.Node, path string, master string, devel string, user stri newRepo.status.SetMasterName(master) newRepo.status.SetDevelName(devel) newRepo.status.SetUserName(user) + newRepo.hidden = false newRepo.status.Update() newRepo.newScan() allrepos = append(allrepos, newRepo) @@ -104,6 +107,7 @@ func repoworld() { box2 := reposwin.Box().NewBox("bw vbox", false) + globalDisplayOptions(box2) globalBuildOptions(box2) globalResetOptions(box2) diff --git a/structs.go b/structs.go index 23b845a..afa16af 100644 --- a/structs.go +++ b/structs.go @@ -19,6 +19,7 @@ var me repoType type repoType struct { script [][]string toMoveToBranch string // what the current working branch name is + autoHidePerfect *gui.Node mainBranch *gadgets.BasicCombobox develBranch *gadgets.BasicCombobox @@ -32,6 +33,7 @@ var dryrun *gui.Node var allrepos []*repo type repo struct { + hidden bool path string lasttagrev string lasttag string @@ -53,6 +55,7 @@ type repo struct { cButton *gui.Node // commit button pButton *gui.Node // push button + showButton *gui.Node // the button! status *repostatus.RepoStatus }