more window handling

Signed-off-by: Jeff Carr <jcarr@wit.com>
This commit is contained in:
Jeff Carr 2024-01-06 05:55:51 -06:00
parent 8b59a3141a
commit f35ad0837b
3 changed files with 50 additions and 22 deletions

View File

@ -5,30 +5,37 @@ import (
"go.wit.com/log" "go.wit.com/log"
) )
func (hs *LinuxStatus) Show() { func (ls *LinuxStatus) Show() {
log.Log(CHANGE, "linuxStatus.Show() window") log.Log(CHANGE, "linuxStatus.Show() window")
hs.window.Show() ls.window.Show()
hs.hidden = false ls.hidden = false
} }
func (hs *LinuxStatus) Hide() { func (ls *LinuxStatus) Hide() {
log.Log(CHANGE, "linuxStatus.Hide() window") log.Log(CHANGE, "linuxStatus.Hide() window")
hs.window.Hide() ls.window.Hide()
hs.hidden = true ls.hidden = true
} }
func (hs *LinuxStatus) Toggle() { func (ls *LinuxStatus) Toggle() {
log.Log(CHANGE, "linuxStatus.Toggle() window") log.Log(CHANGE, "linuxStatus.Toggle() window")
if hs.hidden { if ls.hidden {
hs.window.Show() ls.window.Show()
} else { } else {
hs.window.Hide() ls.window.Hide()
} }
} }
func (hs *LinuxStatus) Ready() bool { func (ls *LinuxStatus) Ready() bool {
if me == nil {return false} if me == nil {return false}
if hs == nil {return false} if ls == nil {return false}
if hs.window == nil {return false} if ls.window == nil {return false}
return me.ready return me.ready
} }
func (ls *LinuxStatus) Initialized() bool {
if me == nil {return false}
if ls == nil {return false}
if ls.parent == nil {return false}
return true
}

View File

@ -2,16 +2,36 @@
package linuxstatus package linuxstatus
import ( import (
"go.wit.com/log"
"go.wit.com/gui/gadgets"
) )
func New() *LinuxStatus { func New() *LinuxStatus {
if me != nil {
log.Warn("You have done New() twice. You can only do this once")
return me
}
me = &LinuxStatus { me = &LinuxStatus {
hidden: true, hidden: true,
ready: false, ready: false,
} }
me.init = true
return me return me
}
// me.window = gadgets.NewBasicWindow(me.myGui, "Linux OS Details")
func (ls *LinuxStatus) InitWindow() {
if ! ls.Initialized() {
log.Warn("LinuxStatus() is not initalized yet (no parent for the window?)")
return
}
if ls.window != nil {
log.Warn("You already have a window")
ls.ready = true
return
}
ls.ready = true
log.Warn("Creating the Window")
ls.window = gadgets.NewBasicWindow(ls.parent, "Linux OS Details")
} }

View File

@ -14,11 +14,12 @@ import (
var me *LinuxStatus var me *LinuxStatus
type LinuxStatus struct { type LinuxStatus struct {
init bool
ready bool ready bool
hidden bool hidden bool
changed bool changed bool
parent *gui.Node
ifmap map[int]*IFtype // the current interfaces ifmap map[int]*IFtype // the current interfaces
ipmap map[string]*IPtype // the current ip addresses ipmap map[string]*IPtype // the current ip addresses