From 4641eceda817e822b1e4e096086a2227a04bb3fd Mon Sep 17 00:00:00 2001 From: Jeff Carr Date: Wed, 31 Jan 2024 13:34:13 -0600 Subject: [PATCH] remove testing code Signed-off-by: Jeff Carr --- common.go | 56 ------------------------------------------------------- draw.go | 3 --- new.go | 26 +++++++++----------------- update.go | 1 + 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) + log.Log(WARN, "Creating the Window") + me.window = gadgets.NewBasicWindow(parent, "OS Hostname Details") + me.window.Make() + draw(me) + me.window.Draw() + + me.ready = true 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 -} 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"))