|Write an applet
|Cairo-dock put at your disposal a framework dedicated to quickly writing standardized applets.
Let's see how to do.
First we can generate a fonctionnal applet with the script geenrate-new-applet.sh, located in the "plug-ins" folder of the sources.
Run it, answer the few questions, after all is finishezd go to your new applet's folder, and type sudo make install. You're done ! If you restart the dock, you will see it in the config panel. You can even activate it, it will appear in the main dock.
Now all we have to do is to complete the code.
Before we go further, let us look at the structure of your applet (let's say that its name is "truc") :
Source Tree structureThe source tree structure is basic and can be copied from any existing applet:
truc ---> configure.ac, Makefile.am
+--> src -> applet-init.c/h, applet-config.c/h, applet-notifications.c/h, *.c/h
+--> data -> truc.conf.in, preview, readme.in, *
+--> po -> Makefile.in.in, LINGUAS, POTFILES.in, *.po
The files names are not imposed, but respecting these conventions will make it possible to immediately find your way around for any applets even the one you don't know about.
Sources FolderIn ./src, we have :
- applet-init.c : contains the functions to initialize, stop and reload the applet.
- applet-config.c : contains the functions to load the config, reset it, and reset the datas.
- applet-notifications.c : contains the functions which are called when the applet is notified by Cairo-Dock that something interesting has happened (a click, a drop, etc)
- *.c : the others can contain everything you need (connection to a server, functions of drawings, calculations, etc...) Separating your functions into different files by familly is a good habit.
Data FolderIn --./data-- we find :
- preview : a picture (png or jpg) giving a preview of the applet, around 200x200 pixels. It will be displayed in the config panel of Cairo-Dock.
- readme.in : a file giving the author of the applet (you; -)), and a short summary of this one (the text will also be displayed in the config panel of Cairo-Dock).
- truc.conf.in : the config file of the applet, which contains all the parameters that the user can change. We'll see later how to use it.
Translation FolderIn ./po we have :
- Makefile.in.in : no need to care this one.
- LINGUAS : the list of the available languages.
- POTFILES.in : the files list where one finds messages to be translated.
- *.po : files containing the translations of each message.
Installation Tree structureThe installation tree structure is very simple :
- the contents of the folder "data" will be copied in /usr/share/cairo-dock/plug-ins/truc
- the plug-in itself will be in /usr/lib/cairo-dock/libcd-truc.so
- the translation files will go in /usr/share/locale/$lang/LC_MESSAGES/cd-truc.mo, where $lang = fr, jp, ...
Don't forget to define the dependencies with other libs in configure.ac if needed, along with the version number of your applet. Also, report the files you need to install in the Makefile.am files.
Well, now start the serious things !
Using the applet framework