On Apr 21, 2011, at 12:30 AM, Andrew wrote:
So... :)
Don't add a refresh button, tie the code into inotify so you can get a signal when files change in the directory. Should be fairly simple and anything to reduce the complexity of the design the user is a positive.
There are some significant problems with inotify, so I'd recommend
avoid it if
possible.
I really like Martin's idea, that the directory should automatically update when a file is added/removed.
How about Glib::FileMonitor? I haven't used it before, but I just came across it and it looks the part, should work on other platforms as well, rather than inotify which is restricted to Linux.
Yes, that one seems good for now. http://developer.gnome.org/glibmm/unstable/classGio_1_1FileMonitor.html
I'd gone through and updated our dependency page to track: http://wiki.inkscape.org/wiki/index.php/Tracking_Dependencies#Distros
That class exists since glibmm 2.16, and the currently supported distros start there, so we're good. We just need to take a little poking about builds on the different platforms to make sure we're covered.
The existing reload checking on images ended up better for that use case to not use it. I'm moving that checking out of SPImage, but for the moment it probably won't match your needs directly, so go ahead and push in with Glib::FileMonitor directly. One suggestion would be to try to keep it separated so that the trigger mechanism can be changed easily later on (don't drop everything in one big method, etc).
Another consideration would be to ensure you "de-bounce" the signaling so that you don't end up trying for force repeated repaints before things are finished. Marking things as dirty and then passing on to an idle callback with some time window can really help. Taking care in that area can really improve the "speed" and responsiveness of the UI.