I’m building an app and I want to have a custom icon, instead of the OF icon that apperas on the window bar. I searched this forum and the net, but couldn’t find anything for Linux, which is my OS. Also, most threads are old, and I guess it’s likely they won’t work with recent OS versions, even for macOS and Windows.
So, my initial question is: how do I set a custon icon from a .png file on Linux?
My second question is: how do I set a custon icon on other OSes?
I only did on macOS. you have to convert somehow your PNG to icns file format.
After this you can add to the Project.xcconfig, or maybe the optional App.xcconfig the lines for custom icon
Hm, that doesn’t seem to work on Linux. .icns seems to be a macOS file type. I tried to put the last two line of the config file you posted to config.make, with my .png file, but nothing happened.
It looks like ofAppGLFWWindow::setWindowIcon() should be a public method now in the nightly build, where it used to be private.
Also, if you can figure out where the OF icon file is stored, I wonder if you could just replace its file with another .png file with the same name. That might be a hacky solution though.
@TimChi the nightly build for Linux doens’t include this change. As soon as I put the lines from Setting Icons in 0.8.0 I got an error saying that it is not public.
@grimus I downloaded the GitHub version, but compiling OF from there is not as straight forward as it is with the stable versions from OF’s site. Any hints on how to compile it?
@alexandrosdrymonitis if you don’t want to deal with the nightly build, you just need to make that function public. If you compare the ofAppGLFWWindow.h with the latest changes, you should be able to figure it out…i.e. you can make the same changes in your 0.11.2 build.
First of all, I was putting the code to set the icon in the ofApp.cpp file, as I didn’t notice it has to go to the main.cpp file. Also, @TimChi I’m not on a Pi this time .
I realised what’s wrong. I copied my project from the stable release to the nightly build, but the compiler draws sources from the stable release, even when I’m trying to compile from the nightly build. I guess there’s some file where I need to change something, but which one is that?
Hey have you tried importing the copied project in the PG? Qt Creator has a similar option to import a project. The PG has seemingly magical powers to restore and renew a project. I find this is particularly true with Xcode, where there are a ton of IDE-related things that need to be setup correctly.
To copy a project, I typically make a new, empty one with the PG (or with Qt Creator) and then copy only the contents of the /src and /bin/data folders from the old project to the new one. This helps to keep all of the IDE stuff correct for each project.
Finally I got it to work! I tried the project generator but it didn’t either. Perhaps some shared object that was copied from the original app, or some other file was causing the compiler to draw sources from the stable release. I copied the source code only, and the rest of the stuff from the emptyExample, and it compiled with my logo on it!
Does this process apply to all OSes, or is it just Linux?
Ugh the magical powers of the PG failed! But hey that’s great that you got it working. I do like copying (only) the source code and data folder into an empty project; it’s quick and IDE-agnostic. Make is common to all platforms though (I think), so a process that uses make should be similar for all of them.