Checking for a non-existant key?



-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Hi

Here is the scenario. I have a key say "/apps/foobar/something" which is of
(or is supposed to be) type boolean. The very first time I run my program, how
do I check if the key exists or not? I want to know this, so that I can setup
default values in the prefs for my app.

Currently what I did was something like this.

<code-snippet>

GConfClient *client;
GError *err = NULL;
const gchar *key = "/apps/foobar/something";
gboolean val;

client = gconf_client_get_default ();

val = gconf_client_get_bool (client, key, &err);
if (err)
   printf ("Error : %s\n", err->message);

</code-snippet>

What I figure is that if there is no key, it should return a valid GError
object in the form of err (in this case), tell me about a non-existant key.
Or is there another way? I can't check the value of the variable "val", because
it is a bool, and a TRUE or FALSE both are vaild values.

phew! Help :-)

Archit Baweja
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.0.6 (GNU/Linux)
Comment: Processed by Mailcrypt 3.5.6 and Gnu Privacy Guard <http://www.gnupg.org/>

iD8DBQE9Jn8A2rWNPKmGjMcRAsrJAJ974O4e1QMkgi/4OymuX5z7tOCeOwCgk2KD
QG5BcsG2FuDeLAcj+jeLer4=
=h/0L
-----END PGP SIGNATURE-----



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]