Monday, January 11, 2010

Plasma applet development: adding icons micro-HOWTO

The introduction to Plasma applet development on the KDE TechBase site describes the contents of CMakeLists.txt file used for compilation  and installation of a plasmoid. The installation of corresponding icon(s) is not covered there.

Actually, the process is rather simple

  1. Create an icon, or an icon set
  2. Name icon file(s) correctly
  3. Add an icon reference to the .desktop file
  4. Put an installation line to CMakeLists.txt
  5. Run cmake && make && sudo make install

1. You can use raster icons in the PNG format, or vector icons in compressed SVG format. When using bitmap icons, a whole set should be created with following sizes in pixels: 8x8, 16x16, 22x22, 48x48, 64x64, 128x128. You could create the biggest image, copy to different files and resize it accordingly. On the other hand, a single icon in .svgz file could be put to all uses in KDE4 environment. 

2. The trickiest part is to give the images proper filenames which cmake installation algorithm is able to recognize. You must adhere to the following scheme. kde4-icon-naming-scheme

The first two letters of the filename describe the KDE theme, which the icon belongs to: ox(ygen), cr(ystal SVG), lo-color, hi-color. (You may wonder, which theme code should you use? For a typical desktop-linux applet or application ‘hi’ seems to be a good choice). Then comes the size description: either sc(alable), for SVG icons, or one to three digits corresponding to pixel dimension. After this,  the ‘-app-’ part categorizes the file as an applet or application icon.

And just before the extension you put the name by which the icon would be referred to.  You may choose any icon name you like ( it may even contain dashes). If you are using PNG format, the name part, naturally, should be the same for all the icons from the set.

The icon(s), named appropriately, should reside in the same directory where the CMakeLists.txt file for the project is.

3. Use icon name part (not the icon file name, just the part which goes after ‘–app-’ and before the extension) in the following line you put to your applet .desktop file:

Icon=<name>

No extension here.

4. The following line should be added to CMakeLists.txt file, verbatim:

kde4_install_icons(${ICON_INSTALL_DIR})


For example, a plasma applet named ‘gioco1’ uses icon associated with it, which is also named ‘gioco1’ (internally). And the icon file is named ‘hisc-app-gioco1.svgz’.



Look at the source here: http://github.com/ub/gioco1.



5. As usually, when you modify CMakeLists.txt, you should run cmake command from the build directory. After this ‘sudo make install’ command (or just ‘make install’, if your account has write access to the target) would copy your icons to the places where KDE4, Plasma and your applet will be able to find them.

2 comments:

  1. Thank you! I was very confused on how to get icons to work with my application and couldn't find anything on Techbase.

    ReplyDelete
  2. Playtech secures deal with CasinoStars for distribution across
    Playtech 제주 출장샵 has confirmed the acquisition of its 영주 출장샵 leading 피망 포커 iGaming software supplier 강릉 출장마사지 to a global market with 광양 출장안마 a further 10 employees Sep 17, 2021 · Uploaded by CasinoStars International

    ReplyDelete