Refactor header bar mode changing

Fixes #101
Add missing dependency for cairo

It is required for the chart previews