~ubuntu-branches/ubuntu/quantal/cairo-dock-plug-ins/quantal-201208191523

« back to all changes in this revision

Viewing changes to clock/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:
21
21
#define __USE_POSIX
22
22
#include <time.h>
23
23
#include <signal.h>
 
24
#include <math.h>
24
25
 
25
26
#include "applet-struct.h"
26
27
#include "applet-config.h"
27
28
#include "applet-digital.h" //Digital html like renderer
 
29
#include "applet-calendar.h"
28
30
#include "applet-draw.h"
29
31
 
30
32
#define CD_CLOCK_DATE_BUFFER_LENGTH 50
37
39
        g_free (pAlarm);
38
40
}
39
41
 
 
42
static void _set_warning_repetition (int iClickedButton, GtkWidget *pInteractiveWidget, CDClockTask *pTask, CairoDialog *pDialog);
 
43
static gboolean _task_warning (CDClockTask *pTask, const gchar *cMessage)
 
44
{
 
45
        cd_debug ("%s (%s)", __func__, cMessage);
 
46
        CairoDockModuleInstance *myApplet = pTask->pApplet;
 
47
        
 
48
        GtkWidget *pScale = gtk_hscale_new_with_range (1, 60, 1);  // 1mn-60mn et 1 cran/mn.
 
49
        gtk_scale_set_digits (GTK_SCALE (pScale), 0);
 
50
        gtk_range_set_value (GTK_RANGE (pScale), pTask->iWarningDelay != 0 ? pTask->iWarningDelay : 15);  // 15mn par defaut.
 
51
        gtk_widget_set (pScale, "width-request", CAIRO_DIALOG_MIN_SCALE_WIDTH, NULL);
 
52
        
 
53
        GtkWidget *pExtendedWidget = gtk_hbox_new (FALSE, 0);
 
54
        GtkWidget *label = gtk_label_new (D_("1mn"));
 
55
        GtkWidget *pAlign = gtk_alignment_new (1., 1., 0., 0.);
 
56
        gtk_container_add (GTK_CONTAINER (pAlign), label);
 
57
        gtk_box_pack_start (GTK_BOX (pExtendedWidget), pAlign, FALSE, FALSE, 0);
 
58
        gtk_box_pack_start (GTK_BOX (pExtendedWidget), pScale, FALSE, FALSE, 0);
 
59
        label = gtk_label_new (D_("1h"));
 
60
        pAlign = gtk_alignment_new (1., 1., 0., 0.);
 
61
        gtk_container_add (GTK_CONTAINER (pAlign), label);
 
62
        gtk_box_pack_start (GTK_BOX (pExtendedWidget), pAlign, FALSE, FALSE, 0);
 
63
        
 
64
        cairo_dock_dialog_unreference (pTask->pWarningDialog);
 
65
        myDialogs.dialogTextDescription.bUseMarkup = TRUE;
 
66
        pTask->pWarningDialog = cairo_dock_show_dialog_full (cMessage,
 
67
                myIcon, myContainer,
 
68
                (pTask->iWarningDelay != 0 ? MIN (pTask->iWarningDelay-.1, 15.) : 15) * 60e3,  // on laisse le dialogue visible le plus longtemps possible, jusqu'a 15mn.
 
69
                MY_APPLET_SHARE_DATA_DIR"/icon-task.png",
 
70
                pExtendedWidget,
 
71
                (CairoDockActionOnAnswerFunc) _set_warning_repetition,
 
72
                pTask,
 
73
                NULL);
 
74
        myDialogs.dialogTextDescription.bUseMarkup = FALSE;
 
75
        
 
76
        CD_APPLET_DEMANDS_ATTENTION (NULL, 3600);  // ~ 1h, pour si on loupe le dialogue.
 
77
        return TRUE;
 
78
}
 
79
static gboolean _task_warning_repeat (CDClockTask *pTask, const gchar *cMessage)
 
80
{
 
81
        gchar *cText = g_strdup_printf ("%s %d:%02d\n<b>%s</b>\n %s\n\n%s",
 
82
                D_("The following task was scheduled at"), pTask->iHour, pTask->iMinute,
 
83
                pTask->cTitle?pTask->cTitle:D_("No title"),
 
84
                pTask->cText?pTask->cText:"",
 
85
                D_("Repeat this message every:"));
 
86
        _task_warning (pTask, cText);
 
87
        g_free (cText);
 
88
        return TRUE;
 
89
}
 
