User:Pino/Handling icons

From KDE TechBase
Revision as of 21:30, 24 May 2011 by Pino (talk | contribs) (first draft)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Warning
This is not an official page.


noframe
noframe
 
Under Construction
This page is under construction. This page is actively being developed and updated with new information, and may be incomplete. You can help by editing this page


Installing

Compact naming

One of the most common ways to name icons in sources is a "compact" form which includes various details. The format is the following:

<theme><size>-<context>-<name>.<extension>

Where:

  • theme: the two-letter name of the icon theme; for example:
    • hi: hicolor
    • ox: Oxygen
    • cr: Crystal SVG
    • lo: locolor
  • size: the size of the icon in pixels (e.g. 24 for a 24x24 icon), with the special value sc for scalable icons in SVG(Z) format
  • context: the context for the icon, as specified in either the XDG icon theme specification or the XDG icon naming specification; e.g. app for application icons, mime for MIME type icons, and so on
  • name: the real name of the icon
  • extension: the extension of the icon, e.g. png, svg, etc

Installing with CMake (KDE 4)

To install icons with the CMake buildsystem using the KDE4 macros, you just need to use

kde4_install_icons(<installation directory>)

This CMake macros takes all the icons with a "compact" naming in the current directory, and installs them in the <installation directory> specified. Hence, if you want to install some icons in one location and some in another, the only solution you have is to put the icons in different directories with ad-hoc kde4_install_icons() calls.

<installation directory> is usually

  • ${ICON_INSTALL_DIR}: installs the icons in the share/icons subdirectory of the installation prefix.
  • ${DATA_INSTALL_DIR}/applicationname/icons: locally for an application only (see also the section below)

Choosing the right icon theme and installation directory

There are few things to keep into account when choosing which icon theme use for icons, and which directory install them into.

Own application icon

When install the icon of your own application, you want to make it used by any other user, regarless of which icon theme they are using. Because of this:

  • use the hi (hicolor) icon theme, which is the only common denominator (called also fallback theme) among any icon theme
  • use ${ICON_INSTALL_DIR} as installation directory, as it allows the icon to be seen by all the other applications installed in the same prefix

Other icons for own application

TODO