Trigger a script on file selection event?

The first three cases can be handled by existing events, since there are script events for tabs being activated etc. Tab-Labelizer is probably a good example script that handles the relevant events.

I don't think there's a (sensible) way to handle the 4th case at the moment. Not sure if it would make sense to run scripts whenever the selection changes, as that could slow things down, but changing the way the viewer responds to selections may happen.