~ubuntu-branches/ubuntu/oneiric/cairo-dock/oneiric

« back to all changes in this revision

Viewing changes to src/cairo-dock-applet-facility.h

  • Committer: Bazaar Package Importer
  • Author(s): Matthieu Baerts (matttbe)
  • Date: 2010-08-09 23:26:12 UTC
  • mto: (18.1.1 cairo-dock) (19.1.1 cairo-dock)
  • mto: This revision was merged to the branch mainline in revision 13.
  • Revision ID: james.westby@ubuntu.com-20100809232612-pocdxliaxjdetm37
Tags: upstream-2.2.0~0beta4
ImportĀ upstreamĀ versionĀ 2.2.0~0beta4

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_APPLET_FACILITY__
21
 
#define  __CAIRO_DOCK_APPLET_FACILITY__
22
 
 
23
 
#include "cairo-dock-struct.h"
24
 
#include "cairo-dock-modules.h"
25
 
#include "cairo-dock-menu.h"
26
 
#include "cairo-dock-applet-factory.h"
27
 
G_BEGIN_DECLS
28
 
 
29
 
/**
30
 
*@file cairo-dock-applet-facility.h A collection of useful macros for applets.
31
 
* Macros provides a normalized API that will :
32
 
*  - lets you perform complex operations with a minimum amount of code
33
 
*  - ensures a bug-free functioning
34
 
*  - masks the internal complexity
35
 
*  - allows a normalized and easy-to-maintain code amongst all the applets.
36
 
*/
37
 
 
38
 
/** Apply a surface on a context, with a zoom and a transparency factor. The context is cleared beforehand with the default icon background.
39
 
*@param pIconContext the drawing context; is not altered by the function.
40
 
*@param pSurface the surface to apply.
41
 
*@param fScale zoom fastor.
42
 
*@param fAlpha transparency in [0,1].
43
 
*@param pIcon the icon.
44
 
*@param pContainer the container of the icon.
45
 
*/
46
 
void cairo_dock_set_icon_surface_full (cairo_t *pIconContext, cairo_surface_t *pSurface, double fScale, double fAlpha, Icon *pIcon, CairoContainer *pContainer);
47
 
 
48
 
/** Apply a surface on a context. The context is cleared beforehand with the default icon background..
49
 
*@param pIconContext the drawing context; is not altered by the function.
50
 
*@param pSurface the surface to apply.
51
 
*/
52
 
#define cairo_dock_set_icon_surface(pIconContext, pSurface) cairo_dock_set_icon_surface_full (pIconContext, pSurface, 1, 1, NULL, NULL)
53
 
 
54
 
/** Draw a bar at the bottom of an Icon, with a gradation from red to green and a given length.
55
 
*@param pIconContext the drawing context; is not altered by the function.
56
 
*@param fValue the value representing a percentage, in [-1,1]. if negative, the gradation is inverted, and the absolute value is used.
57
 
*@param pIcon the icon.
58
 
*@param pContainer the container of the icon.
59
 
*/
60
 
void cairo_dock_draw_bar_on_icon (cairo_t *pIconContext, double fValue, Icon *pIcon, CairoContainer *pContainer);
61
 
 
62
 
void cairo_dock_set_icon_surface_with_bar (cairo_t *pIconContext, cairo_surface_t *pSurface, double fValue, Icon *pIcon, CairoContainer *pContainer);
63
 
 
64
 
/** Apply a surface on the context of an icon, clearing it beforehand, and adding the reflect.
65
 
*@param pIconContext the drawing context; is not altered by the function.
66
 
*@param pSurface the surface to apply.
67
 
*@param pIcon the icon.
68
 
*@param pContainer the container of the icon.
69
 
*/
70
 
void cairo_dock_set_icon_surface_with_reflect (cairo_t *pIconContext, cairo_surface_t *pSurface, Icon *pIcon, CairoContainer *pContainer);
71
 
 
72
 
/** Apply an image on the context of an icon, clearing it beforehand, and adding the reflect.
73
 
*@param pIconContext the drawing context; is not altered by the function.
74
 
*@param cImagePath path of an image to apply on the icon.
75
 
*@param pIcon the icon.
76
 
*@param pContainer the container of the icon.
77
 
*/
78
 
void cairo_dock_set_image_on_icon (cairo_t *pIconContext, const gchar *cImagePath, Icon *pIcon, CairoContainer *pContainer);
79
 
 
80
 
 
81
 
void cairo_dock_set_hours_minutes_as_quick_info (cairo_t *pSourceContext, Icon *pIcon, CairoContainer *pContainer, int iTimeInSeconds);
82
 
void cairo_dock_set_minutes_secondes_as_quick_info (cairo_t *pSourceContext, Icon *pIcon, CairoContainer *pContainer, int iTimeInSeconds);
83
 
 
84
 
/** Convert a size in bytes into a readable format.
85
 
*@param iSizeInBytes size in bytes.
86
 
*@return a newly allocated string.
87
 
*/
88
 
gchar *cairo_dock_get_human_readable_size (long long int iSizeInBytes);
89
 
void cairo_dock_set_size_as_quick_info (cairo_t *pSourceContext, Icon *pIcon, CairoContainer *pContainer, long long int iSizeInBytes);
90
 
 
91
 
/// type of possible display on a Icon.
92
 
typedef enum {
93
 
        /// don't display anything.
94
 
        CAIRO_DOCK_INFO_NONE = 0,
95
 
        /// display info on the icon (as quick-info).
96
 
        CAIRO_DOCK_INFO_ON_ICON,
97
 
        /// display on the label of the icon.
98
 
        CAIRO_DOCK_INFO_ON_LABEL,
99
 
        CAIRO_DOCK_NB_INFO_DISPLAY
100
 
} CairoDockInfoDisplay;
101
 
 
102
 
 
103
 
gchar *cairo_dock_get_theme_path_for_module (const gchar *cAppletConfFilePath, GKeyFile *pKeyFile, const gchar *cGroupName, const gchar *cKeyName, gboolean *bFlushConfFileNeeded, const gchar *cDefaultThemeName, const gchar *cShareThemesDir, const gchar *cExtraDirName);
104
 
 
105
 
GtkWidget *cairo_dock_create_sub_menu (const gchar *cLabel, GtkWidget *pMenu, const gchar *cImage);
106
 
 
107
 
 
108
 
/** Play a sound, through Alsa or PulseAudio.
109
 
*@param cSoundPath path to an audio file.
110
 
*/
111
 
void cairo_dock_play_sound (const gchar *cSoundPath);
112
 
 
113
 
 
114
 
/** Get the Gnome's version.
115
 
*@param iMajor pointer to the major.
116
 
*@param iMinor pointer to the minor.
117
 
*@param iMicro pointer to the micro.
118
 
*/
119
 
void cairo_dock_get_gnome_version (int *iMajor, int *iMinor, int *iMicro);
120
 
 
121
 
 
122
 
void cairo_dock_pop_up_about_applet (GtkMenuItem *menu_item, CairoDockModuleInstance *pModuleInstance);
123
 
 
124
 
void cairo_dock_open_module_config_on_demand (int iClickedButton, GtkWidget *pInteractiveWidget, CairoDockModuleInstance *pModuleInstance, CairoDialog *pDialog);
125
 
 
126
 
 
127
 
 
128
 
  ////////////
129
 
 // CONFIG //
130
 
////////////
131
 
 
132
 
/** Get the value of a 'boolean' from the conf file.
133
 
*@param cGroupName name of the group in the conf file.
134
 
*@param cKeyName name of the key in the conf file.
135
 
*@param bDefaultValue default value if the group/key is not found (typically if the key is new).
136
 
*@return a gboolean.
137
 
*/
138
 
