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

« back to all changes in this revision

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

  • Committer: Bazaar Package Importer
  • Author(s): Matthieu Baerts (matttbe), Matthieu Baerts (matttbe), Didier Roche
  • Date: 2010-03-01 21:24:00 UTC
  • mfrom: (1.1.8 upstream)
  • Revision ID: james.westby@ubuntu.com-20100301212400-3a3csog6eonse3in
Tags: 2.1.3-6-0ubuntu1
[ Matthieu Baerts (matttbe) ]
* New Upstream Version. (LP: #521534)
* Updated debian/watch and debian/copyright with LP account.
* Removed debian/patches/02-merge-changelog.patch'
 - data/ChangeLog.txt has to respect a syntax and is used by CD.
* debian/cairo-dock.1:
 - Updated with the latest release.
 - The domain name 'cairo-dock.org' has changed to 'glx-dock.org'
* debian/control:
 - Changed the homepage and other links (glx-dock.org)
 - Updated cairo-dock-dev architecture to 'all' (it no longer contains compiled files)
* debian/cairo-dock-dev.install
 - libcairo-dock.a and libcairo-dock.so no longer exist
* debian/rules
 - removed uneeded changelog file
* Updated debian/patches/01-desktop-file-category.patch

[ Didier Roche ]
* Fix debian/watch
* Fix some issue in versionning
* debian/control: clean the packaging and add right -plugins depends

Show diffs side-by-side

added added

removed removed

Lines of Context:
17
17
* along with this program.  If not, see <http://www.gnu.org/licenses/>.
18
18
*/
19
19
 
 
20
/** Exemple of a gauge with text inside :
 
21
 * 
 
22
 * <gauge>
 
23
        <name>Screenlets Vista'ish Default</name>
 
24
        <author>(conversion by Nochka85)</author>
 
25
        <rank>2</rank>
 
26
        <file key="background">back.svg</file>
 
27
        <file key="foreground">dialdot.svg</file>
 
28
        <indicator>
 
29
                <posX>-0,35</posX>
 
30
                <posY>-0,10</posY>
 
31
                <posStart>-130</posStart>
 
32
                <posStop>130</posStop>
 
33
                <file key="needle">dial.svg</file>
 
34
                <offset_x>0</offset_x>
 
35
                <width>40</width>
 
36
                <height>8</height>
 
37
                <text_zone>
 
38
                        <x_center>-0,34</x_center>
 
39
                        <y_center>-0,47</y_center>
 
40
                        <width>0,18</width>
 
41
                        <height>0,10</height>
 
42
                        <red>1.0</red>
 
43
                        <green>1,0</green>
 
44
                        <blue>1,0</blue>
 
45
                </text_zone>
 
46
                <logo_zone>
 
47
                        <x_center>-0,32</x_center>
 
48
                        <y_center>0,00</y_center>
 
49
                        <width>0,10</width>
 
50
                        <height>0,10</height>
 
51
                        <alpha>1.0</alpha>
 
52
                </logo_zone>
 
53
        </indicator>
 
54
        <indicator>
 
55
                <posX>0,48</posX>
 
56
                <posY>0,27</posY>
 
57
                <direction>1</direction>
 
58
                <posStart>-128</posStart>
 
59
                <posStop>128</posStop>
 
60
                <file key="needle">dial2.svg</file>
 
61
                <offset_x>0</offset_x>
 
62
                <width>30</width>
 
63
                <height>8</height>
 
64
                <text_zone>
 
65
                        <x_center>0,50</x_center>
 
66
                        <y_center>-0,00</y_center>
 
67
                        <width>0,18</width>
 
68
                        <height>0,08</height>
 
69
                        <red>1.0</red>
 
70
                        <green>1,0</green>
 
71
                        <blue>1,0</blue>
 
72
                </text_zone>
 
73
                <logo_zone>
 
74
                        <x_center>0,50</x_center>
 
75
                        <y_center>0,30</y_center>
 
76
                        <width>0,10</width>
 
77
                        <height>0,10</height>
 
78
                        <alpha>1.0</alpha>
 
79
                </logo_zone>
 
80
        </indicator>
 
81
</gauge>
 
82
 * 
 
83
 * */
 
84
 
20
85
#include <string.h>
21
86
#include <math.h>
22
87
#include <libxml/tree.h>
38
103
 
39
104
extern gchar *g_cCairoDockDataDir;
40
105
extern gboolean g_bUseOpenGL;
 
106
extern gboolean g_bEasterEggs;
41
107
 
42
108
  ////////////////////////////////////////////
43
109
 /////////////// LOAD GAUGE /////////////////
44
110
////////////////////////////////////////////
45
 
void cairo_dock_xml_open_file (const gchar *filePath, const gchar *mainNodeName,xmlDocPtr *myXmlDoc,xmlNodePtr *myXmlNode)
 
111
/*void cairo_dock_xml_open_file (const gchar *filePath, const gchar *mainNodeName,xmlDocPtr *myXmlDoc,xmlNodePtr *myXmlNode)
46
112
{
47
113
        xmlDocPtr doc = xmlParseFile (filePath);
48
114
        if (doc == NULL)
64
130
        
65
131
        *myXmlDoc = doc;
66
132
        *myXmlNode = node;
 
133
}*/
 
134
 
 
135
static double _str2double (gchar *s)
 
136
{
 
137
        gchar *str = strchr (s, ',');
 
138
        if (str)
 
139
                *str = '.';
 
140
        return g_ascii_strtod (s, NULL);
67
141
}
68
142
 
69
143
static void _cairo_dock_init_gauge_image (const gchar *cImagePath, GaugeImage *pGaugeImage)
79
153
}
80
154
static GaugeImage *_cairo_dock_new_gauge_image (const gchar *cImagePath)
81
155
{
82
 
        cd_debug ("%s (%s)", __func__, cImagePath);
83
156
        GaugeImage *pGaugeImage = g_new0 (GaugeImage, 1);
84
157
        
85
158
        _cairo_dock_init_gauge_image (cImagePath, pGaugeImage);
134
207
        if (pGaugeImage->pSvgHandle != NULL)
135
208
        {
136
209
                int iSize = MIN (iWidth, iHeight);
137
 
                g_print ("size : applet : %d, image : %d\n", iSize, pGaugeImage->sizeX);
 
210
                //g_print ("size : applet : %d, image : %d\n", iSize, pGaugeImage->sizeX);
138
211
                pGaugeIndicator->fNeedleScale = (double)iSize / (double) pGaugeImage->sizeX;  // car l'aiguille est a l'horizontale dans le fichier svg.
139
212
                pGaugeIndicator->iNeedleWidth = (double) pGaugeIndicator->iNeedleRealWidth * pGaugeIndicator->fNeedleScale;
140
213
                pGaugeIndicator->iNeedleHeight = (double) pGaugeIndicator->iNeedleRealHeight * pGaugeIndicator->fNeedleScale;
141
 
                g_print (" + needle %dx%d\n", pGaugeIndicator->iNeedleWidth, pGaugeIndicator->iNeedleHeight);
 
214
                //g_print (" + needle %dx%d\n", pGaugeIndicator->iNeedleWidth, pGaugeIndicator->iNeedleHeight);
142
215
                
143
216
                cairo_surface_t *pNeedleSurface = _cairo_dock_create_blank_surface (pSourceContext, pGaugeIndicator->iNeedleWidth, pGaugeIndicator->iNeedleHeight);
144
217
                g_return_if_fail (cairo_surface_status (pNeedleSurface) == CAIRO_STATUS_SUCCESS);
166
239
        int iWidth = pGauge->dataRenderer.iWidth, iHeight = pGauge->dataRenderer.iHeight;
167
240
        if (iWidth == 0 || iHeight == 0)
168
241
                return FALSE;
 
242
        CairoDataRenderer *pRenderer = CAIRO_DATA_RENDERER (pGauge);
169
243
        
170
244
        g_return_val_if_fail (cThemePath != NULL, FALSE);
171
245
        xmlInitParser ();
172
246
        xmlDocPtr pGaugeTheme;
173
247
        xmlNodePtr pGaugeMainNode;
174
248
        gchar *cXmlFile = g_strdup_printf("%s/theme.xml",cThemePath);
175
 
        cairo_dock_xml_open_file (cXmlFile, "gauge",&pGaugeTheme,&pGaugeMainNode);
 
249
        //cairo_dock_xml_open_file (cXmlFile, "gauge",&pGaugeTheme,&pGaugeMainNode);
 
250
        pGaugeTheme = cairo_dock_open_xml_file (cXmlFile, "gauge", &pGaugeMainNode, NULL);
176
251
        g_free (cXmlFile);
177
 
        g_return_val_if_fail (pGaugeTheme != NULL, FALSE);
 
252
        g_return_val_if_fail (pGaugeTheme != NULL && pGaugeMainNode != NULL, FALSE);
178
253
        
179
254
        xmlAttrPtr ap;
180
255
        xmlChar *cAttribute, *cNodeContent, *cTextNodeContent;
182
257
        GaugeImage *pGaugeImage;
183
258
        GaugeIndicator *pGaugeIndicator = NULL;
184
259
        xmlNodePtr pGaugeNode;
185
 
        for (pGaugeNode = pGaugeMainNode->xmlChildrenNode; pGaugeNode != NULL; pGaugeNode = pGaugeNode->next)
 
260
        int i;
 
261
        for (pGaugeNode = pGaugeMainNode->children, i = 0; pGaugeNode != NULL; pGaugeNode = pGaugeNode->next, i ++)
186
262
        {
187
263
                if (xmlStrcmp (pGaugeNode->name, (const xmlChar *) "name") == 0)
188
264
                {
189
265
                        pGauge->cThemeName = xmlNodeGetContent(pGaugeNode);
190
 
                        cd_debug("gauge : Nom du theme(%s)",pGauge->pIndicatorList);
191
266
                }
192
267
                else if (xmlStrcmp (pGaugeNode->name, (const xmlChar *) "rank") == 0)
193
268
                {
200
275
                        cNodeContent = xmlNodeGetContent (pGaugeNode);
201
276
                        g_string_printf (sImagePath, "%s/%s", cThemePath, cNodeContent);
202
277
                        ap = xmlHasProp (pGaugeNode, "key");
203
 
                        cAttribute = xmlNodeGetContent(ap->xmlChildrenNode);
 
278
                        cAttribute = xmlNodeGetContent(ap->children);
204
279
                        if (xmlStrcmp (cAttribute, "background") == 0)
205
280
                        {
206
281
                                pGauge->pImageBackground = _cairo_dock_new_gauge_image (sImagePath->str);
226
301
                                                CAIRO_DATA_RENDERER (pGauge)->iRank ++;
227
302
                                }
228
303
                        }
229
 
 
 
304
                        
230
305
                        pGaugeIndicator = g_new0 (GaugeIndicator, 1);
231
306
                        pGaugeIndicator->direction = 1;
232
307
                        
233
308
                        cd_debug ("gauge : On charge un indicateur");
234
309
                        xmlNodePtr pGaugeSubNode;
235
 
                        for (pGaugeSubNode = pGaugeNode->xmlChildrenNode; pGaugeSubNode != NULL; pGaugeSubNode = pGaugeSubNode->next)
 
310
                        for (pGaugeSubNode = pGaugeNode->children; pGaugeSubNode != NULL; pGaugeSubNode = pGaugeSubNode->next)
236
311
                        {
237
312
                                if (xmlStrcmp (pGaugeSubNode->name, (const xmlChar *) "text") == 0)
238
313
                                        continue;
239
314
                                //g_print ("+ %s\n", pGaugeSubNode->name);
240
315
                                cNodeContent = xmlNodeGetContent (pGaugeSubNode);
241
316
                                if(xmlStrcmp (pGaugeSubNode->name, (const xmlChar *) "posX") == 0)
242
 
                                        pGaugeIndicator->posX = atof (cNodeContent);
 
317
                                        pGaugeIndicator->posX = _str2double (cNodeContent);
243
318
                                else if(xmlStrcmp (pGaugeSubNode->name, (const xmlChar *) "posY") == 0)
244
 
                                        pGaugeIndicator->posY = atof (cNodeContent);
 
319
                                        pGaugeIndicator->posY = _str2double (cNodeContent);
245
320
                                else if(xmlStrcmp (pGaugeSubNode->name, (const xmlChar *) "text_zone") == 0)
246
321
                                {
247
322
                                        xmlNodePtr pTextSubNode;
248
 
                                        for (pTextSubNode = pGaugeSubNode->xmlChildrenNode; pTextSubNode != NULL; pTextSubNode = pTextSubNode->next)
 
323
                                        for (pTextSubNode = pGaugeSubNode->children; pTextSubNode != NULL; pTextSubNode = pTextSubNode->next)
249
324
                                        {
250
 
                                                if (xmlStrcmp (pTextSubNode->name, (const xmlChar *) "text") == 0)
251
 
                                                        continue;
252
 
                                                //g_print ("  + %s\n", pTextSubNode->name);
253
325
                                                cTextNodeContent = xmlNodeGetContent (pTextSubNode);
254
 
                                                //g_print ("     -> '%s'\n", cTextNodeContent);
255
 
                                                if(xmlStrcmp (pTextSubNode->name, (const xmlChar *) "textX") == 0)
256
 
                                                        pGaugeIndicator->textX = atof (cTextNodeContent);
257
 
                                                else if(xmlStrcmp (pTextSubNode->name, (const xmlChar *) "textY") == 0)
258
 
                                                        pGaugeIndicator->textY = atof (cTextNodeContent);
259
 
                                                else if(xmlStrcmp (pTextSubNode->name, (const xmlChar *) "textWidth") == 0)
260
 
                                                        pGaugeIndicator->textWidth = atof (cTextNodeContent);
261
 
                                                else if(xmlStrcmp (pTextSubNode->name, (const xmlChar *) "textHeight") == 0)
262
 
                                                        pGaugeIndicator->textHeight = atof (cTextNodeContent);
263
 
                                                else if(xmlStrcmp (pTextSubNode->name, (const xmlChar *) "textColorR") == 0)
264
 
                                                        pGaugeIndicator->textColor[0] = atof (cTextNodeContent);
265
 
                                                else if(xmlStrcmp (pTextSubNode->name, (const xmlChar *) "textColorG") == 0)
266
 
                                                        pGaugeIndicator->textColor[1] = atof (cTextNodeContent);
267
 
                                                else if(xmlStrcmp (pTextSubNode->name, (const xmlChar *) "textColorB") == 0)
268
 
                                                        pGaugeIndicator->textColor[2] = atof (cTextNodeContent);
269
 
                                        }
270
 
                                        g_print ("pGaugeIndicator->textWidth:%.2f\n", pGaugeIndicator->textWidth);
 
326
                                                if(xmlStrcmp (pTextSubNode->name, (const xmlChar *) "x_center") == 0)
 
327
                                                        pGaugeIndicator->textZone.fX = _str2double (cTextNodeContent);
 
328
                                                else if(xmlStrcmp (pTextSubNode->name, (const xmlChar *) "y_center") == 0)
 
329
                                                        pGaugeIndicator->textZone.fY = _str2double (cTextNodeContent);
 
330
                                                else if(xmlStrcmp (pTextSubNode->name, (const xmlChar *) "width") == 0)
 
331
                                                        pGaugeIndicator->textZone.fWidth = _str2double (cTextNodeContent);
 
332
                                                else if(xmlStrcmp (pTextSubNode->name, (const xmlChar *) "height") == 0)
 
333
                                                        pGaugeIndicator->textZone.fHeight = _str2double (cTextNodeContent);
 
334
                                                else if(xmlStrcmp (pTextSubNode->name, (const xmlChar *) "red") == 0)
 
335
                                                        pGaugeIndicator->textZone.pColor[0] = _str2double (cTextNodeContent);
 
336
                                                else if(xmlStrcmp (pTextSubNode->name, (const xmlChar *) "green") == 0)
 
337
                                                        pGaugeIndicator->textZone.pColor[1] = _str2double (cTextNodeContent);
 
338
                                                else if(xmlStrcmp (pTextSubNode->name, (const xmlChar *) "blue") == 0)
 
339
                                                        pGaugeIndicator->textZone.pColor[2] = _str2double (cTextNodeContent);
 
340
                                        }
 
341
                                }
 
342
                                else if(xmlStrcmp (pGaugeSubNode->name, (const xmlChar *) "logo_zone") == 0)
 
343
                                {
 
344
                                        xmlNodePtr pLogoSubNode;
 
345
                                        for (pLogoSubNode = pGaugeSubNode->children; pLogoSubNode != NULL; pLogoSubNode = pLogoSubNode->next)
 
346
                                        {
 
347
                                                cTextNodeContent = xmlNodeGetContent (pLogoSubNode);
 
348
                                                if(xmlStrcmp (pLogoSubNode->name, (const xmlChar *) "x_center") == 0)
 
349
                                                        pGaugeIndicator->emblem.fX = _str2double (cTextNodeContent);
 
350
                                                else if(xmlStrcmp (pLogoSubNode->name, (const xmlChar *) "y_center") == 0)
 
351
                                                        pGaugeIndicator->emblem.fY = _str2double (cTextNodeContent);
 
352
                                                else if(xmlStrcmp (pLogoSubNode->name, (const xmlChar *) "width") == 0)
 
353
                                                        pGaugeIndicator->emblem.fWidth = _str2double (cTextNodeContent);
 
354
                                                else if(xmlStrcmp (pLogoSubNode->name, (const xmlChar *) "height") == 0)
 
355
                                                        pGaugeIndicator->emblem.fHeight = _str2double (cTextNodeContent);
 
356
                                                else if(xmlStrcmp (pLogoSubNode->name, (const xmlChar *) "alpha") == 0)
 
357
                                                        pGaugeIndicator->emblem.fAlpha = _str2double (cTextNodeContent);
 
358
                                        }
271
359
                                }
272
360
                                else if(xmlStrcmp (pGaugeSubNode->name, (const xmlChar *) "direction") == 0)
273
 
                                        pGaugeIndicator->direction = atof (cNodeContent);
 
361
                                        pGaugeIndicator->direction = _str2double (cNodeContent);
274
362
                                else if(xmlStrcmp (pGaugeSubNode->name, (const xmlChar *) "posStart") == 0)
275
 
                                        pGaugeIndicator->posStart = atof (cNodeContent);
 
363
                                        pGaugeIndicator->posStart = _str2double (cNodeContent);
276
364
                                else if(xmlStrcmp (pGaugeSubNode->name, (const xmlChar *) "posStop") == 0)
277
 
                                        pGaugeIndicator->posStop = atof (cNodeContent);
 
365
                                        pGaugeIndicator->posStop = _str2double (cNodeContent);
278
366
                                else if(xmlStrcmp (pGaugeSubNode->name, (const xmlChar *) "nb images") == 0)
279
367
                                        pGaugeIndicator->iNbImages = atoi (cNodeContent);
280
368
                                else if(xmlStrcmp (pGaugeSubNode->name, (const xmlChar *) "offset_x") == 0)
294
382
                                {
295
383
                                        cd_debug("gauge : On charge un fichier (%s)",cNodeContent);
296
384
                                        ap = xmlHasProp(pGaugeSubNode, "key");
297
 
                                        cAttribute = xmlNodeGetContent(ap->xmlChildrenNode);
 
385
                                        cAttribute = xmlNodeGetContent(ap->children);
298
386
                                        if (strcmp (cAttribute, "needle") == 0 && pGaugeIndicator->pImageNeedle == NULL)
299
387
                                        {
300
388
                                                g_string_printf (sImagePath, "%s/%s", cThemePath, cNodeContent);
346
434
                        pGauge->pIndicatorList = g_list_append (pGauge->pIndicatorList, pGaugeIndicator);
347
435
                }
348
436
        }
349
 
        xmlFreeDoc (pGaugeTheme);
350
 
        xmlCleanupParser ();
 
437
        cairo_dock_close_xml_file (pGaugeTheme);
351
438
        g_string_free (sImagePath, TRUE);
352
439
        
353
440
        g_return_val_if_fail (CAIRO_DATA_RENDERER (pGauge)->iRank != 0 && pGaugeIndicator != NULL, FALSE);
354
 
        CAIRO_DATA_RENDERER (pGauge)->bCanRenderValueAsText = (pGaugeIndicator->textWidth != 0 && pGaugeIndicator->textHeight != 0);
 
441
        CAIRO_DATA_RENDERER (pGauge)->bCanRenderValueAsText = (pGaugeIndicator->textZone.fWidth != 0 && pGaugeIndicator->textZone.fHeight != 0);
355
442
        
356
443
        return TRUE;
357
444
}
358
445
static void cairo_dock_load_gauge (Gauge *pGauge, cairo_t *pSourceContext, CairoContainer *pContainer, CairoGaugeAttribute *pAttribute)
359
446
{
360
447
        _cairo_dock_load_gauge_theme (pGauge, pSourceContext, pAttribute->cThemePath);
 
448
        
 
449
        /// charger les emblemes...
 
450
        
361
451
}
362
452
 
363
453
  ////////////////////////////////////////////
438
528
                {
439
529
                        _draw_gauge_image (pSourceContext, pGauge, pIndicator, fValue);
440
530
                }
441
 
 
442
 
                if (pIndicator->textWidth != 0 && pIndicator->textHeight != 0)  // cet indicateur a un emplacement pour le texte de la valeur.
 
531
                
 
532
                if (/**pRenderer->bWriteValues && */pIndicator->textZone.fWidth != 0 && pIndicator->textZone.fHeight != 0)  // cet indicateur a un emplacement pour le texte de la valeur.
443
533
                {
444
534
                        cairo_data_renderer_format_value (pRenderer, fValue, i);
445
535
                        //g_print (" >>>%s\n", pRenderer->cFormatBuffer);
446
536
                        cairo_save (pSourceContext);
447
 
                        cairo_set_source_rgb (pSourceContext, pIndicator->textColor[0], pIndicator->textColor[1], pIndicator->textColor[2]);
448
 
                        cairo_set_line_width (pSourceContext, 20);
449
 
                        
450
 
                        cairo_text_extents_t textExtents;
451
 
                        cairo_text_extents (pSourceContext, pRenderer->cFormatBuffer, &textExtents);
452
 
                        double fZoom = MIN (pIndicator->textWidth * pRenderer->iWidth / textExtents.width, pIndicator->textHeight * pRenderer->iHeight / textExtents.height);
 
537
                        cairo_set_source_rgb (pSourceContext, pIndicator->textZone.pColor[0], pIndicator->textZone.pColor[1], pIndicator->textZone.pColor[2]);
 
538
                        
 
539
                        PangoLayout *pLayout = pango_cairo_create_layout (pSourceContext);
 
540
                        PangoFontDescription *fd = pango_font_description_from_string ("Monospace 12");
 
541
                        pango_layout_set_font_description (pLayout, fd);
 
542
                        
 
543
                        PangoRectangle ink, log;
 
544
                        pango_layout_set_text (pLayout, pRenderer->cFormatBuffer, -1);
 
545
                        pango_layout_get_pixel_extents (pLayout, &ink, &log);
 
546
                        double fZoom = MIN (pIndicator->textZone.fWidth * pRenderer->iWidth / (log.width), pIndicator->textZone.fHeight * pRenderer->iHeight / log.height);
 
547
                        
453
548
                        cairo_move_to (pSourceContext,
454
 
                                (1. + pIndicator->textX) * pRenderer->iWidth/2 - textExtents.width / 2,
455
 
                                (1. - pIndicator->textY) * pRenderer->iHeight/2 + textExtents.height);
 
549
                                floor ((1. + pIndicator->textZone.fX) * pRenderer->iWidth/2 - log.width*fZoom/2),
 
550
                                floor ((1. - pIndicator->textZone.fY) * pRenderer->iHeight/2 - log.height*fZoom/2));
456
551
                        cairo_scale (pSourceContext,
457
552
                                fZoom,
458
553
                                fZoom);
459
 
                        cairo_show_text (pSourceContext, pRenderer->cFormatBuffer);
 
554
                        pango_cairo_show_layout (pSourceContext, pLayout);
460
555
                        cairo_restore (pSourceContext);
461
556
                }
462
557
        }
