mainWindow: Move some code

We will replace the Toolbar with a HeaderBar on newer versions of
Gtk, so move out some code that is shared between both paths.
mainWindow: Use a HeaderBar if available

It's the new rage :-)