@@ -10,6 +10,7 @@ import (
10
10
"fyne.io/fyne/v2/container"
11
11
"fyne.io/fyne/v2/data/binding"
12
12
"fyne.io/fyne/v2/dialog"
13
+ "fyne.io/fyne/v2/driver/desktop"
13
14
"fyne.io/fyne/v2/theme"
14
15
"fyne.io/fyne/v2/widget"
15
16
"github.com/fynelabs/fynetailscale"
@@ -104,6 +105,9 @@ func (a *appData) createUI(lastHost string) {
104
105
nil , nil , nil , tree ),
105
106
container .NewBorder (header , footer , nil , nil , tabs )))
106
107
a .win .Resize (fyne .NewSize (800 , 600 ))
108
+ a .win .SetCloseIntercept (func () {
109
+ a .win .Hide ()
110
+ })
107
111
108
112
if a .salt () != nil {
109
113
a .getPassword (lastHost , sel )
@@ -178,6 +182,29 @@ func (a *appData) displayNeighbor(sel *widget.Select) {
178
182
d .Show ()
179
183
}
180
184
185
+ func (a * appData ) updateSystray (sel * widget.Select ) {
186
+ if _ , ok := a .app .(desktop.App ); ok {
187
+ items := []* fyne.MenuItem {}
188
+
189
+ for idx := range sel .Options {
190
+ host := sel .Options [idx ]
191
+
192
+ items = append (items , fyne .NewMenuItem (host , func () {
193
+ sel .SetSelected (host )
194
+ a .win .Show ()
195
+ }))
196
+ }
197
+
198
+ if len (items ) == 0 {
199
+ items = append (items , fyne .NewMenuItem ("Show" , func () {
200
+ a .win .Show ()
201
+ }))
202
+ }
203
+ a .m .Items = items
204
+ a .m .Refresh ()
205
+ }
206
+ }
207
+
181
208
func (a * appData ) newHost (sel * widget.Select , ip string ) {
182
209
host := widget .NewEntry ()
183
210
host .PlaceHolder = "127.0.0.1"
@@ -203,6 +230,8 @@ func (a *appData) newHost(sel *widget.Select, ip string) {
203
230
sel .SetSelected (r .host )
204
231
sel .Refresh ()
205
232
233
+ a .updateSystray (sel )
234
+
206
235
if a .key == nil {
207
236
a .createPassword (func () {
208
237
if err := a .saveRouter (r , pass .Text ); err != nil {
@@ -393,6 +422,7 @@ func (a *appData) removeHost(sel *widget.Select) {
393
422
}
394
423
}
395
424
sel .Refresh ()
425
+ a .updateSystray (sel )
396
426
}
397
427
398
428
func (a * appData ) reconnectHost (updateStatus func (identity binding.String , ssl bool , err error ), sel * widget.Select ) {
0 commit comments