File system event?

Hey.

I am making a little TaskBar app, whos task it is to monitor a file and
change icon when the file is updated.

First is there any way to catch a file change event direct in WxRuby?
Does WxRuby have a way to catch system event directly?

If I can’t do it in WxRuby, how do I then combine the RInotify package
with WxRuby.

Exactly where do I put the rinotify.wait_for_events call ?

Is there some way to a it to the App.main_loop ?

Or should put it in a evt_idle? This might slow down UI.

Or should I try to figure out how to make a separate thread that
could wait and then generate a custom event.

So what do you think, have any of you tried any thing like it before?

PS. I am working on a linux box.

On 01/07/2010 15:59, Svend Haugaard Sørensen wrote:

I am making a little TaskBar app, whos task it is to monitor a file and
change icon when the file is updated.

First is there any way to catch a file change event direct in WxRuby?
Does WxRuby have a way to catch system event directly?

No, not in the version of wxWidgets we’re based on. I think there’s been
a recent GSOC project to add file system notifications to wxWidgets.

If I can’t do it in WxRuby, how do I then combine the RInotify package
with WxRuby.

Exactly where do I put the rinotify.wait_for_events call ?

I don’t know RInotify, but I think you may need to use threads if it’s
the kind of call that waits and hands to a block (similar to TCP servers
in Ruby).

Is there some way to a it to the App.main_loop ?

Not if the execution stops in wait_for_events - your whole UI will stop.

Or should put it in a evt_idle? This might slow down UI.

evt_idle are intended to do a short something then return.

Or should I try to figure out how to make a separate thread that
could wait and then generate a custom event.

So what do you think, have any of you tried any thing like it before?

Yes, this is the way to go I’d think. It’s perfectly do-able but needs
more care. If using 1.8, you need to manually nudge Ruby’s thread
scheduler to give time to the RInotify thread. If using 1.9, this won’t
be needed, but you must not call GUI update code in the non-wx thread.
GUI updates must be signalled by posting a Wx::Event to the GUI loop.

a