diff options
Diffstat (limited to '')
-rw-r--r-- | ui/confview.go | 27 | ||||
-rw-r--r-- | ui/iconprovider.go | 22 | ||||
-rw-r--r-- | ui/tray.go | 11 |
3 files changed, 28 insertions, 32 deletions
diff --git a/ui/confview.go b/ui/confview.go index 11226cc4..869ba229 100644 --- a/ui/confview.go +++ b/ui/confview.go @@ -108,22 +108,7 @@ func (lsl *labelStatusLine) update(state service.TunnelState) { } lsl.statusImage.SetImage(img) s, e := lsl.statusLabel.TextSelection() - switch state { - case service.TunnelStarted: - lsl.statusLabel.SetText("Active") - - case service.TunnelStarting: - lsl.statusLabel.SetText("Activating") - - case service.TunnelStopped: - lsl.statusLabel.SetText("Inactive") - - case service.TunnelStopping: - lsl.statusLabel.SetText("Deactivating") - - case service.TunnelUnknown: - lsl.statusLabel.SetText("Unknown state") - } + lsl.statusLabel.SetText(textForState(state, false)) lsl.statusLabel.SetTextSelection(s, e) } @@ -208,16 +193,10 @@ func (tal *toggleActiveLine) update(state service.TunnelState) { switch state { case service.TunnelStarted: text = "Deactivate" - - case service.TunnelStarting: - text = "Activating..." - case service.TunnelStopped: text = "Activate" - - case service.TunnelStopping: - text = "Deactivating..." - + case service.TunnelStarting, service.TunnelStopping: + text = textForState(state, true) default: text = "" } diff --git a/ui/iconprovider.go b/ui/iconprovider.go index 3b3fd13d..52150a46 100644 --- a/ui/iconprovider.go +++ b/ui/iconprovider.go @@ -101,6 +101,28 @@ func iconForState(state service.TunnelState, size int) (icon *walk.Icon, err err return } +func textForState(state service.TunnelState, withEllipsis bool) (text string) { + switch state { + case service.TunnelStarted: + text = "Active" + case service.TunnelStarting: + text = "Activating" + case service.TunnelStopped: + text = "Inactive" + case service.TunnelStopping: + text = "Deactivating" + case service.TunnelUnknown: + text = "Unknown state" + } + if withEllipsis { + switch state { + case service.TunnelStarting, service.TunnelStopping: + text += "..." + } + } + return +} + var cachedSystemIconsForWidthAndDllIdx = make(map[widthAndDllIdx]*walk.Icon) func loadSystemIcon(dll string, index int32, size int) (icon *walk.Icon, err error) { @@ -234,28 +234,23 @@ func (tray *Tray) updateGlobalState(globalState service.TunnelState) { } } + tray.SetToolTip(fmt.Sprintf("WireGuard: %s", textForState(globalState, true))) + statusAction.SetText(fmt.Sprintf("Status: %s", textForState(globalState, false))) + switch globalState { case service.TunnelStarting: - statusAction.SetText("Status: Activating") setTunnelActionsEnabled(false) - tray.SetToolTip("WireGuard: Activating...") case service.TunnelStarted: activeCIDRsAction.SetVisible(true) - statusAction.SetText("Status: Active") setTunnelActionsEnabled(true) - tray.SetToolTip("WireGuard: Activated") case service.TunnelStopping: - statusAction.SetText("Status: Deactivating") setTunnelActionsEnabled(false) - tray.SetToolTip("WireGuard: Deactivating...") case service.TunnelStopped: activeCIDRsAction.SetVisible(false) - statusAction.SetText("Status: Inactive") setTunnelActionsEnabled(true) - tray.SetToolTip("WireGuard: Deactivated") } } |