Herding your program’s icons, how?

The last weeks I have been doing my small share of bit-flipping to contribute to the polishing of that big, big rough diamond which there is called Calligra, doing some pixel pushing here and there (e.g. on the line-end-style selectors and the rulers) and fixing a few bugs.

Now I wanted to give all icons used in Calligra a check, to see both if there is an icon for the given icon-id as well as if there are icon files installed which are no longer used. After all Calligra is a quite large codebase, coming over a long and winding road (some files have up to 13 and more authors, the first one usually in 1998 🙂 ), so a few icon usages got broken during the trip.

But how to get all icon-ids in your codebase?

I have used a simple approach to get at least most of them, doing a grep for lines with “KIcon(“. That gave me more than 1000 lines for Calligra, and almost all also directly used an icon-id, so there was chance to do a check and create a report for these.

Now this is quite unsatisfying to not be able to easily get a list of all the icon resources used in your codebase. How do you deal with this in your project?

Ideally icon-ids would be kind-of tagged when used, so like gettext is able to extract all strings which need a translation, some geticon would be able to extract all icon-ids. The result could then be used to check the icon-ids against the icons available from the icon themes and the icons installed from the project itself, ideally automatically (as doing that manually is… pretty boring, time-consuming and error-prone).

I could imagine that there could be some macros




which would resolve to




and would enable to automatically extract these icon-ids.

What do you think? Comments, other/better proposals welcome!