[maemo-developers] [maemo-developers] gconf notifications?
From: ratna mahawadhi.ratna at wipro.comDate: Tue Dec 12 10:07:11 EET 2006
- Previous message: [maemo-developers] gconf notifications?
- Next message: [maemo-developers] Complete source tree for maemo.
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Hi, The main function should have a main loop running this will fix the problem. in your graphical app you had the gtk_main_run so it was working.... below patch in gcont_test.c would fix the problem. int main(int argc, char **argv) { //Initialize GConf GMainLoop *loop = NULL; g_type_init(); loop = g_main_loop_new(NULL, FALSE); gconf_init(argc, argv, NULL); config_init(); g_main_loop_run(loop); } Regards, Ratna ----- Original Message ----- From: Manuel Roman To: maemo-developers at maemo.org Sent: Tuesday, December 12, 2006 12:08 PM Subject: [maemo-developers] gconf notifications? Hi, 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. GCONF_TEST #include <gconf/gconf-client.h> #define GCONF_MAEMO_PREFIX "/apps/maemo" #define GCONF_KEY_OPERATION GCONF_MAEMO_PREFIX"/mc/operation" static void callback(GConfClient *gconf_client, guint cnxn_id, GConfEntry *entry, gpointer user_data) { char *operationName = gconf_client_get_string(gconf_client, GCONF_KEY_OPERATION, NULL); printf("OpName:%s\n",operationName); } void config_init() { GConfValue *value; gchar *str; GConfClient *gconf_client = gconf_client_get_default(); if(!gconf_client) { printf("Failed to initialize GConf. Quitting."); exit(1); } gconf_client_add_dir(gconf_client, GCONF_KEY_OPERATION, GCONF_CLIENT_PRELOAD_RECURSIVE, NULL); gconf_client_notify_add(gconf_client, GCONF_KEY_OPERATION, callback, NULL, NULL, NULL); g_object_unref(gconf_client); } int main(int argc, char **argv) { //Initialize GConf g_type_init(); gconf_init(argc, argv, NULL); config_init(); while(1) sleep(1); } GCONF_TEST #include <gconf/gconf-client.h> #define GCONF_MAEMO_PREFIX "/apps/maemo" #define GCONF_KEY_OPERATION GCONF_MAEMO_PREFIX"/mc/operation" static void config_init() { GConfValue *value; gchar *str; GConfClient *gconf_client = gconf_client_get_default(); if(!gconf_client) { printf("Failed to initialize GConf. Quitting."); exit(1); } printf("Setting:%s\n",GCONF_KEY_OPERATION); gconf_client_set_string(gconf_client, GCONF_KEY_OPERATION, "deactivate", NULL); g_object_unref(gconf_client); } int main(int argc, char **argv) { //Initialize GConf g_type_init(); gconf_init(argc, argv, NULL); config_init(); return 1; } Thanks! Manuel ------------------------------------------------------------------------------ _______________________________________________ maemo-developers mailing list maemo-developers at maemo.org https://maemo.org/mailman/listinfo/maemo-developers -------------- next part -------------- An HTML attachment was scrubbed... URL: http://lists.maemo.org/pipermail/maemo-developers/attachments/20061212/7a31b7dd/attachment.htm
- Previous message: [maemo-developers] gconf notifications?
- Next message: [maemo-developers] Complete source tree for maemo.
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]