<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META http-equiv=Content-Type content="text/html; charset=iso-8859-1">
<META content="MSHTML 5.50.4937.800" name=GENERATOR>
<STYLE></STYLE>
</HEAD>
<BODY bgColor=#ffffff><FONT face=Arial size=2>
<DIV>Hi,</DIV>
<DIV>The main function should have a main loop running this will fix the 
problem.</DIV>
<DIV>in your graphical app you had the gtk_main_run so it was working....</DIV>
<DIV>below patch in gcont_test.c would fix&nbsp;the&nbsp;problem.</DIV>
<DIV><BR>int main(int argc, char 
**argv)<BR>{<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; //Initialize 
GConf<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; GMainLoop *loop = 
NULL;<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
g_type_init();<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; loop = 
g_main_loop_new(NULL, FALSE);<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
gconf_init(argc, argv, NULL);<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
config_init();<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
g_main_loop_run(loop);</DIV>
<DIV>&nbsp;</DIV>
<DIV>}<BR></DIV>
<DIV>Regards,</DIV>
<DIV>Ratna</DIV></FONT>
<BLOCKQUOTE 
style="PADDING-RIGHT: 0px; PADDING-LEFT: 5px; MARGIN-LEFT: 5px; BORDER-LEFT: #000000 2px solid; MARGIN-RIGHT: 0px">
  <DIV style="FONT: 10pt arial">----- Original Message ----- </DIV>
  <DIV 
  style="BACKGROUND: #e4e4e4; FONT: 10pt arial; font-color: black"><B>From:</B> 
  <A title=mraccount1@gmail.com href="mailto:mraccount1@gmail.com">Manuel 
  Roman</A> </DIV>
  <DIV style="FONT: 10pt arial"><B>To:</B> <A title=maemo-developers@maemo.org 
  href="mailto:maemo-developers@maemo.org">maemo-developers@maemo.org</A> </DIV>
  <DIV style="FONT: 10pt arial"><B>Sent:</B> Tuesday, December 12, 2006 12:08 
  PM</DIV>
  <DIV style="FONT: 10pt arial"><B>Subject:</B> [maemo-developers] gconf 
  notifications?</DIV>
  <DIV><BR></DIV>Hi,<BR><BR>I just wrote a very simple application that uses 
  gconf notifications. Unfortunately, the callback is never called.&nbsp; 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 
  &lt;gconf/gconf-client.h&gt;<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>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; char 
  *operationName&nbsp;&nbsp;&nbsp;&nbsp; = gconf_client_get_string(gconf_client, 
  GCONF_KEY_OPERATION, NULL);<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
  printf("OpName:%s\n",operationName);<BR>}<BR><BR>void 
  config_init()<BR>{<BR>&nbsp;&nbsp;&nbsp; GConfValue 
  *value;<BR>&nbsp;&nbsp;&nbsp; gchar *str;<BR><BR>&nbsp;&nbsp;&nbsp; 
  GConfClient *gconf_client = 
  gconf_client_get_default();<BR><BR>&nbsp;&nbsp;&nbsp; 
  if(!gconf_client)<BR>&nbsp;&nbsp;&nbsp; 
  {<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; printf("Failed to initialize 
  GConf.&nbsp; Quitting.");<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
  exit(1);<BR>&nbsp;&nbsp;&nbsp; }<BR><BR>&nbsp;&nbsp;&nbsp; 
  gconf_client_add_dir(gconf_client, GCONF_KEY_OPERATION, 
  GCONF_CLIENT_PRELOAD_RECURSIVE, NULL);<BR>&nbsp;&nbsp;&nbsp; 
  gconf_client_notify_add(gconf_client, GCONF_KEY_OPERATION, callback, NULL, 
  NULL, NULL);<BR><BR>&nbsp;&nbsp;&nbsp; 
  g_object_unref(gconf_client);<BR>}<BR><BR>int main(int argc, char 
  **argv)<BR>{<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; //Initialize 
  GConf<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
  g_type_init();<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; gconf_init(argc, 
  argv, NULL);<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
  config_init();<BR><BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
  while(1)<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
  sleep(1);<BR>}<BR><BR><BR>GCONF_TEST<BR>#include 
  &lt;gconf/gconf-client.h&gt;<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>&nbsp;&nbsp;&nbsp; GConfValue 
  *value;<BR>&nbsp;&nbsp;&nbsp; gchar *str;<BR><BR>&nbsp;&nbsp;&nbsp; 
  GConfClient *gconf_client = 
  gconf_client_get_default();<BR><BR>&nbsp;&nbsp;&nbsp; 
  if(!gconf_client)<BR>&nbsp;&nbsp;&nbsp; 
  {<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; printf("Failed to initialize 
  GConf.&nbsp; Quitting.");<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
  exit(1);<BR>&nbsp;&nbsp;&nbsp; }<BR><BR>&nbsp;&nbsp;&nbsp; 
  printf("Setting:%s\n",GCONF_KEY_OPERATION);<BR>&nbsp;&nbsp;&nbsp; 
  gconf_client_set_string(gconf_client, GCONF_KEY_OPERATION, "deactivate", 
  NULL);<BR><BR>&nbsp;&nbsp;&nbsp; g_object_unref(gconf_client);<BR>}<BR><BR>int 
  main(int argc, char **argv)<BR>{<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
  //Initialize GConf<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
  g_type_init();<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; gconf_init(argc, 
  argv, NULL);<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
  config_init();<BR><BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; return 
  1;<BR>}<BR><BR>Thanks!<BR>Manuel<BR>
  <P>
  <HR>

  <P></P>_______________________________________________<BR>maemo-developers 
  mailing 
  list<BR>maemo-developers@maemo.org<BR>https://maemo.org/mailman/listinfo/maemo-developers<BR></BLOCKQUOTE></BODY></HTML>