#define CD_CONFIG_GET_BOOLEAN_WITH_DEFAULT(cGroupName, cKeyName, bDefaultValue) cairo_dock_get_boolean_key_value (pKeyFile, cGroupName, cKeyName, &bFlushConfFileNeeded, bDefaultValue, NULL, NULL)
139
 
/** Get the value of a 'boolean' from the conf file, with TRUE as default value.
140
 
*@param cGroupName name of the group in the conf file.
141
 
*@param cKeyName name of the key in the conf file.
142
 
*@return a gboolean.
143
 
*/
144
 
#define CD_CONFIG_GET_BOOLEAN(cGroupName, cKeyName) CD_CONFIG_GET_BOOLEAN_WITH_DEFAULT (cGroupName, cKeyName, TRUE)
145
 
 
146
 
/** Get the value of an 'integer' from the conf file.
147
 
*@param cGroupName name of the group in the conf file.
148
 
*@param cKeyName name of the key in the conf file.
149
 
*@param iDefaultValue default value if the group/key is not found (typically if the key is new).
150
 
*@return an integer.
151
 
*/
152
 
#define CD_CONFIG_GET_INTEGER_WITH_DEFAULT(cGroupName, cKeyName, iDefaultValue) cairo_dock_get_integer_key_value (pKeyFile, cGroupName, cKeyName, &bFlushConfFileNeeded, iDefaultValue, NULL, NULL)
153
 
/** Get the value of a 'entier' from the conf file, with 0 as default value.
154
 
*@param cGroupName name of the group in the conf file.
155
 
*@param cKeyName name of the key in the conf file.
156
 
*@return an integer.
157
 
*/
158
 
#define CD_CONFIG_GET_INTEGER(cGroupName, cKeyName) CD_CONFIG_GET_INTEGER_WITH_DEFAULT (cGroupName, cKeyName, 0)
159
 
 
160
 
/** Get the value of a 'double' from the conf file.
161
 
*@param cGroupName name of the group in the conf file.
162
 
*@param cKeyName name of the key in the conf file.
163
 
*@param fDefaultValue default value if the group/key is not found (typically if the key is new).
164
 
*@return a double.
165
 
*/
166
 
#define CD_CONFIG_GET_DOUBLE_WITH_DEFAULT(cGroupName, cKeyName, fDefaultValue) cairo_dock_get_double_key_value (pKeyFile, cGroupName, cKeyName, &bFlushConfFileNeeded, fDefaultValue, NULL, NULL)
167
 
/** Get the value of a 'double' from the conf file, with 0. as default value.
168
 
*@param cGroupName name of the group in the conf file.
169
 
*@param cKeyName name of the key in the conf file.
170
 
*@return a double.
171
 
*/
172
 
#define CD_CONFIG_GET_DOUBLE(cGroupName, cKeyName) CD_CONFIG_GET_DOUBLE_WITH_DEFAULT (cGroupName, cKeyName, 0.)
173
 
 
174
 
/** Get the value of an 'integers list' from the conf file.
175
 
*@param cGroupName name of the group in the conf file.
176
 
*@param cKeyName name of the key in the conf file.
177
 
*@param iNbElements number of elements to get from the conf file.
178
 
*@param iValueBuffer buffer to fill with the values.
179
 
*/
180
 
#define CD_CONFIG_GET_INTEGER_LIST(cGroupName, cKeyName, iNbElements, iValueBuffer) \
181
 
cairo_dock_get_integer_list_key_value (pKeyFile, cGroupName, cKeyName, &bFlushConfFileNeeded, iValueBuffer, iNbElements, NULL, NULL, NULL)
182
 
 
183
 
/** Get the value of a 'string' from the conf file.
184
 
*@param cGroupName name of the group in the conf file.
185
 
*@param cKeyName name of the key in the conf file.
186
 
*@param cDefaultValue default value if the group/key is not found (typically if the key is new). can be NULL.
187
 
*@return a newly allocated string.
188
 
*/
189
 
#define CD_CONFIG_GET_STRING_WITH_DEFAULT(cGroupName, cKeyName, cDefaultValue) cairo_dock_get_string_key_value (pKeyFile, cGroupName, cKeyName, &bFlushConfFileNeeded, cDefaultValue, NULL, NULL)
190
 
/** Get the value of a 'string' from the conf file, with NULL as default value.
191
 
*@param cGroupName name of the group in the conf file.
192
 
*@param cKeyName name of the key in the conf file.
193
 
*@return a newly allocated string.
194
 
*/
195
 
#define CD_CONFIG_GET_STRING(cGroupName, cKeyName) CD_CONFIG_GET_STRING_WITH_DEFAULT (cGroupName, cKeyName, NULL)
196
 
 
197
 
/** Get the value of a 'file' from the conf file, with NULL as default value. If the value is a file name (not a path), it is supposed to be in the Cairo-Dock's current theme folder. If the value is NULL, the default file is used, taken at the applet's data folder, but the conf file is not updated with this value.
198
 
*@param cGroupName name of the group in the conf file.
199
 
*@param cKeyName name of the key in the conf file.
200
 
*@param cDefaultFileName defaul tfile if none is specified in the conf file.
201
 
*@return a newly allocated string giving the complete path of the file.
202
 
*/
203
 
#define CD_CONFIG_GET_FILE_PATH(cGroupName, cKeyName, cDefaultFileName) cairo_dock_get_file_path_key_value (pKeyFile, cGroupName, cKeyName, &bFlushConfFileNeeded, NULL, NULL, MY_APPLET_SHARE_DATA_DIR, cDefaultFileName)
204
 
 
205
 
/** Get the value of a 'strings list' from the conf file.
206
 
*@param cGroupName name of the group in the conf file.
207
 
*@param cKeyName name of the key in the conf file.
208
 
*@param length pointer to the number of strings that were extracted from the conf file.
209
 
*@param cDefaultValues default value if the group/key is not found (typically if the key is new). It is a string with words separated by ';'. It can be NULL.
210
 
*@return a table of strings, to be freeed with 'g_strfreev'.
211
 
*/
212
 
#define CD_CONFIG_GET_STRING_LIST_WITH_DEFAULT(cGroupName, cKeyName, length, cDefaultValues) cairo_dock_get_string_list_key_value (pKeyFile, cGroupName, cKeyName, &bFlushConfFileNeeded, length, cDefaultValues, NULL, NULL)
213
 
/** Get the value of a 'strings list' from the conf file, with NULL as default value.
214
 
*@param cGroupName name of the group in the conf file.
215
 
*@param cKeyName name of the key in the conf file.
216
 
*@param length pointer to the number of strings that were extracted from the conf file.
217
 
*@return a table of strings, to be freeed with 'g_strfreev'.
218
 
*/
219
 
#define CD_CONFIG_GET_STRING_LIST(cGroupName, cKeyName, length) CD_CONFIG_GET_STRING_LIST_WITH_DEFAULT(cGroupName, cKeyName, length, NULL)
220
 
 
221
 
/** Get the value of a 'color' in the RGBA format from the conf file.
222
 
*@param cGroupName name of the group in the conf file.
223
 
*@param cKeyName name of the key in the conf file.
224
 
*@param pColorBuffer a table of 4 'double' already allocated, that will be filled with the color components.
225
 
*@param pDefaultColor default value if the group/key is not found (typically if the key is new). It is a table of 4 'double'. It can be NULL.
226
 
*/
227
 
