Difference between revisions of "Application Icon"

From Lazarus wiki
Jump to navigationJump to search
(New page: The application icon is usually displayed on the main window of the application, and it can be controlled by setting Application.Icon To change the icon of the executable itself, it is ne...)
 
m (→‎Setting the Application Icon on macOS: Added syntax highlighting)
 
(24 intermediate revisions by 13 users not shown)
Line 1: Line 1:
The application icon is usually displayed on the main window of the application, and it can be controlled by setting Application.Icon
+
{{Application Icon}}
  
To change the icon of the executable itself, it is necessary to emply a platform-dependent technique.
+
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]].
 +
 
 +
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.
  
 
__TOC__
 
__TOC__
  
==Setting the Application Icon on Windows==
+
==IDE support for the Application Icon==
  
Please write me
+
Just set the icon in the Project Options dialog, accessible in the Project menu.
  
==Setting the Application Icon on Mac OS X==
+
Works for Windows and macOS.
  
 +
==Platform-specific techniques==
  
Under Mac OS X 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:
+
===Windows===
  
 +
1. Create a new file named "project.rc" (for example) containing:
 +
 +
  MAINICON ICON "editor.ico"
 +
 +
2. Include in you project *.lpr file the following instruction:
 +
 +
  {$R project.rc}
 +
 +
Work with version 0.9.24 and above.
 +
 +
3. In the article [[Windows Icon]] you can see the best practices for creating the icon.
 +
 +
===Setting the Application Icon on macOS===
 +
 +
 +
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:
 +
 +
<syntaxhighlight lang=xml>
 
   <key>CFBundleIconFile</key>
 
   <key>CFBundleIconFile</key>
 
   <string>iconfile.icns</string>
 
   <string>iconfile.icns</string>
 +
</syntaxhighlight>
  
 
Where iconfile.icns is located inside MyBundle.app/Contents/Resources
 
Where iconfile.icns is located inside MyBundle.app/Contents/Resources
Line 21: Line 43:
 
You can find instructions to create an icns file [http://www.macinstruct.com/node/59 here]
 
You can find instructions to create an icns file [http://www.macinstruct.com/node/59 here]
  
==Setting the Application Icon on Linux==
+
===Linux===
 +
 
 +
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 [http://www.freedesktop.org/Standards/icon-theme-spec Icon Theme Specification].
  
Under Linux application icons are located in special directories which are different on each Window Manager. The structure inside that directory, however, is standarized and described on the [http://www.freedesktop.org/Standards/icon-theme-spec Icon Theme Specification]
+
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 [http://www.freedesktop.org/wiki/Specifications/desktop-entry-spec/ Desktop Entry Specification] of freedesktop.org.
  
===K Desktop Environment (KDE)===
+
====K Desktop Environment (KDE)====
  
 
You can find the directory for application icons for use by all users and for each user using the command:
 
You can find the directory for application icons for use by all users and for each user using the command:
Line 33: Line 57:
 
This should print a list of colon-separated paths to stdout.
 
This should print a list of colon-separated paths to stdout.
  
===GNOME===
+
====GNOME====
  
 
You can find the directory for application icons for use by all users and for each user using the command:
 
You can find the directory for application icons for use by all users and for each user using the command:
Line 40: Line 64:
  
 
This should print a path to stdout, inside which is found a directory called pixmaps that attends to the Icon Theme Specification.
 
This should print a path to stdout, inside which is found a directory called pixmaps that attends to the Icon Theme Specification.
 +
 +
====LXDE====
 +
 +
In LXDE, icons are located in the directory
 +
 +
/usr/share/pixmaps
 +
 +
.application files are in
 +
 +
/usr/share/applications
 +
 +
[[Category:Lazarus]]
 +
[[Category:GUI]]

Latest revision as of 13:48, 2 August 2020

Deutsch (de) English (en) español (es) 日本語 (ja) português (pt)

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.

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.

IDE support for the Application Icon

Just set the icon in the Project Options dialog, accessible in the Project menu.

Works for Windows and macOS.

Platform-specific techniques

Windows

1. Create a new file named "project.rc" (for example) containing:

  MAINICON ICON "editor.ico" 

2. Include in you project *.lpr file the following instruction:

  {$R project.rc} 

Work with version 0.9.24 and above.

3. In the article Windows Icon you can see the best practices for creating the icon.

Setting the Application Icon on macOS

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:

   <key>CFBundleIconFile</key>
   <string>iconfile.icns</string>

Where iconfile.icns is located inside MyBundle.app/Contents/Resources

You can find instructions to create an icns file here

Linux

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.

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 of freedesktop.org.

K Desktop Environment (KDE)

You can find the directory for application icons for use by all users and for each user using the command:

kde-config --path icon

This should print a list of colon-separated paths to stdout.

GNOME

You can find the directory for application icons for use by all users and for each user using the command:

gnome-config --datadir

This should print a path to stdout, inside which is found a directory called pixmaps that attends to the Icon Theme Specification.

LXDE

In LXDE, icons are located in the directory

/usr/share/pixmaps

.application files are in

/usr/share/applications