Skip to content

Commit

Permalink
include icon to exe
Browse files Browse the repository at this point in the history
  • Loading branch information
balazsgrill committed Aug 31, 2024
1 parent ba957b1 commit e8380a1
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 11 deletions.
3 changes: 1 addition & 2 deletions cmd/main/aboutdialog.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import (
"fmt"
"os/exec"

"github.com/balazsgrill/potatodrive/win"
"github.com/lxn/walk"
. "github.com/lxn/walk/declarative"
"github.com/rs/zerolog/log"
Expand All @@ -20,7 +19,7 @@ func openlink(link *walk.LinkLabelLink) {
func aboutDialog(_ walk.Form) (int, error) {
return MainWindow{
Title: "About PotatoDrive",
Icon: win.InstalledFile(win.POTATOICO, false),
Icon: "#2\\0409",
MinSize: Size{300, 200},
Size: Size{300, 200},
MaxSize: Size{300, 200},
Expand Down
2 changes: 1 addition & 1 deletion cmd/main/ui.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import (
"golang.org/x/sys/windows"
)

//go:generate rsrc -manifest .\main.exe.manifest -o rsrc.syso
//go:generate rsrc -manifest .\main.exe.manifest -o rsrc.syso -ico ../../potato.ico

type UI struct {
*walk.MainWindow
Expand Down
11 changes: 3 additions & 8 deletions win/installation.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,24 +15,19 @@ const (
MUTEXNAME = "7122117b-3a2e-4c5d-bb21-2c9d0d2243bd"
)

func InstalledFile(relativename string, absolute bool) string {
func InstalledFile(relativename string, short bool) string {
exec, err := os.Executable()
if strings.HasPrefix(exec, os.TempDir()) {
// Detects development mode, where files are looked for in the working directory rather than along with the exe
if absolute {
exec, err = os.Getwd()
} else {
exec = "."
}
exec, err = os.Getwd()
} else {
exec = filepath.Dir(exec)
}

if err != nil {
panic(err)
}
path := filepath.Join(exec, relativename)
if absolute {
if short {
return ToShortPath(path)
}
return path
Expand Down

0 comments on commit e8380a1

Please sign in to comment.