#define CD_CONFIG_GET_COLOR_WITH_DEFAULT(cGroupName, cKeyName, pColorBuffer, pDefaultColor) cairo_dock_get_double_list_key_value (pKeyFile, cGroupName, cKeyName, &bFlushConfFileNeeded, (double*)pColorBuffer, 4, pDefaultColor, NULL, NULL)
228
 
/** Get the value of a 'color' in the RGBA format from the conf file, with NULL as default value.
229
 
*@param cGroupName name of the group in the conf file.
230
 
*@param cKeyName name of the key in the conf file.
231
 
*@param pColorBuffer a table of 4 'double' already allocated, that will be filled with the color components.
232
 
*/
233
 
#define CD_CONFIG_GET_COLOR(cGroupName, cKeyName, pColorBuffer) CD_CONFIG_GET_COLOR_WITH_DEFAULT(cGroupName, cKeyName, pColorBuffer, NULL)
234
 
/** Get the value of a 'color' in the RGB format from the conf file.
235
 
*@param cGroupName name of the group in the conf file.
236
 
*@param cKeyName name of the key in the conf file.
237
 
*@param pColorBuffer a table of 3 'double' already allocated, that will be filled with the color components.
238
 
*@param pDefaultColor default value if the group/key is not found (typically if the key is new). It is a table of 3 'double'. It can be NULL.
239
 
*/
240
 
#define CD_CONFIG_GET_COLOR_RVB_WITH_DEFAULT(cGroupName, cKeyName, pColorBuffer, pDefaultColor) cairo_dock_get_double_list_key_value (pKeyFile, cGroupName, cKeyName, &bFlushConfFileNeeded, pColorBuffer, 3, pDefaultColor, NULL, NULL)
241
 
/** Get the value of a 'color' in the RGB format from the conf file, with NULL as default value.
242
 
*@param cGroupName name of the group in the conf file.
243
 
*@param cKeyName name of the key in the conf file.
244
 
*@param pColorBuffer a table of 3 'double' already allocated, that will be filled with the color components.
245
 
*/
246
 
#define CD_CONFIG_GET_COLOR_RVB(cGroupName, cKeyName, pColorBuffer) CD_CONFIG_GET_COLOR_RVB_WITH_DEFAULT(cGroupName, cKeyName, pColorBuffer, NULL)
247
 
 
248
 
/** Get the complete path of a theme in the conf file.
249
 
*@param cGroupName name of the group (in the conf file).
250
 
*@param cKeyName name of the key (in the conf file).
251
 
*@param cThemeDirName name of the folder containing the local, user, and distant themes.
252
 
*@param cDefaultThemeName default value, if the key/group/theme doesn't exist.
253
 
*@return Path to the folder of the theme, in a newly allocated string.
254
 
*/
255
 
#define CD_CONFIG_GET_THEME_PATH(cGroupName, cKeyName, cThemeDirName, cDefaultThemeName) \
256
 
        __extension__ ({\
257
 
        gchar *_cThemePath = cairo_dock_get_theme_path_for_module (CD_APPLET_MY_CONF_FILE, pKeyFile, cGroupName, cKeyName, &bFlushConfFileNeeded, cDefaultThemeName, MY_APPLET_SHARE_DATA_DIR"/"cThemeDirName, MY_APPLET_USER_DATA_DIR);\
258
 
        if (_cThemePath == NULL) {\
259
 
                const gchar *_cMessage = _("the theme couldn't be found; the default theme will be used instead.\n You can change this by opening the configuration of this module; do you want to do it now ?");\
260
 
                Icon *_pIcon = cairo_dock_get_dialogless_icon ();\
261
 
                gchar *_cQuestion = g_strdup_printf ("%s : %s", myApplet->pModule->pVisitCard->cModuleName, _cMessage);\
262
 
                cairo_dock_show_dialog_with_question (_cQuestion, _pIcon, CAIRO_CONTAINER (g_pMainDock), MY_APPLET_SHARE_DATA_DIR"/"MY_APPLET_ICON_FILE, (CairoDockActionOnAnswerFunc) cairo_dock_open_module_config_on_demand, myApplet, NULL);\
263
 
                g_free (_cQuestion); }\
264
 
        _cThemePath; })
265
 
 
266
 
/** Get the complete path of a Gauge theme in the conf file.
267
 
*@param cGroupName name of the group (in the conf file).
268
 
*@param cKeyName name of the key (in the conf file).
269
 
*/
270
 
#define CD_CONFIG_GET_GAUGE_THEME(cGroupName, cKeyName) \
271
 
        __extension__ ({\
272
 
        gchar *_cThemePath = cairo_dock_get_theme_path_for_gauge(CD_APPLET_MY_CONF_FILE, pKeyFile, cGroupName, cKeyName, &bFlushConfFileNeeded, "turbo-night-fuel");\
273
 
        if (_cThemePath == NULL) {\
274
 
                const gchar *_cMessage = _("the gauge theme couldn't be found; a default gauge will be used instead.\n You can change this by opening the configuration of this module; do you want to do it now ?");\
275
 
                Icon *_pIcon = cairo_dock_get_dialogless_icon ();\
276
 
                gchar *_cQuestion = g_strdup_printf ("%s : %s", myApplet->pModule->pVisitCard->cModuleName, _cMessage);\
277
 
                cairo_dock_show_dialog_with_question (_cQuestion, _pIcon, CAIRO_CONTAINER (g_pMainDock), MY_APPLET_SHARE_DATA_DIR"/"MY_APPLET_ICON_FILE, (CairoDockActionOnAnswerFunc) cairo_dock_open_module_config_on_demand, myApplet, NULL);\
278
 
                g_free (_cQuestion); }\
279
 
        _cThemePath; })
280
 
 
281
 
/** Rename a group in the conf file, in case you had to change it. Do nothing if the old group no more exists in the conf file.
282
 
*@param cGroupName name of the group.
283
 
*@param cNewGroupName new name of the group.
284
 
*/
285
 
#define CD_CONFIG_RENAME_GROUP(cGroupName, cNewGroupName) do {\
286
 
        if (cairo_dock_rename_group_in_conf_file (pKeyFile, cGroupName, cNewGroupName))\
287
 
                bFlushConfFileNeeded = TRUE; } while (0)
288
 
 
289
 
  //////////
290
 
 // MENU //
291
 
//////////
292
 
/** Create and add a sub-menu to a given menu.
293
 
*@param cLabel name of the sub-menu.
294
 
*@param pMenu GtkWidget of the menu we will add the sub-menu to..
295
 
*@param cImage name of an image (can be a path or a GtkStock).
296
 
*@return the sub-menu, newly created and attached to the menu.
297
 
*/
298
 
#define CD_APPLET_ADD_SUB_MENU_WITH_IMAGE(cLabel, pMenu, cImage) \
299
 
        cairo_dock_create_sub_menu (cLabel, pMenu, cImage)
300
 
 
301
 
/** Create and add a sub-menu to a given menu.
302
 
*@param cLabel name of the sub-menu.
303
 
*@param pMenu GtkWidget of the menu we will add the sub-menu to..
304
 
*@return the sub-menu, newly created and attached to the menu.
305
 
*/
306
 
#define CD_APPLET_ADD_SUB_MENU(cLabel, pMenu) CD_APPLET_ADD_SUB_MENU_WITH_IMAGE(cLabel, pMenu, NULL)
307
 
#define CD_APPLET_CREATE_AND_ADD_SUB_MENU CD_APPLET_ADD_SUB_MENU
308
 
 
309
 
