-
Notifications
You must be signed in to change notification settings - Fork 52
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add Icon to Windows native binary #1090
Conversation
super.link(); | ||
clearExplorerCache(); | ||
} catch (IOException ioe) { | ||
ioe.printStackTrace(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We typically don't print stack traces from here, use Logger.logSevere()
instead. You can use logFatal()
too, but that will throw a RTE. But since link
already propagates an IOE, I'd remove the try-catch, and add a check to super.link()
. If it fails, return false. Else continue with the cache.
} else { | ||
FileOps.copyResource("/native/windows/assets/icon.ico", iconDir.resolve("icon.ico")); | ||
Logger.logInfo("Default icon.ico image used. " + | ||
"Consider adding a custom icon to '/native/windows/assets'."); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you mean src/windows/assets
?
// Copy icon.ico to gvm/tmp/icon | ||
if (Files.exists(userAssets) && Files.isDirectory(userAssets) && Files.exists(userAssets.resolve("icon.ico"))) { | ||
FileOps.copyFile(userAssets.resolve("icon.ico"), iconDir.resolve("icon.ico")) ; | ||
Logger.logInfo("User provided icon.ico image used as application icon."); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
move to logDebug
FileOps.copyFile(userAssets.resolve("icon.ico"), iconDir.resolve("icon.ico")) ; | ||
Logger.logInfo("User provided icon.ico image used as application icon."); | ||
} else { | ||
FileOps.copyResource("/native/windows/assets/icon.ico", iconDir.resolve("icon.ico")); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You need to add it to gensrc
first, then copy it to tmp/icon
@@ -0,0 +1,3 @@ | |||
LANGUAGE 0x00, 0x00 | |||
|
|||
1 ICON "icon.ico" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add a blank line
src/main/java/com/gluonhq/substrate/target/WindowsTargetConfiguration.java
Outdated
Show resolved
Hide resolved
Files.createDirectories(windowsAssetPath); | ||
FileOps.copyResource("/native/windows/assets/icon.ico", windowsAssetPath.resolve("icon.ico")); | ||
FileOps.copyFile(windowsAssetPath.resolve("icon.ico"), tmpIconDir.resolve("icon.ico")); | ||
Logger.logInfo("Default icon.ico image used. " + |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The standard message is:
Logger.logInfo("Default icon.ico image generated in " + windowsAssetPath + ".\n" +
"Consider copying it to " + rootPath + " before performing any modification");
How should it be used? Creating a gluonfx app, where should custom icons be placed? |
If it helps someone: (according westinyang's question) |
Taking inspiration from @freya022's comment, I have been able to add an icon to the native exe by linking an icon object.
To create the icon object, we have a static file. Use
rc.exe
command to compile the resource file and thencvtres.exe
to convert the output file into an linkable object.Issue
Fixes #1086
Progress