aboutsummaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
-rw-r--r--resources.rc3
-rw-r--r--ui/icon/add.svg2
-rw-r--r--ui/icon/delete.svg2
-rw-r--r--ui/icon/export.svg2
-rw-r--r--ui/iconprovider.go16
-rw-r--r--ui/tunnelspage.go14
6 files changed, 26 insertions, 13 deletions
diff --git a/resources.rc b/resources.rc
index f1b29f35..f394bfed 100644
--- a/resources.rc
+++ b/resources.rc
@@ -9,9 +9,6 @@
CREATEPROCESS_MANIFEST_RESOURCE_ID RT_MANIFEST manifest.xml
$wireguard.ico ICON ui/icon/wireguard.ico
-add.ico ICON ui/icon/add.ico
-delete.ico ICON ui/icon/delete.ico
-export.ico ICON ui/icon/export.ico
dot-gray.ico ICON ui/icon/dot-gray.ico
dot-yellow.ico ICON ui/icon/dot-yellow.ico
dot-green.ico ICON ui/icon/dot-green.ico
diff --git a/ui/icon/add.svg b/ui/icon/add.svg
deleted file mode 100644
index 2e1dd028..00000000
--- a/ui/icon/add.svg
+++ /dev/null
@@ -1,2 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<svg width="1e3" height="1e3" version="1.1" xmlns="http://www.w3.org/2000/svg"><path d="m893 447v107q0 22-16 38t-38 15h-232v233q0 22-16 37t-38 16h-107q-22 0-38-16t-15-37v-233h-232q-23 0-38-15t-16-38v-107q0-23 16-38t38-16h232v-232q0-22 15-38t38-16h107q23 0 38 16t16 38v232h232q23 0 38 16t16 38z" glyph-name="plus" horiz-adv-x="785.7" unicode=""/></svg>
diff --git a/ui/icon/delete.svg b/ui/icon/delete.svg
deleted file mode 100644
index 6c204271..00000000
--- a/ui/icon/delete.svg
+++ /dev/null
@@ -1,2 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<svg width="1e3" height="1e3" version="1.1" xmlns="http://www.w3.org/2000/svg"><path d="m893 446.97v107q0 22-16 38t-38 15h-678q-23 0-38-15t-16-38v-107q0-23 16-38t38-16h678q23 0 38 16t16 38z" glyph-name="minus" horiz-adv-x="785.7" unicode=""/></svg>
diff --git a/ui/icon/export.svg b/ui/icon/export.svg
deleted file mode 100644
index caef7a2c..00000000
--- a/ui/icon/export.svg
+++ /dev/null
@@ -1,2 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<svg width="1e3" height="1e3" version="1.1" xmlns="http://www.w3.org/2000/svg"><path d="m821.5 623.5v144q0 67-47 114t-114 47h-464q-67 0-114-47t-47-114v-464q0-66 47-113t114-48h142q7 0 13 6t5 12q0 15-15 18-43 15-74 34-5 2-9 2h-62q-37 0-63 26t-27 63v464q0 37 27 63t63 27h464q37 0 63-27t26-63v-119q0-11 10-16 16-7 31-21 8-9 19-4 12 5 12 16zm132-277-214 214q-10 11-25 11-7 0-14-3-22-9-22-33v-107h-89q-181 0-245 73-66 77-41 264 2 13-11 19-5 1-7 1-9 0-14-7-6-8-12-17t-22-39-28-55-21-64-10-68q0-27 2-51t8-50 15-49 27-45 38-42 52-34 70-27 89-17 110-6h89v-107q0-24 22-33 7-3 14-3 14 0 25 11l214 214q11 10 11 25t-11 25z" glyph-name="export" horiz-adv-x="928.6" unicode=""/></svg>
diff --git a/ui/iconprovider.go b/ui/iconprovider.go
index 5ebf93bb..b56a4a5b 100644
--- a/ui/iconprovider.go
+++ b/ui/iconprovider.go
@@ -6,8 +6,12 @@
package ui
import (
+ "fmt"
"github.com/lxn/walk"
+ "github.com/lxn/win"
+ "golang.org/x/sys/windows"
"golang.zx2c4.com/wireguard/windows/service"
+ "path"
)
type rectAndState struct {
@@ -229,3 +233,15 @@ func (tsip *IconProvider) PaintForState(state service.TunnelState, canvas *walk.
return nil
}
+
+func loadSystemIcon(dll string, index uint) (*walk.Icon, error) {
+ system32, err := windows.GetSystemDirectory()
+ if err != nil {
+ return nil, err
+ }
+ hicon := win.ExtractIcon(win.GetModuleHandle(nil), windows.StringToUTF16Ptr(path.Join(system32, dll+".dll")), int32(index))
+ if hicon <= 1 {
+ return nil, fmt.Errorf("Unable to find icon %d of %s", index, dll)
+ }
+ return walk.NewIconFromHICON(hicon)
+}
diff --git a/ui/tunnelspage.go b/ui/tunnelspage.go
index 10a6c782..c2e555cf 100644
--- a/ui/tunnelspage.go
+++ b/ui/tunnelspage.go
@@ -70,23 +70,29 @@ func NewTunnelsPage() (*TunnelsPage, error) {
tunnelsToolBar, _ := walk.NewToolBarWithOrientationAndButtonStyle(toolBarContainer, walk.Horizontal, walk.ToolBarButtonImageBeforeText)
imageSize := walk.Size{tp.DPI() / 6, tp.DPI() / 6} // Dividing by six is the same as dividing by 96 and multiplying by 16. TODO: Use dynamic DPI
- imageList, _ := walk.NewImageList(imageSize, walk.RGB(255, 255, 255))
+ imageList, _ := walk.NewImageList(imageSize, walk.RGB(0, 0, 0))
tunnelsToolBar.SetImageList(imageList)
addMenu, _ := walk.NewMenu()
tp.AddDisposable(addMenu)
importAction := walk.NewAction()
importAction.SetText("Import tunnel(s) from file...")
+ importActionIcon, _ := loadSystemIcon("imageres", 3)
+ importActionImage, _ := walk.NewBitmapFromIcon(importActionIcon, imageSize)
+ importAction.SetImage(importActionImage)
importAction.SetShortcut(walk.Shortcut{walk.ModControl, walk.KeyO})
importAction.Triggered().Attach(tp.onImport)
addAction := walk.NewAction()
addAction.SetText("Add empty tunnel")
+ addActionIcon, _ := loadSystemIcon("imageres", 2)
+ addActionImage, _ := walk.NewBitmapFromIcon(addActionIcon, imageSize)
+ addAction.SetImage(addActionImage)
addAction.SetShortcut(walk.Shortcut{walk.ModControl, walk.KeyN})
addAction.Triggered().Attach(tp.onAddTunnel)
addMenu.Actions().Add(importAction)
addMenu.Actions().Add(addAction)
addMenuAction := walk.NewMenuAction(addMenu)
- addMenuActionIcon, _ := walk.NewIconFromResourceWithSize("add.ico", imageSize)
+ addMenuActionIcon, _ := loadSystemIcon("shell32", 149)
addMenuActionImage, _ := walk.NewBitmapFromIcon(addMenuActionIcon, imageSize)
addMenuAction.SetImage(addMenuActionImage)
addMenuAction.SetText("Add Tunnel")
@@ -97,7 +103,7 @@ func NewTunnelsPage() (*TunnelsPage, error) {
tunnelsToolBar.Actions().Add(walk.NewSeparatorAction())
deleteAction := walk.NewAction()
- deleteActionIcon, _ := walk.NewIconFromResourceWithSize("delete.ico", imageSize)
+ deleteActionIcon, _ := loadSystemIcon("shell32", 131)
deleteActionImage, _ := walk.NewBitmapFromIcon(deleteActionIcon, imageSize)
deleteAction.SetImage(deleteActionImage)
deleteAction.SetShortcut(walk.Shortcut{0, walk.KeyDelete})
@@ -108,7 +114,7 @@ func NewTunnelsPage() (*TunnelsPage, error) {
tunnelsToolBar.Actions().Add(walk.NewSeparatorAction())
exportAction := walk.NewAction()
- exportActionIcon, _ := walk.NewIconFromResourceWithSize("export.ico", imageSize)
+ exportActionIcon, _ := loadSystemIcon("imageres", 165) // Or "shell32", 45?
exportActionImage, _ := walk.NewBitmapFromIcon(exportActionIcon, imageSize)
exportAction.SetImage(exportActionImage)
exportAction.SetToolTip("Export all tunnels to zip...")