/** Create and add the default sub-menu of an applet to the main menu. This sub-menu is named according to the name of the applet, and is represented by the default icon of the applet.
310
 
*@return the sub-menu, newly created and attached to the main menu.
311
 
*/
312
 
#define CD_APPLET_CREATE_MY_SUB_MENU(...) CD_APPLET_ADD_SUB_MENU_WITH_IMAGE (D_ (myApplet->pModule->pVisitCard->cTitle), CD_APPLET_MY_MENU, MY_APPLET_SHARE_DATA_DIR"/"MY_APPLET_ICON_FILE)
313
 
 
314
 
/** Create and add an entry to a menu, with an icon.
315
 
*@param cLabel name of the entry.
316
 
*@param gtkStock name of a GTK icon or path to an image.
317
 
*@param pCallBack function called when the user selects this entry.
318
 
*@param pMenu menu to add the entry to.
319
 
*@param pData data passed as parameter of the callback.
320
 
*/
321
 
#define CD_APPLET_ADD_IN_MENU_WITH_STOCK_AND_DATA(cLabel, gtkStock, pCallBack, pMenu, pData) cairo_dock_add_in_menu_with_stock_and_data (cLabel, gtkStock, (GFunc)pCallBack, pMenu, pData)
322
 
 
323
 
/** Create and add an entry to a menu.
324
 
*@param cLabel name of the entry.
325
 
*@param pCallBack function called when the user selects this entry.
326
 
*@param pMenu menu to add the entry to.
327
 
*@param pData data passed as parameter of the callback.
328
 
*/
329
 
#define CD_APPLET_ADD_IN_MENU_WITH_DATA(cLabel, pCallBack, pMenu, pData) CD_APPLET_ADD_IN_MENU_WITH_STOCK_AND_DATA (cLabel, NULL, pCallBack, pMenu, pData)
330
 
 
331
 
/** Create and add an entry to a menu. 'myApplet' will be passed to the callback.
332
 
*@param cLabel name of the entry.
333
 
*@param pCallBack function called when the user selects this entry.
334
 
*@param pMenu menu to add the entry to.
335
 
*/
336
 
#define CD_APPLET_ADD_IN_MENU(cLabel, pCallBack, pMenu) CD_APPLET_ADD_IN_MENU_WITH_DATA(cLabel, pCallBack, pMenu, myApplet)
337
 
 
338
 
/** Create and add an entry to a menu, with an icon. 'myApplet' will be passed to the callback.
339
 
*@param cLabel name of the entry.
340
 
*@param gtkStock name of a GTK icon or path to an image.
341
 
*@param pCallBack function called when the user selects this entry.
342
 
*@param pMenu menu to add the entry to.
343
 
*/
344
 
#define CD_APPLET_ADD_IN_MENU_WITH_STOCK(cLabel, gtkStock, pCallBack, pMenu) CD_APPLET_ADD_IN_MENU_WITH_STOCK_AND_DATA(cLabel, gtkStock, pCallBack, pMenu, myApplet)
345
 
 
346
 
/** Create and add a separator to a menu.
347
 
 */
348
 
#define CD_APPLET_ADD_SEPARATOR_IN_MENU(pMenu) do { \
349
 
        pMenuItem = gtk_separator_menu_item_new (); \
350
 
        gtk_menu_shell_append(GTK_MENU_SHELL (pMenu), pMenuItem); } while (0)
351
 
#define CD_APPLET_ADD_SEPARATOR CD_APPLET_ADD_SEPARATOR_IN_MENU
352
 
 
353
 
/** Create and add an entry to a menu for the 'about' function.
354
 
*@param pMenu menu to add the entry to.
355
 
*/
356
 
#define CD_APPLET_ADD_ABOUT_IN_MENU(pMenu) CD_APPLET_ADD_IN_MENU_WITH_STOCK (_("Applet's handbook"), GTK_STOCK_ABOUT, cairo_dock_pop_up_about_applet, pMenu)
357
 
 
358
 
/** Reload the config panel of the applet. This is useful if you have custom widgets inside your conf file, and need to reload them.
359
 
*/
360
 
#define CD_APPLET_RELOAD_CONFIG_PANEL cairo_dock_reload_current_module_widget (myApplet)
361
 
/** Reload the config panel of the applet and jump to the given page. This is useful if you have custom widgets inside your conf file, and need to reload them.
362
 
*/
363
 
#define CD_APPLET_RELOAD_CONFIG_PANEL_WITH_PAGE(iNumPage) cairo_dock_reload_current_module_widget_full (myApplet, iNumPage)
364
 
 
365
 
 
366
 
  /////////////////////////
367
 
 // AVAILABLE VARIABLES //
368
 
/////////////////////////
369
 
 
370
 
//\______________________ init, config, reload.
371
 
/** Path of the applet's instance's conf file.
372
 
*/
373
 
#define CD_APPLET_MY_CONF_FILE myApplet->cConfFilePath
374
 
/** Key file of the applet instance, availale during the init, config, and reload.
375
 
*/
376
 
#define CD_APPLET_MY_KEY_FILE pKeyFile
377
 
 
378
 
//\______________________ reload.
379
 
/** TRUE if the conf file has changed before the reload.
380
 
*/
381
 
#define CD_APPLET_MY_CONFIG_CHANGED (pKeyFile != NULL)
382
 
 
383
 
/** TRUE if the container type has changed.
384
 
*/
385
 
#define CD_APPLET_MY_CONTAINER_TYPE_CHANGED (myApplet->pContainer == NULL || myApplet->pContainer->iType != pOldContainer->iType)
386
 
 
387
 
/** The previous Container.
388
 
*/
389
 
#define CD_APPLET_MY_OLD_CONTAINER pOldContainer
390
 
 
391
 
 
392
 
//\______________________ clic droit, clic milieu, clic gauche.
393
 
/** The clicked Icon.
394
 
*/
395
 
#define CD_APPLET_CLICKED_ICON pClickedIcon
396
 
/** The clicked Container.
397
 
*/
398
 
#define CD_APPLET_CLICKED_CONTAINER pClickedContainer
399
 
 
400
 
//\______________________ clic droit
401
 
/**  TRUE if the 'SHIFT' key was pressed during the click.
402
 
*/
403
 
#define CD_APPLET_SHIFT_CLICK (iButtonState & GDK_SHIFT_MASK)
404
 
/**  TRUE if the 'CTRL' key was pressed during the click.
405
 
*/
406
 
#define CD_APPLET_CTRL_CLICK (iButtonState & GDK_CONTROL_MASK)
407
 
/**  TRUE if the 'ALT' key was pressed during the click.
408
 
*/
409
 
#define CD_APPLET_ALT_CLICK (iButtonState & GDK_MOD1_MASK)
410
 
 
411
 
//\______________________ construction du menu.
412
 
/** Main menu of the applet.
413
 
*/
414
 
#define CD_APPLET_MY_MENU pAppletMenu
415
 
 
416
 
//\______________________ drop.
417
 
/** Data received after a drop occured (string).
418
 
*/
419
 
#define CD_APPLET_RECEIVED_DATA cReceivedData
420
 
 
421
 
//\______________________ scroll
422
 
#define CD_APPLET_SCROLL_DIRECTION iDirection
423
 
/** TRUE if the user scrolled up.
424
 
*/
425
 
#define CD_APPLET_SCROLL_UP (CD_APPLET_SCROLL_DIRECTION == GDK_SCROLL_UP)
426
 
/** TRUE if the user scrolled down.
427
 
*/
428
 
