Way of the Monkey
November 2006
S M T W T F S
1 2 3 4
5 6 7 8 9 10 11
12 13 14 15 16 17 18
19 20 21 22 23 24 25
26 27 28 29 30
Donate!
Themeable App-specific Icons Wed, 15 Nov 2006 09:07:01 -0500

Unfortunately, there is no standard way for installing app-specific icons, such as the paint bucket/paintbrush/crop/etc... icons in GIMP or Inkscape, in a way that lets them be themable, and follow the naming spec guidlines, but not potentially cause file conflicts with other packages. We don't want both GIMP and Inkscape trying to install the same file into the theme. KDE has an interesting little hack in their libraries, and has for a long time, so I don't know why what I'm recommending here hasn't been put into the Icon Theme spec, or why the KDE people are so adamantly against doing it now. Their icon theme implementation will automatically look for icons in the private app directories as well as the standard icon locations, and it looks for them inside themes, in those private directories as well.

In GTK+ we have a similarly interesting piece of API that we can use to do the same thing. While the application's logo icon for use in the system menus, and the app's about box and window titlebars, should still go into the system hicolor theme, following the guidelines in the Icon Theme and Icon Naming specifications, we can't really do this for other icons. What you should do instead for these other icons specific to your app, that will be used for actions, status, or other contexts, is to install them into a hicolor theme in your application's private data directory. For instance, the application foo, might want to use the icon bar, for displaying status in the system tray. This icon could be installed in the following directory, like so:

/usr/share/foo/icons/hicolor/16x16/status/bar.png

In your application, where you initialize GTK+, you also want to do the following, so that your application will find these icons if the theme tree structure in use, doesn't provide them:

gtk_icon_theme_append_search_path (gtk_icon_theme_get_default (), PKGDATADIR "/icons");

This adds the $pkgdatadir/icons directory to the search path, and GtkIconTheme will then look in here for icons as well as the standard search paths. You can also provide icons for other themes in here, by installing them into a subdirectory for that theme.

Developers, please switch to this method if you are currently installing icons other than the standard app logo icon for launchers and such, into the system hicolor or other themes.




Ninja Monkey icon based on face-monkey icon from The Tango Project