600
695
                {
601
696
                        _draw_gauge_image_opengl (pGauge, pIndicator, fValue);
602
697
                }
603
 
 
604
 
                if (pIndicator->textWidth != 0 && pIndicator->textHeight != 0)  // cet indicateur a un emplacement pour le texte de la valeur.
 
698
                
 
699
                if (/**pRenderer->bWriteValues && */pIndicator->textZone.fWidth != 0 && pIndicator->textZone.fHeight != 0)  // cet indicateur a un emplacement pour le texte de la valeur.
605
700
                {
606
701
                        cairo_data_renderer_format_value (pRenderer, fValue, i);
607
 
                        //g_print (" >>>%s\n", pRenderer->cFormatBuffer);
608
 
                        /*cairo_save (pSourceContext);
609
 
                        cairo_set_source_rgb (pSourceContext, pIndicator->textColor[0], pIndicator->textColor[1], pIndicator->textColor[2]);
610
 
                        cairo_set_line_width (pSourceContext, 20.);
611
 
                        
612
 
                        cairo_text_extents_t textExtents;
613
 
                        cairo_text_extents (pSourceContext, pRenderer->cFormatBuffer, &textExtents);
614
 
                        cairo_move_to (pSourceContext,
615
 
                                pIndicator->textX * pRenderer->iWidth - textExtents.width / 2,
616
 
                                pIndicator->textY * pRenderer->iHeight + textExtents.height / 2);
617
 
                        cairo_show_text (pSourceContext, pRenderer->cFormatBuffer);
618
 
                        cairo_restore (pSourceContext);*/
 
702
                        
 
703
                        CairoDockGLFont *pFont = cairo_dock_get_default_data_renderer_font ();
 
704
                        glColor3f (pIndicator->textZone.pColor[0], pIndicator->textZone.pColor[1], pIndicator->textZone.pColor[2]);
 
705
                        glPushMatrix ();
 
706
                        
 
707
                        cairo_dock_draw_gl_text_at_position_in_area (pRenderer->cFormatBuffer,
 
708
                                pFont,
 
709
                                floor (pIndicator->textZone.fX * pRenderer->iWidth/2),
 
710
                                floor (pIndicator->textZone.fY * pRenderer->iHeight/2),
 
711
                                pIndicator->textZone.fWidth * pRenderer->iWidth,
 
712
                                pIndicator->textZone.fHeight * pRenderer->iHeight,
 
713
                                TRUE);
 
714
                        
 
715
                        glPopMatrix ();
 
716
                        _cairo_dock_enable_texture ();
 
717
                        glColor3f (1.0, 1.0, 1.0);
619
718
                }
