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 1de593fd63
commit c59247824f
3 changed files with 50 additions and 22 deletions

View File

@ -5,30 +5,37 @@ import (
"go.wit.com/log"
)
func (hs *LinuxStatus) Show() {
func (ls *LinuxStatus) Show() {
log.Log(CHANGE, "linuxStatus.Show() window")
hs.window.Show()
hs.hidden = false
ls.window.Show()
ls.hidden = false
}
func (hs *LinuxStatus) Hide() {
func (ls *LinuxStatus) Hide() {
log.Log(CHANGE, "linuxStatus.Hide() window")
hs.window.Hide()
hs.hidden = true
ls.window.Hide()
ls.hidden = true
}
func (hs *LinuxStatus) Toggle() {
func (ls *LinuxStatus) Toggle() {
log.Log(CHANGE, "linuxStatus.Toggle() window")
if hs.hidden {
hs.window.Show()
if ls.hidden {
ls.window.Show()
} else {
hs.window.Hide()
ls.window.Hide()
}
}
func (hs *LinuxStatus) Ready() bool {
func (ls *LinuxStatus) Ready() bool {
if me == nil {return false}
if hs == nil {return false}
if hs.window == nil {return false}
if ls == nil {return false}
if ls.window == nil {return false}
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
import (
"go.wit.com/log"
"go.wit.com/gui/gadgets"
)
func New() *LinuxStatus {
if me != nil {
log.Warn("You have done New() twice. You can only do this once")
return me
}
me = &LinuxStatus {
hidden: true,
ready: false,
}
me.init = true
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,13 +14,14 @@ import (
var me *LinuxStatus
type LinuxStatus struct {
init bool
ready bool
hidden bool
changed bool
ready bool
hidden bool
changed bool
ifmap map[int]*IFtype // the current interfaces
ipmap map[string]*IPtype // the current ip addresses
parent *gui.Node
ifmap map[int]*IFtype // the current interfaces
ipmap map[string]*IPtype // the current ip addresses
window *gadgets.BasicWindow
group *gui.Node