#define CD_APPLET_SCROLL_DOWN (CD_APPLET_SCROLL_DIRECTION == GDK_SCROLL_DOWN)
429
 
 
430
 
 
431
 
  /////////////////////
432
 
 // DRAWING SURFACE //
433
 
/////////////////////
434
 
 
435
 
/** Redraw the applet's icon (as soon as the main loop is available).
436
 
*/
437
 
#define CD_APPLET_REDRAW_MY_ICON \
438
 
        cairo_dock_redraw_icon (myIcon, myContainer)
439
 
/** Redraw the applet's container (as soon as the main loop is available).
440
 
*/
441
 
#define CAIRO_DOCK_REDRAW_MY_CONTAINER \
442
 
        cairo_dock_redraw_container (myContainer)
443
 
/** Reload the reflect of the applet's icon (do nothing in OpenGL mode).
444
 
*/
445
 
#define CD_APPLET_UPDATE_REFLECT_ON_MY_ICON \
446
 
        if (myContainer->bUseReflect) cairo_dock_add_reflection_to_icon (myDrawContext, myIcon, myContainer)
447
 
 
448
 
/** Load an image into a surface, at the same size as the applet's icon. If the image is given by its sole name, it is searched inside the current theme root folder. 
449
 
*@param cImagePath path or name of an image.
450
 
*@return the newly allocated surface.
451
 
*/
452
 
#define CD_APPLET_LOAD_SURFACE_FOR_MY_APPLET(cImagePath) \
453
 
        cairo_dock_create_surface_from_image_simple (cImagePath, myDrawContext, myIcon->fWidth * (myDock ? (1 + g_fAmplitude) / myDock->container.fRatio : 1), myIcon->fHeight* (myDock ? (1 + g_fAmplitude) / myDock->container.fRatio : 1))
454
 
 
455
 
/** Load a user image into a surface, at the same size as the applet's icon, or a default image taken in the installed folder of the applet if the first one is NULL. If the user image is given by its sole name, it is searched inside the current theme root folder.
456
 
*@param cUserImageName name or path of an user image.
457
 
*@param cDefaultLocalImageName default image
458
 
*@return the newly allocated surface.
459
 
*/
460
 
#define CD_APPLET_LOAD_SURFACE_FOR_MY_APPLET_WITH_DEFAULT(cUserImageName, cDefaultLocalImageName) \
461
 
        __extension__ ({\
462
 
        cairo_surface_t *pSurface; \
463
 
        if (cUserImageName != NULL) \
464
 
                pSurface = CD_APPLET_LOAD_SURFACE_FOR_MY_APPLET (cUserImageName); \
465
 
        else if (cDefaultLocalImageName != NULL)\
466
 
                pSurface = CD_APPLET_LOAD_SURFACE_FOR_MY_APPLET (MY_APPLET_SHARE_DATA_DIR"/"cDefaultLocalImageName); \
467
 
        else\
468
 
                pSurface = NULL;\
469
 
        pSurface; })
470
 
 
471
 
/** Apply a surface on the applet's icon, and redraw it.
472
 
*@param pSurface the surface to draw on your icon.
473
 
*/
474
 
#define CD_APPLET_SET_SURFACE_ON_MY_ICON(pSurface) do { \
475
 
        cairo_dock_set_icon_surface_with_reflect (myDrawContext, pSurface, myIcon, myContainer); \
476
 
        cairo_dock_redraw_icon (myIcon, myContainer); } while (0)
477
 
 
478
 
/** Apply a surface on the applet's icon, with a zoom factor and centered, and redraw it.
479
 
*@param pSurface the surface to draw on your icon.
480
 
*@param fScale zoom factor (at 1 the surface will fill all the icon).
481
 
*/
482
 
#define CD_APPLET_SET_SURFACE_ON_MY_ICON_WITH_ZOOM(pSurface, fScale) do { \
483
 
        cairo_dock_set_icon_surface_full (myDrawContext, pSurface, fScale, 1., myIcon, myContainer); \
484
 
        cairo_dock_add_reflection_to_icon (myDrawContext, myIcon, myContainer); \
485
 
        cairo_dock_redraw_icon (myIcon, myContainer); } while (0)
486
 
 
487
 
/** Apply a surface on the applet's icon with a transparency factor, and redraw it.
488
 
*@param pSurface the surface to draw on your icon.
489
 
*@param fAlpha transparency (in [0,1]).
490
 
*/
491
 
#define CD_APPLET_SET_SURFACE_ON_MY_ICON_WITH_ALPHA(pSurface, fAlpha) do { \
492
 
        cairo_dock_set_icon_surface_full (myDrawContext, pSurface, 1., fAlpha, myIcon, myContainer); \
493
 
        cairo_dock_add_reflection_to_icon (myDrawContext, myIcon, myContainer); \
494
 
        cairo_dock_redraw_icon (myIcon, myContainer); } while (0)
495
 
 
496
 
/** Apply a surface on the applet's icon with add a bar at the bottom, and redraw it. The bar is drawn at the bottom of the icon with a gradation from red to green and a given length.
497
 
*@param pSurface the surface to draw on your icon.
498
 
*@param fValue the value representing a percentage, in [-1,1]. If negative, the gradation is inverted, and the absolute value is used.
499
 
*/
500
 
#define CD_APPLET_SET_SURFACE_ON_MY_ICON_WITH_BAR(pSurface, fValue) do { \
501
 
        cairo_dock_set_icon_surface_with_bar (myDrawContext, pSurface, fValue, myIcon, myContainer); \
502
 
        cairo_dock_add_reflection_to_icon (myDrawContext, myIcon, myContainer); \
503
 
        cairo_dock_redraw_icon (myIcon, myContainer); } while (0)
504
 
 
505
 
/** Apply an image on the applet's icon. The image is resized at the same size as the icon. Does not trigger the icon refresh.
506
 
*@param cImagePath path to an image.
507
 
*/
508
 
#define CD_APPLET_SET_IMAGE_ON_MY_ICON(cImagePath)  \
509
 
        cairo_dock_set_image_on_icon (myDrawContext, cImagePath, myIcon, myContainer)
510
 
 
511
 
/** Apply an image, taken inside the installation folder of the applet, on the applet's icon. The image is resized at the same size as the icon. Does not trigger the icon refresh.
512
 
*@param cImageName name of an image 
513
 
*/
514
 
#define CD_APPLET_SET_LOCAL_IMAGE_ON_MY_ICON(cImageName) do { \
515
 
        gchar *_cImageFilePath = g_strconcat (MY_APPLET_SHARE_DATA_DIR, "/", cImageName, NULL); \
516
 
        CD_APPLET_SET_IMAGE_ON_MY_ICON (_cImageFilePath); \
517
 
        g_free (_cImageFilePath); } while (0)
518
 
 
519
 
/** Apply an image on the applet's icon at the same size as the applet's icon, or a default image taken in the installed folder of the applet if the first one is NULL. If the user image is given by its sole name, it is searched inside the current theme root folder.
520
 
*@param cUserImageName nom du fichier of l'image cote utilisateur.
521
 
*@param cDefaultLocalImageName image locale par defaut cote installation.
522
 
*/
523
 
#define CD_APPLET_SET_USER_IMAGE_ON_MY_ICON(cUserImageName, cDefaultLocalImageName) do { \
524
 
        gchar *cImagePath; \
525
 
        if (cUserImageName != NULL) \
526
 
                cImagePath = cairo_dock_generate_file_path (cUserImageName); \
527
 
        else \
528
 
                cImagePath = g_strdup_printf ("%s/%s", MY_APPLET_SHARE_DATA_DIR, cDefaultLocalImageName); \
