This example is somewhat obsolete. New Desktop applets should use Cairo for transparency. Using Cairo is much easier and Cairo allows doing many neat tricks.
How to write a Maemo Desktop plugin with transparency/shaped widget? How do I know when the plugin was clicked instead of dragged? How do I add an entry to Applet settings menu? How do I package a Desktop plugin? It’s fairly simple, really. I’m not a tutorial writer, so I’ll just mention a few key points here. Use the source, Luke! Also, don’t trust me blindly, I’m sure there are better ways to do at least some of the things…
Files
- Full source
- Applet source (single C source file)
Transparency / shaped widget
Older releases of Maemo did not allow having transparent plugins, so people often hacked around this by grabbing a part of Desktop’s background image and using that as applet’s background iamge. Fortunately developers no longer need to do this. This example should also compile on platforms without real transparency (not tested), but take full advantage of XComposite where available.
Basically you’ll just need an image with alpha channel. PNG-images are perfect
for this purpose. Once you have loaded the image and created a mask with
hildon_desktop_picture_and_mask_from_file()
(see applet_style_set()
) you
just need to paint that picture in expose (see applet_expose()
).
Clicked vs. dragged
Simply listening to button-pressed-event
and button-released-event
doesn’t
work, since if you’re dragging a widget, release always occurs on top of the
widget. The framework also does not eat the signals on drag, so special care
must be taken. See widget_class->button_release_event
and
cb_button_release()
.
Applet settings
Adding an entry to Applet settings menu is very easy, but at some point
information about it was very tricky to find. You just need to set a function
pointer for applet_class->settings
and use the function to create a new menu
item. See settings_menu_entry()
.
Packaging
There no point explaining things here. If I started to explain about building Debian packages, I would be typing this thing tomorrow… Take a look at the package, it’s all there.