icon theme cache mechanism

edscott wilson garcia edscott at xfce.org
Thu Nov 4 03:25:57 EET 2004


El mié, 03-11-2004 a las 08:33, Benedikt Meurer escribió:

> 
> An icon theme cache mechanism is currently being discussed by the 
> freedesktop.org people. Edscott, how about proposing your ideas on the 
> xdg list, I don't see the benefit if everyone comes up with its own 
> implementation, lets create _one_ usable standard instead.

OK. Here goes.

There's really not much to it, just use disk based hashes. The hash key
is generated by glib function g_string_hash(). Disk based hashes are
constructed for each icon size whenever this is requested. Only the path
to the best match is saved. To figure out when the cache needs
rebuilding, the keep track of ctime+mtime of base directories. 
To construct the disk based hash table, a memory hash table is created
using the ideas of Brian T. in libxfcegui4 (but instead of just one hash
table, use separate hash tables for each inherits and fix some other
small bugs).

A working example, complete with a test program, can be found at xfce
CVS: xfce4/libxfcegui4/xfce4-modules/mime-icons/icon-theme.{c,h}. You
will have to make your own makefile, but that should not be a problem.

The best explanation can be obtained by reading the source code cited
above, and playing around with the build. Note: dbh-1.0 is required.
This is a tiny library for big things.


Regards,

Edscott





More information about the xdg mailing list