What’s for lunch?

2 minute read

If you're working in a company or go to university or college, that's probably close to the most important question of the day. Wouldn't it be great to have that information right on your desktop? While I was playing around with KDE4, I thought it would be great to have a Plasmoid (like a Dashboard Widget for all the Mac users out there) displaying today's menu.

That was actually half a year ago, but back then I didn't find time to look more closely at it. First I thought I'd be able to write the Plasmoid using ECMA-Script (JavaScript). But it seems that the bindings are still under heavy development (like everything in the Plasma:: namespace) and not really usable yet. So I found a tutorial on how to write a Plasmoid using C++. Doing further reading, I also found out that I'd need to write a DataEngine to get the data, too.

It took me a while to fight my way throught the documentation *cough* ([1], [2], [3]) and understand the basic concepts, I think I got it mostly working now :-)

Before I continue with more talking, have a look:

The data comes from a webservice I operate, which currently gives the menus of all cafeterias of the Studentenwerk München. Drop me a note if you like it and would like to get your cafeteria's menu in there, too.

So finally, here are the sources:
The data engine: cafeteria_engine-0.1.tar.bz2
The plasmoid: cafeteria_plasmoid-0.1.tar.bz2

I did development on openSUSE 11.0 using the Factory KDE repository (which currently contains KDE 4.1.2).

This is getting long, so I'll postpone my rant about missing documentation to the next blog post ;-) I'd love to get some freeback on this, so feel free to drop me a note.

Update: I just noticed that sometimes after adding the plasmoid to the desktop for the first time and clicking on "Configure", you'll get a segfault with a backtrace like in bug #168278. To work around that, add the plasmoid to the desktop, log off and on again and configure it then (and possibly do the same again?). That way it should work. I guess this is a bug in Qt, but that's not yet for sure (the QGraphics* stuff is pretty new and known to be buggy).

Update 2: There is a fix in qt-copy now, which will be part of Qt 4.4.4 and 4.5 (see here).