620
719
        }
621
720
        
701
800
        
702
801
        GaugeIndicator *pGaugeIndicator;
703
802
        GaugeImage *pGaugeImage;
704
 
        int i;
 
803
        int i, j;
705
804
        GList *pElement, *pElement2;
706
805
        for (pElement = pGauge->pIndicatorList; pElement != NULL; pElement = pElement->next)
707
806
        {
783
882
        pGauge->dataRenderer.interface.new                              = (CairoDataRendererNewFunc) cairo_dock_new_gauge;
784
883
        pGauge->dataRenderer.interface.load                             = (CairoDataRendererLoadFunc) cairo_dock_load_gauge;
785
884
        pGauge->dataRenderer.interface.render                   = (CairoDataRendererRenderFunc) cairo_dock_render_gauge;
786
 
        pGauge->dataRenderer.interface.render_opengl    = (CairoDataRendererRenderOpenGLFunc) cairo_dock_render_gauge_opengl;
 
885
        pGauge->dataRenderer.interface.render_opengl            = (CairoDataRendererRenderOpenGLFunc) cairo_dock_render_gauge_opengl;
787
886
        pGauge->dataRenderer.interface.reload                   = (CairoDataRendererReloadFunc) cairo_dock_reload_gauge;
788
887
        pGauge->dataRenderer.interface.free                             = (CairoDataRendererFreeFunc) cairo_dock_free_gauge;
789
888
        return pGauge;
804
903
        return pGaugeTable;
805
904
}
806
905
 
