aboutsummaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
authorJason A. Donenfeld <Jason@zx2c4.com>2019-05-14 14:02:33 +0200
committerJason A. Donenfeld <Jason@zx2c4.com>2019-05-14 14:02:33 +0200
commitccfee260c14fa53ac6f16a1ce249dec89af5dc64 (patch)
tree2a4966a13f87385863097b3f1ba2d6cd939f3ece
parentui: update progress indicator when created (diff)
downloadwireguard-windows-ccfee260c14fa53ac6f16a1ce249dec89af5dc64.tar.xz
wireguard-windows-ccfee260c14fa53ac6f16a1ce249dec89af5dc64.zip
ui: centralize state labels
-rw-r--r--ui/confview.go27
-rw-r--r--ui/iconprovider.go22
-rw-r--r--ui/tray.go11
3 files changed, 28 insertions, 32 deletions
diff --git a/ui/confview.go b/ui/confview.go
index 11226cc..869ba22 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 3b3fd13..52150a4 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) {
diff --git a/ui/tray.go b/ui/tray.go
index 749748e..7b5e55c 100644
--- a/ui/tray.go
+++ b/ui/tray.go
@@ -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")
}
}