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