Create a source factory and document factories

This improves the source and widget creation mechanisms and allows the creation of more powerful sources in the future (like adapter sources).