~cairo-dock-team/ubuntu/precise/cairo-dock-plug-ins/984054

« back to all changes in this revision

Viewing changes to Doncky/src/applet-draw.c

  • Committer: Bazaar Package Importer
  • Author(s): Matthieu Baerts (matttbe)
  • Date: 2010-08-10 00:05:57 UTC
  • mfrom: (1.1.5 upstream)
  • Revision ID: james.westby@ubuntu.com-20100810000557-pfxoz5w7hbyclcqh
Tags: 2.2.0~0beta4-0ubuntu1
* New Upstream Version (LP: #614625)
* Fixed a few bugs on LP:
 - LP: #483963: Dustbin applet does not display trashes on all volumes
 - LP: #485159: Some apps have problem with Systray
 - LP: #500677: ~/.xsession-errors is too much used by CD
 - LP: #500979: Shortcuts: the order gets messed up
 - LP: #521531: Mail: crashes on Maildir
 - LP: #519915: GTG: create a new applet to control GTG
 - LP: #526138: GMenu doesn't handle desktop file exec strings properly
 - LP: #531317: CMake: Added an error if the prefix of 'cairo-dock-plugins'
                 is not the same 'cairo-dock-core'
 - LP: #531319: CMake: check the version of 'cairo-dock' when building
                 'cairo-dock-plugins'
 - LP: #537115: Click at the position where icon lavel was, the icon
                 and dock still receive the event
 - LP: #537943: Terminal applet shortkey behaviour
 - LP: #538637: Trash applet doesn't create .trashinfo files on XFCE
 - More details on the 'ChangeLog' file
* debian/rules:
 - Autotools has been replaced by CMake
 - cdbs is now used.
* debian/copyright:
 - Updated with the new applets
* debian/control:
 - Autotools has been replaced by CMake
 - Added libcurl4-gnutls-dev, libindicator-dev, libdbusmenu-glib-dev
   libido-0.1-dev, libical-dev, libdbusmenu-gtk-dev as Build-deps
 - Bump Standard-Version to 3.9.1
 - Wget is required for dnd2share applet
 - Added the exact realease for 'cairo-dock-dev' in order to prevent any
    build error if this package is not already available (thx to didrocks)
* debian/cairo-dock-plug-ins*.install:
 - All sonames are now installed into lib32 or lib64 (lib*)

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/**
 
2
* This file is a part of the Cairo-Dock project
 
3
*
 
4
* Copyright : (C) see the 'copyright' file.
 
5
* E-mail    : see the 'copyright' file.
 
6
*
 
7
* This program is free software; you can redistribute it and/or
 
8
* modify it under the terms of the GNU General Public License
 
9
* as published by the Free Software Foundation; either version 3
 
10
* of the License, or (at your option) any later version.
 
11
*
 
12
* This program is distributed in the hope that it will be useful,
 
13
* but WITHOUT ANY WARRANTY; without even the implied warranty of
 
14
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
15
* GNU General Public License for more details.
 
16
* You should have received a copy of the GNU General Public License
 
17
* along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
18
*/
 
19
 
 
20
//\________________ Add your name in the copyright file (and / or modify your name here)
 
21
 
 
22
#include <cairo-dock.h>
 
23
#include <math.h>
 
24
#include "applet-struct.h"
 
25
#include "applet-draw.h"
 
26
#include "applet-xml.h"
 
27
#include "applet-nvidia.h"
 
28
#include "applet-cpusage.h"
 
29
#include "applet-disk-usage.h"
 
30
#include "applet-rame.h"
 
31
 
 
32
gchar* ltrim( gchar* str, const gchar* t )  // Couper tout depuis la gauche
 
33
{
 
34
        char* curStr = NULL;
 
35
 
 
36
        char look[ 256 ] = { 1, 0 };
 
37
        while( *t )
 
38
                look[ (unsigned char)*t++ ] = 1;
 
39
 
 
40
        curStr = str;
 
41
        while( *curStr && look[ *curStr ] )
 
42
                ++curStr;
 
43
        strcpy( str, curStr );
 
44
        
 
45
        return str; 
 
46
 
47
 
 
48
gchar* rtrim( gchar* str, const gchar* t )  // Couper tout depuis la droite
 
49
{
 
50
        char* curEnd = str, *end = str;
 
51
 
 
52
        char look[ 256 ] = { 1, 0 };
 
53
        while( *t )
 
54
                look[ (unsigned char)*t++ ] = 1;
 
55
 
 
56
        while( *end )
 
57
        {
 
58
                if ( !look[ *end ] )
 
59
                        curEnd = end + 1;
 
60
                ++end;
 
61
        }
 
62
        *curEnd = '\0';
 
63
 
 
64
        return str;
 
65
}
 
66
 
 
67
 
 
68
gchar *g_str_replace (const gchar *cString, const gchar *cWord, const gchar *cReplace)
 
69
{
 
70
        if (g_strstr_len (cString, -1, cWord) != NULL) // On remplace
 
71
        {
 
72
                gchar *cFinalString = g_strdup_printf("%s", cString);
 
73
                while (g_strstr_len (cFinalString, -1, cWord) != NULL)
 
74
                {
 
75
                        gchar *cPart1 = g_strdup_printf("%s", cFinalString);
 
76
                        gchar *cWordTemp = g_strdup_printf("%s", cWord);
 
77
                        g_strreverse (cPart1);
 
78
                        g_strreverse (cWordTemp);
 
79
                        cPart1 = strstr(cPart1, cWordTemp) ;
 
80
                        ltrim( cPart1, cWordTemp );
 
81
                        g_strreverse (cPart1);
 
82
                        gchar *cPart2 = g_strdup_printf("%s", cFinalString);
 
83
                        
 
84
                        while (g_strstr_len (cPart2, -1, cWord) != NULL)
 
85
                        {
 
86
                                cPart2 = strstr(cPart2, cWord);
 
87
                                ltrim( cPart2, cWord );
 
88
                        }
 
89
                        // On colle le texte au milieu
 
90
                        cFinalString = g_strdup_printf ("%s%s%s", cPart1,  g_strdup_printf("%s",cReplace), cPart2);
 
91
                        
 
92
                }
 
93
                return g_strdup_printf("%s", cFinalString);     
 
94
        }
 
95
        else
 
96
                return g_strdup_printf("%s",cString); // On retourne la phrase d'origine        
 
97
}
 
98
 
 
99
 
 
100
double _Ko_to_Mo (CairoDockModuleInstance *myApplet , double fValueInKo)
 
101
{
 
102
        fValueInKo = fValueInKo / 1024;
 
103
        return fValueInKo;
 
104
}
 
105
 
 
106
double _Ko_to_Go (CairoDockModuleInstance *myApplet , double fValueInKo)
 
107
{
 
108
        fValueInKo = _Ko_to_Mo (myApplet ,fValueInKo);
 
109
        fValueInKo = _Ko_to_Mo (myApplet ,fValueInKo);
 
110
        return fValueInKo;
 
111
}
 
112
 
 
113
 
 
114
void cd_launch_command (CairoDockModuleInstance *myApplet)
 
115
{
 
116
        
 
117
        // SYSTEM-MONITOR
 
118
        myData.bNeedsUpdate = FALSE;    
 
119
        if (myConfig.bShowCpu)
 
120
                cd_sysmonitor_get_cpu_data (myApplet);
 
121
        if (myConfig.bShowRam || myConfig.bShowSwap)
 
122
                cd_sysmonitor_get_ram_data (myApplet);
 
123
        if (myConfig.bShowNvidia)
 
124
        {
 
125
                if ((myData.iTimerCount % 3) == 0)  // la temperature ne varie pas tres vite et le script nvidia-settings est lours, on decide donc de ne mettre a jour qu'une fois sur 3.
 
126
                        cd_sysmonitor_get_nvidia_data (myApplet);
 
127
        }       
 
128
        if (! myData.bInitialized)
 
129
        {
 
130
                cd_sysmonitor_get_cpu_info (myApplet);
 
131
                myData.bInitialized = TRUE;
 
132
        }
 
133
        myData.iTimerCount ++;
 
134
        
 
135
        
 
136
        
 
137
        // Autre :
 
138
        GList *it;
 
139
        TextZone *pTextZone;
 
140
        
 
141
        for (it = myData.pTextZoneList; it != NULL; it = it->next)
 
142
        {
 
143
                pTextZone = it->data;
 
144
                
 
145
                
 
146
                
 
147
                if (!pTextZone->bImgDraw && pTextZone->cImgPath != NULL) // L'image n'a pas encore été chargée
 
148
                {
 
149
                        
 
150
                        if (pTextZone->iWidth == 0 && pTextZone->iHeight ==0) // On n'a pas forcé le ratio
 
151
                        {
 
152
                                if (pTextZone->iImgSize == 0) // Oups !! -> Pas de taille de spécifié -> On en impose une !
 
153
                                        pTextZone->iImgSize = 50;
 
154
                                        
 
155
                                double fImgW=0, fImgH=0;
 
156
                                CairoDockLoadImageModifier iLoadingModifier = 0;  /// CAIRO_DOCK_FILL_SPACE
 
157
                                iLoadingModifier |= CAIRO_DOCK_KEEP_RATIO;
 
158
                                
 
159
                                pTextZone->pImgSurface = cairo_dock_create_surface_from_image (pTextZone->cImgPath,
 
160
                                        1.,
 
161
                                        pTextZone->iImgSize, pTextZone->iImgSize,
 
162
                                        iLoadingModifier,
 
163
                                        &fImgW, &fImgH,
 
164
                                        NULL, NULL);
 
165
                                
 
166
                                //\_______________ On garde l'aire de la surface/texture.                       
 
167
                                pTextZone->iWidth = (int)fImgW;
 
168
                                pTextZone->iHeight = (int)fImgH;
 
169
                        }
 
170
                                                
 
171
                        pTextZone->pImgSurface = cairo_dock_create_surface_for_icon (pTextZone->cImgPath,
 
172
                                        pTextZone->iWidth, pTextZone->iHeight);
 
173
                                        
 
174
                        pTextZone->bImgDraw = TRUE; // L'image est désormais chargée -> On peut la dessiner
 
175
                }
 
176
                
 
177
                
 
178
                
 
179
                
 
180
                                
 
181
                if (pTextZone->iRefresh != 0)
 
182
                                pTextZone->iTimer++;
 
183
                
 
184
                
 
185
                if (pTextZone->bRefresh)
 
186
                {
 
187
                        if (pTextZone->bIsBash) // C'est une commande bash !
 
188
                                pTextZone->cResult = cairo_dock_launch_command_sync (pTextZone->cCommand);
 
189
                        else if (pTextZone->bIsInternal)// C'est une commande interne !
 
190
                        {
 
191
                        
 
192
                                if (strcmp (pTextZone->cCommand, "cpuperc") == 0)
 
193
                                {
 
194
                                        pTextZone->cResult = g_strdup_printf ("%.0f", myData.fCpuPercent);
 
195
                                                                                
 
196
                                        if (atof(pTextZone->cResult) < 10)
 
197
                                                pTextZone->cResult = g_strdup_printf ("%.1f", myData.fCpuPercent);
 
198
                                        else
 
199
                                                pTextZone->cResult = g_strdup_printf ("%.0f", myData.fCpuPercent);
 
200
                                }
 
201
                                
 
202
                                else if (strcmp (pTextZone->cCommand, "cpuperc2f") == 0) // Restreint à 2 chiffres : de 00 à 99 !
 
203
                                {
 
204
                                        pTextZone->cResult = g_strdup_printf ("%.0f", myData.fCpuPercent);
 
205
                                        
 
206
                                        if (atof(pTextZone->cResult) < 10)
 
207
                                                pTextZone->cResult = g_strdup_printf ("0%.0f", myData.fCpuPercent);
 
208
                                        else if (atof(pTextZone->cResult) == 100)
 
209
                                                pTextZone->cResult = g_strdup_printf ("99");
 
210
                                        else
 
211
                                                pTextZone->cResult = g_strdup_printf ("%.0f", myData.fCpuPercent);
 
212
                                }
 
213
                                        
 
214
                                else if (strcmp (pTextZone->cCommand, "memperc") == 0)
 
215
                                {
 
216
                                        pTextZone->cResult = g_strdup_printf ("%.0f", myData.fRamPercent);
 
217
                                        
 
218
                                        if (atof(pTextZone->cResult) < 10)
 
219
                                                pTextZone->cResult = g_strdup_printf ("0%.0f", myData.fRamPercent);
 
220
                                        else if (atof(pTextZone->cResult) == 100)
 
221
                                                pTextZone->cResult = g_strdup_printf ("99");                                            
 
222
                                        else
 
223
                                                pTextZone->cResult = g_strdup_printf ("%.0f", myData.fRamPercent);
 
224
                                }
 
225
                                
 
226
                                else if (strcmp (pTextZone->cCommand, "memperc2f") == 0) // Restreint à 2 chiffres : de 00 à 99 !
 
227
                                {
 
228
                                        pTextZone->cResult = g_strdup_printf ("%.0f", myData.fRamPercent);
 
229
                                        
 
230
                                        if (atof(pTextZone->cResult) < 10)
 
231
                                                pTextZone->cResult = g_strdup_printf ("%.1f", myData.fRamPercent);
 
232
                                        else
 
233
                                                pTextZone->cResult = g_strdup_printf ("%.0f", myData.fRamPercent);
 
234
                                }
 
235
        
 
236
                                                                                
 
237
                                else if (strcmp (pTextZone->cCommand, "mem") == 0) // en Mo
 
238
                                {
 
239
                                        pTextZone->cResult = g_strdup_printf ("%f", _Ko_to_Mo(myApplet, myData.ramTotal /100. * myData.fRamPercent));
 
240
                                        pTextZone->cResult = g_strdup_printf ("%.0f", atof(pTextZone->cResult));
 
241
                                }
 
242
                                
 
243
                                else if (strcmp (pTextZone->cCommand, "memg") == 0) // Identique à mem mais en Go
 
244
                                {
 
245
                                        pTextZone->cResult = g_strdup_printf ("%f", _Ko_to_Go(myApplet, myData.ramTotal /100. * myData.fRamPercent));
 
246
                                        pTextZone->cResult = g_strdup_printf ("%.2f", atof(pTextZone->cResult));
 
247
                                }
 
248
 
 
249
                                else if (strcmp (pTextZone->cCommand, "memmax") == 0) // en Mo
 
250
                                {
 
251
                                        pTextZone->cResult = g_strdup_printf ("%f", _Ko_to_Mo(myApplet, myData.ramTotal));
 
252
                                        pTextZone->cResult = g_strdup_printf ("%.0f", atof(pTextZone->cResult));
 
253
                                }
 
254
                                
 
255
                                else if (strcmp (pTextZone->cCommand, "memmaxg") == 0) // Identique à memmax mais en Go
 
256
                                {
 
257
                                        pTextZone->cResult = g_strdup_printf ("%f", _Ko_to_Go(myApplet, myData.ramTotal));
 
258
                                        pTextZone->cResult = g_strdup_printf ("%.2f", atof(pTextZone->cResult));
 
259
                                }
 
260
                                
 
261
                                                                
 
262
                                else if (strcmp (pTextZone->cCommand, "swapperc") == 0)
 
263
                                {
 
264
                                        pTextZone->cResult = g_strdup_printf ("%.0f", myData.fSwapPercent);
 
265
                                        
 
266
                                        if (atof(pTextZone->cResult) < 10)
 
267
                                                pTextZone->cResult = g_strdup_printf ("%.1f", myData.fSwapPercent);
 
268
                                        else
 
269
                                                pTextZone->cResult = g_strdup_printf ("%.0f", myData.fSwapPercent);                             
 
270
                                }
 
271
                                
 
272
                                else if (strcmp (pTextZone->cCommand, "swapperc2f") == 0) // Restreint à 2 chiffres : de 00 à 99 !
 
273
                                {
 
274
                                        pTextZone->cResult = g_strdup_printf ("%.0f", myData.fSwapPercent);
 
275
                                        
 
276
                                        if (atof(pTextZone->cResult) < 10)
 
277
                                                pTextZone->cResult = g_strdup_printf ("0%.0f", myData.fSwapPercent);
 
278
                                        else if (atof(pTextZone->cResult) == 100)
 
279
                                                pTextZone->cResult = g_strdup_printf ("99");
 
280
                                        else
 
281
                                                pTextZone->cResult = g_strdup_printf ("%.0f", myData.fSwapPercent);
 
282
                                }
 
283
                                
 
284
                                else if (strcmp (pTextZone->cCommand, "swap") == 0) // en Mo
 
285
                                {
 
286
                                        pTextZone->cResult = g_strdup_printf ("%f", _Ko_to_Mo(myApplet, myData.swapUsed));
 
287
                                        
 
288
                                        if (atof(pTextZone->cResult) < 10)
 
289
                                                pTextZone->cResult = g_strdup_printf ("%.2f", atof(pTextZone->cResult));
 
290
                                        else if (atof(pTextZone->cResult) < 100)
 
291
                                                pTextZone->cResult = g_strdup_printf ("%.1f", atof(pTextZone->cResult));
 
292
                                        else
 
293
                                                pTextZone->cResult = g_strdup_printf ("%.0f", atof(pTextZone->cResult));
 
294
                                }
 
295
                                
 
296
                                else if (strcmp (pTextZone->cCommand, "swapg") == 0) // Identique à swap mais en Go
 
297
                                {
 
298
                                        pTextZone->cResult = g_strdup_printf ("%f", _Ko_to_Go(myApplet, myData.swapUsed));
 
299
                                        pTextZone->cResult = g_strdup_printf ("%.2f", atof(pTextZone->cResult));
 
300
                                }
 
301
                                
 
302
                                else if (strcmp (pTextZone->cCommand, "swapmax") == 0) // en Mo
 
303
                                {
 
304
                                        pTextZone->cResult = g_strdup_printf ("%f", _Ko_to_Mo(myApplet, myData.swapTotal));
 
305
                                        pTextZone->cResult = g_strdup_printf ("%.0f", atof(pTextZone->cResult));
 
306
                                }
 
307
                                
 
308
                                else if (strcmp (pTextZone->cCommand, "swapmaxg") == 0) // Identique à swapmax mais en Go
 
309
                                {
 
310
                                        pTextZone->cResult = g_strdup_printf ("%f", _Ko_to_Go(myApplet, myData.swapTotal));
 
311
                                        pTextZone->cResult = g_strdup_printf ("%.2f", atof(pTextZone->cResult));
 
312
                                }
 
313
                                
 
314
                                
 
315
                                
 
316
                                else if (strcmp (pTextZone->cCommand, "nvtemp") == 0)
 
317
                                {
 
318
                                        myConfig.bShowNvidia = TRUE;
 
319
                                        pTextZone->cResult = g_strdup_printf ("%i", myData.iGPUTemp);
 
320
                                }
 
321
                                        
 
322
                                else if (strcmp (pTextZone->cCommand, "nvname") == 0)
 
323
                                {
 
324
                                        myConfig.bShowNvidia = TRUE;
 
325
                                        cd_sysmonitor_get_nvidia_info (myApplet);                                       
 
326
                                        pTextZone->cResult = g_strdup_printf ("%s", myData.cGPUName);                                   
 
327
                                }
 
328
                                
 
329
                                else if (strcmp (pTextZone->cCommand, "nvdriver") == 0)
 
330
                                {
 
331
                                        myConfig.bShowNvidia = TRUE;
 
332
                                        cd_sysmonitor_get_nvidia_info (myApplet);                                       
 
333
                                        pTextZone->cResult = g_strdup_printf ("%s", myData.cDriverVersion);                                     
 
334
                                }
 
335
                                
 
336
                                else if (strcmp (pTextZone->cCommand, "nvram") == 0)
 
337
                                {
 
338
                                        myConfig.bShowNvidia = TRUE;
 
339
                                        cd_sysmonitor_get_nvidia_info (myApplet);                                       
 
340
                                        pTextZone->cResult = g_strdup_printf ("%i", myData.iVideoRam);                                  
 
341
                                }
 
342
                                
 
343
                                
 
344
                                
 
345
                                
 
346
                                else if (strcmp (pTextZone->cCommand, "uptime") == 0)
 
347
                                {
 
348
                                        gchar *cUpTime = NULL, *cActivityTime = NULL;
 
349
                                        cd_sysmonitor_get_uptime (&cUpTime, &cActivityTime);            
 
350
                                        pTextZone->cResult = g_strdup_printf ("%s", cUpTime);                   
 
351
                                }
 
352
                                
 
353
                                else if (strcmp (pTextZone->cCommand, "fs_size") == 0)
 
354
                                {
 
355
                                        if (strcmp (pTextZone->cMountPoint, "") != 0)
 
356
                                                pTextZone->cResult = g_strdup_printf ("%s", cd_doncky_get_disk_info (pTextZone->cMountPoint, 0));
 
357
                                }
 
358
                                
 
359
                                else if (strcmp (pTextZone->cCommand, "fs_free") == 0)
 
360
                                        pTextZone->cResult = g_strdup_printf ("%s", cd_doncky_get_disk_info (pTextZone->cMountPoint, 1));
 
361
                                        
 
362
                                else if (strcmp (pTextZone->cCommand, "fs_used") == 0)
 
363
                                        pTextZone->cResult = g_strdup_printf ("%s", cd_doncky_get_disk_info (pTextZone->cMountPoint, 2));
 
364
                                
 
365
                                else if (strcmp (pTextZone->cCommand, "fs_freeperc") == 0)
 
366
                                        pTextZone->cResult = g_strdup_printf ("%s", cd_doncky_get_disk_info (pTextZone->cMountPoint, 3));
 
367
                                
 
368
                                else if (strcmp (pTextZone->cCommand, "fs_usedperc") == 0)
 
369
                                {
 
370
                                        if (strcmp (pTextZone->cMountPoint, "") == 0 || pTextZone->cMountPoint == NULL)
 
371
                                                pTextZone->cMountPoint = g_strdup_printf ("/"); 
 
372
                                        pTextZone->cResult = g_strdup_printf ("%s", cd_doncky_get_disk_info (pTextZone->cMountPoint, 4));
 
373
                                }
 
374
                                
 
375
                                else if (strcmp (pTextZone->cCommand, "fs_type") == 0)
 
376
                                        pTextZone->cResult = g_strdup_printf ("%s", cd_doncky_get_disk_info (pTextZone->cMountPoint, 5));
 
377
                                
 
378
                                else if (strcmp (pTextZone->cCommand, "fs_device") == 0)
 
379
                                        pTextZone->cResult = g_strdup_printf ("%s", cd_doncky_get_disk_info (pTextZone->cMountPoint, 6));                               
 
380
                                
 
381
                        }                       
 
382
                }
 
383
        }       
 
384
}
 
385
 
 
386
gboolean cd_retrieve_command_result (CairoDockModuleInstance *myApplet)
 
387
{
 
388
        
 
389
        // SYSTEM-MONITOR
 
390
        static double s_fValues[CD_SYSMONITOR_NB_MAX_VALUES];
 
391
        CD_APPLET_ENTER;
 
392
        
 
393
        if ( ! myData.bAcquisitionOK)
 
394
        {
 
395
                cd_warning ("One or more datas couldn't be retrieved"); 
 
396
                memset (s_fValues, 0, sizeof (s_fValues));
 
397
                CD_APPLET_RENDER_NEW_DATA_ON_MY_ICON (s_fValues);
 
398
        }
 
399
        else
 
400
        {
 
401
                if (! myData.bInitialized)
 
402
                {
 
403
                        memset (s_fValues, 0, sizeof (s_fValues));
 
404
                        CD_APPLET_RENDER_NEW_DATA_ON_MY_ICON (s_fValues);
 
405
                }
 
406
                else
 
407
                {
 
408
                        // Copier les donnes en memoire partagee...
 
409
                        
 
410
                        //~ if (myConfig.iInfoDisplay == CAIRO_DOCK_INFO_ON_ICON || (myDock && myConfig.iInfoDisplay == CAIRO_DOCK_INFO_ON_LABEL))  // on affiche les valeurs soit en info-rapide, soit sur l'etiquette en mode dock.
 
411
                        //~ {
 
412
                                //~ gboolean bOneLine = (myConfig.iInfoDisplay == CAIRO_DOCK_INFO_ON_LABEL);
 
413
                                //~ GString *sInfo = g_string_new ("");
 
414
                                //~ if (myConfig.bShowCpu)
 
415
                                //~ {
 
416
                                        //~ g_string_printf (sInfo, (myData.fCpuPercent < 10 ? "%s%.1f%%%s" : "%s%.0f%%%s"),
 
417
                                                //~ (myDesklet ? "CPU:" : ""),
 
418
                                                //~ myData.fCpuPercent,
 
419
                                                //~ (bOneLine ? " - " : "\n"));
 
420
                                //~ }
 
421
                                //~ if (myConfig.bShowRam)
 
422
                                //~ {
 
423
                                        //~ g_string_append_printf (sInfo, (myData.fRamPercent < 10 ? "%s%.1f%%%s" : "%s%.0f%%%s"),
 
424
                                                //~ (myDesklet ? "RAM:" : ""),
 
425
                                                //~ myData.fRamPercent,
 
426
                                                //~ (bOneLine ? " - " : "\n"));
 
427
                                //~ }
 
428
                                //~ if (myConfig.bShowSwap)
 
429
                                //~ {
 
430
                                        //~ g_string_append_printf (sInfo, (myData.fSwapPercent < 10 ? "%s%.1f%%%s" : "%s%.0f%%%s"),
 
431
                                                //~ (myDesklet ? "SWAP:" : ""),
 
432
                                                //~ myData.fSwapPercent,
 
433
                                                //~ (bOneLine ? " - " : "\n"));
 
434
                                //~ }
 
435
                                //~ if (myConfig.bShowNvidia)
 
436
                                //~ {
 
437
                                        //~ g_string_append_printf (sInfo, "%s%d°C%s",
 
438
                                                //~ (myDesklet ? "GPU:" : ""),
 
439
                                                //~ myData.iGPUTemp,
 
440
                                                //~ (bOneLine ? " - " : "\n"));
 
441
                                //~ }
 
442
                                //~ sInfo->str[sInfo->len-(bOneLine?3:1)] = '\0';
 
443
                                //~ if (bOneLine)
 
444
                                        //~ CD_APPLET_SET_NAME_FOR_MY_ICON (sInfo->str);
 
445
                                //~ else
 
446
                                        //~ CD_APPLET_SET_QUICK_INFO_ON_MY_ICON (sInfo->str);
 
447
                                //~ g_string_free (sInfo, TRUE);
 
448
                        //~ }
 
449
                        
 
450
                        if (myData.bNeedsUpdate || myConfig.iDisplayType == CD_SYSMONITOR_GRAPH)
 
451
                        {
 
452
                                int i = 0;
 
453
                                if (myConfig.bShowCpu)
 
454
                                {
 
455
                                        s_fValues[i++] = myData.fCpuPercent / 100.;
 
456
                                }
 
457
                                if (myConfig.bShowRam)
 
458
                                {
 
459
                                        s_fValues[i++] = myData.fRamPercent / 100.;
 
460
                                }
 
461
                                if (myConfig.bShowSwap)
 
462
                                        s_fValues[i++] = (myData.swapTotal ? ((double)myData.swapUsed) / myData.swapTotal : 0.);
 
463
                                if (myConfig.bShowNvidia)
 
464
                                        s_fValues[i++] = myData.fGpuTempPercent / 100.;
 
465
                                
 
466
                                CD_APPLET_RENDER_NEW_DATA_ON_MY_ICON (s_fValues);
 
467
                        }
 
468
                }
 
469
        }
 
470
        
 
471
        
 
472
        
 
473
        // Autre :
 
474
        
 
475
        GList *it;
 
476
        TextZone *pTextZone;
 
477
        
 
478
 
 
479
        for (it = myData.pTextZoneList; it != NULL; it = it->next)
 
480
        {
 
481
                pTextZone = it->data;
 
482
                        
 
483
                if (pTextZone->iRefresh != 0 || pTextZone->bRefresh)
 
484
                {
 
485
                        if (pTextZone->bRefresh && pTextZone->cResult != NULL)
 
486
                        {
 
487
                                pTextZone->cText = g_strdup_printf ("%s",pTextZone->cResult);
 
488
                        }
 
489
                                                    
 
490
                        if (pTextZone->iRefresh != 0 && pTextZone->iTimer >= pTextZone->iRefresh)
 
491
                        {
 
492
                                pTextZone->bRefresh = TRUE;
 
493
                                pTextZone->iTimer = 0; // On remet le timer à 0
 
494
                        }
 
495
                        else // Pas de refresh de spécifié
 
496
                        {
 
497
                                
 
498
                                if (pTextZone->cText == NULL || strcmp (pTextZone->cText, "") == 0) // La récupération s'est mal passé -> On relance !
 
499
                                        pTextZone->bRefresh = TRUE;
 
500
                                else                    
 
501
                                        pTextZone->bRefresh = FALSE; // On a récupéré l'info -> On arrête là !
 
502
                        }
 
503
                }       
 
504
        }
 
505
        cd_applet_update_my_icon (myApplet); // Quand tous les textes sont chargés, on peut dessiner
 
506
        myData.pPeriodicRefreshTask = NULL;
 
507
                
 
508
        CD_APPLET_LEAVE (myData.bAcquisitionOK);
 
509
}
 
510
 
 
511
 
 
512
void cd_applet_draw_my_desklet (CairoDockModuleInstance *myApplet, int iWidth, int iHeight)
 
513
{
 
514
        PangoLayout *pLayout = pango_cairo_create_layout (myDrawContext);
 
515
        PangoRectangle ink, log;
 
516
        
 
517
        // On efface la surface cairo actuelle
 
518
        cairo_dock_erase_cairo_context (myDrawContext); 
 
519
        
 
520
        // dessin du fond (optionnel).
 
521
        if (myConfig.bDisplayBackground)
 
522
        {
 
523
                cairo_save (myDrawContext);
 
524
                cairo_translate (myDrawContext,
 
525
                        .5*myConfig.iBorderThickness,
 
526
                        .5*myConfig.iBorderThickness);          
 
527
                cairo_pattern_t *pGradationPattern = cairo_pattern_create_linear (0.,
 
528
                        0.,
 
529
                        0.,
 
530
                        iHeight);
 
531
                cairo_pattern_add_color_stop_rgba (pGradationPattern,
 
532
                        0.,
 
533
                        myConfig.fBackgroundColor1[0],
 
534
                        myConfig.fBackgroundColor1[1],
 
535
                        myConfig.fBackgroundColor1[2],
 
536
                        myConfig.fBackgroundColor1[3]);
 
537
                cairo_pattern_add_color_stop_rgba (pGradationPattern,
 
538
                        1.,
 
539
                        myConfig.fBackgroundColor2[0],
 
540
                        myConfig.fBackgroundColor2[1],
 
541
                        myConfig.fBackgroundColor2[2],
 
542
                        myConfig.fBackgroundColor2[3]);
 
543
                cairo_set_source (myDrawContext, pGradationPattern);
 
544
                
 
545
                if (myConfig.iBackgroundRadius != 0)  // On a besoin d'un rayon
 
546
                {
 
547
                        cairo_dock_draw_rounded_rectangle (myDrawContext,
 
548
                                myConfig.iBackgroundRadius,
 
549
                                0.,
 
550
                                iWidth - myConfig.iBorderThickness - 2 * myConfig.iBackgroundRadius,
 
551
                                iHeight - myConfig.iBorderThickness);
 
552
                }
 
553
                else  // Il ne faut pas de rayon
 
554
                {
 
555
                        cairo_rectangle (myDrawContext,
 
556
                                0., 0.,
 
557
                                iWidth - myConfig.iBorderThickness,
 
558
                                iHeight - myConfig.iBorderThickness);
 
559
                }
 
560
                cairo_fill (myDrawContext);
 
561
                cairo_pattern_destroy (pGradationPattern);
 
562
                cairo_restore (myDrawContext);
 
563
        }
 
564
        
 
565
        
 
566
        
 
567
        // ################################################################################################################################################################
 
568
        // ############ DEBUT DU DESSIN DU TEXTE
 
569
        // ################################################################################################################################################################
 
570
        
 
571
        int iMargin = .5 * myConfig.iBorderThickness + (1. - sqrt (2) / 2) * myConfig.iBackgroundRadius;  // marge a gauche et au-dessus, pour ne pas mordre sur le coin arrondi.       
 
572
        int iSpaceBetweenElements = 8; // Décalage horizontal entre les barres et les autres éléments <- Sinon, tout est collé et c'est pô bô ! :-D
 
573
        
 
574
        myData.fCurrentX = iMargin + myConfig.iTextMargin;  // position du curseur sur la ligne.
 
575
        myData.fCurrentY = iMargin + myConfig.iTextMargin;  // position de la ligne courante.
 
576
        
 
577
        GList *it = myData.pTextZoneList;
 
578
        TextZone *pTextZone;
 
579
        
 
580
        GList *it1;
 
581
        gboolean bFirstPass=TRUE;
 
582
 
 
583
        double fCurrentLineWidth = 0; // Dimension de la ligne complète (= avec plusieurs zones de textes)
 
584
        double fCurrentLineHeight = 0;
 
585
        gboolean bFirstTextInLine = TRUE;
 
586
        
 
587
        
 
588
        if (myData.pTextZoneList == NULL)
 
589
                return;
 
590
        
 
591
        it = myData.pTextZoneList;
 
592
        do
 
593
        {
 
594
                it1=it;
 
595
                
 
596
                //\_______ boucle sur it de it1 jusqu'à retour chariot => LINE_WIDTH & LINE_HEIGHT
 
597
                do 
 
598
                {
 
599
                        pTextZone = it->data;
 
600
                        
 
601
                        if (pTextZone->cFont == NULL || pTextZone->cFont =="") // Si aucune font -> on prend celle de la config
 
602
                                pTextZone->cFont = g_strdup_printf("%s", myConfig.cDefaultFont);                        
 
603
                                                
 
604
                        if (pTextZone->cText != NULL && ! (pTextZone->bBar || pTextZone->bLimitedBar || pTextZone->bImgDraw))
 
605
                        {
 
606
                                PangoFontDescription *fd = pango_font_description_from_string (pTextZone->cFont);
 
607
                                pango_layout_set_font_description (pLayout, fd);
 
608
                                pango_font_description_free (fd);
 
609
                                
 
610
                                // On récupère la largeur d'un espace pour caler le texte à droite
 
611
                                pango_layout_set_text (pLayout, " ", -1);
 
612
                                pango_layout_get_pixel_extents (pLayout, &ink, &log);
 
613
                                pTextZone->iFontSizeWidth = (int)log.width;
 
614
                                pTextZone->iFontSizeHeight = (int)log.height;
 
615
                                
 
616
                                // On récupère la largeur du texte à afficher
 
617
                                pango_layout_set_text (pLayout, pTextZone->cText, -1);
 
618
                                pango_layout_get_pixel_extents (pLayout, &ink, &log);                           
 
619
                                fCurrentLineWidth += log.width;
 
620
                                
 
621
                                if (log.height > fCurrentLineHeight && ! myData.bLastWasSameLine)
 
622
                                        fCurrentLineHeight = log.height;
 
623
                                else if (myData.bLastWasSameLine)
 
624
                                        fCurrentLineHeight = (double)myData.iLastLineHeight;
 
625
                                
 
626
                        }                       
 
627
                        else if (pTextZone->bLimitedBar || pTextZone->bImgDraw || pTextZone->bBar )
 
628
                        {
 
629
                                fCurrentLineWidth += pTextZone->iWidth;
 
630
                                
 
631
                                if ( (pTextZone->iHeight > fCurrentLineHeight) && ! myData.bLastWasSameLine)
 
632
                                        fCurrentLineHeight = (double)pTextZone->iHeight;
 
633
                                else if (myData.bLastWasSameLine)
 
634
                                        fCurrentLineHeight = (double)myData.iLastLineHeight;
 
635
                        }
 
636
                                                                        
 
637
                        it = it->next;
 
638
                } while (it != NULL && ! pTextZone->bEndOfLine);
 
639
                
 
640
                
 
641
                
 
642
                
 
643
                //\_______ boucle sur it de it1 jusqu'à retour chariot => DESSIN
 
644
                it = it1;
 
645
                do
 
646
                {
 
647
        
 
648
                        pTextZone = it->data;
 
649
                        
 
650
                        
 
651
                        
 
652
                        
 
653
                        
 
654
                        
 
655
                
 
656
                        
 
657
                        
 
658
                        
 
659
                        
 
660
                        
 
661
                        
 
662
                        
 
663
                        
 
664
                        
 
665
                        
 
666
                        
 
667
                        
 
668
                        
 
669
                        
 
670
                        
 
671
                        
 
672
                        
 
673
                        
 
674
                        
 
675
                        
 
676
                        
 
677
                        
 
678
                        
 
679
                        
 
680
                        
 
681
                        
 
682
                        
 
683
                                                
 
684
                        if (pTextZone->cFont == NULL || pTextZone->cFont =="") // Si aucune font -> on prend celle de la config
 
685
                                pTextZone->cFont = g_strdup_printf("%s", myConfig.cDefaultFont);
 
686
                        
 
687
                        
 
688
                         // On calcule le décalage WIDTH nécéssaire pour respecter l'alignement sur la largeur souhaité
 
689
                        if (bFirstTextInLine)
 
690
                        {
 
691
                                int iWidth, iHeight;
 
692
                                CD_APPLET_GET_MY_ICON_EXTENT (&iWidth, &iHeight);
 
693
                                
 
694
                                if (strcmp (pTextZone->cAlignWidth, "left") == 0)
 
695
                                        myData.fCurrentX = iMargin + myConfig.iTextMargin;
 
696
                                else if (strcmp (pTextZone->cAlignWidth, "center") == 0)
 
697
                                {
 
698
                                        if (pTextZone->cImgPath != NULL)
 
699
                                                myData.fCurrentX = (iWidth/2) - (pTextZone->iWidth/2);
 
700
                                        else
 
701
                                                myData.fCurrentX = (iWidth/2)- (fCurrentLineWidth/2);
 
702
                                }
 
703
                                else if (strcmp (pTextZone->cAlignWidth, "right") == 0)
 
704
                                {
 
705
                                        if (pTextZone->cImgPath != NULL)
 
706
                                                myData.fCurrentX = iWidth - iMargin - myConfig.iTextMargin - pTextZone->iWidth - pTextZone->iFontSizeWidth;
 
707
                                        else
 
708
                                                myData.fCurrentX = iWidth - iMargin - myConfig.iTextMargin - fCurrentLineWidth - pTextZone->iFontSizeWidth;
 
709
                                        
 
710
                                }
 
711
                                
 
712
                                if (pTextZone->bBar)
 
713
                                         myData.fCurrentX -= iSpaceBetweenElements ; // Il y a un élément avant la barre -> On supprime l'espace
 
714
                        }
 
715
                        
 
716
                        
 
717
                        if (! bFirstTextInLine)
 
718
                                pTextZone->cAlignHeight = g_strdup_printf("%s", myData.cLastAlignHeight); // On récupère l'alignement de la ligne (=l'alignement du 1er élément)
 
719
                        else
 
720
                                myData.cLastAlignHeight = g_strdup_printf("%s", pTextZone->cAlignHeight); // On mémorise l'aligenement du 1er élément de la ligne
 
721
                                
 
722
                        // On calcule le décalage HEIGHT nécéssaire pour respecter l'alignement sur la hauteur souhaité         
 
723
                        if (strcmp (pTextZone->cAlignHeight, "middle") == 0)
 
724
                        {
 
725
                                if (pTextZone->cImgPath != NULL || pTextZone->bBar || pTextZone->bLimitedBar )
 
726
                                        myData.fCurrentYalign = myData.fCurrentY + fCurrentLineHeight/2 - pTextZone->iHeight/2; 
 
727
                                else // C'est un texte -> On décale un peu pour aligner
 
728
                                        myData.fCurrentYalign = myData.fCurrentY  + fCurrentLineHeight/2 - pTextZone->iFontSizeHeight/2;
 
729
                        }                       
 
730
                        else if (strcmp (pTextZone->cAlignHeight, "low") == 0)
 
731
                        {
 
732
                                if (pTextZone->cImgPath != NULL || pTextZone->bBar || pTextZone->bLimitedBar )
 
733
                                        myData.fCurrentYalign = myData.fCurrentY + fCurrentLineHeight - pTextZone->iHeight;
 
734
                                else // C'est un texte -> On décale un peu pour aligner
 
735
                                        myData.fCurrentYalign = myData.fCurrentY + fCurrentLineHeight - pTextZone->iFontSizeHeight;
 
736
                        }
 
737
                        else if (strcmp (pTextZone->cAlignHeight, "top") == 0)
 
738
                        {
 
739
                                if (pTextZone->cImgPath != NULL || pTextZone->bBar || pTextZone->bLimitedBar )
 
740
                                        myData.fCurrentYalign = myData.fCurrentY; // On laisse à la position courante
 
741
                                else // C'est un texte -> On décale un peu pour aligner
 
742
                                        myData.fCurrentYalign = myData.fCurrentY;
 
743
                        }
 
744
                        
 
745
                        
 
746
                        PangoFontDescription *fd = pango_font_description_from_string (pTextZone->cFont);
 
747
                        pango_layout_set_font_description (pLayout, fd);
 
748
                        pango_font_description_free (fd);
 
749
                        
 
750
                        
 
751
                        if (pTextZone->fTextColor[3]== 0 && pTextZone->cText != NULL) // Si aucune couleur alors qu'un texte est défini -> on prend celle de la config
 
752
                                cairo_set_source_rgba (myDrawContext, myConfig.fDefaultTextColor[0], myConfig.fDefaultTextColor[1], myConfig.fDefaultTextColor[2], myConfig.fDefaultTextColor[3]);
 
753
                        else // sinon, on utilise la couleur du .xml
 
754
                                cairo_set_source_rgba (myDrawContext, pTextZone->fTextColor[0], pTextZone->fTextColor[1], pTextZone->fTextColor[2], pTextZone->fTextColor[3]);
 
755
                        
 
756
                        
 
757
                        if (pTextZone->cText != NULL)
 
758
                                pango_layout_set_text (pLayout, pTextZone->cText, -1);
 
759
                        else
 
760
                                pango_layout_set_text (pLayout,"", -1);
 
761
                        pango_layout_get_pixel_extents (pLayout, &ink, &log);
 
762
                        
 
763
                        
 
764
                        if (pTextZone->bBar || pTextZone->bLimitedBar) // On dessine la barre
 
765
                        {
 
766
                                int value;
 
767
                                if (pTextZone->bBar)
 
768
                                {
 
769
                                        int iWidth, iHeight;
 
770
                                        CD_APPLET_GET_MY_ICON_EXTENT (&iWidth, &iHeight);
 
771
                                        if (bFirstTextInLine)
 
772
                                                pTextZone->iWidth =  iWidth - iMargin*2 - myConfig.iTextMargin*2;
 
773
                                        else
 
774
                                                pTextZone->iWidth =  iWidth - myData.fCurrentX - iMargin - myConfig.iTextMargin  - iSpaceBetweenElements;
 
775
                                }
 
776
                                
 
777
                                int i;
 
778
                                for (i=0 ; i < 2 ; i++)
 
779
                                {
 
780
                                        if (i==0)
 
781
                                        {
 
782
                                                myData.cCurrentText = g_strdup_printf ("%s",pTextZone->cText); // Sinon, çà plante à la ligne d'en dessous
 
783
                                                value = (int)((atof(myData.cCurrentText) / 100)*pTextZone->iWidth);                                             
 
784
                                        }
 
785
                                        else
 
786
                                                value = pTextZone->iWidth;
 
787
                                        
 
788
                                        // On dessine la valeur PUIS le cadre                                                   
 
789
                                        cairo_save (myDrawContext);
 
790
                                        
 
791
                                        if (pTextZone->fTextColor[3]== 0 && pTextZone->cText != NULL) // Si aucune couleur
 
792
                                                cairo_set_source_rgba (myDrawContext,
 
793
                                                        myConfig.fDefaultTextColor[0],
 
794
                                                        myConfig.fDefaultTextColor[1],
 
795
                                                        myConfig.fDefaultTextColor[2],
 
796
                                                        myConfig.fDefaultTextColor[3]);
 
797
                                        else
 
798
                                                cairo_set_source_rgba (myDrawContext,
 
799
                                                        pTextZone->fTextColor[0],
 
800
                                                        pTextZone->fTextColor[1],
 
801
                                                        pTextZone->fTextColor[2],
 
802
                                                        pTextZone->fTextColor[3]);
 
803
                                                                                        
 
804
                                        cairo_set_line_width (myDrawContext, 0.5);
 
805
                                        
 
806
                                        if (pTextZone->bBar)
 
807
                                                cairo_translate (myDrawContext,
 
808
                                                        myData.fCurrentX + iSpaceBetweenElements + myData.iPrevOverrideW,
 
809
                                                        myData.fCurrentYalign + myData.iPrevOverrideH);
 
810
                                        else
 
811
                                                cairo_translate (myDrawContext,
 
812
                                                        myData.fCurrentX + myData.iPrevOverrideW,
 
813
                                                        myData.fCurrentYalign + myData.iPrevOverrideH);
 
814
                                        
 
815
                                        cairo_dock_draw_rounded_rectangle (myDrawContext,
 
816
                                                0,
 
817
                                                0.,
 
818
                                                value,
 
819
                                                pTextZone->iHeight);
 
820
                                        
 
821
                                        if (i==0)
 
822
                                                cairo_fill (myDrawContext);
 
823
                                        else
 
824
                                                cairo_stroke (myDrawContext);
 
825
                                        cairo_restore (myDrawContext);                                  
 
826
                                }
 
827
                        }
 
828
                        
 
829
                        
 
830
                        else if (pTextZone->bImgDraw) // Il y a une image
 
831
                        {
 
832
                                if (pTextZone->pImgSurface != NULL)
 
833
                                {
 
834
                                        cairo_set_source_surface (myDrawContext, pTextZone->pImgSurface,
 
835
                                                        myData.fCurrentX + myData.iPrevOverrideW,
 
836
                                                        myData.fCurrentYalign + myData.iPrevOverrideH);
 
837
                                        cairo_paint (myDrawContext);
 
838
                                }                       
 
839
                        }
 
840
                        else // C'est un texte !
 
841
                        {
 
842
                                cairo_move_to (myDrawContext,
 
843
                                        myData.fCurrentX + myData.iPrevOverrideW,
 
844
                                        myData.fCurrentYalign + myData.iPrevOverrideH);
 
845
                                pango_cairo_show_layout (myDrawContext, pLayout); // On dessine la ligne sur notre desklet
 
846
                        }
 
847
                                
 
848
                        if (pTextZone->bEndOfLine) // On passe à la ligne du dessous
 
849
                        {
 
850
                                if (pTextZone->bNextNewLine) // C'est un <br/> (ou un <br>0</br> )-> On passe à la ligne d'en dessous
 
851
                                {
 
852
                                        myData.fCurrentY += fCurrentLineHeight + myConfig.iSpaceBetweenLines + pTextZone->iSpaceBetweenLines;
 
853
                                        myData.bLastWasSameLine = FALSE;
 
854
                                }
 
855
                                else  // C'est un <nbr/> -> on reste sur la même ligne -> Utile pour avoir 1 zone alignée à gauche et 1 zone alignée à droite par exemple ;-)
 
856
                                {
 
857
                                        myData.iLastLineHeight = (int)fCurrentLineHeight + pTextZone->iSpaceBetweenLines;                                       
 
858
                                        myData.bLastWasSameLine = TRUE;
 
859
                                }
 
860
                                                                                                
 
861
                                myData.fCurrentX = iMargin + myConfig.iTextMargin;
 
862
                                
 
863
                                bFirstTextInLine = TRUE;
 
864
                                fCurrentLineWidth = 0; // On remet la largeur de ligne à 0 pour le prochain calcul
 
865
                                fCurrentLineHeight = 0; // On remet la hauteur de ligne à 0 pour le prochain calcul
 
866
                        }
 
867
                        else // On laisse le curseur à la position actuelle
 
868
                        {
 
869
                                if (pTextZone->bBar || pTextZone->bLimitedBar || pTextZone->bImgDraw)  // On prend en compte un éventuelle barre ou une image
 
870
                                        myData.fCurrentX += pTextZone->iWidth;                          
 
871
                                else  // valable pour les textes
 
872
                                {
 
873
                                        double w;
 
874
                                        pango_layout_get_pixel_extents (pLayout, &ink, &log);
 
875
                                
 
876
                                        w = log.width + log.x;
 
877
                                        myData.fCurrentX += w;
 
878
                                }
 
879
                                
 
880
                                bFirstTextInLine = FALSE;
 
881
                        } 
 
882
                        
 
883
                        
 
884
                        if (pTextZone->iOverrideH != 0)
 
885
                                myData.iPrevOverrideH = pTextZone->iOverrideH;
 
886
                        else
 
887
                                myData.iPrevOverrideH = 0;
 
888
                        if (pTextZone->iOverrideW != 0)
 
889
                                myData.iPrevOverrideW = pTextZone->iOverrideW;
 
890
                        else
 
891
                                myData.iPrevOverrideW = 0;
 
892
                        
 
893
                        it = it->next;
 
894
                } while (it != NULL && ! pTextZone->bEndOfLine);
 
895
                
 
896
                
 
897
                
 
898
        } while (it != NULL);
 
899
        
 
900
        // ################################################################################################################################################################
 
901
        // ############ FIN DU DESSIN DU TEXTE
 
902
        // ################################################################################################################################################################
 
903
        
 
904
        
 
905
        // dessin du cadre (optionnel).
 
906
        if (myConfig.bDisplayBackground)
 
907
        {
 
908
                cairo_save (myDrawContext);
 
909
                cairo_set_source_rgba (myDrawContext,
 
910
                        myConfig.fBorderColor[0],
 
911
                        myConfig.fBorderColor[1],
 
912
                        myConfig.fBorderColor[2],
 
913
                        myConfig.fBorderColor[3]);
 
914
                cairo_set_line_width (myDrawContext, myConfig.iBorderThickness);
 
915
                cairo_translate (myDrawContext,
 
916
                        .5*myConfig.iBorderThickness,
 
917
                        .5*myConfig.iBorderThickness);
 
918
                cairo_dock_draw_rounded_rectangle (myDrawContext,
 
919
                        myConfig.iBackgroundRadius,
 
920
                        0.,
 
921
                        iWidth - 2*myConfig.iBackgroundRadius - myConfig.iBorderThickness,
 
922
                        iHeight - myConfig.iBorderThickness);
 
923
                cairo_stroke (myDrawContext);
 
924
                cairo_restore (myDrawContext);
 
925
        }
 
926
        
 
927
        g_object_unref (pLayout);
 
928
        
 
929
        
 
930
        // on met a jour la texture OpenGL.
 
931
        if (CD_APPLET_MY_CONTAINER_IS_OPENGL)
 
932
        {
 
933
                cairo_dock_update_icon_texture (myIcon);
 
934
        }
 
935
}
 
936
 
 
937
 
 
938
void cd_applet_update_my_icon (CairoDockModuleInstance *myApplet)
 
939
{
 
940
        //~ if (myDesklet)
 
941
        //~ {
 
942
                // taille de la texture.
 
943
                int iWidth, iHeight;
 
944
                CD_APPLET_GET_MY_ICON_EXTENT (&iWidth, &iHeight);
 
945
                
 
946
                cd_applet_draw_my_desklet (myApplet, iWidth, iHeight);          
 
947
                
 
948
                CD_APPLET_REDRAW_MY_ICON;
 
949
        //~ }
 
950
}