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!

6 thoughts on “Herding your program’s icons, how?

  1. Another thing that is worth checking is whether the icons are the size (dimensions) they are supposed to be. I see a lot of rpmlint warnings that a KDE icon is in a folder for icons of a particular size but isn’t that size. This may be intentional, but it would be good to include in the report just to be sure.


    • Not sure how that could be intentional, IMHO that would indeed be a bug, good that you mention it.
      But IMHO this is something that should be checked independently of the problem here, as the check for correct icon sizes could than be used for all icon themes, not just the Oxygen set.

      To have the rpmlint warnings fixed, please file a bug at bugs.kde.org for the product “Oxygen” and the component “icons” and post there the rpmlint warnings that you see, thanks.
      Follow e.g. this link: https://bugs.kde.org/enter_bug.cgi?product=Oxygen&format=guided

  2. The heuristics you used means you also some unused code has been checked (e.g. in Kexi – but we’ll have it removed rather soon).

    IMHO a good idea for real would be to temporarily re-define KIcon function into some global function that gives a compiler warning when used; then it’s possible to grep for that specific warnings. This way we’re sure only used code is checked.

    • I thought about redefining KIcon(…) before as well, but after more thinking Idropped the idea, because it means you have to make sure that all code which does a KIcon(…) call is actually run. Ensuring that (especially with all the #ifdefs) looked like way more work in the end, so I chose to use the grep method, at least for the first approach to this problem. It definitely needs to be made done automatically, e.g. as krazy task.

      Well, and checking unused code at least increases the chance that once it gets used more icons are correct:)

    • Yes, that is another nice use-case idea.
      KDevelop and other IDEs could also help if recognising the macros with checking the validness of icon-ids or offer code-completion when the user starts typing, again with preview of the icons for the possible completions.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s