Code by Rikard: https://code.google.com/p/apwidgets/