From: Masao Mutoh Date: 2005-08-15T23:32:03+09:00 Subject: Re: Asynchronous events in GTK application? Hi, On Mon, 15 Aug 2005 22:11:13 +0900 Clifford Heath wrote: > Ok, I learnt some more, and I think I'm hung up on a GTK "feature". > This is with the Debian Linux version that calls itself 0.9.1. > > My asynchronous device events cause a condition variable to get > set. I've written a main loop that checks the variable, like this: > > while true > processEvent if (@device_event) > Gtk.main_iteration > end > > (According to the documentation, I should use: > break if Gtk.main_iteration Do you mean to call Gtk.events_pending? ? > but in this version, main_iteration always returns true. I guess > that's a change from the 0.9.1 version.) Hmm. I've not change the behavior of Gtk.main_iteration for long time. Anyway, if you don't call Gtk.main anywhere, Gtk.main_iteration doesn't work correctly. > In case there are no GUI events, I added a timeout which pumps > the loop. If the timeout is set to 1000ms, 500ms, no problem. > As soon as I drop the timeout much more (like 250ms or, what I'd > like, 100ms) the display never gets refreshed. > It seems that Gtk.main_iteration doesn't seem to ever process > paint (expose) events if an event has occurred recently, including > a timeout event(!). > Anyone have a solution to this? I wish the Debian packages weren't > always so far behind :-(. How about to use Gtk.timeout_add ? P.S. I think gtk-demo(in Ruby-GNOME2 tar ball) scripts may be helpful. -- .:% Masao Mutoh