807
 
gchar *cairo_dock_get_gauge_theme_path (const gchar *cThemeName)
 
906
 
 
907
gchar *cairo_dock_get_gauge_theme_path (const gchar *cThemeName, CairoDockThemeType iType)  // utile pour DBus aussi.
808
908
{
809
 
        if (cThemeName == NULL)
810
 
                return g_strdup ("Turbo-night-fuel");
811
909
        const gchar *cGaugeShareDir = CAIRO_DOCK_SHARE_DATA_DIR"/"CAIRO_DOCK_GAUGES_DIR;
812
910
        gchar *cGaugeUserDir = g_strdup_printf ("%s/%s", g_cCairoDockDataDir, CAIRO_DOCK_EXTRAS_DIR"/"CAIRO_DOCK_GAUGES_DIR);
813
 
        gchar *cGaugePath = cairo_dock_get_theme_path (cThemeName, cGaugeShareDir, cGaugeUserDir, CAIRO_DOCK_GAUGES_DIR);
 
911
        gchar *cGaugePath = cairo_dock_get_theme_path (cThemeName, cGaugeShareDir, cGaugeUserDir, CAIRO_DOCK_GAUGES_DIR, iType);
814
912
        g_free (cGaugeUserDir);
815
913
        return cGaugePath;
816
914
}
817
915
 
