/
SystemInfoBox.go
58 lines (48 loc) · 1.19 KB
/
SystemInfoBox.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
package uiWidgets
import (
// "fmt"
"github.com/gotk3/gotk3/gtk"
"github.com/Pyxis66/YallyScreen/logger"
"github.com/Pyxis66/YallyScreen/octoprintApis"
// "github.com/Pyxis66/YallyScreen/octoprintApis/dataModels"
"github.com/Pyxis66/YallyScreen/utils"
)
type SystemInfoBox struct {
*gtk.Box
}
func CreateSystemInfoBox(
client *octoprintApis.Client,
image *gtk.Image,
str1 string,
str2 string,
str3 string,
) *SystemInfoBox {
base := utils.MustBox(gtk.ORIENTATION_VERTICAL, 0)
base.SetHExpand(true)
base.SetHAlign(gtk.ALIGN_CENTER)
base.SetVExpand(true)
base.SetVAlign(gtk.ALIGN_CENTER)
ctx, _ := image.GetStyleContext()
ctx.AddClass("margin-top-5")
base.Add(image)
label1 := utils.MustLabel(str1)
ctx, _ = label1.GetStyleContext()
ctx.AddClass("margin-top-10")
ctx.AddClass("font-size-18")
base.Add(label1)
label2 := utils.MustLabel(str2)
ctx, _ = label2.GetStyleContext()
ctx.AddClass("font-size-18")
base.Add(label2)
logLevel := logger.LogLevel()
if logLevel == "debug" {
label3 := utils.MustLabel(str3)
ctx, _ = label3.GetStyleContext()
ctx.AddClass("font-size-16")
base.Add(label3)
}
instance := &SystemInfoBox {
Box: base,
}
return instance
}