529
 
        CD_APPLET_SET_IMAGE_ON_MY_ICON (cImagePath); \
530
 
        g_free (cImagePath); } while (0)
531
 
 
532
 
/** Apply the default icon on the applet's icon if there is no image yet.
533
 
*/
534
 
#define CD_APPLET_SET_DEFAULT_IMAGE_ON_MY_ICON_IF_NONE do { \
535
 
        if (myIcon->cFileName == NULL) { \
536
 
                CD_APPLET_SET_IMAGE_ON_MY_ICON (MY_APPLET_SHARE_DATA_DIR"/"MY_APPLET_ICON_FILE); } } while (0)
537
 
 
538
 
 
539
 
  ///////////
540
 
 // LABEL //
541
 
///////////
542
 
/** Set a new label on the applet's icon.
543
 
*@param cIconName the label.
544
 
*/
545
 
#define CD_APPLET_SET_NAME_FOR_MY_ICON(cIconName) \
546
 
        cairo_dock_set_icon_name (myDrawContext, cIconName, myIcon, myContainer)
547
 
/** Set a new label on the applet's icon.
548
 
*@param cIconNameFormat the label, in a 'printf'-like format.
549
 
*@param ... values to be written in the string.
550
 
*/
551
 
#define CD_APPLET_SET_NAME_FOR_MY_ICON_PRINTF(cIconNameFormat, ...) \
552
 
        cairo_dock_set_icon_name_full (myDrawContext, myIcon, myContainer, cIconNameFormat, ##__VA_ARGS__)
553
 
 
554
 
 
555
 
  ///////////////
556
 
 // QUICK-INFO//
557
 
///////////////
558
 
/** Set a quick-info on the applet's icon.
559
 
*@param cQuickInfo the quick-info. This is a small text (a few characters) that is superimposed on the icon.
560
 
*/
561
 
#define CD_APPLET_SET_QUICK_INFO_ON_MY_ICON(cQuickInfo) \
562
 
        cairo_dock_set_quick_info (myDrawContext, myIcon, myContainer, cQuickInfo)
563
 
/** Set a quick-info on the applet's icon.
564
 
*@param cQuickInfoFormat the label, in a 'printf'-like format.
565
 
*@param ... values to be written in the string.
566
 
*/
567
 
#define CD_APPLET_SET_QUICK_INFO_ON_MY_ICON_PRINTF(cQuickInfoFormat, ...) \
568
 
        cairo_dock_set_quick_info_full (myDrawContext, myIcon, myContainer, cQuickInfoFormat, ##__VA_ARGS__)
569
 
 
570
 
/** Write the time in hours-minutes as a quick-info on the applet's icon.
571
 
*@param iTimeInSeconds the time in seconds.
572
 
*/
573
 
#define CD_APPLET_SET_HOURS_MINUTES_AS_QUICK_INFO(iTimeInSeconds) \
574
 
        cairo_dock_set_hours_minutes_as_quick_info (myDrawContext, myIcon, myContainer, iTimeInSeconds)
575
 
/** Write the time in minutes-secondes as a quick-info on the applet's icon.
576
 
*@param iTimeInSeconds the time in seconds.
577
 
*/
578
 
#define CD_APPLET_SET_MINUTES_SECONDES_AS_QUICK_INFO(iTimeInSeconds) \
579
 
        cairo_dock_set_minutes_secondes_as_quick_info (myDrawContext, myIcon, myContainer, iTimeInSeconds)
580
 
/** Write a size in bytes as a quick-info on the applet's icon.
581
 
*@param iSizeInBytes the size in bytes, converted into a readable format.
582
 
*/
583
 
#define CD_APPLET_SET_SIZE_AS_QUICK_INFO(iSizeInBytes) \
584
 
        cairo_dock_set_size_as_quick_info (myDrawContext, myIcon, myContainer, iSizeInBytes)
585
 
 
586
 
 
587
 
  ///////////////
588
 
 // ANIMATION //
589
 
///////////////
590
 
/** Prevent the applet's icon to be animated when the mouse hovers it (call it once at init).
591
 
*/
592
 
#define CD_APPLET_SET_STATIC_ICON cairo_dock_set_icon_static (myIcon)
593
 
 
594
 
/** Launch an animation on the applet's icon.
595
 
*@param cAnimationName name of the animation.
596
 
*@param iAnimationLength number of rounds the animation should be played.
597
 
*/
598
 
#define CD_APPLET_ANIMATE_MY_ICON(cAnimationName, iAnimationLength) \
599
 
        cairo_dock_request_icon_animation (myIcon, myDock, cAnimationName, iAnimationLength)
600
 
 
601
 
/** Stop any animation on the applet's icon.
602
 
*/
603
 
#define CD_APPLET_STOP_ANIMATING_MY_ICON \
604
 
        cairo_dock_stop_icon_animation (myIcon)
605
 
 
606
 
 
607
 
/** Get the dimension allocated to the surface/texture of the applet's icon.
608
 
*@param iWidthPtr pointer to the width.
609
 
*@param iHeightPtr pointer to the height.
610
 
*/
611
 
#define CD_APPLET_GET_MY_ICON_EXTENT(iWidthPtr, iHeightPtr) cairo_dock_get_icon_extent (myIcon, myContainer, iWidthPtr, iHeightPtr)
612
 
 
613
 
/** Initiate an OpenGL drawing session on the applet's icon.
614
 
*/
615
 
#define CD_APPLET_START_DRAWING_MY_ICON cairo_dock_begin_draw_icon (myIcon, myContainer)
616
 
 
617
 
/** Initiate an OpenGL drawing session on the applet's icon, or quit the function if failed.
618
 
*@param ... value to return in case of failure.
619
 
*/
620
 
#define CD_APPLET_START_DRAWING_MY_ICON_OR_RETURN(...) \
621
 
        if (! cairo_dock_begin_draw_icon (myIcon, myContainer)) \
622
 
                return __VA_ARGS__
623
 
 
624
 
/** Terminate an OpenGL drawing session on the applet's icon. Does not trigger the icon's redraw.
625
 
*/
626
 
#define CD_APPLET_FINISH_DRAWING_MY_ICON cairo_dock_end_draw_icon (myIcon, myContainer)
627
 
 
628
 
/** Make an emblem from an image. If the image is given by its sole name, it is looked up inside the root theme folder. Free it with cairo_dock_free_emblem.
629
 
*@param cImageFile name of an image file.
630
 
*@return a newly allocated CairoEmblem.
631
 
*/
632
 
#define CD_APPLET_MAKE_EMBLEM(cImageFile) cairo_dock_make_emblem (cImageFile, myIcon, myContainer, myDrawContext)
633
 
 
634
 
/** Draw an emblem on the applet's icon. The emblem is drawn directly on the icon, and is erased if the icon is redrawn.
635
 
*@param pEmblem an emblem.
636
 
*/
637
 
#define CD_APPLET_DRAW_EMBLEM_ON_MY_ICON(pEmblem) cairo_dock_draw_emblem_on_icon (pEmblem, myIcon, myContainer)
638
 
 
639
 
 
640
 
/** Add a Data Renderer the applet's icon.
641
 
*@param pAttr the attributes of the Data Renderer. They allow you to define its properties.
642
 
*/
643
 
#define CD_APPLET_ADD_DATA_RENDERER_ON_MY_ICON(pAttr) cairo_dock_add_new_data_renderer_on_icon (myIcon, myContainer, myDrawContext, pAttr)
644
 
 
645
 
/** Reload the Data Renderer of the applet's icon. Pass NULL as the attributes to simply reload the current data renderer without changing any of its parameters. Previous values are kept.
646
 
*@param pAttr the attributes of the Data Renderer, or NULL to simply reload the Data Renderer as it it.
647
 
*/
648
 
#define CD_APPLET_RELOAD_MY_DATA_RENDERER(pAttr) cairo_dock_reload_data_renderer_on_icon (myIcon, myContainer, myDrawContext, pAttr)
649
 
 
650
 
/** Add new values to the Data Renderer of the applet's icon. Values are a table of 'double', having the same size as defined when the data renderer was created (1 by default). It also triggers the redraw of the icon.
651
 
*@param pValues the values, a table of double of the correct size.
652
 
*/
653
 
#define CD_APPLET_RENDER_NEW_DATA_ON_MY_ICON(pValues) cairo_dock_render_new_data_on_icon (myIcon, myContainer, myDrawContext, pValues)
654
 
 
655
 
/** Completely remove the Data Renderer of the applet's icon, including the values associated with.
656
 
*/
657
 
#define CD_APPLET_REMOVE_MY_DATA_RENDERER cairo_dock_remove_data_renderer_on_icon (myIcon)
658
 
 
659
 
/** Refresh the Data Renderer of the applet's icon, to redraw it when the applet's size has changed.
660
 
*/
661
 
#define CD_APPLET_REFRESH_MY_DATA_RENDERER cairo_dock_refresh_data_renderer (myIcon, myContainer, myDrawContext)
662
 
 
663
 
 
664
 
/** Set the history size of the Data Renderer of the applet's icon to the maximum size, that is to say 1 value per pixel.
665
 
*/
666
 
#define CD_APPLET_SET_MY_DATA_RENDERER_HISTORY_TO_MAX cairo_dock_resize_data_renderer_history (myIcon, myIcon->fWidth)
667
 
 
668
 
 
669
 
#define CD_APPLET_GET_MY_ICON_DATA(pIcon) cairo_dock_get_icon_data (pIcon, myApplet)
670
 
#define CD_APPLET_GET_MY_CONTAINER_DATA(pContainer) cairo_dock_get_container_data (pContainer, myApplet)
671
 
#define CD_APPLET_GET_MY_DOCK_DATA(pDock) CD_APPLET_GET_MY_CONTAINER_DATA (CAIRO_CONTAINER (pDock))
672
 
#define CD_APPLET_GET_MY_DESKLET_DATA(pDesklet) CD_APPLET_GET_MY_CONTAINER_DATA (CAIRO_CONTAINER (pDesklet))
673
 
 
674
 
#define CD_APPLET_SET_MY_ICON_DATA(pIcon, pData) cairo_dock_set_icon_data (pIcon, myApplet, pData)
675
 
#define CD_APPLET_SET_MY_CONTAINER_DATA(pContainer, pData) cairo_dock_set_container_data (pContainer, myApplet, pData)
676
 
#define CD_APPLET_SET_MY_DOCK_DATA(pDock, pData) CD_APPLET_SET_MY_CONTAINER_DATA (CAIRO_CONTAINER (pDock), pData)
677
 
#define CD_APPLET_SET_MY_DESKLET_DATA(pDesklet, pData) CD_APPLET_SET_MY_CONTAINER_DATA (CAIRO_CONTAINER (pDesklet), pData)
678
 
 
679
 
#define CD_APPLET_LOAD_LOCAL_TEXTURE(cImageName) cairo_dock_create_texture_from_image (MY_APPLET_SHARE_DATA_DIR"/"cImageName)
680
 
 
681
 
#define CD_APPLET_LOAD_TEXTURE_WITH_DEFAULT(cUserImageName, cDefaultLocalImageName) \
682
 
        __extension__ ({\
683
 
        GLuint iTexture; \
684
 
        if (cUserImageName != NULL) \
685
 
                iTexture = cairo_dock_create_texture_from_image (cUserImageName); \
686
 
        else if (cDefaultLocalImageName != NULL)\
687
 
                iTexture = cairo_dock_create_texture_from_image (MY_APPLET_SHARE_DATA_DIR"/"cDefaultLocalImageName); \
688
 
        else\
689
 
                iTexture = 0;\
690
 
        iTexture; })
691
 
 
692
 
/** Say if the applet's container currently supports OpenGL.
693
 
*/
694
 
#define CD_APPLET_MY_CONTAINER_IS_OPENGL (g_bUseOpenGL && ((myDock && myDock->pRenderer->render_opengl) || (myDesklet && myDesklet->pRenderer && myDesklet->pRenderer->render_opengl)))
695
 
 
696
 
#define CD_APPLET_SET_TRANSITION_ON_MY_ICON(render_step_cairo, render_step_opengl, bFastPace, iDuration, bRemoveWhenFinished) \
697
 
        cairo_dock_set_transition_on_icon (myIcon, myContainer, myDrawContext,\
698
 
                (CairoDockTransitionRenderFunc) render_step_cairo,\
699
 
                (CairoDockTransitionGLRenderFunc) render_step_opengl,\
700
 
                bFastPace,\
701
 
                iDuration,\
702
 
                bRemoveWhenFinished,\
703
 
                myApplet,\
704
 
                NULL)
705
 
#define CD_APPLET_GET_TRANSITION_FRACTION(...) \
706
 
        (cairo_dock_has_transition (myIcon) ? cairo_dock_get_transition_fraction (myIcon) : 1.)
707
 
#define CD_APPLET_REMOVE_TRANSITION_ON_MY_ICON \
708
 
        cairo_dock_remove_transition_on_icon (myIcon)
709
 
 
710
 
 
711
 
//\_________________________________ DESKLETS et SOUS-DOCKS
712
 
 
713
 
/** Set a renderer to the applet's desklet and create myDrawContext. Call it at the beginning of init and also reload, to take into account the desklet's resizing.
714
 
*@param cRendererName name of the renderer.
715
 
*@param pConfig configuration data for the renderer, or NULL.
716
 
*/
717
 
#define CD_APPLET_SET_DESKLET_RENDERER_WITH_DATA(cRendererName, pConfig) do { \
718
 
        cairo_dock_set_desklet_renderer_by_name (myDesklet, cRendererName, NULL, CAIRO_DOCK_LOAD_ICONS_FOR_DESKLET, (CairoDeskletRendererConfigPtr) pConfig); \
719
 
        myDrawContext = cairo_create (myIcon->pIconBuffer); } while (0)
720
 
 
721
 
/** Set a renderer to the applet's desklet and create myDrawContext. Call it at the beginning of init and also reload, to take into account the desklet's resizing.
722
 
*@param cRendererName name of the renderer.
723
 
*/
724
 
#define CD_APPLET_SET_DESKLET_RENDERER(cRendererName) CD_APPLET_SET_DESKLET_RENDERER_WITH_DATA (cRendererName, NULL)
725
 
 
726
 
/** Prevent the desklet from being rotated. Use it if your desklet has some static GtkWidget inside.
727
 
*/
728
 
#define CD_APPLET_SET_STATIC_DESKLET cairo_dock_set_static_desklet (myDesklet)
729
 
 
730
 
#define CD_APPLET_CREATE_MY_SUBDOCK(pIconsList, cRenderer) do { \
731
 
        if (myIcon->cName == NULL) { \
732
 
                CD_APPLET_SET_NAME_FOR_MY_ICON (myApplet->pModule->pVisitCard->cModuleName); } \
733
 
        if (cairo_dock_check_unique_subdock_name (myIcon)) { \
734
 
                CD_APPLET_SET_NAME_FOR_MY_ICON (myIcon->cName); } \
735
 
        myIcon->pSubDock = cairo_dock_create_subdock_from_scratch (pIconsList, myIcon->cName, myDock); \
736
 
        cairo_dock_set_renderer (myIcon->pSubDock, cRenderer); \
737
 
        cairo_dock_update_dock_size (myIcon->pSubDock); } while (0)
