| 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 |
#include <string.h> |
| 21 |
#include <cairo-dock.h> |
| 22 |
|
| 23 |
#include "applet-struct.h" |
| 24 |
#include "applet-config.h" |
| 25 |
|
| 26 |
|
| 27 |
//\_________________ Here you have to get all your parameters from the conf file. Use the macros CD_CONFIG_GET_BOOLEAN, CD_CONFIG_GET_INTEGER, CD_CONFIG_GET_STRING, etc. myConfig has been reseted to 0 at this point. This function is called at the beginning of init and reload. |
| 28 |
CD_APPLET_GET_CONFIG_BEGIN |
| 29 |
myConfig.cShortkey = CD_CONFIG_GET_STRING ("Configuration", "shortkey"); |
| 30 |
myConfig.bShowKbdIndicator = CD_CONFIG_GET_BOOLEAN ("Configuration", "show indic"); |
| 31 |
myConfig.cEmblemNumLock = CD_CONFIG_GET_STRING ("Configuration", "emblem numlock"); |
| 32 |
myConfig.cEmblemCapsLock = CD_CONFIG_GET_STRING ("Configuration", "emblem capslock"); |
| 33 |
myConfig.iTransitionDuration = CD_CONFIG_GET_INTEGER ("Configuration", "transition"); |
| 34 |
myConfig.fTextRatio = CD_CONFIG_GET_DOUBLE_WITH_DEFAULT ("Configuration", "text ratio", 1.); |
| 35 |
|
| 36 |
gboolean bUseDefaultColors = (CD_CONFIG_GET_INTEGER_WITH_DEFAULT ("Configuration", "style", 1) == 0); |
| 37 |
gboolean bCustomFont = CD_CONFIG_GET_BOOLEAN_WITH_DEFAULT ("Configuration", "custom font", FALSE); // false by default |
| 38 |
if (! bUseDefaultColors && bCustomFont) // custom font |
| 39 |
{ |
| 40 |
gchar *cFont = CD_CONFIG_GET_STRING ("Configuration", "font"); |
| 41 |
gldi_text_description_set_font (&myConfig.textDescription, cFont); |
| 42 |
} |
| 43 |
else // use the default font |
| 44 |
{ |
| 45 |
gldi_text_description_copy (&myConfig.textDescription, &myStyleParam.textDescription); |
| 46 |
} |
| 47 |
myConfig.textDescription.bNoDecorations = TRUE; |
| 48 |
|
| 49 |
if (! bUseDefaultColors) // custom colors |
| 50 |
{ |
| 51 |
CD_CONFIG_GET_COLOR ("Configuration", "text color", &myConfig.textDescription.fColorStart); |
| 52 |
myConfig.textDescription.bOutlined = CD_CONFIG_GET_BOOLEAN ("Configuration", "outlined"); |
| 53 |
myConfig.textDescription.bUseDefaultColors = FALSE; |
| 54 |
} |
| 55 |
else // else, no outline and keep default colors |
| 56 |
myConfig.textDescription.bUseDefaultColors = TRUE; |
| 57 |
|
| 58 |
myConfig.cBackgroundImage = CD_CONFIG_GET_STRING ("Configuration", "bg image"); |
| 59 |
myConfig.iNLetters = CD_CONFIG_GET_INTEGER_WITH_DEFAULT ("Configuration", "nLetters", 3); |
| 60 |
CD_APPLET_GET_CONFIG_END |
| 61 |
|
| 62 |
|
| 63 |
//\_________________ Here you have to free all ressources allocated for myConfig. This one will be reseted to 0 at the end of this function. This function is called right before you get the applet's config, and when your applet is stopped, in the end. |
| 64 |
CD_APPLET_RESET_CONFIG_BEGIN |
| 65 |
g_free (myConfig.cBackgroundImage); |
| 66 |
g_free (myConfig.cEmblemCapsLock); |
| 67 |
g_free (myConfig.cEmblemNumLock); |
| 68 |
gldi_text_description_reset (&myConfig.textDescription); |
| 69 |
g_free (myConfig.cShortkey); |
| 70 |
CD_APPLET_RESET_CONFIG_END |
| 71 |
|
| 72 |
|
| 73 |
//\_________________ Here you have to free all ressources allocated for myData. This one will be reseted to 0 at the end of this function. This function is called when your applet is stopped, in the very end. |
| 74 |
CD_APPLET_RESET_DATA_BEGIN |
| 75 |
cairo_dock_unload_image_buffer (&myData.bgImage); |
| 76 |
cairo_dock_free_image_buffer (myData.pOldImage); |
| 77 |
cairo_dock_free_image_buffer (myData.pCurrentImage); |
| 78 |
/**if (myData.pOldSurface != NULL) |
| 79 |
cairo_surface_destroy (myData.pOldSurface); |
| 80 |
if (myData.iOldTexture != 0) |
| 81 |
_cairo_dock_delete_texture (myData.iOldTexture); |
| 82 |
if (myData.pCurrentSurface != NULL) |
| 83 |
cairo_surface_destroy (myData.pCurrentSurface); |
| 84 |
if (myData.iCurrentTexture != 0) |
| 85 |
_cairo_dock_delete_texture (myData.iCurrentTexture);*/ |
| 86 |
g_free (myData.cEmblemCapsLock); |
| 87 |
g_free (myData.cEmblemNumLock); |
| 88 |
g_free (myData.cShortGroupName); |
| 89 |
g_free (myData.cGroupName); |
| 90 |
CD_APPLET_RESET_DATA_END |