I am currently angry over: GConf

This issue made me angry on Wednesday the 1 of October, 2003. Other irritations may be found here . The most recent irritation may be found here

Update

It turns out that there is a function in the gconf_client interface that does what I want it to do. gconf_client_get_value_without_default will return NULL if the value is unset. However, it's entirely undocumented. A patch was submitted n June 2002 but has not been applied as yet.

Original content

GConf is a nice centralised configuration system that superficially resembles the Windows registry, but has the advantages that keys can be documented, the backend is pluggable and so it's possible to use binary formats or plain text files to actually store the data, keys can be locked in a sensible way to force users to use certain configuration options and so on.

It has two interfaces - the lowlevel gconf_engine, and the higher level gconf_client. gconf_client is reasonably sane and makes it trivial to obtain configuration options, but there's one minor issue - if a key doesn't exist, it doesn't flag an error and it just returns a blank result (or false in the case of a bool). gtk_engine doesn't return a bool or string or whatever, it returns a struct that has to be dealt with and as a result it's a bit of a faff. But it does return NULL if the key doesn't exist.

The "correct" way to deal with this is to have a gconf schema that defines default values, and then when the application is started they'll get filled in automatically. In my case, I'm trying to keep default values consistent across a cross-platform codebase and so they're dealt with in the core code that isn't going to speak gconf. Trying to produce a schema would be a bit of a bugger.

Never mind. I can use gconf_client for everything except checking whether a key exists or not, and then use gconf_engine, right? Well, no. If you're using gconf_client you're not allowed to use gconf_engine because there could be weird shit caching issues. In my case, the gconf_engine calls are only made in very limited circumstances and so it's probably safe, but gconf complains anyway and that's reasonable enough and not what irritates me.

No, it says
GConf-WARNING **: : You can't use a GConfEngine that has an active GConfClient wrapper object. Use GConfClient API instead.

Use. GConfClient. API. Instead.

You FUCKERS.

g_log_set_handler ("GConf", G_LOG_LEVEL_WARNING, null_log_handler, NULL);

Sorted.