90
static void _set_warning_repetition (int iClickedButton, GtkWidget *pInteractiveWidget, CDClockTask *pTask, CairoDialog *pDialog)
 
91
{
 
92
        g_print ("%s (%d)\n", __func__, iClickedButton);
 
93
        GList *cl = gtk_container_get_children (GTK_CONTAINER (pInteractiveWidget));
 
94
        g_return_if_fail (cl != NULL && cl->next != NULL);
 
95
        GtkWidget *pScale = cl->next->data;
 
96
        g_return_if_fail (pScale != NULL);
 
97
        
 
98
        int dt = gtk_range_get_value (GTK_RANGE (pScale));
 
99
        if (dt == 0 || (iClickedButton != 0 && iClickedButton != -1))
 
100
        {
 
101
                if (pTask->iSidWarning != 0)
 
102
                {
 
103
                        g_source_remove (pTask->iSidWarning);
 
104
                        pTask->iSidWarning = 0;
 
105
                }
 
106
        }
 
107
        else
 
108
        {
 
109
                if (pTask->iSidWarning != 0 && dt != pTask->iWarningDelay)
 
110
                {
 
111
                        g_source_remove (pTask->iSidWarning);
 
112
                        pTask->iSidWarning = 0;
 
113
                }
 
114
                if (pTask->iSidWarning == 0)
 
115
                {
 
116
                        pTask->iSidWarning = g_timeout_add_seconds (dt*60, (GSourceFunc) _task_warning_repeat, pTask);
 
117
                        pTask->iWarningDelay = dt;
 
118
                }
 
119
        }
 
120
        pTask->pWarningDialog = NULL;
 
121
        CairoDockModuleInstance *myApplet = pTask->pApplet;
 
122
        CD_APPLET_STOP_DEMANDING_ATTENTION;
 
123
}
40
124
 
41
 
gboolean cd_clock_update_with_time (CairoDockModuleInstance *myApplet)
 
125
static inline void _get_current_time (time_t epoch, CairoDockModuleInstance *myApplet)
42
126
{
43
 
        CD_APPLET_ENTER;
44
 
        //\________________ On recupere l'heure courante.
45
 
        time_t epoch = (time_t) time (NULL);
46
127
        if (myConfig.cLocation != NULL)
47
128
        {
48
129
                g_setenv ("TZ", myConfig.cLocation, TRUE);
56
137
                else
57
138
                        g_unsetenv ("TZ");
58
139
        }
 
140
}
 
141
 
 
142
void cd_clock_init_time (CairoDockModuleInstance *myApplet)
 
143
{
 
144
        time_t epoch = (time_t) time (NULL);
 
145
        _get_current_time (epoch, myApplet);
 
146
}
 
147
 
 
148
gboolean cd_clock_update_with_time (CairoDockModuleInstance *myApplet)
 
