Documentation/Maemo 5 Developer Guide/Application Development/Writing Control Panel Applets

The control panel is designed to be extendable, and items can be added to it with dynamic libraries with certain functions and desktop files describing the library.

Functions

A control panel applet (libapplet.c) needs two functions. These functions are defined in the following:

#include <hildon-cp-plugin/hildon-cp-plugin-interface.h>

The first and more important one, execute, is called when the applet is activated from Control Panel. Usually this function creates a dialog and waits until it is done. Any dialog created should be modal to the window in parameter.

N.B. The library can be unloaded when execute returns, so no g_timeouts, gconf_notifys or such must be left when done. GTK+ or osso initialization is not needed, because they are already done at this point.

#include <hildon-cp-plugin/hildon-cp-plugin-interface.h>
#include <gtk/gtk.h>
 
osso_return_t execute(osso_context_t *osso, gpointer data, gboolean user_activated)
{
	GtkWidget *dialog;
	gint response;
	/* Create dialog with OK and Cancel buttons. Leave the separator out,
	 * as we do not have any content. */
	dialog = gtk_dialog_new_with_buttons(
		"Hello control panel",
		GTK_WINDOW(data),
		GTK_DIALOG_MODAL | GTK_DIALOG_NO_SEPARATOR,
		GTK_STOCK_OK,
		GTK_RESPONSE_OK,
		GTK_STOCK_CANCEL,
		GTK_RESPONSE_CANCEL,
		NULL);
	/* ... add something to the dialog ... */
	if (!user_activated)
	{
		/* ... load state ... */
	}
	/* Wait until user finishes the dialog. */
	response = gtk_dialog_run(GTK_DIALOG(dialog));
	if (response == GTK_RESPONSE_OK)
	{
		/* ... do something with the dialog stuff ... */
	}
	/* Free the dialog (and it's children) */
	gtk_widget_destroy(GTK_WIDGET(dialog));
	return OSSO_OK;
}

The other function is called save_state. It is called when application using the applet is saving state. Usually this does nothing, but if support for state saving is needed, use it.

osso_return_t save_state(osso_context_t *osso, gpointer data)
{
	/* ... save state ... */
	return OSSO_OK;
}

Building applet

To use the applet, build it into a dynamic library aka shared object by passing the -shared flag to gcc.

[sbox-FREMANTLE_X86: ~] > gcc -shared `pkg-config gtk+-2.0 hildon-control-panel libosso --libs --cflags` libapplet.c -o libapplet.so

Install the binary produced by gcc to a path specified in hildon-control-panel pkg-config entry. You can obtain this path with:

pkg-config hildon-control-panel --variable=pluginlibdir

By default it is /usr/lib/hildon-control-panel.

Anne, try our Enhanced File Sending mode and see if it works for you now. We recently upradged the functionality to remember your settings and also includes default setting options. For example, your activity setting 'do not notify' should now stay selected.