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

« back to all changes in this revision

Viewing changes to src/cairo-dock-gauge2.c

  • Committer: Bazaar Package Importer
  • Author(s): Julien Lavergne
  • Date: 2009-06-20 23:46:54 UTC
  • mfrom: (1.1.4 upstream)
  • Revision ID: james.westby@ubuntu.com-20090620234654-hlg7pqvys6temuqq
Tags: 2.0.5-0ubuntu1
* New Upstream Version. (LP: #390053)
* debian/rules: 
 - Drop autoreconf call, it's fixed upstream.
 - Call dh_desktop for all desktop files.
* debian/control:
 - Add libgtkglext1-dev as depends for cairo-dock-dev.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*********************************************************************************
 
2
 
 
3
This file is a part of the cairo-dock program,
 
4
released under the terms of the GNU General Public License.
 
5
 
 
6
Written by Necropotame (for any bug report, please mail me to fabounet@users.berlios.de)
 
7
 
 
8
*********************************************************************************/
 
9
#include <string.h>
 
10
#include <math.h>
 
11
#include <libxml/tree.h>
 
12
#include <libxml/parser.h>
 
13
 
 
14
//#include <cairo-dock-struct.h>
 
15
#include <cairo-dock-log.h>
 
16
#include <cairo-dock-applet-facility.h>
 
17
#include <cairo-dock-draw.h>
 
18
#include <cairo-dock-draw-opengl.h>
 
19
#include <cairo-dock-themes-manager.h>
 
20
#include <cairo-dock-surface-factory.h>
 
21
#include <cairo-dock-dock-factory.h>
 
22
#include <cairo-dock-keyfile-utilities.h>
 
23
#include <cairo-dock-config.h>
 
24
#include <cairo-dock-renderer-manager.h>
 
25
#include <cairo-dock-internal-icons.h>
 
26
#include <cairo-dock-gui-factory.h>
 
27
#include <cairo-dock-gauge2.h>
 
28
 
 
29
extern gchar *g_cCairoDockDataDir;
 
30
extern gboolean g_bUseOpenGL;
 
31
 
 
32
  ////////////////////////////////////////////
 
33
 /////////////// LOAD GAUGE /////////////////
 
34
////////////////////////////////////////////
 
35
void cairo_dock_xml_open_file2 (const gchar *filePath, const gchar *mainNodeName,xmlDocPtr *myXmlDoc,xmlNodePtr *myXmlNode)
 
36
{
 
37
        xmlDocPtr doc = xmlParseFile (filePath);
 
38
        if (doc == NULL)
 
39
        {
 
40
                cd_warning ("Impossible de lire le fichier XML.");
 
41
                *myXmlDoc = NULL;
 
42
                *myXmlNode = NULL;
 
43
                return ;
 
44
        }
 
45
        
 
46
        xmlNodePtr node = xmlDocGetRootElement (doc);
 
47
        if (node == NULL || xmlStrcmp (node->name, (const xmlChar *) mainNodeName) != 0)
 
48
        {
 
49
                cd_warning ("Le format du fichier XML n'est pas valide.");
 
50
                *myXmlDoc = NULL;
 
51
                *myXmlNode = NULL;
 
52
                return ;
 
53
        }
 
54
        
 
55
        *myXmlDoc = doc;
 
56
        *myXmlNode = node;
 
57
}
 
58
 
 
59
static void _cairo_dock_init_gauge_image (const gchar *cImagePath, GaugeImage2 *pGaugeImage2)
 
60
{
 
61
        // chargement du fichier.
 
62
        pGaugeImage2->pSvgHandle = rsvg_handle_new_from_file (cImagePath, NULL);
 
63
        
 
64
        //On récupère la taille de l'image.
 
65
        RsvgDimensionData SizeInfo;
 
66
        rsvg_handle_get_dimensions (pGaugeImage2->pSvgHandle, &SizeInfo);
 
67
        pGaugeImage2->sizeX = SizeInfo.width;
 
68
        pGaugeImage2->sizeY = SizeInfo.height;
 
69
}
 
70
static GaugeImage2 *_cairo_dock_new_gauge_image (const gchar *cImagePath)
 
71
{
 
72
        cd_debug ("%s (%s)", __func__, cImagePath);
 
73
        GaugeImage2 *pGaugeImage2 = g_new0 (GaugeImage2, 1);
 
74
        
 
75
        _cairo_dock_init_gauge_image (cImagePath, pGaugeImage2);
 
76
        
 
77
        return pGaugeImage2;
 
78
}
 
79
static void _cairo_dock_load_gauge_image (cairo_t *pSourceContext, GaugeImage2 *pGaugeImage2, int iWidth, int iHeight)
 
80
{
 
81
        cd_message ("%s (%dx%d)", __func__, iWidth, iHeight);
 
82
        if (pGaugeImage2->pSurface != NULL)
 
83
                cairo_surface_destroy (pGaugeImage2->pSurface);
 
84
        if (pGaugeImage2->iTexture != 0)
 
85
                glDeleteTextures (1, &pGaugeImage2->iTexture);
 
86
        
 
87
        if (pGaugeImage2->pSvgHandle != NULL)
 
88
        {
 
89
                pGaugeImage2->pSurface = _cairo_dock_create_blank_surface (pSourceContext,
 
90
                        iWidth,
 
91
                        iHeight);
 
92
                
 
93
                cairo_t* pDrawingContext = cairo_create (pGaugeImage2->pSurface);
 
94
                
 
95
                cairo_scale (pDrawingContext,
 
96
                        (double) iWidth / (double) pGaugeImage2->sizeX,
 
97
                        (double) iHeight / (double) pGaugeImage2->sizeY);
 
98
                
 
99
                rsvg_handle_render_cairo (pGaugeImage2->pSvgHandle, pDrawingContext);
 
100
                cairo_destroy (pDrawingContext);
 
101
                
 
102
                if (g_bUseOpenGL)
 
103
                {
 
104
                        pGaugeImage2->iTexture = cairo_dock_create_texture_from_surface (pGaugeImage2->pSurface);
 
105
                }
 
106
        }
 
107
        else
 
108
        {
 
109
                pGaugeImage2->pSurface = NULL;
 
110
                pGaugeImage2->iTexture = 0;
 
111
        }
 
112
}
 
113
static void _cairo_dock_load_gauge_needle (cairo_t *pSourceContext, GaugeIndicator2 *pGaugeIndicator2, int iWidth, int iHeight)
 
114
{
 
115
        cd_message ("%s (%dx%d)", __func__, iWidth, iHeight);
 
116
        GaugeImage2 *pGaugeImage2 = pGaugeIndicator2->pImageNeedle;
 
117
        g_return_if_fail (pGaugeImage2 != NULL);
 
118
        
 
119
        if (pGaugeImage2->pSurface != NULL)
 
120
                cairo_surface_destroy (pGaugeImage2->pSurface);
 
121
        if (pGaugeImage2->iTexture != 0)
 
122
                glDeleteTextures (1, &pGaugeImage2->iTexture);
 
123
        
 
124
        if (pGaugeImage2->pSvgHandle != NULL)
 
125
        {
 
126
                int iSize = MIN (iWidth, iHeight);
 
127
                g_print ("size:%d ; %d\n", iSize, pGaugeImage2->sizeX);
 
128
                pGaugeIndicator2->fNeedleScale = (double)iSize / (double) pGaugeImage2->sizeX;  // car l'aiguille est a l'horizontale dans le fichier svg.
 
129
                pGaugeIndicator2->iNeedleWidth = (double) pGaugeIndicator2->iNeedleRealWidth * pGaugeIndicator2->fNeedleScale;
 
130
                pGaugeIndicator2->iNeedleHeight = (double) pGaugeIndicator2->iNeedleRealHeight * pGaugeIndicator2->fNeedleScale;
 
131
                
 
132
                cairo_surface_t *pNeedleSurface = _cairo_dock_create_blank_surface (pSourceContext, pGaugeIndicator2->iNeedleWidth, pGaugeIndicator2->iNeedleHeight);
 
133
                g_return_if_fail (cairo_surface_status (pNeedleSurface) == CAIRO_STATUS_SUCCESS);
 
134
                
 
135
                cairo_t* pDrawingContext = cairo_create (pNeedleSurface);
 
136
                g_return_if_fail (cairo_status (pDrawingContext) == CAIRO_STATUS_SUCCESS);
 
137
                
 
138
                cairo_scale (pDrawingContext, pGaugeIndicator2->fNeedleScale, pGaugeIndicator2->fNeedleScale);
 
139
                cairo_translate (pDrawingContext, pGaugeIndicator2->iNeedleOffsetX, pGaugeIndicator2->iNeedleOffsetY);
 
140
                rsvg_handle_render_cairo (pGaugeImage2->pSvgHandle, pDrawingContext);
 
141
                cairo_destroy (pDrawingContext);
 
142
                
 
143
                pGaugeImage2->iTexture = cairo_dock_create_texture_from_surface (pNeedleSurface);
 
144
                cairo_surface_destroy (pNeedleSurface);
 
145
        }
 
146
        else
 
147
        {
 
148
                pGaugeImage2->pSurface = NULL;
 
149
                pGaugeImage2->iTexture = 0;
 
150
        }
 
151
}
 
152
static gboolean cairo_dock_load_gauge_theme (Gauge2 *pGauge, cairo_t *pSourceContext, const gchar *cThemePath)
 
153
{
 
154
        cd_debug ("%s (%s)", __func__, cThemePath);
 
155
        int iWidth = pGauge->dataRenderer.iWidth, iHeight = pGauge->dataRenderer.iHeight;
 
156
        if (iWidth == 0 || iHeight == 0)
 
157
                return FALSE;
 
158
        
 
159
        g_return_val_if_fail (cThemePath != NULL, FALSE);
 
160
        xmlInitParser ();
 
161
        xmlDocPtr pGaugeTheme;
 
162
        xmlNodePtr pGaugeMainNode;
 
163
        gchar *cXmlFile = g_strdup_printf("%s/theme.xml",cThemePath);
 
164
        cairo_dock_xml_open_file2 (cXmlFile, "gauge",&pGaugeTheme,&pGaugeMainNode);
 
165
        g_free (cXmlFile);
 
166
        g_return_val_if_fail (pGaugeTheme != NULL, FALSE);
 
167
        
 
168
        xmlAttrPtr ap;
 
169
        xmlChar *cAttribute, *cNodeContent, *cTextNodeContent;
 
170
        GString *sImagePath = g_string_new ("");
 
171
        GaugeImage2 *pGaugeImage2;
 
172
        GaugeIndicator2 *pGaugeIndicator2 = NULL;
 
173
        xmlNodePtr pGaugeNode;
 
174
        for (pGaugeNode = pGaugeMainNode->xmlChildrenNode; pGaugeNode != NULL; pGaugeNode = pGaugeNode->next)
 
175
        {
 
176
                if (xmlStrcmp (pGaugeNode->name, (const xmlChar *) "name") == 0)
 
177
                {
 
178
                        pGauge->cThemeName = xmlNodeGetContent(pGaugeNode);
 
179
                        cd_debug("gauge : Nom du theme(%s)",pGauge->pIndicatorList);
 
180
                }
 
181
                else if (xmlStrcmp (pGaugeNode->name, (const xmlChar *) "rank") == 0)
 
182
                {
 
183
                        cNodeContent = xmlNodeGetContent (pGaugeNode);
 
184
                        CAIRO_DATA_RENDERER (pGauge)->iRank = atoi (cNodeContent);
 
185
                        xmlFree (cNodeContent);
 
186
                }
 
187
                else if (xmlStrcmp (pGaugeNode->name, (const xmlChar *) "file") == 0)
 
188
                {
 
189
                        cNodeContent = xmlNodeGetContent (pGaugeNode);
 
190
                        g_string_printf (sImagePath, "%s/%s", cThemePath, cNodeContent);
 
191
                        ap = xmlHasProp (pGaugeNode, "key");
 
192
                        cAttribute = xmlNodeGetContent(ap->xmlChildrenNode);
 
193
                        if (xmlStrcmp (cAttribute, "background") == 0)
 
194
                        {
 
195
                                pGauge->pImageBackground = _cairo_dock_new_gauge_image (sImagePath->str);
 
196
                                _cairo_dock_load_gauge_image (pSourceContext, pGauge->pImageBackground, iWidth, iHeight);
 
197
                        }
 
198
                        else if (xmlStrcmp (cAttribute, "foreground") == 0)
 
199
                        {
 
200
                                pGauge->pImageForeground = _cairo_dock_new_gauge_image (sImagePath->str);
 
201
                                _cairo_dock_load_gauge_image (pSourceContext, pGauge->pImageForeground, iWidth, iHeight);
 
202
                        }
 
203
                        xmlFree (cNodeContent);
 
204
                        xmlFree (cAttribute);
 
205
                }
 
206
                else if (xmlStrcmp (pGaugeNode->name, (const xmlChar *) "indicator") == 0)
 
207
                {
 
208
                        if (CAIRO_DATA_RENDERER (pGauge)->iRank == 0)
 
209
                        {
 
210
                                CAIRO_DATA_RENDERER (pGauge)->iRank = 1;
 
211
                                xmlNodePtr node;
 
212
                                for (node = pGaugeNode->next; node != NULL; node = node->next)
 
213
                                {
 
214
                                        if (xmlStrcmp (node->name, (const xmlChar *) "indicator") == 0)
 
215
                                                CAIRO_DATA_RENDERER (pGauge)->iRank ++;
 
216
                                }
 
217
                        }
 
218
 
 
219
                        pGaugeIndicator2 = g_new0 (GaugeIndicator2, 1);
 
220
                        pGaugeIndicator2->direction = 1;
 
221
                        
 
222
                        cd_debug ("gauge : On charge un indicateur");
 
223
                        xmlNodePtr pGaugeSubNode;
 
224
                        for (pGaugeSubNode = pGaugeNode->xmlChildrenNode; pGaugeSubNode != NULL; pGaugeSubNode = pGaugeSubNode->next)
 
225
                        {
 
226
                                cNodeContent = xmlNodeGetContent (pGaugeSubNode);
 
227
                                if(xmlStrcmp (pGaugeSubNode->name, (const xmlChar *) "posX") == 0)
 
228
                                        pGaugeIndicator2->posX = atof (cNodeContent);
 
229
                                else if(xmlStrcmp (pGaugeSubNode->name, (const xmlChar *) "posY") == 0)
 
230
                                        pGaugeIndicator2->posY = atof (cNodeContent);
 
231
                                else if(xmlStrcmp (pGaugeSubNode->name, (const xmlChar *) "text") == 0)
 
232
                                {
 
233
                                        xmlNodePtr pTextSubNode;
 
234
                                        for (pTextSubNode = pGaugeSubNode->xmlChildrenNode; pTextSubNode != NULL; pTextSubNode = pTextSubNode->next)
 
235
                                        {
 
236
                                                cTextNodeContent = xmlNodeGetContent (pTextSubNode);
 
237
                                                if(xmlStrcmp (pGaugeSubNode->name, (const xmlChar *) "textX") == 0)
 
238
                                                        pGaugeIndicator2->textX = atof (cNodeContent);
 
239
                                                else if(xmlStrcmp (pGaugeSubNode->name, (const xmlChar *) "textY") == 0)
 
240
                                                        pGaugeIndicator2->textY = atof (cNodeContent);
 
241
                                                else if(xmlStrcmp (pGaugeSubNode->name, (const xmlChar *) "textWidth") == 0)
 
242
                                                        pGaugeIndicator2->textWidth = atof (cNodeContent);
 
243
                                                else if(xmlStrcmp (pGaugeSubNode->name, (const xmlChar *) "textHeight") == 0)
 
244
                                                        pGaugeIndicator2->textHeight = atof (cNodeContent);
 
245
                                                else if(xmlStrcmp (pGaugeSubNode->name, (const xmlChar *) "textColorR") == 0)
 
246
                                                        pGaugeIndicator2->textColor[0] = atof (cNodeContent);
 
247
                                                else if(xmlStrcmp (pGaugeSubNode->name, (const xmlChar *) "textColorG") == 0)
 
248
                                                        pGaugeIndicator2->textColor[1] = atof (cNodeContent);
 
249
                                                else if(xmlStrcmp (pGaugeSubNode->name, (const xmlChar *) "textColorB") == 0)
 
250
                                                        pGaugeIndicator2->textColor[2] = atof (cNodeContent);
 
251
                                        }
 
252
                                }
 
253
                                else if(xmlStrcmp (pGaugeSubNode->name, (const xmlChar *) "direction") == 0)
 
254
                                        pGaugeIndicator2->direction = atof (cNodeContent);
 
255
                                else if(xmlStrcmp (pGaugeSubNode->name, (const xmlChar *) "posStart") == 0)
 
256
                                        pGaugeIndicator2->posStart = atof (cNodeContent);
 
257
                                else if(xmlStrcmp (pGaugeSubNode->name, (const xmlChar *) "posStop") == 0)
 
258
                                        pGaugeIndicator2->posStop = atof (cNodeContent);
 
259
                                else if(xmlStrcmp (pGaugeSubNode->name, (const xmlChar *) "nb images") == 0)
 
260
                                        pGaugeIndicator2->iNbImages = atoi (cNodeContent);
 
261
                                else if(xmlStrcmp (pGaugeSubNode->name, (const xmlChar *) "offset x") == 0)
 
262
                                {
 
263
                                        pGaugeIndicator2->iNeedleOffsetX = atoi (cNodeContent);
 
264
                                }
 
265
                                else if(xmlStrcmp (pGaugeSubNode->name, (const xmlChar *) "width") == 0)
 
266
                                {
 
267
                                        pGaugeIndicator2->iNeedleRealWidth = atoi (cNodeContent);
 
268
                                }
 
269
                                else if(xmlStrcmp (pGaugeSubNode->name, (const xmlChar *) "height") == 0)
 
270
                                {
 
271
                                        pGaugeIndicator2->iNeedleRealHeight = atoi (cNodeContent);
 
272
                                        pGaugeIndicator2->iNeedleOffsetY = .5 * pGaugeIndicator2->iNeedleRealHeight;
 
273
                                }
 
274
                                else if(xmlStrcmp (pGaugeSubNode->name, (const xmlChar *) "file") == 0)
 
275
                                {
 
276
                                        cd_debug("gauge : On charge un fichier (%s)",cNodeContent);
 
277
                                        ap = xmlHasProp(pGaugeSubNode, "key");
 
278
                                        cAttribute = xmlNodeGetContent(ap->xmlChildrenNode);
 
279
                                        if (strcmp (cAttribute, "needle") == 0 && pGaugeIndicator2->pImageNeedle == NULL)
 
280
                                        {
 
281
                                                g_string_printf (sImagePath, "%s/%s", cThemePath, cNodeContent);
 
282
                                                pGaugeIndicator2->pImageNeedle = _cairo_dock_new_gauge_image (sImagePath->str);
 
283
                                        }
 
284
                                        else if (strcmp (cAttribute,"image") == 0)
 
285
                                        {
 
286
                                                if (pGaugeIndicator2->iNbImages == 0)
 
287
                                                {
 
288
                                                        pGaugeIndicator2->iNbImages = 1;
 
289
                                                        xmlNodePtr node;
 
290
                                                        for (node = pGaugeSubNode->next; node != NULL; node = node->next)
 
291
                                                        {
 
292
                                                                if (xmlStrcmp (node->name, (const xmlChar *) "file") == 0)
 
293
                                                                        pGaugeIndicator2->iNbImages ++;
 
294
                                                        }
 
295
                                                }
 
296
                                                if (pGaugeIndicator2->pImageList == NULL)
 
297
                                                        pGaugeIndicator2->pImageList = g_new0 (GaugeImage2, pGaugeIndicator2->iNbImages);
 
298
                                                
 
299
                                                if (pGaugeIndicator2->iNbImageLoaded < pGaugeIndicator2->iNbImages)
 
300
                                                {
 
301
                                                        g_string_printf (sImagePath, "%s/%s", cThemePath, cNodeContent);
 
302
                                                        _cairo_dock_init_gauge_image (sImagePath->str, &pGaugeIndicator2->pImageList[pGaugeIndicator2->iNbImageLoaded]);
 
303
                                                        pGaugeIndicator2->iNbImageLoaded ++;
 
304
                                                }
 
305
                                        }
 
306
                                        xmlFree (cAttribute);
 
307
                                }
 
308
                                xmlFree (cNodeContent);
 
309
                        }
 
310
                        if (pGaugeIndicator2->pImageNeedle != NULL)  // taille par defaut de l'aiguille si non fournie.
 
311
                        {
 
312
                                if (pGaugeIndicator2->iNeedleRealHeight == 0)
 
313
                                {
 
314
                                        pGaugeIndicator2->iNeedleRealHeight = .12*pGaugeIndicator2->pImageNeedle->sizeY;  // 12px utiles sur les 100
 
315
                                        pGaugeIndicator2->iNeedleOffsetY = pGaugeIndicator2->iNeedleRealHeight/2;
 
316
                                }
 
317
                                if (pGaugeIndicator2->iNeedleRealWidth == 0)
 
318
                                {
 
319
                                        pGaugeIndicator2->iNeedleRealWidth = pGaugeIndicator2->pImageNeedle->sizeY;  // 100px utiles sur les 100
 
320
                                        pGaugeIndicator2->iNeedleOffsetX = 10;
 
321
                                }
 
322
                        }
 
323
                        pGauge->pIndicatorList = g_list_append (pGauge->pIndicatorList, pGaugeIndicator2);
 
324
                }
 
325
        }
 
326
        xmlFreeDoc (pGaugeTheme);
 
327
        xmlCleanupParser ();
 
328
        g_string_free (sImagePath, TRUE);
 
329
        
 
330
        g_return_val_if_fail (CAIRO_DATA_RENDERER (pGauge)->iRank != 0 && pGaugeIndicator2 != NULL, FALSE);
 
331
        CAIRO_DATA_RENDERER (pGauge)->bCanRenderValueAsText = (pGaugeIndicator2->textWidth != 0 && pGaugeIndicator2->textHeight != 0);
 
332
        
 
333
        return TRUE;
 
334
}
 
335
void cairo_dock_load_gauge2 (Gauge2 *pGauge, cairo_t *pSourceContext, CairoContainer *pContainer, CairoGaugeAttribute *pAttribute)
 
336
{
 
337
        gboolean bLoadOK = cairo_dock_load_gauge_theme (pGauge, pSourceContext, pAttribute->cThemePath);
 
338
}
 
339
 
 
340
  ////////////////////////////////////////////
 
341
 /////////////// DRAW GAUGE /////////////////
 
342
////////////////////////////////////////////
 
343
static void _draw_gauge_needle (cairo_t *pSourceContext, Gauge2 *pGauge, GaugeIndicator2 *pGaugeIndicator2, double fValue)
 
344
{
 
345
        GaugeImage2 *pGaugeImage2 = pGaugeIndicator2->pImageNeedle;
 
346
        if(pGaugeImage2 != NULL)
 
347
        {
 
348
                double fAngle = (pGaugeIndicator2->posStart + fValue * (pGaugeIndicator2->posStop - pGaugeIndicator2->posStart)) * G_PI / 180.;
 
349
                if (pGaugeIndicator2->direction < 0)
 
350
                        fAngle = - fAngle;
 
351
                
 
352
                double fHalfX = pGauge->pImageBackground->sizeX / 2.0f * (1 + pGaugeIndicator2->posX);
 
353
                double fHalfY = pGauge->pImageBackground->sizeY / 2.0f * (1 - pGaugeIndicator2->posY);
 
354
                
 
355
                cairo_save (pSourceContext);
 
356
                
 
357
                cairo_scale (pSourceContext,
 
358
                        (double) CAIRO_DATA_RENDERER (pGauge)->iWidth / (double) pGaugeImage2->sizeX,
 
359
                        (double) CAIRO_DATA_RENDERER (pGauge)->iHeight / (double) pGaugeImage2->sizeY);
 
360
                cairo_translate (pSourceContext, fHalfX, fHalfY);
 
361
                cairo_rotate (pSourceContext, -G_PI/2 + fAngle);
 
362
                
 
363
                rsvg_handle_render_cairo (pGaugeImage2->pSvgHandle, pSourceContext);
 
364
                
 
365
                cairo_restore (pSourceContext);
 
366
        }
 
367
}
 
368
static void _draw_gauge_image (cairo_t *pSourceContext, Gauge2 *pGauge, GaugeIndicator2 *pGaugeIndicator2, double fValue)
 
369
{
 
370
        int iNumImage = fValue * (pGaugeIndicator2->iNbImages - 1) + 0.5;
 
371
        g_return_if_fail (iNumImage < pGaugeIndicator2->iNbImages);
 
372
        
 
373
        GaugeImage2 *pGaugeImage2 = &pGaugeIndicator2->pImageList[iNumImage];
 
374
        if (pGaugeImage2->pSurface == NULL)
 
375
        {
 
376
                int iWidth = pGauge->dataRenderer.iWidth, iHeight = pGauge->dataRenderer.iHeight;
 
377
                _cairo_dock_load_gauge_image (pSourceContext, pGaugeImage2, iWidth, iHeight);
 
378
        }
 
379
        
 
380
        if (pGaugeImage2->pSurface != NULL)
 
381
        {
 
382
                cairo_set_source_surface (pSourceContext, pGaugeImage2->pSurface, 0.0f, 0.0f);
 
383
                cairo_paint (pSourceContext);
 
384
        }
 
385
}
 
386
static void cairo_dock_draw_one_gauge (cairo_t *pSourceContext, Gauge2 *pGauge, int iDataOffset)
 
387
{
 
388
        GaugeImage2 *pGaugeImage2;
 
389
        //\________________ On affiche le fond.
 
390
        if(pGauge->pImageBackground != NULL)
 
391
        {
 
392
                pGaugeImage2 = pGauge->pImageBackground;
 
393
                cairo_set_source_surface (pSourceContext, pGaugeImage2->pSurface, 0.0f, 0.0f);
 
394
                cairo_paint (pSourceContext);
 
395
        }
 
396
        
 
397
        //\________________ On represente l'indicateur de chaque valeur.
 
398
        GList *pIndicatorElement;
 
399
        GList *pValueList;
 
400
        double fValue;
 
401
        GaugeIndicator2 *pIndicator;
 
402
        CairoDataRenderer *pRenderer = CAIRO_DATA_RENDERER (pGauge);
 
403
        CairoDataToRenderer *pData = cairo_data_renderer_get_data (pRenderer);
 
404
        int i;
 
405
        for (i = iDataOffset, pIndicatorElement = pGauge->pIndicatorList; i < pData->iNbValues && pIndicatorElement != NULL; i++, pIndicatorElement = pIndicatorElement->next)
 
406
        {
 
407
                pIndicator = pIndicatorElement->data;
 
408
                fValue = cairo_data_renderer_get_normalized_current_value (pRenderer, i);
 
409
                
 
410
                if (pIndicator->pImageNeedle != NULL)  // c'est une aiguille.
 
411
                {
 
412
                        _draw_gauge_needle (pSourceContext, pGauge, pIndicator, fValue);
 
413
                }
 
414
                else  // c'est une image.
 
415
                {
 
416
                        _draw_gauge_image (pSourceContext, pGauge, pIndicator, fValue);
 
417
                }
 
418
 
 
419
                if (pIndicator->textWidth != 0 && pIndicator->textHeight != 0)  // cet indicateur a un emplacement pour le texte de la valeur.
 
420
                {
 
421
                        cairo_data_renderer_format_value (pRenderer, fValue, i);
 
422
                        g_print (" >>>%s\n", pRenderer->cFormatBuffer);
 
423
                        cairo_save (pSourceContext);
 
424
                        cairo_set_source_rgb (pSourceContext, pIndicator->textColor[0], pIndicator->textColor[1], pIndicator->textColor[2]);
 
425
                        cairo_set_line_width (pSourceContext, 20.);
 
426
                        
 
427
                        cairo_text_extents_t textExtents;
 
428
                        cairo_text_extents (pSourceContext, pRenderer->cFormatBuffer, &textExtents);
 
429
                        cairo_move_to (pSourceContext,
 
430
                                pIndicator->textX * pRenderer->iWidth - textExtents.width / 2,
 
431
                                pIndicator->textY * pRenderer->iHeight + textExtents.height / 2);
 
432
                        cairo_show_text (pSourceContext, pRenderer->cFormatBuffer);
 
433
                        cairo_restore (pSourceContext);
 
434
                }
 
435
        }
 
436
        
 
437
        //\________________ On affiche l'avant-plan.
 
438
        if(pGauge->pImageForeground != NULL)
 
439
        {
 
440
                pGaugeImage2 = pGauge->pImageForeground;
 
441
                cairo_set_source_surface (pSourceContext, pGaugeImage2->pSurface, 0.0f, 0.0f);
 
442
                cairo_paint (pSourceContext);
 
443
        }
 
444
}
 
445
void cairo_dock_render_gauge2 (Gauge2 *pGauge, cairo_t *pCairoContext)
 
446
{
 
447
        g_return_if_fail (pGauge != NULL && pGauge->pIndicatorList != NULL && pCairoContext != NULL);
 
448
        g_return_if_fail (cairo_status (pCairoContext) == CAIRO_STATUS_SUCCESS);
 
449
        
 
450
        CairoDataRenderer *pRenderer = CAIRO_DATA_RENDERER (pGauge);
 
451
        CairoDataToRenderer *pData = cairo_data_renderer_get_data (pRenderer);
 
452
        int iNbDrawings = (int) ceil (1. * pData->iNbValues / pRenderer->iRank);
 
453
        int i, iDataOffset = 0;
 
454
        for (i = 0; i < iNbDrawings; i ++)
 
455
        {
 
456
                if (iNbDrawings > 1)  // on va dessiner la jauges plusieurs fois, la 1ere en grand et les autres en petit autour.
 
457
                {
 
458
                        cairo_save (pCairoContext);
 
459
                        if (i == 0)
 
460
                        {
 
461
                                cairo_scale (pCairoContext, 2./3, 2./3);
 
462
                        }
 
463
                        else if (i == 1)
 
464
                        {
 
465
                                cairo_translate (pCairoContext, 2 * pRenderer->iWidth / 3, 2 * pRenderer->iHeight / 3);
 
466
                                cairo_scale (pCairoContext, 1./3, 1./3);
 
467
                        }
 
468
                        else if (i == 2)
 
469
                        {
 
470
                                cairo_translate (pCairoContext, 2 * pRenderer->iWidth / 3, 0.);
 
471
                                cairo_scale (pCairoContext, 1./3, 1./3);
 
472
                        }
 
473
                        else if (i == 3)
 
474
                        {
 
475
                                cairo_translate (pCairoContext, 0., 2 * pRenderer->iHeight / 3);
 
476
                                cairo_scale (pCairoContext, 1./3, 1./3);
 
477
                        }
 
478
                        else  // 5 valeurs faut pas pousser non plus.
 
479
                                break ;
 
480
                }
 
481
                
 
482
                cairo_dock_draw_one_gauge (pCairoContext, pGauge, iDataOffset);
 
483
                
 
484
                if (iNbDrawings > 1)
 
485
                        cairo_restore (pCairoContext);
 
486
                
 
487
                iDataOffset += pRenderer->iRank;
 
488
        }
 
489
}
 
490
 
 
491
  ///////////////////////////////////////////////
 
492
 /////////////// RENDER OPENGL /////////////////
 
493
///////////////////////////////////////////////
 
494
static void _draw_gauge_image_opengl (Gauge2 *pGauge, GaugeIndicator2 *pGaugeIndicator2, double fValue)
 
495
{
 
496
        int iNumImage = fValue * (pGaugeIndicator2->iNbImages - 1) + 0.5;
 
497
        g_return_if_fail (iNumImage < pGaugeIndicator2->iNbImages);
 
498
        
 
499
        GaugeImage2 *pGaugeImage2 = &pGaugeIndicator2->pImageList[iNumImage];
 
500
        int iWidth = pGauge->dataRenderer.iWidth, iHeight = pGauge->dataRenderer.iHeight;
 
501
        if (pGaugeImage2->iTexture == 0)
 
502
        {
 
503
                _cairo_dock_load_gauge_image (NULL, pGaugeImage2, iWidth, iHeight);  // pas besoin d'un cairo_context pour creer une cairo_image_surface.
 
504
        }
 
505
        
 
506
        if (pGaugeImage2->iTexture != 0)
 
507
        {
 
508
                cairo_dock_apply_texture_at_size (pGaugeImage2->iTexture, iWidth, iHeight);
 
509
        }
 
510
}
 
511
static void _draw_gauge_needle_opengl (Gauge2 *pGauge, GaugeIndicator2 *pGaugeIndicator2, double fValue)
 
512
{
 
513
        GaugeImage2 *pGaugeImage2 = pGaugeIndicator2->pImageNeedle;
 
514
        g_return_if_fail (pGaugeImage2 != NULL);
 
515
        
 
516
        if (pGaugeImage2->iTexture == 0)
 
517
        {
 
518
                int iWidth = pGauge->dataRenderer.iWidth, iHeight = pGauge->dataRenderer.iHeight;
 
519
                _cairo_dock_load_gauge_needle (NULL, pGaugeIndicator2, iWidth, iHeight);  // pas besoin d'un cairo_context pour creer une cairo_image_surface.
 
520
        }
 
521
        
 
522
        if(pGaugeImage2->iTexture != 0)
 
523
        {
 
524
                double fAngle = (pGaugeIndicator2->posStart + fValue * (pGaugeIndicator2->posStop - pGaugeIndicator2->posStart));
 
525
                if (pGaugeIndicator2->direction < 0)
 
526
                        fAngle = - fAngle;
 
527
                double fHalfX = pGauge->pImageBackground->sizeX / 2.0f * (0 + pGaugeIndicator2->posX);
 
528
                double fHalfY = pGauge->pImageBackground->sizeY / 2.0f * (0 + pGaugeIndicator2->posY);
 
529
                
 
530
                glPushMatrix ();
 
531
                
 
532
                glTranslatef (fHalfX, fHalfY, 0.);
 
533
                glRotatef (90. - fAngle, 0., 0., 1.);
 
534
                glTranslatef (pGaugeIndicator2->iNeedleWidth/2 - pGaugeIndicator2->fNeedleScale * pGaugeIndicator2->iNeedleOffsetX, 0., 0.);
 
535
                glScalef (pGaugeIndicator2->iNeedleWidth, pGaugeIndicator2->iNeedleHeight, 1.);
 
536
                cairo_dock_apply_texture (pGaugeImage2->iTexture);
 
537
                
 
538
                glPopMatrix ();
 
539
        }
 
540
}
 
541
static void cairo_dock_draw_one_gauge_opengl (Gauge2 *pGauge, int iDataOffset)
 
542
{
 
543
        int iWidth = pGauge->dataRenderer.iWidth, iHeight = pGauge->dataRenderer.iHeight;
 
544
        GaugeImage2 *pGaugeImage2;
 
545
        
 
546
        glEnable (GL_BLEND);
 
547
        glBlendFunc (GL_ONE, GL_ONE_MINUS_SRC_ALPHA);  // ne me demandez pas pourquoi...
 
548
        
 
549
        glEnable (GL_TEXTURE_2D);
 
550
        glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
 
551
        
 
552
        glPolygonMode (GL_FRONT, GL_FILL);
 
553
        
 
554
        //\________________ On affiche le fond.
 
555
        if(pGauge->pImageBackground != NULL)
 
556
        {
 
557
                pGaugeImage2 = pGauge->pImageBackground;
 
558
                cairo_dock_apply_texture_at_size (pGaugeImage2->iTexture, iWidth, iHeight);
 
559
        }
 
560
        
 
561
        //\________________ On represente l'indicateur de chaque valeur.
 
562
        GList *pIndicatorElement;
 
563
        GList *pValueList;
 
564
        double fValue;
 
565
        GaugeIndicator2 *pIndicator;
 
566
        CairoDataRenderer *pRenderer = CAIRO_DATA_RENDERER (pGauge);
 
567
        CairoDataToRenderer *pData = cairo_data_renderer_get_data (pRenderer);
 
568
        int i;
 
569
        for (i = iDataOffset, pIndicatorElement = pGauge->pIndicatorList; i < pData->iNbValues && pIndicatorElement != NULL; i++, pIndicatorElement = pIndicatorElement->next)
 
570
        {
 
571
                pIndicator = pIndicatorElement->data;
 
572
                fValue = cairo_data_renderer_get_normalized_current_value_with_latency (pRenderer, i);
 
573
                
 
574
                if (pIndicator->pImageNeedle != NULL)  // c'est une aiguille.
 
575
                {
 
576
                        _draw_gauge_needle_opengl (pGauge, pIndicator, fValue);
 
577
                }
 
578
                else  // c'est une image.
 
579
                {
 
580
                        _draw_gauge_image_opengl (pGauge, pIndicator, fValue);
 
581
                }
 
582
 
 
583
                if (pIndicator->textWidth != 0 && pIndicator->textHeight != 0)  // cet indicateur a un emplacement pour le texte de la valeur.
 
584
                {
 
585
                        cairo_data_renderer_format_value (pRenderer, fValue, i);
 
586
                        g_print (" >>>%s\n", pRenderer->cFormatBuffer);
 
587
                        /*cairo_save (pSourceContext);
 
588
                        cairo_set_source_rgb (pSourceContext, pIndicator->textColor[0], pIndicator->textColor[1], pIndicator->textColor[2]);
 
589
                        cairo_set_line_width (pSourceContext, 20.);
 
590
                        
 
591
                        cairo_text_extents_t textExtents;
 
592
                        cairo_text_extents (pSourceContext, pRenderer->cFormatBuffer, &textExtents);
 
593
                        cairo_move_to (pSourceContext,
 
594
                                pIndicator->textX * pRenderer->iWidth - textExtents.width / 2,
 
595
                                pIndicator->textY * pRenderer->iHeight + textExtents.height / 2);
 
596
                        cairo_show_text (pSourceContext, pRenderer->cFormatBuffer);
 
597
                        cairo_restore (pSourceContext);*/
 
598
                }
 
599
        }
 
600
        
 
601
        //\________________ On affiche l'avant-plan.
 
602
        if(pGauge->pImageForeground != NULL)
 
603
        {
 
604
                pGaugeImage2 = pGauge->pImageForeground;
 
605
                cairo_dock_apply_texture_at_size (pGaugeImage2->iTexture, iWidth, iHeight);
 
606
        }
 
607
        
 
608
        glDisable (GL_TEXTURE_2D);
 
609
        glDisable (GL_BLEND);
 
610
}
 
611
void cairo_dock_render_gauge_opengl2 (Gauge2 *pGauge)
 
612
{
 
613
        g_return_if_fail (pGauge != NULL && pGauge->pIndicatorList != NULL);
 
614
        
 
615
        CairoDataRenderer *pRenderer = CAIRO_DATA_RENDERER (pGauge);
 
616
        CairoDataToRenderer *pData = cairo_data_renderer_get_data (pRenderer);
 
617
        int iNbDrawings = (int) ceil (1. * pData->iNbValues / pRenderer->iRank);
 
618
        int i, iDataOffset = 0;
 
619
        for (i = 0; i < iNbDrawings; i ++)
 
620
        {
 
621
                if (iNbDrawings > 1)  // on va dessiner la jauges plusieurs fois, la 1ere en grand et les autres en petit autour.
 
622
                {
 
623
                        glPushMatrix ();
 
624
                        if (i == 0)
 
625
                        {
 
626
                                glTranslatef (-pRenderer->iWidth / 6, pRenderer->iHeight / 6, 0.);
 
627
                                glScalef (2./3, 2./3, 1.);
 
628
                        }
 
629
                        else if (i == 1)
 
630
                        {
 
631
                                glTranslatef (pRenderer->iWidth / 3, - pRenderer->iHeight / 3, 0.);
 
632
                                glScalef (1./3, 1./3, 1.);
 
633
                        }
 
634
                        else if (i == 2)
 
635
                        {
 
636
                                glTranslatef (pRenderer->iWidth / 3, pRenderer->iHeight / 3, 0.);
 
637
                                glScalef (1./3, 1./3, 1.);
 
638
                        }
 
639
                        else if (i == 3)
 
640
                        {
 
641
                                glTranslatef (-pRenderer->iWidth / 3, -pRenderer->iHeight / 3, 0.);
 
642
                                glScalef (1./3, 1./3, 1.);
 
643
                        }
 
644
                        else  // 5 valeurs faut pas pousser non plus.
 
645
                                break ;
 
646
                }
 
647
                
 
648
                cairo_dock_draw_one_gauge_opengl (pGauge, iDataOffset);
 
649
                
 
650
                if (iNbDrawings > 1)
 
651
                        glPopMatrix ();
 
652
                
 
653
                iDataOffset += pRenderer->iRank;
 
654
        }
 
655
}
 
656
 
 
657
 
 
658
  //////////////////////////////////////////////
 
659
 /////////////// RELOAD GAUGE /////////////////
 
660
//////////////////////////////////////////////
 
661
void cairo_dock_reload_gauge2 (Gauge2 *pGauge, cairo_t *pSourceContext)
 
662
{
 
663
        //g_print ("%s (%dx%d)\n", __func__, iWidth, iHeight);
 
664
        g_return_if_fail (pGauge != NULL);
 
665
        
 
666
        CairoDataRenderer *pRenderer = CAIRO_DATA_RENDERER (pGauge);
 
667
        int iWidth = pGauge->dataRenderer.iWidth, iHeight = pGauge->dataRenderer.iHeight;
 
668
        if (pGauge->pImageBackground != NULL)
 
669
        {
 
670
                _cairo_dock_load_gauge_image (pSourceContext, pGauge->pImageBackground, iWidth, iHeight);
 
671
        }
 
672
        
 
673
        if (pGauge->pImageForeground != NULL)
 
674
        {
 
675
                _cairo_dock_load_gauge_image (pSourceContext, pGauge->pImageForeground, iWidth, iHeight);
 
676
        }
 
677
        
 
678
        GaugeIndicator2 *pGaugeIndicator2;
 
679
        GaugeImage2 *pGaugeImage2;
 
680
        int i;
 
681
        GList *pElement, *pElement2;
 
682
        for (pElement = pGauge->pIndicatorList; pElement != NULL; pElement = pElement->next)
 
683
        {
 
684
                pGaugeIndicator2 = pElement->data;
 
685
                for (i = 0; i < pGaugeIndicator2->iNbImages; i ++)
 
686
                {
 
687
                        pGaugeImage2 = &pGaugeIndicator2->pImageList[i];
 
688
                        _cairo_dock_load_gauge_image (pSourceContext, pGaugeImage2, iWidth, iHeight);
 
689
                }
 
690
                if (g_bUseOpenGL && pGaugeIndicator2->pImageNeedle)
 
691
                {
 
692
                        _cairo_dock_load_gauge_needle (pSourceContext, pGaugeIndicator2, iWidth, iHeight);
 
693
                }
 
694
        }
 
695
}
 
696
 
 
697
  ////////////////////////////////////////////
 
698
 /////////////// FREE GAUGE /////////////////
 
699
////////////////////////////////////////////
 
700
static void _cairo_dock_free_gauge_image(GaugeImage2 *pGaugeImage2, gboolean bFree)
 
701
{
 
702
        if (pGaugeImage2 == NULL)
 
703
                return ;
 
704
        cd_debug("");
 
705
 
 
706
        if(pGaugeImage2->pSvgHandle != NULL)
 
707
                rsvg_handle_free (pGaugeImage2->pSvgHandle);
 
708
        if(pGaugeImage2->pSurface != NULL)
 
709
                cairo_surface_destroy (pGaugeImage2->pSurface);
 
710
        if (pGaugeImage2->iTexture != 0)
 
711
                glDeleteTextures (1, &pGaugeImage2->iTexture);
 
712
        
 
713
        if (bFree)
 
714
                g_free (pGaugeImage2);
 
715
}
 
716
static void _cairo_dock_free_gauge_indicator(GaugeIndicator2 *pGaugeIndicator2)
 
717
{
 
718
        if (pGaugeIndicator2 == NULL)
 
719
                return ;
 
720
        cd_debug("");
 
721
        
 
722
        int i;
 
723
        for (i = 0; i < pGaugeIndicator2->iNbImages; i ++)
 
724
        {
 
725
                _cairo_dock_free_gauge_image (&pGaugeIndicator2->pImageList[i], FALSE);
 
726
        }
 
727
        g_free (pGaugeIndicator2->pImageList);
 
728
        
 
729
        _cairo_dock_free_gauge_image (pGaugeIndicator2->pImageNeedle, TRUE);
 
730
        
 
731
        g_free (pGaugeIndicator2);
 
732
}
 
733
void cairo_dock_free_gauge2 (Gauge2 *pGauge)
 
734
{
 
735
        cd_debug("");
 
736
        if(pGauge == NULL)
 
737
                return ;
 
738
        
 
739
        _cairo_dock_free_gauge_image(pGauge->pImageBackground, TRUE);
 
740
        _cairo_dock_free_gauge_image(pGauge->pImageForeground, TRUE);
 
741
        
 
742
        GList *pElement;
 
743
        for (pElement = pGauge->pIndicatorList; pElement != NULL; pElement = pElement->next)
 
744
        {
 
745
                _cairo_dock_free_gauge_indicator (pElement->data);
 
746
        }
 
747
        g_list_free (pGauge->pIndicatorList);
 
748
        
 
749
        g_free (pGauge);
 
750
}
 
751
 
 
752
 
 
753
void cairo_dock_add_watermark_on_gauge2 (cairo_t *pSourceContext, Gauge2 *pGauge, gchar *cImagePath, double fAlpha)
 
754
{
 
755
        g_return_if_fail (pGauge != NULL && cImagePath != NULL);
 
756
        
 
757
        CairoDataRenderer *pRenderer = CAIRO_DATA_RENDERER (pGauge);
 
758
        cairo_surface_t *pWatermarkSurface = cairo_dock_create_surface_for_icon (cImagePath, pSourceContext, pRenderer->iWidth/2, pRenderer->iHeight/2);
 
759
        
 
760
        if (pGauge->pImageBackground == NULL)
 
761
        {
 
762
                pGauge->pImageBackground = g_new0 (GaugeImage2, 1);
 
763
                pGauge->pImageBackground->sizeX = pRenderer->iWidth;
 
764
                pGauge->pImageBackground->sizeY = pRenderer->iHeight;
 
765
                
 
766
                pGauge->pImageBackground->pSurface = cairo_surface_create_similar (cairo_get_target (pSourceContext),
 
767
                        CAIRO_CONTENT_COLOR_ALPHA,
 
768
                        pRenderer->iWidth,
 
769
                        pRenderer->iHeight);
 
770
        }
 
771
        
 
772
        cairo_t *pCairoContext = cairo_create (pGauge->pImageBackground->pSurface);
 
773
        cairo_set_operator (pCairoContext, CAIRO_OPERATOR_OVER);
 
774
        
 
775
        cairo_set_source_surface (pCairoContext, pWatermarkSurface, pRenderer->iWidth/4, pRenderer->iHeight/4);
 
776
        cairo_paint_with_alpha (pCairoContext, fAlpha);
 
777
        
 
778
        cairo_destroy (pCairoContext);
 
779
        
 
780
        cairo_surface_destroy (pWatermarkSurface);
 
781
}
 
782
 
 
783
  //////////////////////////////////////////
 
784
 /////////////// RENDERER /////////////////
 
785
//////////////////////////////////////////
 
786
Gauge2 *cairo_dock_new_gauge (void)
 
787
{
 
788
        Gauge2 *pGauge = g_new0 (Gauge2, 1);
 
789
        pGauge->dataRenderer.interface.new                              = cairo_dock_new_gauge;
 
790
        pGauge->dataRenderer.interface.load                             = cairo_dock_load_gauge2;
 
791
        pGauge->dataRenderer.interface.render                   = cairo_dock_render_gauge2;
 
792
        pGauge->dataRenderer.interface.render_opengl    = cairo_dock_render_gauge_opengl2;
 
793
        pGauge->dataRenderer.interface.free                             = cairo_dock_free_gauge2;
 
794
        pGauge->dataRenderer.interface.reload                   = cairo_dock_reload_gauge2;
 
795
        return pGauge;
 
796
}
 
797
 
 
798
  /////////////////////////////////////////////////
 
799
 /////////////// LIST OF THEMES  /////////////////
 
800
/////////////////////////////////////////////////
 
801
/*GHashTable *cairo_dock_list_available_gauges (void)
 
802
{
 
803
        gchar *cGaugeShareDir = g_strdup_printf ("%s/%s", CAIRO_DOCK_SHARE_DATA_DIR, CAIRO_DOCK_GAUGES_DIR);
 
804
        gchar *cGaugeUserDir = g_strdup_printf ("%s/%s/%s", g_cCairoDockDataDir, CAIRO_DOCK_EXTRAS_DIR, CAIRO_DOCK_GAUGES_DIR);
 
805
        GHashTable *pGaugeTable = cairo_dock_list_themes (cGaugeShareDir, cGaugeUserDir, CAIRO_DOCK_GAUGES_DIR);
 
806
        
 
807
        g_free (cGaugeShareDir);
 
808
        g_free (cGaugeUserDir);
 
809
        return pGaugeTable;
 
810
}
 
811
 
 
812
const gchar *cairo_dock_get_gauge_key_value(gchar *cAppletConfFilePath, GKeyFile *pKeyFile, gchar *cGroupName, gchar *cKeyName, gboolean *bFlushConfFileNeeded, gchar *cDefaultThemeName)
 
813
{
 
814
        gchar *cChosenThemeName = cairo_dock_get_string_key_value (pKeyFile, cGroupName, cKeyName, bFlushConfFileNeeded, cDefaultThemeName, NULL, NULL);
 
815
        gchar *cGaugeShareDir = g_strdup_printf ("%s/%s", CAIRO_DOCK_SHARE_DATA_DIR, CAIRO_DOCK_GAUGES_DIR);
 
816
        gchar *cGaugeUserDir = g_strdup_printf ("%s/%s/%s", g_cCairoDockDataDir, CAIRO_DOCK_EXTRAS_DIR, CAIRO_DOCK_GAUGES_DIR);
 
817
        gchar *cGaugePath = cairo_dock_get_theme_path (cChosenThemeName, cGaugeShareDir, cGaugeUserDir, CAIRO_DOCK_GAUGES_DIR);
 
818
        g_free (cGaugeShareDir);
 
819
        g_free (cGaugeUserDir);
 
820
        
 
821
        cd_debug ("Theme de la jauge : %s", cGaugePath);
 
822
        return cGaugePath;
 
823
}
 
824
*/