summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJeff Carr <[email protected]>2024-01-31 13:34:13 -0600
committerJeff Carr <[email protected]>2024-01-31 13:34:13 -0600
commit4641eceda817e822b1e4e096086a2227a04bb3fd (patch)
tree5960151642ca54cd30fe574e28b463f44ecaf033
parent1a9b13dda5e13d0786718768443bab4a6916aab9 (diff)
Signed-off-by: Jeff Carr <[email protected]>
-rw-r--r--common.go56
-rw-r--r--draw.go3
-rw-r--r--new.go26
-rw-r--r--update.go1
4 files changed, 10 insertions, 76 deletions
diff --git a/common.go b/common.go
index 8d9389e..76f236c 100644
--- a/common.go
+++ b/common.go
@@ -2,7 +2,6 @@
package linuxstatus
import (
- "go.wit.com/gui"
"go.wit.com/log"
)
@@ -19,30 +18,6 @@ func (ls *LinuxStatus) Changed() bool {
return false
}
-func (ls *LinuxStatus) Make() {
- if !ls.Ready() {
- return
- }
- log.Log(CHANGE, "Make() window ready =", ls.ready)
- ls.window.Make()
- ls.ready = true
-}
-func (ls *LinuxStatus) Draw() {
- if !ls.Ready() {
- return
- }
- log.Log(CHANGE, "Draw() window ready =", ls.ready)
- ls.window.Draw()
- ls.ready = true
-}
-func (ls *LinuxStatus) Draw2() {
- if !ls.Ready() {
- return
- }
- log.Log(CHANGE, "draw(ls) ready =", ls.ready)
- draw(ls)
-}
-
func (ls *LinuxStatus) Show() {
if !ls.Ready() {
return
@@ -86,34 +61,3 @@ func (ls *LinuxStatus) Ready() bool {
}
return me.ready
}
-
-func (ls *LinuxStatus) Initialized() bool {
- log.Log(CHANGE, "checking Initialized()")
- if me == nil {
- return false
- }
- if ls == nil {
- return false
- }
- if ls.parent == nil {
- return false
- }
- return true
-}
-
-func (ls *LinuxStatus) SetParent(p *gui.Node) {
- log.Log(CHANGE, "Attempting SetParent")
- if me == nil {
- return
- }
- 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)
- }
-}
diff --git a/draw.go b/draw.go
index ac0e715..64727b6 100644
--- a/draw.go
+++ b/draw.go
@@ -8,9 +8,6 @@ import (
// creates the actual widgets.
// it's assumed you are always passing in a box
func draw(ls *LinuxStatus) {
- if !ls.Ready() {
- return
- }
ls.group = ls.window.Box().NewGroup("What Linux Knows It Is")
ls.grid = ls.group.NewGrid("gridnuts", 2, 2)
diff --git a/new.go b/new.go
index 22a2e59..17d87c9 100644
--- a/new.go
+++ b/new.go
@@ -2,12 +2,13 @@
package linuxstatus
import (
+ "go.wit.com/gui"
"go.wit.com/log"
"go.wit.com/lib/gadgets"
)
-func New() *LinuxStatus {
+func NewLinuxStatus(parent *gui.Node) *LinuxStatus {
if me != nil {
log.Log(WARN, "You have done New() twice. You can only do this once")
return me
@@ -19,21 +20,12 @@ func New() *LinuxStatus {
me.ifmap = make(map[int]*IFtype)
me.ipmap = make(map[string]*IPtype)
- return me
-}
-
-func (ls *LinuxStatus) InitWindow() {
- if !ls.Initialized() {
- log.Log(WARN, "not initalized yet (no parent for the window?)")
- return
- }
- if ls.window != nil {
- log.Log(WARN, "You already have a window")
- ls.ready = true
- return
- }
-
log.Log(WARN, "Creating the Window")
- ls.window = gadgets.NewBasicWindow(ls.parent, "Linux OS Details")
- ls.ready = true
+ me.window = gadgets.NewBasicWindow(parent, "OS Hostname Details")
+ me.window.Make()
+ draw(me)
+ me.window.Draw()
+
+ me.ready = true
+ return me
}
diff --git a/update.go b/update.go
index bd25ff1..69360ab 100644
--- a/update.go
+++ b/update.go
@@ -9,6 +9,7 @@ import (
)
func (ls *LinuxStatus) Update() {
+ if ls == nil { return }
if !ls.Ready() {
log.Log(WARN, "can't update yet. ready is false")
log.Error(errors.New("Update() is not ready yet"))