738
 
 
739
 
#define CD_APPLET_DESTROY_MY_SUBDOCK do { \
740
 
        cairo_dock_destroy_dock (myIcon->pSubDock, myIcon->cName, NULL, NULL); \
741
 
        myIcon->pSubDock = NULL; } while (0)
742
 
 
743
 
#define CD_APPLET_LOAD_ICONS_IN_MY_SUBDOCK(pIconsList) do { \
744
 
        if (myIcon->cName == NULL) { \
745
 
                CD_APPLET_SET_NAME_FOR_MY_ICON (myIcon->pModuleInstance->pModule->pVisitCard->cModuleName); }\
746
 
        else { \
747
 
                Icon *icon;\
748
 
                GList *ic;\
749
 
                for (ic = pIconsList; ic != NULL; ic = ic->next) {\
750
 
                        icon = ic->data;\
751
 
                        if (icon->cParentDockName == NULL)\
752
 
                                icon->cParentDockName = g_strdup (myIcon->cName); } } \
753
 
        myIcon->pSubDock->icons = pIconsList; \
754
 
        myIcon->pSubDock->pFirstDrawnElement = pIconsList; \
755
 
        cairo_dock_load_buffers_in_one_dock (myIcon->pSubDock); \
756
 
        cairo_dock_update_dock_size (myIcon->pSubDock); } while (0)
