This is mainly a copy-paste from an old branch authored by Matthias Clasen. The code style was updated to match Calendar's one, and the theming was improved a little bit.