@@ -14,13 +14,19 @@ var (
14
14
15
15
//go:embed status-icon-inactive.png
16
16
statusIconInactive []byte
17
+
18
+ //go:embed status-icon-exit-node.png
19
+ statusIconExitNode []byte
17
20
)
18
21
19
- func statusIcon (online bool ) []byte {
20
- if online {
21
- return statusIconActive
22
+ func statusIcon (s tsutil. Status ) []byte {
23
+ if ! s . Online () {
24
+ return statusIconInactive
22
25
}
23
- return statusIconInactive
26
+ if s .Status .ExitNodeStatus != nil {
27
+ return statusIconExitNode
28
+ }
29
+ return statusIconActive
24
30
}
25
31
26
32
type Tray struct {
@@ -31,7 +37,7 @@ type Tray struct {
31
37
}
32
38
33
39
func New (online bool ) * Tray {
34
- systray .SetIcon (statusIcon (online ))
40
+ systray .SetIcon (statusIcon (tsutil. Status {} ))
35
41
systray .SetTitle ("Trayscale" )
36
42
37
43
showWindow := systray .AddMenuItem ("Show" , "" )
@@ -49,6 +55,10 @@ func New(online bool) *Tray {
49
55
}
50
56
}
51
57
58
+ func (t * Tray ) ShowChan () <- chan struct {} {
59
+ return t .showItem .ClickedCh
60
+ }
61
+
52
62
func (t * Tray ) ConnToggleChan () <- chan struct {} {
53
63
return t .connToggleItem .ClickedCh
54
64
}
@@ -57,27 +67,17 @@ func (t *Tray) SelfNodeChan() <-chan struct{} {
57
67
return t .selfNodeItem .ClickedCh
58
68
}
59
69
60
- func (t * Tray ) ShowChan () <- chan struct {} {
61
- return t .showItem .ClickedCh
62
- }
63
-
64
70
func (t * Tray ) QuitChan () <- chan struct {} {
65
71
return t .quitItem .ClickedCh
66
72
}
67
73
68
- func (t * Tray ) setOnlineStatus (online bool ) {
69
- systray .SetIcon (statusIcon (online ))
70
- t .connToggleItem .SetTitle (connToggleText (online ))
71
- }
72
-
73
- func (t * Tray ) Update (s tsutil.Status , previousOnlineStatus bool ) {
74
+ func (t * Tray ) Update (s tsutil.Status ) {
74
75
if t == nil {
75
76
return
76
77
}
77
78
78
- if s .Online () != previousOnlineStatus {
79
- t .setOnlineStatus (s .Online ())
80
- }
79
+ systray .SetIcon (statusIcon (s ))
80
+ t .connToggleItem .SetTitle (connToggleText (s .Online ()))
81
81
82
82
selfTitle , connected := selfTitle (s )
83
83
t .selfNodeItem .SetTitle (fmt .Sprintf ("This machine: %v" , selfTitle ))
0 commit comments