Split main window code into separate source file