149
{
 
150
        CD_APPLET_ENTER;
 
151
        //\________________ On recupere l'heure courante.
 
152
        time_t epoch = (time_t) time (NULL);
 
153
        _get_current_time (epoch, myApplet);
59
154
        
60
155
        //\________________ On change la date si necessaire.
61
156
        int iWidth, iHeight;
80
175
                        double fScale = (double) iWidth / (double) myData.DimensionData.width;
81
176
                        CairoDockLabelDescription labelDescription;
82
177
                        labelDescription.iSize = 10;
83
 
                        labelDescription.cFont = "Sans";
 
178
                        labelDescription.cFont = (gchar*)"Sans";  // on peut caster car on ne liberera rien.
84
179
                        labelDescription.iWeight = cairo_dock_get_pango_weight_from_1_9 (5);
85
180
                        labelDescription.iStyle = PANGO_STYLE_NORMAL;
86
181
                        labelDescription.fColorStart[0] = myConfig.fDateColor[0];
91
186
                        labelDescription.bOutlined = FALSE;
92
187
                        labelDescription.iMargin = 0;
93
188
                        cairo_surface_t *pDateSurface = cairo_dock_create_surface_from_text_full (s_cDateBuffer,
94
 
                                myDrawContext,
95
189
                                &labelDescription,
96
190
                                fScale,
97
191
                                iWidth,
133
227
        //\________________ On redessine notre icone.
134
228
        CD_APPLET_REDRAW_MY_ICON;
135
229
        
136
 
        //\________________ On teste les alarmes.
137
 
        if (!myConfig.bShowSeconds || myData.currentTime.tm_min != myData.iLastCheckedMinute)  // un g_timeout de 1min ne s'effectue pas forcement à exectement 1 minute d'intervalle, et donc pourrait "sauter" la minute de l'alarme, d'ou le test sur bShowSeconds dans le cas ou l'applet ne verifie que chaque minute.
 
230
        //\________________ On teste les alarmes et les taches.
 
231
        if (!myConfig.bShowSeconds || myData.currentTime.tm_min != myData.iLastCheckedMinute)  // un g_timeout de 1min ne s'effectue pas forcement a exectement 1 minute d'intervalle, et donc pourrait "sauter" la minute de l'alarme, d'ou le test sur bShowSeconds dans le cas ou l'applet ne verifie que chaque minute.
138
232
        {
139
233
                myData.iLastCheckedMinute = myData.currentTime.tm_min;
 
234
                
 
235
                // les alarmes.
140
236
                CDClockAlarm *pAlarm;
141
 
                int i;
 
237
                guint i;
142
238
                for (i = 0; i < myConfig.pAlarms->len; i ++)
143
239
                {
144
240
                        pAlarm = g_ptr_array_index (myConfig.pAlarms, i);
191
287
                                                        &erreur);
192
288
                                                if (erreur != NULL)
193
289
                                                {
194
 
                                                        cd_warning ("Attention : when trying to execute '%s' : %s", pAlarm->cCommand, erreur->message);
 
290
                                                        cd_warning ("clock : when trying to execute '%s' : %s", pAlarm->cCommand, erreur->message);
195
291
                                                        g_error_free (erreur);
196
292
                                                        myData.iAlarmPID = 0;
197
293
                                                }
202
298
                                
203
299
                                if (bRemoveAlarm)
204
300
                                {
205
 
                                        cd_message ("Cette alarme ne sera pas répétée");
 
301
                                        cd_message ("Cette alarme ne sera pas repetee");
206
302
                                        g_ptr_array_remove_index (myConfig.pAlarms, i);
207
303
                                        cd_clock_free_alarm (pAlarm);
208
304
                                        /// A FAIRE : effacer l'heure dans le fichier de conf pour cette alarme.
209
305
                                }
210
306
                        }
211
307
                }
 
308
                
 
309
                // les taches.
 
310
                if (myData.pNextTask != NULL)
 
311
                {
 
312
                        //g_print ("next task : %s\n", myData.pNextTask->cTitle);
 
313
                        struct tm st;
 
314
                        st.tm_min = myData.pNextTask->iMinute;
 
315
                        st.tm_hour = myData.pNextTask->iHour;
 
316
                        st.tm_mday = myData.pNextTask->iDay;
 
317
                        st.tm_mon = myData.pNextTask->iMonth;
 
318
                        st.tm_year = myData.pNextTask->iYear - 1900;
 
319
                        st.tm_sec = 0;
 
320
                        st.tm_isdst = myData.currentTime.tm_isdst;
 
321
                        time_t t = mktime (&st);
 
322
                        //g_print ("time : %ld, task : %ld\n", epoch, t);
 
323
                        if (t < epoch)  // la tache est depassee.
 
324
                        {
 
325
                                myData.pNextTask = cd_clock_get_next_scheduled_task (myApplet);
 
326
                        }
 
327
                        else if (t < epoch + 15*60 && t >= epoch)
 
328
                        {
 
329
                                if (! myData.pNextTask->b15mnWarning)
 
330
                                {
 
331
                                        //g_print ("15 mn warning\n");
 
332
                                        myData.pNextTask->b15mnWarning = TRUE;
 
333
                                        myDialogs.dialogTextDescription.bUseMarkup = TRUE;
 
334
                                        cairo_dock_show_temporary_dialog_with_icon_printf ("%s\n<b>%s</b>\n %s",
 
335
                                                myIcon, myContainer,
 
336
                                                60e3,
 
337
                                                MY_APPLET_SHARE_DATA_DIR"/icon-task.png",
 
338
                                                D_("This task will begin in 15 minutes:"),
 
339
                                                myData.pNextTask->cTitle?myData.pNextTask->cTitle:D_("No title"),
 
340
                                                myData.pNextTask->cText?myData.pNextTask->cText:"");
 
341
                                        myDialogs.dialogTextDescription.bUseMarkup = FALSE;
 
342
                                        CD_APPLET_DEMANDS_ATTENTION (NULL, 60);
 
343
                                }
 
344
                                else if (t < epoch + 60)
 
345
                                {
 
346
                                        if (! myData.pNextTask->bFirstWarning)
 
347
                                        {
 
348
                                                //g_print ("first warning\n");
 
349
                                                myData.pNextTask->bFirstWarning = TRUE;
 
350
                                                myDialogs.dialogTextDescription.bUseMarkup = TRUE;
 
351
                                                gchar *cText = g_strdup_printf ("%s\n<b>%s</b>\n %s\n\n%s",
 
352
                                                        D_("It's time for the following task:"),
 
353
                                                        myData.pNextTask->cTitle?myData.pNextTask->cTitle:D_("No title"),
 
354
                                                        myData.pNextTask->cText?myData.pNextTask->cText:"",
 
355
                                                        D_("Repeat this message every:"));
 
356
                                                _task_warning (myData.pNextTask, cText);
 
357
                                                g_free (cText);
 
358
                                        }
 
359
                                }
 
360
                        }
 
361
                        
 
362
                        if (myData.pNextAnniversary != NULL)
 
363
                        {
 
364
                                if (!myData.pNextAnniversary->b1DayWarning && ! myData.pNextAnniversary->bFirstWarning && ! myData.pNextTask->b15mnWarning)
 
365
                                {
 
366
                                        GDate* pCurrentDate = g_date_new_dmy (myData.currentTime.tm_mday, myData.currentTime.tm_mon + 1, myData.currentTime.tm_year+1900);
 
367
                                        GDate* pAnnivDate = g_date_new_dmy (myData.pNextAnniversary->iDay, myData.pNextAnniversary->iMonth + 1, myData.currentTime.tm_year+1900);
 
368
                                        gint iDaysToNextAnniversary = g_date_days_between (pCurrentDate, pAnnivDate);
 
369
                                        if (iDaysToNextAnniversary >= 0 && iDaysToNextAnniversary <= 1)
 
370
                                        {
 
371
                                                myData.pNextAnniversary->b1DayWarning = TRUE;
 
372
                                                gchar *cText = g_strdup_printf ("%s\n<b>%s</b>\n %s\n\n%s",
 
373
                                                        iDaysToNextAnniversary == 0 ? D_("Today is the following anniversary:") : D_("Tomorrow is the following anniversary:"),
 
374
                                                        myData.pNextTask->cTitle?myData.pNextTask->cTitle:D_("No title"),
 
375
                                                        myData.pNextTask->cText?myData.pNextTask->cText:"",
 
376
                                                        D_("Repeat this message every:"));
 
377
                                                _task_warning (myData.pNextTask, cText);
 
378
                                                g_free (cText);
 
379
                                                myData.pNextAnniversary = cd_clock_get_next_anniversary (myApplet);
 
380
                                        }
 
381
                                        g_date_free (pCurrentDate);
 
382
                                        g_date_free (pAnnivDate);
 
383
                                }
 
384
                        }
 
385
                }
212
386
        }
