Home Forums Wiki Doc Install Extras Screenshots Source Code Projects Blog Users Groups Register
Glx-Dock / Cairo-Dock Wiki Write an applet
The latest stable release is the *3.4.0* : How to install it here.
Note: We just switched from BZR to Git on Github! (only to host the code and your future pull requests)
Information : The version displayed on this page is not the latest available.
History View code

Glx-Dock / Cairo-Dock




en English

fr Français

ru Russian

Support Us

Flattr this


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") :

Applet Structure

Source Tree structure
The 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 Folder
In ./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 Folder
In --./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 Folder
In ./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 structure
The 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, ...

Compilation files
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

Glx-Dock / Cairo-Dock Wiki Write an applet Top

Online users :

Powered by ElementSpeak © 2007 Adrien Pilleboue, 2009-2013 Matthieu Baerts.
Dock based on CSS Dock Menu (Ndesign) with jQuery. Icons by zgegball
Cairo-Dock is a free software under GNU-GPL3 licence. First stable version created by Fabounet.
Many thanks to TuxFamily for the web Hosting and Mav for the domain name.