818
 
gchar *cairo_dock_get_gauge_key_value(gchar *cAppletConfFilePath, GKeyFile *pKeyFile, gchar *cGroupName, gchar *cKeyName, gboolean *bFlushConfFileNeeded, gchar *cDefaultThemeName)
 
916
gchar *cairo_dock_get_theme_path_for_gauge (const gchar *cAppletConfFilePath, GKeyFile *pKeyFile, const gchar *cGroupName, const gchar *cKeyName, gboolean *bFlushConfFileNeeded, const gchar *cDefaultThemeName)
819
917
{
820
918
        gchar *cChosenThemeName = cairo_dock_get_string_key_value (pKeyFile, cGroupName, cKeyName, bFlushConfFileNeeded, cDefaultThemeName, NULL, NULL);
821
 
        gchar *cGaugePath = cairo_dock_get_gauge_theme_path (cChosenThemeName);
 
919
        if (cChosenThemeName == NULL)
 
920
                return g_strdup ("Turbo-night-fuel");
 
921
        
 
922
        CairoDockThemeType iType = cairo_dock_extract_theme_type_from_name (cChosenThemeName);
 
923
        gchar *cGaugePath = cairo_dock_get_gauge_theme_path (cChosenThemeName, iType);
 
924
        
 
925
        if (iType != CAIRO_DOCK_ANY_THEME)
 
926
        {
 
927
                g_key_file_set_string (pKeyFile, cGroupName, cKeyName, cChosenThemeName);
 
928
                cairo_dock_write_keys_to_file (pKeyFile, cAppletConfFilePath);
 
929
        }
 
930
        cd_debug ("Theme de la jauge : %s", cGaugePath);
822
931
        g_free (cChosenThemeName);
823
 
        
824
 
        cd_debug ("Theme de la jauge : %s", cGaugePath);
825
932
        return cGaugePath;
826
933
}
827
934