~cairo-dock-team/ubuntu/oneiric/cairo-dock/2.3.0-3

« back to all changes in this revision

Viewing changes to src/gldit/cairo-dock-struct.h

  • Committer: Bazaar Package Importer
  • Author(s): Matthieu Baerts (matttbe)
  • Date: 2010-08-09 23:26:12 UTC
  • mfrom: (1.1.10 upstream)
  • Revision ID: james.westby@ubuntu.com-20100809232612-yp4c6ig3jt1bzpdv
Tags: 2.2.0~0beta4-0ubuntu1
* New Upstream Version (LP: #614624)
* Fixed a few bugs on LP:
 - LP: #518453: Dock appears under all windows
                 (Compiz - fullscreen window)
 - LP: #521369: Separator are not removed when closing
                 grouped windows
 - LP: #521762: Some sentences are not correct
 - LP: #526466: Icons of apps with same class shouldn't
                 be stacked by default
 - LP: #535083: Dialogues looks ugly when a lot of them
                 appears at the same time
 - More details on the 'ChangeLog' file
* debian/rules:
 - Autotools has been replaced by CMake
 - Man pages are now included in the source code
* debian/copyright:
 - Updated with the new pathes and new files
* debian/control:
 - Autotools has been replaced by CMake
 - Added libcurl4-gnutls-dev as Build-deps
 - Bump Standard-Version to 3.9.1
* debian/cairo-dock-core.install:
 - Man pages are now included in the source code
 - All sonames are now installed into lib32 or lib64
* debian/cairo-dock-dev.install:
 - pkgconfig is now installed into lib32 or lib64

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
* This file is a part of the Cairo-Dock project
 
3
*
 
4
* Copyright : (C) see the 'copyright' file.
 
5
* E-mail    : see the 'copyright' file.
 
6
*
 
7
* This program is free software; you can redistribute it and/or
 
8
* modify it under the terms of the GNU General Public License
 
9
* as published by the Free Software Foundation; either version 3
 
10
* of the License, or (at your option) any later version.
 
11
*
 
12
* This program is distributed in the hope that it will be useful,
 
13
* but WITHOUT ANY WARRANTY; without even the implied warranty of
 
14
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
15
* GNU General Public License for more details.
 
16
* You should have received a copy of the GNU General Public License
 
17
* along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
18
*/
 
19
 
 
20
#ifndef __CAIRO_DOCK_STRUCT__
 
21
#define  __CAIRO_DOCK_STRUCT__
 
22
 
 
23
#include <X11/Xlib.h>
 
24
#include <glib.h>
 
25
#include <gdk/gdk.h>
 
26
#include <gtk/gtk.h>
 
27
#include <cairo.h>
 
28
#include <librsvg/rsvg.h>
 
29
#include <librsvg/rsvg-cairo.h>
 
30
#include <glib/gi18n.h>
 
31
//#include <X11/extensions/Xdamage.h>
 
32
 
 
33
#ifdef HAVE_GLITZ
 
34
#include <gdk/gdkx.h>
 
35
#include <glitz-glx.h>
 
36
#include <cairo-glitz.h>
 
37
#endif
 
38
 
 
39
#include <GL/gl.h>
 
40
#include <GL/glx.h>
 
41
 
 
42
/*! \mainpage Cairo-Dock's API documentation.
 
43
 * \ref intro_sec
 
44
 * 
 
45
 * \ref install_sec
 
46
 * 
 
47
 * \ref struct_sec
 
48
 * -  \ref containers
 
49
 * -  \ref icons
 
50
 * -  \ref dock
 
51
 * -  \ref desklet
 
52
 * -  \ref dialog
 
53
 * -  \ref flying
 
54
 * 
 
55
 * \ref applets_sec
 
56
 * -  \ref module
 
57
 * -  \ref generate
 
58
 * -  \ref definition
 
59
 * -  \ref sections
 
60
 * -  \ref notifications
 
61
 * -  \ref useful_functions
 
62
 * -  \ref opengl
 
63
 * -  \ref animation
 
64
 * -  \ref tasks
 
65
 * -  \ref sub-icons
 
66
 * 
 
67
 * \ref advanced_sec
 
68
 * -  \ref advanced_config
 
69
 * -  \ref steal_appli
 
70
 * -  \ref data_renderer
 
71
 * -  \ref multi
 
72
 * -  \ref render_container
 
73
 * 
 
74
 * 
 
75
 * 
 
76
 * \n
 
77
 * \section intro_sec Introduction
 
78
 *
 
79
 * Cairo-Dock's API can be divided into 3 parts :
 
80
 * - the definition of the main classes (dock, icon, etc)
 
81
 * - utilities functions (interaction with X, GUI, etc)
 
82
 * - plug-ins framework.
 
83
 *
 
84
 * Each class is defined in its own header. When a class is complex, it is divided into several files :
 
85
 * - "factory" define structures/enums and creation/modification/destruction functions
 
86
 * - "manager" manage all the ressources needed by a class and all the instances of a class
 
87
 * - "utilities" are a collection of helper functions.
 
88
 *
 
89
 * Cairo-Dock has a <b>decentralized conception</b> : it has a minimalistic core, and lets external modules extend its functionnalities.\n
 
90
 * This is a strong design, because it allows to extend functionnalities easily without having to hack into the core, which makes the project more stable and allows developpers to use high-level functions only, that are very tested and optimized.\n
 
91
 * Thus, Cairo-Dock itself has no animation, but has a convenient notification system that allows external plug-ins to animate icons when they want.\n
 
92
 * We will focus on this system and the plug-ins framework in this document. Part 1 will be seen briefly, and part 2 will be let to your curiosity. This should be enough to quickly be able to write a lot of applets.
 
93
 * 
 
94
 * \n
 
95
 * \section install_sec Installation
 
96
 *
 
97
 * The installation is very easy and uses cmake. In a terminal, copy-paste the following commands :
 
98
 * \code
 
99
 *   ### grab the sources of the core
 
100
 *   mkdir CD && cd CD
 
101
 *   bzr checkout --lightweight lp:cairo-dock-core
 
102
 *   ### compil the dock and install it
 
103
 *   cd cairo-dock-core
 
104
 *   cmake CMakeLists.txt  -DCMAKE_INSTALL_PREFIX=/usr
 
105
 *   make
 
106
 *   sudo make install
 
107
 *   ### grab the sources of the plug-ins
 
108
 *   cd ..
 
109
 *   bzr checkout --lightweight lp:cairo-dock-plug-ins
 
110
 *   ### compil the stable plug-ins and install them
 
111
 *   cmake CMakeLists.txt  -DCMAKE_INSTALL_PREFIX=/usr
 
112
 *   make
 
113
 *   sudo make install
 
114
 * \endcode
 
115
 * To install unstable applets, add some -Denable-xxx=yes to the cmake command, where xxx is the lower-case name of the applet.
 
116
 * 
 
117
 * 
 
118
 * \n
 
119
 * \section struct_sec Main structures
 
120
 *
 
121
 * \subsection containers Containers
 
122
 * See _CairoContainer for the definition of a Container, and cairo-dock-container.h for a complete description of the Container class.
 
123
 * 
 
124
 * \subsection icons Icons
 
125
 * See _Icon for the definition of an Icon, and cairo-dock-icons.h for a complete description of the Icon class.
 
126
 * 
 
127
 * \subsection dock Dock
 
128
 * See _CairoDock for the definition of a Dock, and cairo-dock-dock-factory.h for a complete description of the Dock class.
 
129
 * 
 
130
 * \subsection desklet Desklet
 
131
 * See _CairoDesklet for the definition of a Desklet, and cairo-dock-desklet.h for a complete description of the Desklet class.
 
132
 * 
 
133
 * \subsection dialog Dialog
 
134
 * See _CairoDialog for the definition of a Dialog, and cairo-dock-dialogs.h for a complete description of the Dialog class.
 
135
 * 
 
136
 * \subsection flying Flying Container
 
137
 * See _CairoFlyingContainer for the definition of a Flying Container, and cairo-dock-flying-container.h for a complete description of the FlyingContainer class.
 
138
 * 
 
139
 * 
 
140
 * 
 
141
 * \n
 
142
 * \section applets_sec External Modules
 
143
 * 
 
144
 * \subsection module First, what is a module ?
 
145
 * 
 
146
 * Modules are compiled .so files (that is to say, library) that are plugged into the dock at run-time.
 
147
 * Due to this fact, they can use any function used by the dock, and have a total interaction freedom on the dock.
 
148
 * The advantage is that applets can do anything, in fact they are extensions of the dock itself.
 
149
 * The drawback is that a buggy applet can make the dock unstable.
 
150
 * 
 
151
 * A module has an <b>interface</b> and a <b>visit card</b> :
 
152
 *  - the visit card allows it to define itself (name, category, default icon, etc)
 
153
 *  - the interface defines the entry points for init, stop, reload, read config, and reset datas.
 
154
 * 
 
155
 * Modules can be instanciated several times; each time they are, an <b>instance</b> is created. This instance will hold all the data used by the module's functions : the icon and its container, the config structure and its conf file, the data structure and a slot to plug datas into containers and icons. All these parameters are optionnal; a module that has an icon is also called an <b>applet</b>.
 
156
 * 
 
157
 * When instanciating a module, CD will check the presence of an "Icon" group in the conf file. If there is one, it will create an icon accordingly and insert it into its container. If there is a "Desklet" group, the module is considered as detachable, and can be placed into a desklet.
 
158
 * Here we will focus on applets, that is to say, we will have an icon and a container (dock or desklet).
 
159
 * 
 
160
 * 
 
161
 * \subsection generate Let's start, how do I create an empty applet ?
 
162
 * 
 
163
 * Easy ! just go to the "plug-ins" folder, and run the <i>generate-applet.sh</i> script. Answer the few questions, and you're done ! Don't forget to install the plug-in each time you modify it (<i>sudo make install</i> in your applet's folder).
 
164
 * You can see that the script has created for you the architecture of your applet :
 
165
 * - in the <b>root</b> folder, you have the "configure.ac", where you can set the version number of your applet, the dependencies, etc
 
166
 * - in the <b>src</b> folder, you have the sources of your applet. It is common to put the init/stop/reload in applet-init.c, the get_config/reset_config/reset_data in applet-config.c, the notifications in applet-notifications.c, and the structures in applet-struct.h. Of course, you can add as many files as you want, just don't forget to specify them in the Makefile.am
 
167
 * - in the <b>po</b> folder, you have the translation files. Currently the dock is widely translated into French, Japanese, and Italian.
 
168
 * - in the <b>data</b> folder, you have the config file, the default icon, and a preview. You will have to choose a default icon that fits your applet, and make a preview that makes users want to try it ;-)
 
169
 * If you have other files to install, it's here you will do it.
 
170
 * If you change the name of the default icon (for instance you use an SVG file), don't forget to modify the data/Makefile.am and also the src/Makefile.am.
 
171
 * 
 
172
 * 
 
173
 * \subsection definition Ok I have a generic applet, how do I define it ?
 
174
 * 
 
175
 * As we saw, a module must fill a visit card and an interface, to be acecpted by the dock.
 
176
 * This is done very easily by the \ref CD_APPLET_DEFINITION macro. All you have to give is the name of the applet, its category, a brief description/manual (very important !), and your name.
 
177
 * 
 
178
 * Once have finished your applet, don't forget to make a nice preview (~200x200 pixels) and a nice default icon, and place them in the <i>data</i> folder.
 
179
 * 
 
180
 * 
 
181
 * \subsection sections Great, I can see my applet in the dock ! Now, where should I continue ?
 
182
 * 
 
183
 * We saw that when our applet is activated, an instance is created. It is called <b>myApplet</b>, and it will hold the following :
 
184
 * - <b>myIcon</b> : this is your icon ! It will act as a drawing surface to represent whatever you want.
 
185
 * - <b>myDrawContext</b> : a cairo context, to draw on your icon with the libcairo.
 
186
 * - <b>myContainer</b> : the container your icon belongs to (a Dock or a Desklet). For convenience, the following 2 parameters are availale.
 
187
 * - <b>myDock</b> : if your container is a dock, myDock = myContainer, otherwise it is NULL.
 
188
 * - <b>myDesklet</b> : if your container is a desklet, myDesklet = myContainer, otherwise it is NULL.
 
189
 * - <b>myConfig</b> : the structure holding all the parameters you get in your conf file. You have to define it in applet-struct.h.
 
190
 * - <b>myData</b> : the structure holding all the ressources loaded at run-time. You have to define it in applet-struct.h.
 
191
 * 
 
192
 * The framework defines different <b>sections</b>, and all you have to do is to fill them :
 
193
 * 
 
194
 * - First of all you will have to get your config parameters. This is done in the \ref CD_APPLET_GET_CONFIG_BEGIN/\ref CD_APPLET_GET_CONFIG_END section, in applet-config.c.
 
195
 * - Each time you add a parameter, think of freeing it if it's a dynamic ressource like a string; this is done in the \ref CD_APPLET_RESET_CONFIG_BEGIN/\ref CD_APPLET_RESET_CONFIG_END section.
 
196
 * - In a similar way, you will free all the ressources you allocated by myData in the \ref CD_APPLET_RESET_DATA_BEGIN/\ref CD_APPLET_RESET_DATA_END section.
 
197
 * - After the instance is created, the dock lets you start. This is done in the \ref CD_APPLET_INIT_BEGIN/\ref CD_APPLET_INIT_END section. At this point, myApplet is already fully defined, and myConfig has been filled. Therefore you can already draw on your icon, launch timers, register to notifications, etc.
 
198
 * - Each time the user changes something in its config, or the desklet is resized, your applet is reloaded. This is done in the \ref CD_APPLET_RELOAD_BEGIN/\ref CD_APPLET_RELOAD_END section. The macro \ref CD_APPLET_MY_CONFIG_CHANGED tells you if something has changed in your config or if it's just a resizing.
 
199
 * - Last, when your applet is stopped, you have to stop everything you set up in the init (timers, notifications, etc) in the \ref CD_APPLET_STOP_BEGIN/\ref CD_APPLET_STOP_END section.
 
200
 * 
 
201
 * 
 
202
 * \subsection notifications The notifications system.
 
203
 * 
 
204
 * When something happens, Cairo-Dock notifies everybody about it, including itself. An applet can register to any notification (see \ref cairo-dock-notifications.h) before or after the dock, to be notified of the event of its choice. When you are notified, the function you registered for this event will be called; it must match the notification prototype as defined in \ref cairo-dock-notifications.h.
 
205
 *
 
206
 * For instance if you want to know when the user clicks on your icon, you will register to the \ref CAIRO_DOCK_CLICK_ICON notification.
 
207
 *
 
208
 * To register to a notification, you have the \ref cairo_dock_register_notification function. Always unregister when your applet is stopped, to avoid being notified when you shouldn't, with the function \ref cairo_dock_remove_notification_func.
 
209
 * 
 
210
 * For convenience, there are sections dedicated to the most common events; you just have to fill the corresponding sections :
 
211
 * - \ref CD_APPLET_ON_CLICK_BEGIN/\ref CD_APPLET_ON_CLICK_END for the actions on right click on your icon or one of its sub-dock.
 
212
 * - \ref CD_APPLET_ON_MIDDLE_CLICK_BEGIN/\ref CD_APPLET_ON_MIDDLE_CLICK_END for the actions on middle click on your icon or one of its sub-dock.
 
213
 * - \ref CD_APPLET_ON_DOUBLE_CLICK_BEGIN/\ref CD_APPLET_ON_DOUBLE_CLICK_END for the actions on double click on your icon or one of its sub-dock.
 
214
 * - \ref CD_APPLET_ON_SCROLL_BEGIN/\ref CD_APPLET_ON_SCROLL_END for the actions on scroll on your icon or one of its sub-dock.
 
215
 * - \ref CD_APPLET_ON_BUILD_MENU_BEGIN/\ref CD_APPLET_ON_BUILD_MENU_END for the building of the menu on left click on your icon or one of its sub-dock.
 
216
 * 
 
217
 * To register to these notifications, you can use the convenient macros :
 
218
 * - \ref CD_APPLET_REGISTER_FOR_CLICK_EVENT
 
219
 * - \ref CD_APPLET_REGISTER_FOR_MIDDLE_CLICK_EVENT
 
220
 * - \ref CD_APPLET_REGISTER_FOR_DOUBLE_CLICK_EVENT
 
221
 * - \ref CD_APPLET_REGISTER_FOR_SCROLL_EVENT
 
222
 * - \ref CD_APPLET_REGISTER_FOR_BUILD_MENU_EVENT
 
223
 *
 
224
 *
 
225
 * \subsection useful_functions Ok now I have several sections of code to fill. Are there any useful functions to do it ?
 
226
 * A lot of useful macros are provided in cairo-dock-applet-facility.h to make your life easier :
 
227
 * - To get values contained inside your <b>conf file</b>, you can use the following :\n
 
228
 * \ref CD_CONFIG_GET_BOOLEAN & cie
 
229
 * 
 
230
 * - To <b>build your menu</b>, you can use the following :\n
 
231
 * \ref CD_APPLET_ADD_SUB_MENU & cie
 
232
 * 
 
233
 * - To <b>create a surface</b> that fits your icon from an image, you can use the following :\n
 
234
 * \ref CD_APPLET_LOAD_SURFACE_FOR_MY_APPLET & cie
 
235
 * 
 
236
 * - To directly <b>set an image on your icon</b>, you can use the following :\n
 
237
 * \ref CD_APPLET_SET_IMAGE_ON_MY_ICON & cie
 
238
 * 
 
239
 * - To trigger the <b>refresh</b> of your icon or container after you drew something, you can use the following :\n
 
240
 * \ref CD_APPLET_REDRAW_MY_ICON & \ref CAIRO_DOCK_REDRAW_MY_CONTAINER
 
241
 * 
 
242
 * - To modify the <b>label</b> of your icon, you can use the following :\n
 
243
 * \ref CD_APPLET_SET_NAME_FOR_MY_ICON & cie
 
244
 * 
 
245
 * - To set a <b>quick-info</b> on your icon, you can use the following :\n
 
246
 * \ref CD_APPLET_SET_QUICK_INFO_ON_MY_ICON & cie
 
247
 * 
 
248
 *
 
249
 * \subsection opengl How can I take advantage of the OpenGL ?
 
250
 * 
 
251
 * There are 3 cases :
 
252
 * - your applet just has a static icon; there is nothing to take into account, the common functions to set an image or a surface on an icon already handle the texture mapping.
 
253
 * - you draw dynamically on your icon with libcairo (using myDrawContext), but you don't want to bother with OpenGL; all you have to do is to call /ref cairo_dock_update_icon_texture to update your icon's texture after you drawn your surface. This can be done for occasional drawings, like Switcher redrawing its icon each time a window is moved.
 
254
 * - you draw your icon differently whether the dock is in OpenGL mode or not; in this case, you just need to put all the OpenGL commands into a CD_APPLET_START_DRAWING_MY_ICON/CD_APPLET_FINISH_DRAWING_MY_ICON section inside your code.
 
255
 * 
 
256
 * There are also a lot of convenient functions you can use to draw in OpenGL. See cairo-dock-draw-opengl.h for loading and drawing textures and paths, and cairo-dock-particle-system.h for an easy way to draw particle systems.
 
257
 * 
 
258
 * 
 
259
 * \subsection animation How can I animate my applet to make it more lively ?
 
260
 *
 
261
 * If you want to animate your icon easily, to signal some action (like <i>Music-Player</i> when a new song starts), you can simply <b>request for one of the registered animations</b> with \ref CD_APPLET_ANIMATE_MY_ICON and stop it with \ref CD_APPLET_STOP_ANIMATING_MY_ICON. You just need to specify the name of the animation (like "rotate" or "pulse") and the number of time it will be played.
 
262
 * 
 
263
 * But you can also make your own animation, like <i>Clock</i> of <i>Cairo-Penguin</i>. You will have to integrate yourself into the rendering loop of your container. Don't panic, here again, Cairo-Dock helps you !
 
264
 * 
 
265
 * First you will register to the "update container" notification, with a simple call to \ref CD_APPLET_REGISTER_FOR_UPDATE_ICON_SLOW_EVENT or \ref CD_APPLET_REGISTER_FOR_UPDATE_ICON_EVENT, depending on the refresh frequency you need : ~10Hz or ~33Hz. A high frequency needs of course more CPU, and most of the time the slow frequancy is enough.
 
266
 * 
 
267
 * Then you will just put all your code in a \ref CD_APPLET_ON_UPDATE_ICON_BEGIN/\ref CD_APPLET_ON_UPDATE_ICON_END section. That's all ! In this section, do what you want, like redrawing your icon, possibly incrementing a counter to know until where you went, etc. See \ref opengl "the previous paragraph" to draw on your icon.
 
268
 * Inside the rendering loop, you can skip an iteration with \ref CD_APPLET_SKIP_UPDATE_ICON, and quit the loop with \ref CD_APPLET_STOP_UPDATE_ICON or \ref CD_APPLET_PAUSE_UPDATE_ICON (don't forget to quit the loop when you're done, otherwise your container may continue to redraw itself, which means a needless CPU load).
 
269
 * 
 
270
 * To know the size allocated to your icon, use the convenient \ref CD_APPLET_GET_MY_ICON_EXTENT.
 
271
 *
 
272
 *
 
273
 * \subsection tasks I have heavy treatments to do, how can I make them without slowing the dock ?
 
274
 * 
 
275
 * Say for instance you want to download a file on the Net, it is likely to take some amount of time, during which the dock will be frozen, waiting for you. To avoid such a situation, Cairo-Dock defines \ref _CairoDockTask "Tasks". They are perform their job <b>asynchronously</b>, and can be <b>periodic</b>. See cairo-dock-task.h for a quick explanation on how a Task works.
 
276
 * 
 
277
 * You create a Task with \ref cairo_dock_new_task, launch it with \ref cairo_dock_launch_task, and destroy it with \ref cairo_dock_free_task.
 
278
 * 
 
279
 * 
 
280
 * \subsection sub-icons I need more than one icon, how can I easily get more ?
 
281
 * 
 
282
 * In dock mode, your icon can have a sub-dock; in desklet mode, you can load a list of icons into your desklet. Cairo-Dock provides a convenient macro to <b>quickly load a list of icons</b> in both cases : \ref CD_APPLET_LOAD_MY_ICONS_LIST to load a list of icons and \ref CD_APPLET_DELETE_MY_ICONS_LIST to destroy it. Thus you don't need to know in which mode you are, neither to care about loading the icons, freeing them, or anything.
 
283
 * 
 
284
 * You can get the list of icons with \ref CD_APPLET_MY_ICONS_LIST and to their container with \ref CD_APPLET_MY_ICONS_LIST_CONTAINER.
 
285
 * 
 
286
 * 
 
287
 * \n
 
288
 * \section advanced_sec Advanced functionnalities
 
289
 * 
 
290
 * \subsection advanced_config How can I make my own widgets in the config panel ?
 
291
 * 
 
292
 * Cairo-Dock can build itself the config panel of your applet from the config file. Moreover, it can do the opposite : update the conf file from the config panel. However, it is limited to the widgets it knows, and there are some cases it is not enough.
 
293
 * Because of that, Cairo-Dock offers 2 hooks in the process of building/reading the config panel : 
 
294
when defining your applet in the \ref CD_APPLET_DEFINE_BEGIN/\ref CD_APPLET_DEFINE_END section, add to the interface the 2 functions pInterface->load_custom_widget and pInterface->save_custom_widget.
 
295
 * They will be respectively called when the config panel of your applet is raised, and when it is validated.
 
296
 * 
 
297
 * If you want to modify the content of an existing widget, you can grab it with \ref cairo_dock_get_widget_from_name.
 
298
 * To add your custom widgets, insert in the conf file an empty widget (with the prefix '_'), then grab it and pack some GtkWidget inside.
 
299
 * If you want to dynamically alter the config panel (like having a "new" button that would make appear new widgets on click), you can add in the conf file the new widgets, and then call \ref cairo_dock_reload_current_module_widget to reload the config panel.
 
300
 * See the AlsaMixer or Weather applets for an easy example, and Clock or Mail for a more advanced example.
 
301
 *
 
302
 * 
 
303
 * \subsection steal_appli How can my applet control the window of an application ?
 
304
 * 
 
305
 * Say your applet launches an external application that has its own window. It is logical to <b>make your applet control this application</b>, rather than letting the Taskbar do.
 
306
 * All you need to do is to call the macro \ref CD_APPLET_MANAGE_APPLICATION, indicating which application you wish to manage (you need to enter the class of the application, as you can get from "xprop | grep CLASS"). Your applet will then behave like a launcher that has stolen the appli icon.
 
307
 * 
 
308
 * 
 
309
 * \subsection data_renderer How can I render some numerical values on my icon ?
 
310
 * 
 
311
 * Cairo-Dock offers a powerful and versatile architecture for this case : \ref _CairoDataRenderer.
 
312
 * A DataRenderer is a generic way to render a set of values on an icon; there are several implementations of this class : Gauge, CairoDockGraph, Bar, and it is quite easy to implement a new kind of DataRenderer.
 
313
 * 
 
314
 * Each kind of renderer has a set of attributes that you can use to customize it; you just need to call the \ref CD_APPLET_ADD_DATA_RENDERER_ON_MY_ICON macro with the attributes, and you're done !
 
315
 * Then, each time you want to render some new values, simply call \ref CD_APPLET_RENDER_NEW_DATA_ON_MY_ICON with the new values.
 
316
 * 
 
317
 * When your applet is reloaded, you have to reload the DataRenderer as well, using the convenient \ref CD_APPLET_RELOAD_MY_DATA_RENDERER macro. If you don't specify attributes to it, it will simply reload the current DataRenderer, otherwise it will load the new attributes; the previous data are not lost, which is useful in the case of Graph for instance.
 
318
 * 
 
319
 * You can remove it at any time with \ref CD_APPLET_REMOVE_MY_DATA_RENDERER.
 
320
 * 
 
321
 * 
 
322
 * \subsection multi How can I make my applet multi-instanciable ?
 
323
 *
 
324
 * Applets can be launched several times, an instance will be created each time. To ensure your applet can be instanciated several times, you just need to pass myApplet to any function that uses one of its fields (myData, myIcon, etc). Then, to indicate Cairo-Dock that your applet is multi-instanciable, you'll have to define the macro CD_APPLET_MULTI_INSTANCE in each file. A convenient way to do that is to define it in the Makefile.am, by adding the following line to the CFLAGS : \code -DCD_APPLET_MULTI_INSTANCE=\"1\"\ \endcode.
 
325
 * 
 
326
 * 
 
327
 * \subsection render_container How can I draw anywhere on the dock, not only on my icon ?
 
328
 * 
 
329
 * Say you want to draw directly on your container, like <i>CairoPenguin</i> or <i>ShowMouse</i> do. This can be achieved easily by registering to the \ref CAIRO_DOCK_RENDER_DOCK or \ref CAIRO_DOCK_RENDER_DESKLET notifications. You will then be notified eash time a Dock or a Desklet is drawn. Register AFTER so that you will draw after the view.
 
330
 * 
 
331
 * 
 
332
 * to be continued ...
 
333
 */
 
334
 
 
335
 
 
336
 
 
337
 
 
338
typedef struct _CairoDockRenderer CairoDockRenderer;
 
339
typedef struct _CairoDeskletRenderer CairoDeskletRenderer;
 
340
typedef struct _CairoDeskletDecoration CairoDeskletDecoration;
 
341
typedef struct _CairoDialogRenderer CairoDialogRenderer;
 
342
typedef struct _CairoDialogDecorator CairoDialogDecorator;
 
343
 
 
344
typedef struct _IconInterface IconInterface;
 
345
typedef struct _Icon Icon;
 
346
typedef struct _CairoContainer CairoContainer;
 
347
typedef struct _CairoContainerInterface CairoContainerInterface;
 
348
typedef struct _CairoDock CairoDock;
 
349
typedef struct _CairoDesklet CairoDesklet;
 
350
typedef struct _CairoDialog CairoDialog;
 
351
typedef struct _CairoFlyingContainer CairoFlyingContainer;
 
352
 
 
353
typedef struct _CairoDockModule CairoDockModule;
 
354
typedef struct _CairoDockModuleInterface CairoDockModuleInterface;
 
355
typedef struct _CairoDockModuleInstance CairoDockModuleInstance;
 
356
typedef struct _CairoDockVisitCard CairoDockVisitCard;
 
357
typedef struct _CairoDockInternalModule CairoDockInternalModule;
 
358
typedef struct _CairoDockMinimalAppletConfig CairoDockMinimalAppletConfig;
 
359
typedef struct _CairoDockDesktopEnvBackend CairoDockDesktopEnvBackend;
 
360
typedef struct _CairoDockClassAppli CairoDockClassAppli;
 
361
typedef struct _CairoDockLabelDescription CairoDockLabelDescription;
 
362
typedef struct _CairoDialogAttribute CairoDialogAttribute;
 
363
typedef struct _CairoDeskletAttribute CairoDeskletAttribute;
 
364
typedef struct _CairoDialogButton CairoDialogButton;
 
365
 
 
366
typedef struct _CairoDataRenderer CairoDataRenderer;
 
367
typedef struct _CairoDataRendererAttribute CairoDataRendererAttribute;
 
368
typedef struct _CairoDataRendererInterface CairoDataRendererInterface;
 
369
typedef struct _CairoDataToRenderer CairoDataToRenderer;
 
370
typedef struct _CairoDataRendererEmblem CairoDataRendererEmblem;
 
371
typedef struct _CairoDataRendererTextZone CairoDataRendererTextZone;
 
372
typedef struct _CairoDockDataRendererRecord CairoDockDataRendererRecord;
 
373
 
 
374
typedef struct _CairoDockAnimationRecord CairoDockAnimationRecord;
 
375
 
 
376
typedef struct _CairoDockHidingEffect CairoDockHidingEffect;
 
377
 
 
378
typedef struct _CairoIconContainerRenderer CairoIconContainerRenderer;
 
379
 
 
380
typedef struct _CairoDockTransition CairoDockTransition;
 
381
 
 
382
typedef struct _CairoDockTask CairoDockTask;
 
383
 
 
384
typedef struct _CairoDockPackage CairoDockPackage;
 
385
 
 
386
typedef struct _CairoDockGroupKeyWidget CairoDockGroupKeyWidget;
 
387
 
 
388
typedef struct _CairoDockGLConfig CairoDockGLConfig;
 
389
 
 
390
typedef struct _CairoDockGLFont CairoDockGLFont;
 
391
 
 
392
typedef struct _CairoDockGLPath CairoDockGLPath;
 
393
 
 
394
typedef struct _CairoDockDesktopGeometry CairoDockDesktopGeometry;
 
395
 
 
396
typedef struct _CairoDockDesktopBackground CairoDockDesktopBackground;
 
397
 
 
398
typedef struct _CairoDockImageBuffer CairoDockImageBuffer;
 
399
 
 
400
typedef struct _CairoEmblem CairoEmblem;
 
401
 
 
402
 
 
403
 
 
404
typedef gpointer CairoDockManagerConfigPtr;
 
405
typedef gpointer CairoDockManagerDataPtr;
 
406
typedef void (*CairoDockManagerInitFunc) (void);
 
407
typedef void (*CairoDockManagerLoadFunc) (void);
 
408
typedef void (*CairoDockManagerUnloadFunc) (void);
 
409
typedef void (* CairoDockManagerReloadFunc) (CairoDockManagerConfigPtr *pPrevConfig, CairoDockManagerConfigPtr *pNewConfig);
 
410
typedef gboolean (* CairoDockManagerGetConfigFunc) (GKeyFile *pKeyFile, CairoDockManagerConfigPtr *pConfig);
 
411
typedef void (* CairoDockManagerResetConfigFunc) (CairoDockManagerConfigPtr *pConfig);
 
412
typedef void (* CairoDockManagerResetDataFunc) (CairoDockManagerDataPtr *pData);
 
413
struct _CairoDockManager {
 
414
        //\_____________ Carte de visite.
 
415
        const gchar *cModuleName;
 
416
        const gchar *cDescription;
 
417
        const gchar *cIcon;
 
418
        const gchar *cTitle;
 
419
        gint iCategory;
 
420
        gint iSizeOfConfig;
 
421
        gint iSizeOfData;
 
422
        //\_____________ Interface.
 
423
        CairoDockManagerInitFunc init;
 
424
        CairoDockManagerLoadFunc load;
 
425
        CairoDockManagerUnloadFunc unload;
 
426
        CairoDockManagerReloadFunc reload;
 
427
        CairoDockManagerGetConfigFunc get_config;
 
428
        CairoDockManagerResetConfigFunc reset_config;
 
429
        //\_____________ Instance.
 
430
        CairoDockManagerConfigPtr pConfig;
 
431
        CairoDockManagerDataPtr pData;
 
432
};
 
433
 
 
434
typedef struct _CairoDockManager CairoDockManager;
 
435
 
 
436
 
 
437
 
 
438
#define CAIRO_DOCK_NB_DATA_SLOT 12
 
439
 
 
440
/// Nom du fichier de conf principal du theme.
 
441
#define CAIRO_DOCK_CONF_FILE "cairo-dock.conf"
 
442
/// Nom du fichier de conf d'un dock racine.
 
443
#define CAIRO_DOCK_MAIN_DOCK_CONF_FILE "main-dock.conf"
 
444
 
 
445
/// Nom du repertoire racine du theme courant.
 
446
#define CAIRO_DOCK_CURRENT_THEME_NAME "current_theme"
 
447
/// Nom du repertoire des themes extras.
 
448
#define CAIRO_DOCK_EXTRAS_DIR "extras"
 
449
/// Nom du repertoire des themes de dock.
 
450
#define CAIRO_DOCK_THEMES_DIR "themes"
 
451
 
 
452
/// Nom du dock principal (le 1er cree).
 
453
#define CAIRO_DOCK_MAIN_DOCK_NAME "_MainDock_"
 
454
/// Nom de la vue par defaut.
 
455
#define CAIRO_DOCK_DEFAULT_RENDERER_NAME N_("Default")
 
456
 
 
457
 
 
458
#define CAIRO_DOCK_LAST_ORDER -1e9
 
459
#define CAIRO_DOCK_NB_MAX_ITERATIONS 1000
 
460
 
 
461
#define CAIRO_DOCK_LOAD_ICONS_FOR_DESKLET TRUE
 
462
 
 
463
#endif