Masao said:
Do you mean to call Gtk.events_pending? ?
No, I'm happy if it blocks inside main_iteration, as long as the
timeout I added makes main_iteration return - which it does.
Hmm. I've not change the behavior of Gtk.main_iteration for long time.
Well, then either the documentation or the code is wrong, because it
always returns true. I don't see how I can tell when quit has been
called...?
Anyway, if you don't call Gtk.main anywhere, Gtk.main_iteration
doesn't work correctly.
Ouch! I can't do that, I don't think. What is the effect if main
never gets called?
How about to use Gtk.timeout_add ?
That's what I did, I just didn't want to confuse the issue with too
much code. A bigger snippet of what I'm doing follows:
device_change = false
Gtk.timeout_add(500) {
return true if (@busy)
device_change = true if checkDevice
true
}
while true
if device_change
processDeviceChange
device_change = false
end
puts "iteration"
p Gtk.main_iteration
end
If the timeout is set to 500 or more, all works well. If I set it to
250 or less, then the GUI doesn't refresh, even though "iteration" is
printed continuously.
Ok, I see what I need to do. Where I call main_iteration, I have to
continue calling it while events_pending?, before looping to check
for a device_change again. That seems to work better! I should've
realised.
The reason I'm doing all this is because I don't want the "process"
to occur in the middle of a flurry of GUI events, but at the end.
If I add an "idle" callback, I'll have the problem that it will chew
CPU. For an app that uses idle not to busy wait, should it call
main_iteration once to block before returning? What I really want is
a method that says "wait until the next event", but I can't see one
inthe documentation.
Also, I moved my Debian installation to "unstable", from "testing",
and I find I now have ruby-gnome2 version 1.13.0, yaay!
P.S.
I think gtk-demo(in Ruby-GNOME2 tar ball) scripts may be helpful.
I'll check that out, thanks.
Clifford Heath.