summaryrefslogtreecommitdiff
path: root/linuxstatus
diff options
context:
space:
mode:
authorJeff Carr <[email protected]>2024-01-06 05:55:51 -0600
committerJeff Carr <[email protected]>2024-01-06 05:55:51 -0600
commitc59247824f22cf62b1625f5eeea11b809374d7a0 (patch)
tree4aa43e92ae656d62c5b3d928768dcd7965219652 /linuxstatus
parent1de593fd63d075b58e97ff9a656acef99938e487 (diff)
more window handling
Signed-off-by: Jeff Carr <[email protected]>
Diffstat (limited to 'linuxstatus')
-rw-r--r--linuxstatus/common.go33
-rw-r--r--linuxstatus/new.go24
-rw-r--r--linuxstatus/structs.go13
3 files changed, 49 insertions, 21 deletions
diff --git a/linuxstatus/common.go b/linuxstatus/common.go
index c4aea10..8bedaf8 100644
--- a/linuxstatus/common.go
+++ b/linuxstatus/common.go
@@ -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
+}
diff --git a/linuxstatus/new.go b/linuxstatus/new.go
index 0ce504c..5788ee1 100644
--- a/linuxstatus/new.go
+++ b/linuxstatus/new.go
@@ -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
+}
+
+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
+ }
- // me.window = gadgets.NewBasicWindow(me.myGui, "Linux OS Details")
+ ls.ready = true
+ log.Warn("Creating the Window")
+ ls.window = gadgets.NewBasicWindow(ls.parent, "Linux OS Details")
}
diff --git a/linuxstatus/structs.go b/linuxstatus/structs.go
index 185f0d7..be541f2 100644
--- a/linuxstatus/structs.go
+++ b/linuxstatus/structs.go
@@ -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