Hi,<br>
<br>
I just wrote a very simple application that uses gconf notifications.
Unfortunately, the callback is never called. I have used gconf
from a graphical hildon app and notifications worked fine, however,
when I try from a console application it does not seem to work. I
include the two simple files I wrote: gconf_test, which registers the
callback and gconf_test_set, which sets a value. If you can pinpoint
the problem I would really appreciate it. Although there is no error
checking for gconf_init, I tested it and always returned TRUE.<br>
<br>
GCONF_TEST<br>
#include <gconf/gconf-client.h><br>
#define GCONF_MAEMO_PREFIX "/apps/maemo"<br>
#define GCONF_KEY_OPERATION GCONF_MAEMO_PREFIX"/mc/operation"<br>
<br>
static void callback(GConfClient *gconf_client, guint cnxn_id, GConfEntry *entry, gpointer user_data)<br>
{<br>
char
*operationName =
gconf_client_get_string(gconf_client, GCONF_KEY_OPERATION, NULL);<br>
printf("OpName:%s\n",operationName);<br>
}<br>
<br>
void config_init()<br>
{<br>
GConfValue *value;<br>
gchar *str;<br>
<br>
GConfClient *gconf_client = gconf_client_get_default();<br>
<br>
if(!gconf_client)<br>
{<br>
printf("Failed to initialize GConf. Quitting.");<br>
exit(1);<br>
}<br>
<br>
gconf_client_add_dir(gconf_client, GCONF_KEY_OPERATION, GCONF_CLIENT_PRELOAD_RECURSIVE, NULL);<br>
gconf_client_notify_add(gconf_client, GCONF_KEY_OPERATION, callback, NULL, NULL, NULL);<br>
<br>
g_object_unref(gconf_client);<br>
}<br>
<br>
int main(int argc, char **argv)<br>
{<br>
//Initialize GConf<br>
g_type_init();<br>
gconf_init(argc, argv, NULL);<br>
config_init();<br>
<br>
while(1)<br>
sleep(1);<br>
}<br>
<br>
<br>
GCONF_TEST<br>
#include <gconf/gconf-client.h><br>
#define GCONF_MAEMO_PREFIX "/apps/maemo"<br>
#define GCONF_KEY_OPERATION GCONF_MAEMO_PREFIX"/mc/operation"<br>
<br>
static void<br>
config_init()<br>
{<br>
GConfValue *value;<br>
gchar *str;<br>
<br>
GConfClient *gconf_client = gconf_client_get_default();<br>
<br>
if(!gconf_client)<br>
{<br>
printf("Failed to initialize GConf. Quitting.");<br>
exit(1);<br>
}<br>
<br>
printf("Setting:%s\n",GCONF_KEY_OPERATION);<br>
gconf_client_set_string(gconf_client, GCONF_KEY_OPERATION, "deactivate", NULL);<br>
<br>
g_object_unref(gconf_client);<br>
}<br>
<br>
int main(int argc, char **argv)<br>
{<br>
//Initialize GConf<br>
g_type_init();<br>
gconf_init(argc, argv, NULL);<br>
config_init();<br>
<br>
return 1;<br>
}<br>
<br>
Thanks!<br>
Manuel<br>