make setting the notebook dirty flag an event

also adds a more liberal setting of the dirty flag when the user is typing, to avoid the current state of things where editing a code cell has no effect on the dirty flag unless it is executed.