213
387
        
214
388
        CD_APPLET_LEAVE(TRUE);
220
394
        cd_clock_put_text_on_frames (myApplet, width, height, fMaxScale, pTime);
221
395
}*/
222
396
 
223
 
#define GAP 2
 
397
#define GAPX 12
 
398
#define GAPY 2
224
399
#define MAX_RATIO 2.
225
400
void cd_clock_draw_text (CairoDockModuleInstance *myApplet, int iWidth, int iHeight, struct tm *pTime)
226
401
{
253
428
        else
254
429
        {
255
430
                if (myConfig.bShowSeconds)
256
 
                        g_string_printf (sFormat, "%%r%s", pTime->tm_hour > 12 ? "PM" : "AM");
 
431
                        g_string_assign (sFormat, "%r");  // equivalent a %I:%M:%S %p
257
432
                else
258
 
                        g_string_printf (sFormat, "%%I:%%M%s", pTime->tm_hour > 12 ? "PM" : "AM");
 
433
                        g_string_printf (sFormat, "%%I:%%M %%p");
259
434
        }
260
435
        
261
436
        strftime (s_cDateBuffer, CD_CLOCK_DATE_BUFFER_LENGTH, sFormat->str, pTime);
274
449
                PangoRectangle ink2, log2;
275
450
                pango_layout_get_pixel_extents (pLayout2, &ink2, &log2);
276
451
                
277
 
                double h = ink.height + ink2.height + GAP;
278
 
                double fZoomX = MIN ((double) (iWidth - 1) / ink.width, (double) (iWidth - 1) / ink2.width);
279
 
                double fZoomY = (double) iHeight / h;
280
 
                if (myDock && fZoomY > MAX_RATIO * fZoomX)  // on ne garde pas le ratio car ca ferait un texte trop petit en hauteur, toutefois on limite un peu la deformation en hauteur.
281
 
                        fZoomY = MAX_RATIO * fZoomX;
282
 
                
283
 
                if (fZoomX * MAX (ink.width, ink2.width) > myConfig.fTextRatio * iWidth)
284
 
                {
285
 
                        fZoomY *= myConfig.fTextRatio * iWidth / (MAX (ink.width, ink2.width) * fZoomX);
286
 
                        fZoomX = myConfig.fTextRatio * iWidth / MAX (ink.width, ink2.width);
287
 
                }
288
 
                
289
 
                cairo_translate (myDrawContext, (iWidth - fZoomX * ink.width) / 2, (iHeight - fZoomY * h)/2);  // centre verticalement.
290
 
                cairo_scale (myDrawContext, fZoomX, fZoomY);
291
 
                cairo_translate (myDrawContext, -ink.x, -ink.y);
292
 
                pango_cairo_show_layout (myDrawContext, pLayout);
293
 
                
294
 
                cairo_restore (myDrawContext);
295
 
                cairo_save (myDrawContext);
296
 
                
297
 
                cairo_translate (myDrawContext, (iWidth - fZoomX * ink2.width) / 2, (iHeight + fZoomY * GAP)/2);
298
 
                cairo_scale (myDrawContext, fZoomX, fZoomY);
299
 
                cairo_translate (myDrawContext, -ink2.x, -ink2.y);
300
 
                pango_cairo_show_layout (myDrawContext, pLayout2);
301
 
                
 
452
                double h=0, w=0, fZoomX=0, fZoomY=0;
 
453
                double h_=0, w_=0, fZoomX_=0, fZoomY_=0;
 
454
                if (myData.iTextOrientation == 1 || myData.iTextOrientation == 0)
 
455
                {
 
456
                        h = ink.height + ink2.height + GAPY;
 
457
                        w = MAX (ink.width, ink2.width);
 
458
                        fZoomX = (double) iWidth / w;
 
459
                        fZoomY = (double) iHeight / h;
 
460
                        if (myDock && fZoomY > MAX_RATIO * fZoomX)  // on ne garde pas le ratio car ca ferait un texte trop petit en hauteur, toutefois on limite un peu la deformation en hauteur.
 
461
                                fZoomY = MAX_RATIO * fZoomX;
 
462
                        
 
463
                        if (fZoomX * w > myConfig.fTextRatio * iWidth)
 
464
                        {
 
465
                                fZoomY *= myConfig.fTextRatio * iWidth / w * fZoomX;
 
466
                                fZoomX = myConfig.fTextRatio * iWidth / w;
 
467
                        }
 
468
                }
 
469
                if (myData.iTextOrientation == 2 || myData.iTextOrientation == 0)
 
470
                {
 
471
                        h_ = MAX (ink.height, ink2.height);
 
472
                        w_ = ink.width + ink2.width + GAPX;
 
473
                        fZoomX_ = (double) iWidth / w_;
 
474
                        fZoomY_ = (double) iHeight / h_;
 
475
                        if (myDock && fZoomY_ > MAX_RATIO * fZoomX_)  // on ne garde pas le ratio car ca ferait un texte trop petit en hauteur, toutefois on limite un peu la deformation en hauteur.
 
476
                                fZoomY_ = MAX_RATIO * fZoomX_;
 
477
                        
 
478
                        if (fZoomX_ * w_ > myConfig.fTextRatio * iWidth)
 
479
                        {
 
480
                                fZoomY_ *= myConfig.fTextRatio * iWidth / w_ * fZoomX_;
 
481
                                fZoomX_ = myConfig.fTextRatio * iWidth / w_;
 
482
                        }
 
483
                        if (fZoomY_ > fZoomX_)
 
484
                        {
 
485
                                double fMaxScale = cairo_dock_get_max_scale (myContainer);
 
486
                                fZoomY_ = MAX (fZoomX_, 16. * fMaxScale / h_);  // en mode horizontal, on n'a pas besoin que le texte remplisse toute la hauteur de l'icone. 16 pixels de haut sont suffisant pour etre lisible.
 
487
                        }
 
488
                }
 
489
                
 
490
                if (myData.iTextOrientation == 0)  // si l'orientation n'est pas encore definie, on la definit de facon a ne pas changer (si on est tres proche de la limite, la taille du texte pourrait changer suffisamment pour nous faire passer d'une orientation a l'autre.
 
491
                {
 
492
                        double def = (fZoomX > fZoomY ? fZoomX / fZoomY : fZoomY / fZoomX);  // deformation.
 
493
                        double def_ = (fZoomX_ > fZoomY_ ? fZoomX_ / fZoomY_ : fZoomY_ / fZoomX_);
 
494
                        if (def > def_)  // deformation plus grande en mode vertical => on passe en mode horizontal.
 
495
                                myData.iTextOrientation = 2;
 
496
                        else
 
497
                                myData.iTextOrientation = 1;
 
498
                }
 
499
                
 
500
                if (myData.iTextOrientation == 2)  // mode horizontal
 
501
                {
 
502
                        cairo_translate (myDrawContext, (iWidth - fZoomX_ * w_) / 2, (iHeight - fZoomY_ * h_)/2);  // centre verticalement.
 
503
                        cairo_scale (myDrawContext, fZoomX_, fZoomY_);
 
504
                        cairo_translate (myDrawContext, -ink2.x, -ink2.y);
 
505
                        pango_cairo_show_layout (myDrawContext, pLayout2);
 
506
                        
 
507
                        cairo_restore (myDrawContext);
 
508
                        cairo_save (myDrawContext);
 
509
                        
 
510
                        cairo_translate (myDrawContext, (iWidth + fZoomX_ * w_) / 2 - fZoomX_ * ink.width, (iHeight - fZoomY_ * h_)/2);
 
511
                        cairo_scale (myDrawContext, fZoomX_, fZoomY_);
 
512
                        cairo_translate (myDrawContext, -ink.x, -ink.y);
 
513
                        pango_cairo_show_layout (myDrawContext, pLayout);
 
514
                }
 
515
                else  // mode vertical
 
516
                {
 
517
                        cairo_translate (myDrawContext, (iWidth - fZoomX * ink.width) / 2, (iHeight - fZoomY * h)/2);  // centre verticalement.
 
518
                        cairo_scale (myDrawContext, fZoomX, fZoomY);
 
519
                        cairo_translate (myDrawContext, -ink.x, -ink.y);
 
520
                        pango_cairo_show_layout (myDrawContext, pLayout);
 
521
                        
 
522
                        cairo_restore (myDrawContext);
 
523
                        cairo_save (myDrawContext);
 
524
                        
 
525
                        cairo_translate (myDrawContext, (iWidth - fZoomX * ink2.width) / 2, (iHeight + fZoomY * GAPY)/2);
 
526
                        cairo_scale (myDrawContext, fZoomX, fZoomY);
 
527
                        cairo_translate (myDrawContext, -ink2.x, -ink2.y);
 
528
                        pango_cairo_show_layout (myDrawContext, pLayout2);
 
529
                }
302
530
                g_object_unref (pLayout2);
303
531
        }
304
532
        else