Thread: [Java-gnome-developer] Problem getting change notifications from GConf
Brought to you by:
afcowie
From: Pierre-Charles D. <pc...@gm...> - 2006-11-27 10:23:11
|
Hi all, I'm trying to use the gconf bindings (libgconf-java-2.12.5) from Java. It works well when requesting values, but I can't seem to get notifications of changes. I'm new both to java-gnome and gconf itself, so I may be missing something obvious. Below is the code I am running. While it is waiting on the last line, I run gconf-editor and manually change the (boolean) value of the key "/apps/baobab/properties/enable_home_monitor"; I was expecting my listener to be called, but it is not. Am I doing something wrong / misunderstanding gconf, or is this feature not supported yet? Thanks in advance. public static void main(String[] args) throws Exception { ConfClient cc = ConfClient.getInstance(); cc.addDirectory("/apps/baobab/properties", ConfClientPreloadType.RECURSIVE); System.out.println(cc.get("/apps/baobab/properties/enable_home_monitor")); cc.addListener(new ConfClientListener() { public void clientNotify(ConfEntry entry) { System.out.println(entry.getKey() + " = " + entry.getValue()); } }, "/apps/baobab/properties"); new BufferedReader(new InputStreamReader(System.in)).readLine(); } |
From: Mark H. <mh...@ti...> - 2006-11-27 13:11:20
|
I've not tried, but I'd expect that this is integrated with the glib main loop, so you only get notifications when one of your threads is running gtk.main(). On 11/27/06, Pierre-Charles David <pc...@gm...> wrote: > Hi all, > > I'm trying to use the gconf bindings (libgconf-java-2.12.5) from Java. > It works well when requesting values, but I can't seem to get > notifications of changes. I'm new both to java-gnome and gconf itself, > so I may be missing something obvious. > > Below is the code I am running. While it is waiting on the last line, > I run gconf-editor and manually change the (boolean) value of the key > "/apps/baobab/properties/enable_home_monitor"; I was expecting my > listener to be called, but it is not. Am I doing something wrong / > misunderstanding gconf, or is this feature not supported yet? > > Thanks in advance. > > public static void main(String[] args) throws Exception { > ConfClient cc = ConfClient.getInstance(); > cc.addDirectory("/apps/baobab/properties", > ConfClientPreloadType.RECURSIVE); > System.out.println(cc.get("/apps/baobab/properties/enable_home_monitor")); > cc.addListener(new ConfClientListener() { > public void clientNotify(ConfEntry entry) { > System.out.println(entry.getKey() + " = " + entry.getValue()); > } > }, "/apps/baobab/properties"); > new BufferedReader(new InputStreamReader(System.in)).readLine(); > } > > ------------------------------------------------------------------------- > Take Surveys. Earn Cash. Influence the Future of IT > Join SourceForge.net's Techsay panel and you'll get the chance to share your > opinions on IT & business topics through brief surveys - and earn cash > http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV > _______________________________________________ > java-gnome-developer mailing list > jav...@li... > https://lists.sourceforge.net/lists/listinfo/java-gnome-developer > |
From: Pierre-Charles D. <pc...@gm...> - 2006-11-27 13:28:30
|
2006/11/27, Mark Howard <mh...@ti...>: > I've not tried, but I'd expect that this is integrated with the glib > main loop, so you only get notifications when one of your threads is > running gtk.main(). Yep, that was it. Wrapping the code with Gtk.init() / Gtk.main() makes it work as expected. Thanks a lot, I wouldn't have thought of that! |
From: Andrew C. <an...@op...> - 2006-11-28 00:07:39
|
On Mon, 2006-11-27 at 13:04 +0000, Mark Howard wrote: > I've not tried, but I'd expect that this is integrated with the glib > main loop, so you only get notifications when one of your threads is > running Gtk.main(). Incidentally, one of the things I've been leaning towards adding in 4.0 is a Glib.init(). There isn't such a thing in as g_init() of course (although one DOES have to call g_type_init() if using gobject et al and even though gtk_init() does that for you I'm doing it explicitly much earlier in the execution path) but for the case where you're not actually using GTK it is a but strange to have to fire it up in your code. And the main loop is a GLib construct, after all. So maybe we'll expose a GLib.main() but block its use if Gtk.init() / Gtk.main() have been used. The other possibility is to do it on library load automatically. Still fiddling. I'll write an email to -hackers when something concrete precipitates out. AfC Singapore --=20 Andrew Frederick Cowie Technology strategy, managing change, establishing procedures, and executing successful upgrades to mission critical business infrastructure. That, and hackin' in java-gnome! Need something done, call us! http://www.operationaldynamics.com/ Sydney New York Toronto London |
From: Andrew C. <an...@op...> - 2006-11-27 13:18:49
|
On Mon, 2006-11-27 at 11:23 +0100, Pierre-Charles David wrote: > so I may be missing something obvious. Probably not. That code was written several years ago by {Jeff?} and I don't think anyone has touched it since. I'm glad to hear that at least getting works. Did you try looking at the example code in libgconf-java/doc/examples ? If you figure it out and want to contribute a patch, or need to talk about the internal details of the present 2.x code, then by all means come up on java-gnome-hackers or #java-gnome Good luck! AfC Bangalore --=20 Andrew Frederick Cowie Technology strategy, managing change, establishing procedures, and executing successful upgrades to mission critical business infrastructure. http://www.operationaldynamics.com/ Sydney New York Toronto London |