summaryrefslogtreecommitdiff
path: root/common.go
diff options
context:
space:
mode:
authorJeff Carr <[email protected]>2024-01-09 15:34:53 -0600
committerJeff Carr <[email protected]>2024-01-09 15:34:53 -0600
commit87346d9452b38db517e76e070f11928060bc2b99 (patch)
tree2e6ff93e368fda0a1581496985798fe4c1de3569 /common.go
initial commit
Diffstat (limited to 'common.go')
-rw-r--r--common.go85
1 files changed, 85 insertions, 0 deletions
diff --git a/common.go b/common.go
new file mode 100644
index 0000000..c70356e
--- /dev/null
+++ b/common.go
@@ -0,0 +1,85 @@
+package repostatus
+
+import (
+ "go.wit.com/log"
+ "go.wit.com/gui/gui"
+)
+
+// reports externally if something has changed
+// since the last time it was asked about it
+func (ls *RepoStatus) Changed() bool {
+ if ! ls.Ready() {return false}
+ if ls.changed {
+ ls.changed = false
+ return true
+ }
+ return false
+}
+
+func (ls *RepoStatus) Make() {
+ if ! ls.Ready() {return}
+ log.Log(CHANGE, "Make() window ready =", ls.ready)
+ ls.window.Make()
+ ls.ready = true
+}
+func (ls *RepoStatus) Draw() {
+ if ! ls.Ready() {return}
+ log.Log(CHANGE, "Draw() window ready =", ls.ready)
+ ls.window.Draw()
+ ls.ready = true
+}
+func (ls *RepoStatus) Draw2() {
+ if ! ls.Ready() {return}
+ log.Log(CHANGE, "draw(ls) ready =", ls.ready)
+ draw(ls)
+}
+
+func (ls *RepoStatus) Show() {
+ if ! ls.Ready() {return}
+ log.Log(CHANGE, "Show() window ready =", ls.ready)
+ ls.window.Show()
+ ls.hidden = false
+}
+
+func (ls *RepoStatus) Hide() {
+ if ! ls.Ready() {return}
+ log.Log(CHANGE, "Hide() window ready =", ls.ready)
+ ls.window.Hide()
+ ls.hidden = true
+}
+
+func (ls *RepoStatus) Toggle() {
+ if ! ls.Ready() {return}
+ log.Log(CHANGE, "Toggle() window ready =", ls.ready)
+ if ls.hidden {
+ ls.Show()
+ } else {
+ ls.Hide()
+ }
+}
+
+func (ls *RepoStatus) Ready() bool {
+ log.Log(SPEW, "Ready() maybe not ready? ls =", ls)
+ if ls == nil {return false}
+ if ls.window == nil {return false}
+ return ls.ready
+}
+
+func (ls *RepoStatus) Initialized() bool {
+ log.Log(CHANGE, "checking Initialized()")
+ if ls == nil {return false}
+ if ls.parent == nil {return false}
+ return true
+}
+
+func (ls *RepoStatus) SetParent(p *gui.Node) {
+ log.Log(CHANGE, "Attempting SetParent")
+ if ls == nil {return}
+ if ls.parent == nil {
+ log.Log(CHANGE, "SetParent =", p)
+ ls.parent = p
+ return
+ } else {
+ log.Log(CHANGE, "SetParent was already set to =", ls.parent)
+ }
+}