`gui/viewer.py` has got very large and very ugly. It needs to be refactored before it becomes completely unmanagable. A good first step would be to split off the menu handling into another class/file.