Application Icon: what changed
Revision 2 to 3. Removed lines have a minus sign; added lines have a plus sign.
| Old | New | Line | |
|---|---|---|---|
| 1 | 1 | The application icon is usually displayed on the main window of the application, and it can be changed as per the code in [[Changing application Icon]]. | |
| 2 | 2 | ||
| 3 | 3 | To change the icon of the executable itself, it is necessary to employ a platform-dependent technique. In Lazarus 0.9.27 support for this was added to the Project Options dialog, but it currently doesn't work for Linux because it requires calling an application to set the icon. | |
| 4 | 4 | ||
| 5 | 5 | ## IDE support for the Application Icon | |
| 6 | 6 | ||
| 7 | 7 | Just set the icon in the Project Options dialog, accessible in the Project menu. | |
| 8 | 8 | ||
| 9 | 9 | Works for Windows and macOS. | |
| 10 | 10 | ||
| 11 | 11 | ## Platform-specific techniques | |
| 12 | 12 | ||
| 13 | 13 | ### Windows | |
| 14 | 14 | ||
| 15 | 15 | 1\. Create a new file named "project.rc" (for example) containing: | |
| 16 | 16 | ||
| 17 | - | ||
| 17 | + | ```text | |
| 18 | 18 | MAINICON ICON "editor.ico" | |
| 19 | 19 | ``` | |
| 20 | 20 | ||
| 21 | 21 | 2\. Include in you project *.lpr file the following instruction: | |
| 22 | 22 | ||
| 23 | - | ||
| 23 | + | ```text | |
| 24 | 24 | {$R project.rc} | |
| 25 | 25 | ``` | |
| 26 | 26 | ||
| 27 | 27 | Work with version 0.9.24 and above. | |
| 28 | 28 | ||
| 29 | 29 | 3\. In the article [[Windows Icon]] you can see the best practices for creating the icon. | |
| 30 | 30 | ||
| 31 | 31 | ### Setting the Application Icon on macOS | |
| 32 | 32 | ||
| 33 | 33 | Under macOS it is necessary to set an icon for the Application Bundle. This is done by adding a field to the Info.plist file, like this: | |
| 34 | 34 | ||
| 35 | 35 | ``` xml | |
| 36 | 36 | <key>CFBundleIconFile</key> | |
| 37 | 37 | <string>iconfile.icns</string> | |
| 38 | 38 | ``` | |
| 39 | 39 | ||
| 40 | 40 | Where iconfile.icns is located inside MyBundle.app/Contents/Resources | |
| 41 | 41 | ||
| 42 | 42 | You can find instructions to create an icns file [here](http://www.macinstruct.com/node/59) | |
| 43 | 43 | ||
| 44 | 44 | ### Linux | |
| 45 | 45 | ||
| 46 | 46 | Under Linux application icons are located in special directories which are different on each Window Manager. The structure inside that directory, however, is standardized and described on the [Icon Theme Specification](http://www.freedesktop.org/Standards/icon-theme-spec). | |
| 47 | 47 | ||
| 48 | 48 | In order to determine how an application is launched the operating system uses a text file with the extension *.application*. This file provides different information including a description of the application, categories and locations of the executable and the icon. The standard is described in the [Desktop Entry Specification](http://www.freedesktop.org/wiki/Specifications/desktop-entry-spec/) of freedesktop.org. | |
| 49 | 49 | ||
| 50 | 50 | #### K Desktop Environment (KDE) | |
| 51 | 51 | ||
| 52 | 52 | You can find the directory for application icons for use by all users and for each user using the command: | |
| 53 | 53 | ||
| 54 | - | ||
| 54 | + | ```text | |
| 55 | 55 | kde-config --path icon | |
| 56 | 56 | ``` | |
| 57 | 57 | ||
| 58 | 58 | This should print a list of colon-separated paths to stdout. | |
| 59 | 59 | ||
| 60 | 60 | #### GNOME | |
| 61 | 61 | ||
| 62 | 62 | You can find the directory for application icons for use by all users and for each user using the command: | |
| 63 | 63 | ||
| 64 | - | ||
| 64 | + | ```text | |
| 65 | 65 | gnome-config --datadir | |
| 66 | 66 | ``` | |
| 67 | 67 | ||
| 68 | 68 | This should print a path to stdout, inside which is found a directory called pixmaps that attends to the Icon Theme Specification. | |
| 69 | 69 | ||
| 70 | 70 | #### LXDE | |
| 71 | 71 | ||
| 72 | 72 | In LXDE, icons are located in the directory | |
| 73 | 73 | ||
| 74 | - | ||
| 74 | + | ```text | |
| 75 | 75 | /usr/share/pixmaps | |
| 76 | 76 | ``` | |
| 77 | 77 | ||
| 78 | 78 | .application files are in | |
| 79 | 79 | ||
| 80 | - | ||
| 80 | + | ```text | |
| 81 | 81 | /usr/share/applications | |
| 82 | 82 | ``` | |
| 83 | 83 | ||
| 84 | 84 | --- | |
| 85 | 85 | *From the Free Pascal wiki, page "Application Icon", as it stood on 2020-08-02 after a change by Trev, out of the wiki's dump of 2024-05-26. Copyright stays with the author who wrote it, according to the old wiki's [[Licensing]] page. If you have concerns about this material, [message the admin](/wiki-contact).* | |
| 86 | 86 | Category: GUI | |
| 87 | 87 | Category: Lazarus |
