~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-applet-facility.h

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