aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/ui
diff options
context:
space:
mode:
Diffstat (limited to 'ui')
-rw-r--r--ui/iconprovider.go26
-rw-r--r--ui/tray.go14
-rw-r--r--ui/updatepage.go10
3 files changed, 17 insertions, 33 deletions
diff --git a/ui/iconprovider.go b/ui/iconprovider.go
index 5c698abb..e1bee869 100644
--- a/ui/iconprovider.go
+++ b/ui/iconprovider.go
@@ -23,7 +23,6 @@ type IconProvider struct {
wireguardIcon *walk.Icon
imagesByRectAndState map[rectAndState]*walk.Bitmap
iconsByState map[service.TunnelState]*walk.Icon
- updateAvailabeImage *walk.Bitmap
scale float64
}
@@ -65,33 +64,12 @@ func (tsip *IconProvider) Dispose() {
tsip.wireguardIcon.Dispose()
tsip.wireguardIcon = nil
}
- if tsip.updateAvailabeImage != nil {
- tsip.updateAvailabeImage.Dispose()
- tsip.updateAvailabeImage = nil
- }
}
func (tsip *IconProvider) scaleForDPI(i int) int {
return int(tsip.scale * float64(i))
}
-func (tsip *IconProvider) UpdateAvailableImage() (*walk.Bitmap, error) {
- if tsip.updateAvailabeImage != nil {
- return tsip.updateAvailabeImage, nil
- }
-
- const size = 16 //TODO: this should use dynamic DPI, but we don't due to a walk bug with tab icons.
- updateAvailableIcon, err := loadSystemIcon("imageres", 100)
- if err != nil {
- return nil, err
- }
- tsip.updateAvailabeImage, err = walk.NewBitmapFromIcon(updateAvailableIcon, walk.Size{size, size})
- if err != nil {
- return nil, err
- }
- return tsip.updateAvailabeImage, nil
-}
-
func (tsip *IconProvider) ImageForTunnel(tunnel *service.Tunnel, size walk.Size) (*walk.Bitmap, error) {
state, err := tunnel.State()
if err != nil {
@@ -191,10 +169,10 @@ func (tsip *IconProvider) PaintForState(state service.TunnelState, canvas *walk.
dot, err = loadSystemIcon("imageres", 101)
case service.TunnelStopped:
- dot, err = walk.NewIconFromResourceWithSize("dot-gray.ico", walk.Size{iconSize, iconSize})
+ dot, err = walk.NewIconFromResourceWithSize("dot-gray.ico", walk.Size{iconSize, iconSize}) //TODO: replace with real icon
default:
- dot, err = walk.NewIconFromResourceWithSize("dot-yellow.ico", walk.Size{iconSize, iconSize})
+ dot, err = loadSystemIcon("shell32", 238) //TODO: this doesn't look that great overlayed on the app icon
}
if err != nil {
return err
diff --git a/ui/tray.go b/ui/tray.go
index 005c4089..0597f589 100644
--- a/ui/tray.go
+++ b/ui/tray.go
@@ -257,8 +257,6 @@ func (tray *Tray) SetTunnelState(tunnel *service.Tunnel, state service.TunnelSta
wasChecked := tunnelAction.Checked()
- icon, _ := iconProvider.IconWithOverlayForState(state)
-
switch state {
case service.TunnelStarted:
activeCIDRsAction.SetText("")
@@ -281,12 +279,15 @@ func (tray *Tray) SetTunnelState(tunnel *service.Tunnel, state service.TunnelSta
tunnelAction.SetEnabled(true)
tunnelAction.SetChecked(true)
if !wasChecked && showNotifications {
+ icon, _ := iconProvider.IconWithOverlayForState(state)
tray.ShowCustom("WireGuard Activated", fmt.Sprintf("The %s tunnel has been activated.", tunnel.Name), icon)
}
case service.TunnelStopped:
tunnelAction.SetChecked(false)
if wasChecked && showNotifications {
+ icon, _ := loadSystemIcon("imageres", 26) //TODO: this icon isn't very good...
+ defer icon.Dispose()
tray.ShowCustom("WireGuard Deactivated", fmt.Sprintf("The %s tunnel has been deactivated.", tunnel.Name), icon)
}
}
@@ -295,9 +296,10 @@ func (tray *Tray) SetTunnelState(tunnel *service.Tunnel, state service.TunnelSta
func (tray *Tray) UpdateFound() {
action := walk.NewAction()
action.SetText("An Update is Available!")
- if icon, err := iconProvider.UpdateAvailableImage(); err == nil {
- action.SetImage(icon)
- }
+ icon, _ := loadSystemIcon("imageres", 1)
+ defer icon.Dispose()
+ bitmap, _ := walk.NewBitmapFromIcon(icon, walk.Size{16, 16}) //TODO: This should use dynamic DPI.
+ action.SetImage(bitmap)
action.SetDefault(true)
showUpdateTab := func() {
tray.mtw.Show()
@@ -308,7 +310,7 @@ func (tray *Tray) UpdateFound() {
tray.ContextMenu().Actions().Insert(tray.ContextMenu().Actions().Len()-2, action)
//TODO: make clicking on this call showUpdateTab
- tray.ShowWarning("WireGuard Update Available", "An update to WireGuard is now available. You are advised to update as soon as possible.")
+ tray.ShowCustom("WireGuard Update Available", "An update to WireGuard is now available. You are advised to update as soon as possible.", icon)
}
func (tray *Tray) onManageTunnels() {
diff --git a/ui/updatepage.go b/ui/updatepage.go
index cffea839..04cc39ca 100644
--- a/ui/updatepage.go
+++ b/ui/updatepage.go
@@ -26,9 +26,11 @@ func NewUpdatePage() (*UpdatePage, error) {
up.SetTitle("An Update is Available!")
- if icon, err := iconProvider.UpdateAvailableImage(); err == nil {
- up.SetImage(icon)
- }
+ tabIcon, _ := loadSystemIcon("imageres", 1)
+ defer tabIcon.Dispose()
+ bitmap, _ := walk.NewBitmapFromIcon(tabIcon, walk.Size{16, 16}) //TODO: this should use dynamic DPI, but the tab widget seems broken
+ up.SetImage(bitmap)
+
//TODO: make title bold
up.SetLayout(walk.NewVBoxLayout())
@@ -44,6 +46,8 @@ func NewUpdatePage() (*UpdatePage, error) {
bar.SetVisible(false)
button, _ := walk.NewPushButton(up)
+ updateIcon, _ := loadSystemIcon("shell32", 46)
+ button.SetImage(updateIcon) //TODO: the placement of this looks sort of weird
button.SetText("Update Now")
walk.NewVSpacer(up)