From 5ed61700ffa655c2611db3b3246beb4e2bc8777f Mon Sep 17 00:00:00 2001 From: Rui Lopes Date: Wed, 26 Oct 2022 13:34:30 +0100 Subject: [PATCH] Set the application icon, settings window title and systray tooltip (#523) --- client/ui/client_ui.go | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/client/ui/client_ui.go b/client/ui/client_ui.go index 7a7e1adc6..ed7b8ca79 100644 --- a/client/ui/client_ui.go +++ b/client/ui/client_ui.go @@ -8,7 +8,6 @@ import ( "context" "flag" "fmt" - "github.com/netbirdio/netbird/client/system" "os" "os/exec" "path" @@ -18,6 +17,8 @@ import ( "syscall" "time" + "github.com/netbirdio/netbird/client/system" + "github.com/cenkalti/backoff/v4" _ "embed" @@ -61,6 +62,13 @@ func main() { flag.Parse() a := app.New() + + if runtime.GOOS == "windows" { + a.SetIcon(fyne.NewStaticResource("netbird", iconDisconnectedICO)) + } else { + a.SetIcon(fyne.NewStaticResource("netbird", iconDisconnectedPNG)) + } + client := newServiceClient(daemonAddr, a, showSettings) if showSettings { a.Run() @@ -113,7 +121,7 @@ type serviceClient struct { iLogFile *widget.Entry iPreSharedKey *widget.Entry - // observable settings over correspondign iMngURL and iPreSharedKey values. + // observable settings over corresponding iMngURL and iPreSharedKey values. managementURL string preSharedKey string adminURL string @@ -121,7 +129,7 @@ type serviceClient struct { // newServiceClient instance constructor // -// This constructor olso build UI elements for settings window. +// This constructor also builds the UI elements for the settings window. func newServiceClient(addr string, a fyne.App, showSettings bool) *serviceClient { s := &serviceClient{ ctx: context.Background(), @@ -149,7 +157,7 @@ func newServiceClient(addr string, a fyne.App, showSettings bool) *serviceClient func (s *serviceClient) showUIElements() { // add settings window UI elements. - s.wSettings = s.app.NewWindow("Settings") + s.wSettings = s.app.NewWindow("NetBird Settings") s.iMngURL = widget.NewEntry() s.iAdminURL = widget.NewEntry() s.iConfigFile = widget.NewEntry() @@ -326,11 +334,13 @@ func (s *serviceClient) updateStatus() error { if status.Status == string(internal.StatusConnected) && !s.mUp.Disabled() { systray.SetIcon(s.icConnected) + systray.SetTooltip("NetBird (Connected)") s.mStatus.SetTitle("Connected") s.mUp.Disable() s.mDown.Enable() } else if status.Status != string(internal.StatusConnected) && s.mUp.Disabled() { systray.SetIcon(s.icDisconnected) + systray.SetTooltip("NetBird (Disconnected)") s.mStatus.SetTitle("Disconnected") s.mDown.Disable() s.mUp.Enable() @@ -355,6 +365,7 @@ func (s *serviceClient) updateStatus() error { func (s *serviceClient) onTrayReady() { systray.SetIcon(s.icDisconnected) + systray.SetTooltip("NetBird") // setup systray menu items s.mStatus = systray.AddMenuItem("Disconnected", "Disconnected")