repostatus/common.go

65 lines
1.1 KiB
Go
Raw Normal View History

2024-01-09 15:34:53 -06:00
package repostatus
import (
2024-11-15 09:12:47 -06:00
"go.wit.com/log"
2024-01-09 15:34:53 -06:00
)
// reports externally if something has changed
// since the last time it was asked about it
2024-02-16 17:55:13 -06:00
func (rs *RepoStatus) Changed() (string, bool) {
if !rs.Ready() {
2024-02-16 17:55:13 -06:00
return "", false
}
2024-02-18 15:09:48 -06:00
return rs.getChanges(), rs.changed
2024-02-16 17:55:13 -06:00
}
// keeps a human readable list of things that have
2024-02-18 15:09:48 -06:00
// changed. todo: timestampe these?
func (rs *RepoStatus) getChanges() string {
2024-02-16 17:55:13 -06:00
return rs.changes
}
func (rs *RepoStatus) NoteChange(s string) {
rs.changed = true
rs.changes += s + "\n"
2024-01-09 15:34:53 -06:00
}
func (rs *RepoStatus) Show() {
if !rs.Ready() {
return
}
log.Log(CHANGE, "Show() window ready =", rs.ready)
rs.window.Show()
2024-01-09 15:34:53 -06:00
}
func (rs *RepoStatus) Hide() {
if !rs.Ready() {
return
}
log.Log(CHANGE, "Hide() window ready =", rs.ready)
rs.window.Hide()
2024-01-09 15:34:53 -06:00
}
func (rs *RepoStatus) Toggle() {
if !rs.Ready() {
return
}
log.Log(CHANGE, "Toggle() window ready =", rs.ready)
if rs.window.Hidden() {
rs.Show()
2024-01-09 15:34:53 -06:00
} else {
rs.Hide()
2024-01-09 15:34:53 -06:00
}
}
func (rs *RepoStatus) Ready() bool {
if rs == nil {
return false
}
if rs.window == nil {
return false
}
return rs.ready
2024-01-09 15:34:53 -06:00
}