2
* This file is a part of the Cairo-Dock project
4
* Copyright : (C) see the 'copyright' file.
5
* E-mail : see the 'copyright' file.
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.
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/>.
20
//\________________ Add your name in the copyright file (and / or modify your name here)
22
#include <cairo-dock.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"
31
char* ltrim( char* str, const char* t ) // Couper tout depuis la gauche
35
char look[ 256 ] = { 1, 0 };
37
look[ (unsigned char)*t++ ] = 1;
40
while( *curStr && look[ *curStr ] )
42
strcpy( str, curStr );
47
char* rtrim( char* str, const char* t ) // Couper tout depuis la droite
49
char* curEnd = str, *end = str;
51
char look[ 256 ] = { 1, 0 };
53
look[ (unsigned char)*t++ ] = 1;
68
double _Ko_to_Mo (CairoDockModuleInstance *myApplet , double fValueInKo)
70
fValueInKo = fValueInKo / 1024;
74
double _Ko_to_Go (CairoDockModuleInstance *myApplet , double fValueInKo)
76
fValueInKo = _Ko_to_Mo (myApplet ,fValueInKo);
77
fValueInKo = _Ko_to_Mo (myApplet ,fValueInKo);
82
gchar* _AdjustPrecision0 (CairoDockModuleInstance *myApplet , double fValue)
88
iInteger = (int)fValue;
89
iDecimal = (int)((fValue-iInteger)*10);
94
cReturnValue = g_strdup_printf ("%i", iInteger);
97
g_free (cReturnValue);
100
gchar* _AdjustPrecision1 (CairoDockModuleInstance *myApplet , double fValue)
107
iAfterDecimal = (int)(((fValue*10)-(int)(fValue*10))*10);
108
iInteger = (int)fValue;
109
iDecimal = (int)((fValue-iInteger)*10);
111
if (iAfterDecimal >= 5)
114
cReturnValue = g_strdup_printf ("%i.0", iInteger+1);
116
cReturnValue = g_strdup_printf ("%i.%i", iInteger, iDecimal);
119
g_free (cReturnValue);
122
gchar* _AdjustPrecision2 (CairoDockModuleInstance *myApplet , double fValue)
129
iAfterDecimal = (int)(((fValue*100)-(int)(fValue*100))*10);
130
iInteger = (int)fValue;
131
iDecimal = (int)((fValue-iInteger)*100);
133
if (iAfterDecimal >= 5)
136
cReturnValue = g_strdup_printf ("%i.00", iInteger+1);
140
cReturnValue = g_strdup_printf ("%i.0%i", iInteger, iDecimal);
142
cReturnValue = g_strdup_printf ("%i.%i", iInteger, iDecimal);
146
g_free (cReturnValue);
150
void cd_doncky_periodic_refresh (CairoDockModuleInstance *myApplet)
152
myData.pPeriodicRefreshTask = cairo_dock_new_task (0,
153
(CairoDockGetDataAsyncFunc) cd_launch_command,
154
(CairoDockUpdateSyncFunc) cd_retrieve_command_result,
156
cairo_dock_launch_task (myData.pPeriodicRefreshTask);
160
void cd_launch_command (CairoDockModuleInstance *myApplet)
166
for (it = myData.pTextZoneList; it != NULL; it = it->next)
168
pTextZone = it->data;
170
if (!pTextZone->bImgDraw && pTextZone->cImgPath != NULL) // L'image n'a pas encore été chargée
173
if (pTextZone->iWidth == 0 && pTextZone->iHeight ==0) // On n'a pas forcé le ratio
175
if (pTextZone->iImgSize == 0) // Oups !! -> Pas de taille de spécifié -> On en impose une !
176
pTextZone->iImgSize = 50;
178
double fImgW=0, fImgH=0;
179
CairoDockLoadImageModifier iLoadingModifier = 0; /// CAIRO_DOCK_FILL_SPACE
180
iLoadingModifier |= CAIRO_DOCK_KEEP_RATIO;
182
cairo_t *pCairoContext = cairo_dock_create_context_from_container (myContainer);
183
pTextZone->pImgSurface = cairo_dock_create_surface_from_image (pTextZone->cImgPath,
184
pCairoContext, // myDrawContext,
186
pTextZone->iImgSize, pTextZone->iImgSize,
190
cairo_destroy (pCairoContext);
192
//\_______________ On garde l'aire de la surface/texture.
193
pTextZone->iWidth = (int)fImgW;
194
pTextZone->iHeight = (int)fImgH;
197
pTextZone->pImgSurface = cairo_dock_create_surface_for_icon (pTextZone->cImgPath, myDrawContext,
198
pTextZone->iWidth, pTextZone->iHeight);
200
pTextZone->bImgDraw = TRUE; // L'image est désormais chargée -> On peut la dessiner
204
if (pTextZone->iRefresh != 0)
208
if (pTextZone->bRefresh)
210
if (pTextZone->cInternal == NULL) // C'est une commande bash !
212
// cd_debug ("Doncky-debug : ----------------------> JE RAFFRAICHIS LA COMMANDE `%s`", pTextZone->cCommand);
213
pTextZone->cResult = cairo_dock_launch_command_sync (pTextZone->cCommand);
215
else // C'est une commande interne !
218
if (strcmp (pTextZone->cInternal, "testsm") == 0)
220
cd_sysmonitor_get_nvidia_info (myApplet);
222
pTextZone->cResult = g_strdup_printf ("myData.fCpuPercent : %i%% \nmyData.cpu_user : %lli \nmyData.cpu_user_nice : %lli \nmyData.cpu_system : %lli \nmyData.cpu_idle : %lli \nmyData.iNbCPU : %i \n"
223
"myData.fRamPercent : %i%% \nmyData.ramUsed : %lli \nmyData.ramTotal : %lli \nmyData.ramCached : %lli \nmyData.ramFree : %lli \n"
224
"myData.swapTotal : %lli \nmyData.swapFree : %lli \nmyData.fSwapPercent : %i%% \nmyData.swapUsed : %lli \n"
225
"myData.cGPUName : %s \nmyData.iVideoRam : %iMB \nmyData.cDriverVersion : %s \nmyData.iGPUTemp : %i°C",
226
(int)myData.fCpuPercent,
228
myData.cpu_user_nice,
232
(int)myData.fRamPercent,
239
(int)myData.fSwapPercent,
243
myData.cDriverVersion,
247
else if (strcmp (pTextZone->cInternal, "cpuperc") == 0)
249
pTextZone->cResult = g_strdup_printf ("%s", _AdjustPrecision0 (myApplet, myData.fCpuPercent));
251
if (atof(pTextZone->cResult) < 10)
252
pTextZone->cResult = g_strdup_printf ("%s", _AdjustPrecision1 (myApplet, myData.fCpuPercent));
254
pTextZone->cResult = g_strdup_printf ("%s", _AdjustPrecision0 (myApplet, myData.fCpuPercent));
257
else if (strcmp (pTextZone->cInternal, "cpuperc2f") == 0) // Restreint à 2 chiffres : de 00 à 99 !
259
pTextZone->cResult = g_strdup_printf ("%s", _AdjustPrecision0 (myApplet, myData.fCpuPercent));
261
if (atof(pTextZone->cResult) < 10)
262
pTextZone->cResult = g_strdup_printf ("0%s", _AdjustPrecision0 (myApplet, myData.fCpuPercent));
263
else if (atof(pTextZone->cResult) == 100)
264
pTextZone->cResult = g_strdup_printf ("99");
266
pTextZone->cResult = g_strdup_printf ("%s", _AdjustPrecision0 (myApplet, myData.fCpuPercent));
269
else if (strcmp (pTextZone->cInternal, "memperc") == 0)
271
pTextZone->cResult = g_strdup_printf ("%s", _AdjustPrecision0 (myApplet, myData.fRamPercent));
273
if (atof(pTextZone->cResult) < 10)
274
pTextZone->cResult = g_strdup_printf ("0%s", _AdjustPrecision1 (myApplet, myData.fRamPercent));
275
else if (atof(pTextZone->cResult) == 100)
276
pTextZone->cResult = g_strdup_printf ("99");
278
pTextZone->cResult = g_strdup_printf ("%s", _AdjustPrecision0 (myApplet, myData.fRamPercent));
281
else if (strcmp (pTextZone->cInternal, "memperc2f") == 0) // Restreint à 2 chiffres : de 00 à 99 !
283
pTextZone->cResult = g_strdup_printf ("%s", _AdjustPrecision0 (myApplet, myData.fRamPercent));
285
if (atof(pTextZone->cResult) < 10)
286
pTextZone->cResult = g_strdup_printf ("%s", _AdjustPrecision1 (myApplet, myData.fRamPercent));
288
pTextZone->cResult = g_strdup_printf ("%s", _AdjustPrecision0 (myApplet, myData.fRamPercent));
292
else if (strcmp (pTextZone->cInternal, "mem") == 0) // en Mo
294
pTextZone->cResult = g_strdup_printf ("%f", _Ko_to_Mo(myApplet, myData.ramTotal /100. * myData.fRamPercent));
295
pTextZone->cResult = g_strdup_printf ("%s", _AdjustPrecision0 (myApplet, atof(pTextZone->cResult)));
298
else if (strcmp (pTextZone->cInternal, "memg") == 0) // Identique à mem mais en Go
300
pTextZone->cResult = g_strdup_printf ("%f", _Ko_to_Go(myApplet, myData.ramTotal /100. * myData.fRamPercent));
301
pTextZone->cResult = g_strdup_printf ("%s", _AdjustPrecision2 (myApplet, atof(pTextZone->cResult)));
304
else if (strcmp (pTextZone->cInternal, "memmax") == 0) // en Mo
306
pTextZone->cResult = g_strdup_printf ("%f", _Ko_to_Mo(myApplet, myData.ramTotal));
307
pTextZone->cResult = g_strdup_printf ("%s", _AdjustPrecision0 (myApplet, atof(pTextZone->cResult)));
310
else if (strcmp (pTextZone->cInternal, "memmaxg") == 0) // Identique à memmax mais en Go
312
pTextZone->cResult = g_strdup_printf ("%f", _Ko_to_Go(myApplet, myData.ramTotal));
313
pTextZone->cResult = g_strdup_printf ("%s", _AdjustPrecision2 (myApplet, atof(pTextZone->cResult)));
317
else if (strcmp (pTextZone->cInternal, "swapperc") == 0)
319
pTextZone->cResult = g_strdup_printf ("%s", _AdjustPrecision0 (myApplet, myData.fSwapPercent));
321
if (atof(pTextZone->cResult) < 10)
322
pTextZone->cResult = g_strdup_printf ("%s", _AdjustPrecision1 (myApplet, myData.fSwapPercent));
324
pTextZone->cResult = g_strdup_printf ("%s", _AdjustPrecision0 (myApplet, myData.fSwapPercent));
327
else if (strcmp (pTextZone->cInternal, "swapperc2f") == 0) // Restreint à 2 chiffres : de 00 à 99 !
329
pTextZone->cResult = g_strdup_printf ("%s", _AdjustPrecision0 (myApplet, myData.fSwapPercent));
331
if (atof(pTextZone->cResult) < 10)
332
pTextZone->cResult = g_strdup_printf ("0%s", _AdjustPrecision0 (myApplet, myData.fSwapPercent));
333
else if (atof(pTextZone->cResult) == 100)
334
pTextZone->cResult = g_strdup_printf ("99");
336
pTextZone->cResult = g_strdup_printf ("%s", _AdjustPrecision0 (myApplet, myData.fSwapPercent));
339
else if (strcmp (pTextZone->cInternal, "swap") == 0) // en Mo
341
pTextZone->cResult = g_strdup_printf ("%f", _Ko_to_Mo(myApplet, myData.swapUsed));
343
if (atof(pTextZone->cResult) < 10)
344
pTextZone->cResult = g_strdup_printf ("%s", _AdjustPrecision2 (myApplet, atof(pTextZone->cResult)));
345
else if (atof(pTextZone->cResult) < 100)
346
pTextZone->cResult = g_strdup_printf ("%s", _AdjustPrecision1 (myApplet, atof(pTextZone->cResult)));
348
pTextZone->cResult = g_strdup_printf ("%s", _AdjustPrecision0 (myApplet, atof(pTextZone->cResult)));
351
else if (strcmp (pTextZone->cInternal, "swapg") == 0) // Identique à swap mais en Go
353
pTextZone->cResult = g_strdup_printf ("%f", _Ko_to_Go(myApplet, myData.swapUsed));
354
pTextZone->cResult = g_strdup_printf ("%s", _AdjustPrecision2 (myApplet, atof(pTextZone->cResult)));
357
else if (strcmp (pTextZone->cInternal, "swapmax") == 0) // en Mo
359
pTextZone->cResult = g_strdup_printf ("%f", _Ko_to_Mo(myApplet, myData.swapTotal));
360
pTextZone->cResult = g_strdup_printf ("%s", _AdjustPrecision0 (myApplet, atof(pTextZone->cResult)));
363
else if (strcmp (pTextZone->cInternal, "swapmaxg") == 0) // Identique à swapmax mais en Go
365
pTextZone->cResult = g_strdup_printf ("%f", _Ko_to_Go(myApplet, myData.swapTotal));
366
pTextZone->cResult = g_strdup_printf ("%s", _AdjustPrecision2 (myApplet, atof(pTextZone->cResult)));
369
else if (strcmp (pTextZone->cInternal, "nvtemp") == 0)
370
pTextZone->cResult = g_strdup_printf ("%i", myData.iGPUTemp);
372
else if (strcmp (pTextZone->cInternal, "nvname") == 0)
374
cd_sysmonitor_get_nvidia_info (myApplet);
375
pTextZone->cResult = g_strdup_printf ("%s", myData.cGPUName);
378
else if (strcmp (pTextZone->cInternal, "nvdriver") == 0)
380
cd_sysmonitor_get_nvidia_info (myApplet);
381
pTextZone->cResult = g_strdup_printf ("%s", myData.cDriverVersion);
384
else if (strcmp (pTextZone->cInternal, "nvram") == 0)
386
cd_sysmonitor_get_nvidia_info (myApplet);
387
pTextZone->cResult = g_strdup_printf ("%i", myData.iVideoRam);
390
else if (strcmp (pTextZone->cInternal, "uptime") == 0)
392
gchar *cUpTime = NULL, *cActivityTime = NULL;
393
cd_sysmonitor_get_uptime (&cUpTime, &cActivityTime);
394
pTextZone->cResult = g_strdup_printf ("%s", cUpTime);
401
void cd_retrieve_command_result (CairoDockModuleInstance *myApplet)
407
for (it = myData.pTextZoneList; it != NULL; it = it->next)
409
pTextZone = it->data;
411
if (pTextZone->iRefresh != 0 || pTextZone->bRefresh)
413
if (pTextZone->bRefresh && pTextZone->cResult != NULL)
415
pTextZone->cText = g_strdup_printf ("%s",pTextZone->cResult);
418
if (pTextZone->iRefresh != 0 && pTextZone->iTimer >= pTextZone->iRefresh)
420
pTextZone->bRefresh = TRUE;
421
pTextZone->iTimer = 0; // On remet le timer à 0
424
pTextZone->bRefresh = FALSE;
427
cd_applet_update_my_icon (myApplet); // Quand tous les textes sont chargés, on peut dessiner
428
myData.pPeriodicRefreshTask = NULL;
432
void cd_applet_draw_my_desklet (CairoDockModuleInstance *myApplet, int iWidth, int iHeight)
434
if (iWidth < 20 || iHeight < 20) // inutile de dessiner tant que le desklet n'a pas atteint sa taille definitive.
436
cd_debug ("%s (%dx%d)", __func__, iWidth, iHeight);
437
PangoLayout *pLayout = pango_cairo_create_layout (myDrawContext);
438
PangoRectangle ink, log;
440
// On efface la surface cairo actuelle
441
cairo_dock_erase_cairo_context (myDrawContext);
443
// dessin du fond (optionnel).
444
if (myConfig.bDisplayBackground)
446
cairo_save (myDrawContext);
447
cairo_translate (myDrawContext,
448
.5*myConfig.iBorderThickness,
449
.5*myConfig.iBorderThickness);
450
cairo_pattern_t *pGradationPattern = cairo_pattern_create_linear (0.,
454
cairo_pattern_add_color_stop_rgba (pGradationPattern,
456
myConfig.fBackgroundColor1[0],
457
myConfig.fBackgroundColor1[1],
458
myConfig.fBackgroundColor1[2],
459
myConfig.fBackgroundColor1[3]);
460
cairo_pattern_add_color_stop_rgba (pGradationPattern,
462
myConfig.fBackgroundColor2[0],
463
myConfig.fBackgroundColor2[1],
464
myConfig.fBackgroundColor2[2],
465
myConfig.fBackgroundColor2[3]);
466
cairo_set_source (myDrawContext, pGradationPattern);
468
if (myConfig.iBackgroundRadius != 0) // On a besoin d'un rayon
470
cairo_dock_draw_rounded_rectangle (myDrawContext,
471
myConfig.iBackgroundRadius,
473
iWidth - myConfig.iBorderThickness - 2 * myConfig.iBackgroundRadius,
474
iHeight - myConfig.iBorderThickness);
476
else // Il ne faut pas de rayon
478
cairo_rectangle (myDrawContext,
480
iWidth - myConfig.iBorderThickness,
481
iHeight - myConfig.iBorderThickness);
483
cairo_fill (myDrawContext);
484
cairo_pattern_destroy (pGradationPattern);
485
cairo_restore (myDrawContext);
493
// ################################################################################################################################################################
494
// ############ DEBUT DU DESSIN DU TEXTE
495
// ################################################################################################################################################################
497
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.
499
myData.fCurrentX = iMargin + myConfig.iTextMargin; // position du curseur sur la ligne.
500
myData.fCurrentY = iMargin + myConfig.iTextMargin; // position de la ligne courante.
502
GList *it = myData.pTextZoneList;
506
gboolean bFirstPass=TRUE;
508
double fCurrentLineWidth = 0; // Dimension de la ligne complète (= avec plusieurs zones de textes)
509
double fCurrentLineHeight = 0;
510
gboolean bFirstTextInLine = TRUE;
514
if (myData.pTextZoneList == NULL)
517
it = myData.pTextZoneList;
521
do // boucle sur it de it1 jusqu'à retour chariot => line_width
523
pTextZone = it->data;
525
if (pTextZone->cFont == NULL || pTextZone->cFont =="") // Si aucune font -> on prend celle de la config
526
pTextZone->cFont = g_strdup_printf("%s", myConfig.cDefaultFont);
529
if (pTextZone->cText != NULL) // On récupère la largeur d'un espace pour caler le texte à droite
531
PangoFontDescription *fd = pango_font_description_from_string (pTextZone->cFont);
532
pango_layout_set_font_description (pLayout, fd);
533
pango_font_description_free (fd);
535
pango_layout_set_text (pLayout, " ", -1);
536
pango_layout_get_pixel_extents (pLayout, &ink, &log);
538
pTextZone->iFontSize = (int)log.width;
542
PangoFontDescription *fd = pango_font_description_from_string (pTextZone->cFont);
543
pango_layout_set_font_description (pLayout, fd);
544
pango_font_description_free (fd);
546
pango_layout_set_text (pLayout, pTextZone->cText, -1);
547
pango_layout_get_pixel_extents (pLayout, &ink, &log);
549
if (pTextZone->cText != NULL)
550
fCurrentLineWidth += log.width;
551
else if (pTextZone->bLimitedBar || pTextZone->bImgDraw)
552
fCurrentLineWidth += pTextZone->iWidth;
556
// A voir comment définir l'alignement en Z
557
if (bFirstTextInLine)
558
fCurrentLineHeight = log.height;
561
if (log.height > fCurrentLineHeight)
562
fCurrentLineHeight = log.height;
569
} while (it != NULL && ! pTextZone->bEndOfLine);
572
// boucle sur it de it1 jusqu'à retour chariot => dessin
577
pTextZone = it->data;
579
if (pTextZone->cFont == NULL || pTextZone->cFont =="") // Si aucune font -> on prend celle de la config
580
pTextZone->cFont = g_strdup_printf("%s", myConfig.cDefaultFont);
582
PangoFontDescription *fd = pango_font_description_from_string (pTextZone->cFont);
583
pango_layout_set_font_description (pLayout, fd);
584
pango_font_description_free (fd);
587
if (pTextZone->fTextColor[3]== 0 && pTextZone->cText != NULL) // Si aucune couleur alors qu'un texte est défini -> on prend celle de la config
588
cairo_set_source_rgba (myDrawContext, myConfig.fDefaultTextColor[0], myConfig.fDefaultTextColor[1], myConfig.fDefaultTextColor[2], myConfig.fDefaultTextColor[3]);
589
else // sinon, on utilise la couleur du .xml
590
cairo_set_source_rgba (myDrawContext, pTextZone->fTextColor[0], pTextZone->fTextColor[1], pTextZone->fTextColor[2], pTextZone->fTextColor[3]);
592
myData.cCurrentText = g_strdup_printf ("%s",pTextZone->cText);
594
pango_layout_set_text (pLayout, myData.cCurrentText, -1);
595
pango_layout_get_pixel_extents (pLayout, &ink, &log);
598
if (bFirstTextInLine) // On calcule le décalage nécéssaire pour respecter l'alignement souhaité
601
CD_APPLET_GET_MY_ICON_EXTENT (&iWidth, &iHeight);
603
if (strcmp (pTextZone->cAlign, "left") == 0)
604
myData.fCurrentX = iMargin + myConfig.iTextMargin;
605
else if (strcmp (pTextZone->cAlign, "center") == 0)
607
if (pTextZone->cImgPath != NULL)
608
myData.fCurrentX = (iWidth/2) - (pTextZone->iWidth/2);
610
myData.fCurrentX = (iWidth/2)- (fCurrentLineWidth/2);
612
else if (strcmp (pTextZone->cAlign, "right") == 0)
614
if (pTextZone->cImgPath != NULL)
615
myData.fCurrentX = iWidth - iMargin - myConfig.iTextMargin - pTextZone->iWidth - pTextZone->iFontSize;
617
myData.fCurrentX = iWidth - iMargin - myConfig.iTextMargin - fCurrentLineWidth - pTextZone->iFontSize;
621
if (pTextZone->bBar || pTextZone->bLimitedBar) // On dessine la barre
624
myData.cCurrentText = g_strdup_printf ("%s",pTextZone->cText);
629
CD_APPLET_GET_MY_ICON_EXTENT (&iWidth, &iHeight);
630
pTextZone->iWidth = iWidth - iMargin*2 - myConfig.iTextMargin - (myData.fCurrentX + 8);
636
for (i=0 ; i < 2 ; i++)
639
value = (int)((atof(myData.cCurrentText) / 100)*pTextZone->iWidth);
641
value = pTextZone->iWidth;
643
// On dessine la valeur PUIS le cadre
644
cairo_save (myDrawContext);
646
if (pTextZone->fTextColor[3]== 0 && pTextZone->cText != NULL) // Si aucune couleur
647
cairo_set_source_rgba (myDrawContext,
648
myConfig.fDefaultTextColor[0],
649
myConfig.fDefaultTextColor[1],
650
myConfig.fDefaultTextColor[2],
651
myConfig.fDefaultTextColor[3]);
653
cairo_set_source_rgba (myDrawContext,
654
pTextZone->fTextColor[0],
655
pTextZone->fTextColor[1],
656
pTextZone->fTextColor[2],
657
pTextZone->fTextColor[3]);
659
cairo_set_line_width (myDrawContext, 0.5);
660
cairo_translate (myDrawContext,
661
myData.fCurrentX + 8, // On décale légèrement la barre du texte
662
myData.fCurrentY + log.height*4/5 - pTextZone->iHeight);
663
cairo_dock_draw_rounded_rectangle (myDrawContext,
670
cairo_fill (myDrawContext);
672
cairo_stroke (myDrawContext);
673
cairo_restore (myDrawContext);
676
else if (pTextZone->bImgDraw) // Il y a une image
678
if (pTextZone->pImgSurface != NULL)
680
cairo_set_source_surface (myDrawContext, pTextZone->pImgSurface,
683
cairo_paint (myDrawContext);
686
else // C'est un texte !
688
cairo_move_to (myDrawContext,
690
myData.fCurrentY + (fCurrentLineHeight *4/5) - (log.height * 4/5)); // *4/5 pour se caler sur le bas du texte avec la font la plus grosse
691
pango_cairo_show_layout (myDrawContext, pLayout); // On dessine la ligne sur notre desklet
694
if (pTextZone->bEndOfLine) // On passe à la ligne du dessous
696
if (pTextZone->bNextNewLine) // Sinon, on reste sur la même ligne -> Utile pour avoir 1 zone alignée à gauche et 1 zone alignée à droite par exemple ;-)
698
if (pTextZone->bImgDraw)
699
myData.fCurrentY += pTextZone->iHeight + myConfig.iSpaceBetweenLines;
701
myData.fCurrentY += log.height + myConfig.iSpaceBetweenLines;
703
//~ else if (pTextZone->bNextNewLine && (pTextZone->bBar || pTextZone->bLimitedBar) )
704
//~ myData.fCurrentY += myConfig.iSpaceBetweenLines + pTextZone->iHeight;
706
myData.fCurrentX = iMargin + myConfig.iTextMargin;
708
bFirstTextInLine = TRUE;
709
fCurrentLineWidth = 0;
711
else // On laisse le curseur à la position actuelle
713
if (pTextZone->bBar || pTextZone->bLimitedBar) // On prend en compte un éventuelle barre
714
myData.fCurrentX += pTextZone->iWidth + 16 ;
715
else // valable pour les textes et les images
718
pango_layout_get_pixel_extents (pLayout, &ink, &log);
720
w = log.width + log.x;
721
myData.fCurrentX += w;
724
bFirstTextInLine = FALSE;
728
} while (it != NULL && ! pTextZone->bEndOfLine);
730
} while (it != NULL);
732
// ################################################################################################################################################################
733
// ############ FIN DU DESSIN DU TEXTE
734
// ################################################################################################################################################################
737
// dessin du cadre (optionnel).
738
if (myConfig.bDisplayBackground)
740
cairo_save (myDrawContext);
741
cairo_set_source_rgba (myDrawContext,
742
myConfig.fBorderColor[0],
743
myConfig.fBorderColor[1],
744
myConfig.fBorderColor[2],
745
myConfig.fBorderColor[3]);
746
cairo_set_line_width (myDrawContext, myConfig.iBorderThickness);
747
cairo_translate (myDrawContext,
748
.5*myConfig.iBorderThickness,
749
.5*myConfig.iBorderThickness);
750
cairo_dock_draw_rounded_rectangle (myDrawContext,
751
myConfig.iBackgroundRadius,
753
iWidth - 2*myConfig.iBackgroundRadius - myConfig.iBorderThickness,
754
iHeight - myConfig.iBorderThickness);
755
cairo_stroke (myDrawContext);
756
cairo_restore (myDrawContext);
759
g_object_unref (pLayout);
762
// on met a jour la texture OpenGL.
763
if (CD_APPLET_MY_CONTAINER_IS_OPENGL)
765
cairo_dock_update_icon_texture (myIcon);
770
void cd_applet_update_my_icon (CairoDockModuleInstance *myApplet)
774
// taille de la texture.
776
CD_APPLET_GET_MY_ICON_EXTENT (&iWidth, &iHeight);
778
cd_applet_draw_my_desklet (myApplet, iWidth, iHeight);
780
CD_APPLET_REDRAW_MY_ICON;