757
 
 
758
 
/** Delete the list of icons of an applet (keep the subdock in dock mode).
759
 
*/
760
 
#define CD_APPLET_DELETE_MY_ICONS_LIST do {\
761
 
        if (myDesklet && myDesklet->icons != NULL) {\
762
 
                g_list_foreach (myDesklet->icons, (GFunc) cairo_dock_free_icon, NULL);\
763
 
                g_list_free (myDesklet->icons);\
764
 
                myDesklet->icons = NULL; }\
765
 
        if (myIcon->pSubDock != NULL) {\
766
 
                if (myDesklet) {\
767
 
                        CD_APPLET_DESTROY_MY_SUBDOCK; }\
768
 
                else {\
769
 
                        g_list_foreach (myIcon->pSubDock->icons, (GFunc) cairo_dock_free_icon, NULL);\
770
 
                        g_list_free (myIcon->pSubDock->icons);\
771
 
                        myIcon->pSubDock->icons = NULL;\
772
 
                        myIcon->pSubDock->pFirstDrawnElement = NULL; } } } while (0)
773
 
 
774
 
/** Load a list of icons into an applet, with the given renderer for the sub-dock or the desklet).
775
 
*@param pIconList a list of icons. It will belong to the applet's container after that.
776
 
*@param cDockRendererName name of a renderer in case the applet is in dock mode.
777
 
*@param cDeskletRendererName name of a renderer in case the applet is in desklet mode.
778
 
*@param pDeskletRendererConfig possible configuration parameters for the desklet renderer.
779
 
*/
780
 
#define CD_APPLET_LOAD_MY_ICONS_LIST(pIconList, cDockRendererName, cDeskletRendererName, pDeskletRendererConfig) do {\
781
 
        if (myDock) {\
782
 
                if (myIcon->pSubDock == NULL) {\
783
 
                        if (pIconList != NULL) {\
784
 
                                CD_APPLET_CREATE_MY_SUBDOCK (pIconList, cDockRendererName); } }\
785
 
                else {\
786
 
                        if (pIconList == NULL) {\
787
 
                                CD_APPLET_DESTROY_MY_SUBDOCK; }\
788
 
                        else {\
789
 
                                cairo_dock_set_renderer (myIcon->pSubDock, cDockRendererName); \
790
 
                                CD_APPLET_LOAD_ICONS_IN_MY_SUBDOCK (pIconList); } } }\
791
 
        else {\
792
 
                if (myIcon->pSubDock != NULL) {\
793
 
                        CD_APPLET_DESTROY_MY_SUBDOCK; }\
794
 
                myDesklet->icons = pIconList;\
795
 
                CD_APPLET_SET_DESKLET_RENDERER_WITH_DATA (cDeskletRendererName, pDeskletRendererConfig);\
796
 
                CAIRO_DOCK_REDRAW_MY_CONTAINER;\
797
 
        } } while (0)
798
 
 
799
 
/** Gets the list of icons of your applet. It is either the icons of your sub-dock or of your desklet.
800
 
*/
801
 
#define CD_APPLET_MY_ICONS_LIST (myDock ? (myIcon->pSubDock ? myIcon->pSubDock->icons : NULL) : myDesklet->icons)
802
 
/** Gets the container of the icons of your applet. It is either your sub-dock or your desklet.
803
 
*/
804
 
#define CD_APPLET_MY_ICONS_LIST_CONTAINER (myDock && myIcon->pSubDock ? CAIRO_CONTAINER (myIcon->pSubDock) : myContainer)
805
 
 
806
 
 
807
 
//\_________________________________ TASKBAR
808
 
/** Lets your applet control the window of an external program, instead of the Taskbar.
809
 
 *\param cApplicationClass the class of the application you wish to control (in lower case), or NULL to stop controling any appli.
810
 
*/
811
 
#define CD_APPLET_MANAGE_APPLICATION(cApplicationClass) do {\
812
 
        if (cairo_dock_strings_differ (myIcon->cClass, cApplicationClass)) {\
813
 
                if (myIcon->cClass != NULL)\
814
 
                        cairo_dock_deinhibate_class (myIcon->cClass, myIcon);\
815
 
                if (cApplicationClass != NULL)\
816
 
                        cairo_dock_inhibate_class (cApplicationClass, myIcon); } } while (0)
817
 
 
818
 
//\_________________________________ INTERNATIONNALISATION
819
 
/** Macro for gettext, similar to _() et N_(), but with the domain of the applet. Surround all your strings with this, so that 'xgettext' can find them and automatically include them in the translation files.
820
 
*/
821
 
#define D_(message) dgettext (MY_APPLET_GETTEXT_DOMAIN, message)
822
 
#define _D D_
823
 
 
824
 
//\_________________________________ DEBUG
825
 
#define CD_APPLET_ENTER g_pCurrentModule = myApplet
826
 
#define CD_APPLET_LEAVE(...) do {\
827
 
        g_pCurrentModule = NULL;\
828
 
        return __VA_ARGS__;} while (0)
829
 
#define CD_APPLET_LEAVE_IF_FAIL(condition, ...) do {\
830
 
        if (! (condition)) {\
831
 
                cd_warning ("condition "#condition" failed");\
832
 
                g_pCurrentModule = NULL;\
833
 
                return __VA_ARGS__;} } while (0)
834
 
 
835
 
#define CD_WARNING(s,...) cd_warning ("%s : "##s, myApplet->pModule->pVisitCard->cModuleName, ##__VA_ARGS__)
836
 
#define CD_MESSAGE(s,...) cd_message ("%s : "##s, myApplet->pModule->pVisitCard->cModuleName, ##__VA_ARGS__)
837
 
#define CD_DEBUG(s,...) cd_debug ("%s : "##s, myApplet->pModule->pVisitCard->cModuleName, ##__VA_ARGS__)
838
 
 
839
 
 
840
 
G_END_DECLS
841
 
#endif