Debug warnings for broken icons
jpetso at gmx.at
Mon Dec 24 23:23:54 GMT 2007
On Friday, 21. December 2007, Allen Winter wrote:
> On Thursday 20 December 2007 08:10:47 Jakob Petsovits wrote:
> > Nice idea... although, I could imagine that this would make a really nice
> > Krazy check as well, catching most of the icons by just testing on three
> > or four usage patterns.
> If you give me the usage patterns I can try to put such a check into Krazy.
> .. or you can try to write the plugin yourself :)
Thinking a bit more about it, it might be harder than I originally imagined,
mostly based on the fact that checking icon names is probably a bit hard to
perform with application specific icon folders and minor other issues.
I'm not sure if it's worth the effort at this time... but if it is,
I could imagine the following usage patterns to be checked.
First, you go after one of the following strings
(insert spaces where C++ allows it):
The KIconLoader calls are a small minority so few icons should go missing
because of some variant like loader.loadIcon().
Then you check if the following token is a string and the token after that is
a closing parenthesis or a comma following more arguments, e.g.
* KIcon( "media-playback-start" )
* KIconLoader().loadIcon( "go-back", ...
If this token is not a string, abort, as it's too difficult to determine the
icon name. Otherwise, we have the name and can check it:
Check in all subfolders of kdebase/runtime/pics/oxygen/scalable and the
(magically determined?) app-specific icon folder if an icon with that name
exists there, or an appropriate fallback. If neither of those exist, we have
a positive that would be listed on EBN.
(A fallback has the same name as the original icon minus any amount
of "-[a-zA-z]" suffixes, in other words, "media-playback-start" can fall back
to "media-playback" and afterwards to "media" even.)
An icon in kdebase/runtime/pics/oxygen/scalable/* can be named
[icon-name].svgz. An icon in an application specific icon folder can be named
[size]-[category]-[icon-name].png, the size and category don't really matter
for icon checking purposes.
So that's essentially it. As I said, implementing icon lookups and stuff might
be a bit too much effort for little gain... but in case someone doesn't have
better stuff to do, it might be worth a try.
More information about the kde-core-devel