Make stack switching work from the tree

This is identical to what glade is already doing for notebooks.