Refactor header bar mode changing

Fixes #101
Add missing dependency for cairo

It is required for the chart previews
Merge pull request #102 from gergelypolonkai/refine-ui

Refactor header bar mode changing