Re: How to add a callback that will be called each time when the event queue becomes empty

2013-07-19 Thread Gang Chen
Paul, This is good. Actually I'm thinking about a simpler approach. Any state change causes the callback to be called, which updates all UI elements. Or even simpler. After UI elements are updated, any event causes the callback to be called. Thanks, Gang 2013/7/20 Paul Davis > the general solu

Re: How to add a callback that will be called each time when the event queue becomes empty

2013-07-19 Thread Gang Chen
That looks good. But that's another topic. Thanks! 2013/7/20 richard boaz > hi gang, > > so you are aware of every state change then... > > back when (2010), i provided a solution for this problem that gets around > having to write tons of code for each state change. you can find my > comment

Re: How to add a callback that will be called each time when the event queue becomes empty

2013-07-19 Thread Paul Davis
the general solution to this is to use any kind of signalling system (g_object signals, boost signals, libsigc++ or whatever you prefer) to post notifications about state changes, and the callbacks/handlers for these signals should queue an idle callback that returns FALSE (and only queue it if it

Re: How to add a callback that will be called each time when the event queue becomes empty

2013-07-19 Thread richard boaz
hi gang, so you are aware of every state change then... back when (2010), i provided a solution for this problem that gets around having to write tons of code for each state change. you can find my comment and code posting in the thread here: https://mail.gnome.org/archives/gtk-list/2010-Septem

Re: How to add a callback that will be called each time when the event queue becomes empty

2013-07-19 Thread Jasper St. Pierre
Then you'll have to live with 100% CPU usage, I suppose. I don't know why that's happening, but without the code to your idle callback, we'll never figure it out. I don't know what magical solution you want us to give you. Either you call it when the event queue is empty (in which case you apparen

Re: How to add a callback that will be called each time when the event queue becomes empty

2013-07-19 Thread Gang Chen
Because the idle callback always returns TRUE, the idle callback is called again and again, and CPU usage is 100%. The idle callback doesn't do any heavy processing. Regarding this problem, doing central updating when idle is simpler than using signals to update. 2013/7/20 Jasper St. Pierre >

Re: How to add a callback that will be called each time when the event queue becomes empty

2013-07-19 Thread Jasper St. Pierre
Low-priority idles *are* called every time the event queue is empty. Which could happen quite a lot when the application isn't really doing anything else. I don't know why your idle is causing 100% CPU usage, though. You're not doing any heavy processing in there, right? If you recalculate the sta

Re: How to add a callback that will be called each time when the event queue becomes empty

2013-07-19 Thread Gang Chen
Richard, The UI elements are GTK actions whose sensitivity states are related to the states of the application. There are many possibilities that may change the sensitivity. If I update UI elements whenever necessary, I need to write too much code doing update. I prefer writing one function that u

Re: How to add a callback that will be called each time when the event queue becomes empty

2013-07-19 Thread richard boaz
let's step back one second. your description implies that it is not possible for your UI to be directly aware of the events that require follow-on updates to the UI's widgets. but i don't understand this. can you explain a little more how/why this makes sense on a design level? what exactly hap

Getting a GMenuItem from GtkBuilder

2013-07-19 Thread Murray Cumming
Should the code below work, to get a menu item from a GtkBuilder using the markup? It doesn't seem to. I'm guessing at the XML syntax based on this: https://developer.gnome.org/gtk3/unstable/GtkBuilder.html#BUILDER-UI I would use Glade to show me the correct syntax, but it doesn't use this // syn