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

« back to all changes in this revision

Viewing changes to keyboard-indicator/src/applet-draw.c

  • Committer: Bazaar Package Importer
  • Author(s): Matthieu Baerts (matttbe)
  • Date: 2011-04-20 20:46:51 UTC
  • mfrom: (1.1.9 upstream)
  • Revision ID: james.westby@ubuntu.com-20110420204651-ftnpzesj6uc7qeul
Tags: 2.3.0~1-0ubuntu1
* New Upstream Version (LP: #723995)
* Upstream short ChangeLog (since 2.3.0~0rc1):
 - Updated translations
 - Updated the integration of the new versions of kwin and compiz
    (Switcher, ShowDesktop, etc.)
 - Removed a lot of useless g_print
 - Updated a few plug-ins to fit with the new version of the API (gldit)
 - Fixed a few bugs
 - Updated MeMenu, MessagingMenu and Status-Notifier to works
    with the latest version of dbusmenu, etc.
* Switch to dpkg-source 3.0 (quilt) format
* debian/cairo-dock-plug-ins.install:
 - Added new files (interfaces for python, ruby, vala and mono)
* debian/control:
 - Added new dependences for new applets (sensors and zeitgeist)
    and new interfaces (python, valac, ruby and mono)
 - Updated the version of cairo-dock build-dependences
* debian/rules:
 - Added a new CMake flag to install python interface in debian/tmp
* Updated debian/watch

Show diffs side-by-side

added added

removed removed

Lines of Context:
46
46
                CD_APPLET_GET_MY_ICON_EXTENT (&iWidth, &iHeight);
47
47
                if (iWidth <= 1 && iHeight <= 1)  // peut arriver au lancement en mode desklet.
48
48
                {
 
49
                        myData.pCurrentSurface = NULL;
 
50
                        myData.iCurrentTexture = 0;
 
51
                        myData.iCurrentTextWidth = 0;
 
52
                        myData.iCurrentTextHeight = 0;
49
53
                        return;
50
54
                }
51
55
                double fMaxScale = cairo_dock_get_max_scale (myContainer);
75
79
                        if (CD_APPLET_MY_CONTAINER_IS_OPENGL)
76
80
                        {
77
81
                                CD_APPLET_START_DRAWING_MY_ICON_OR_RETURN ();
78
 
                                cd_xkbd_render_step_opengl (myApplet);  
 
82
                                cd_xkbd_render_step_opengl (myIcon, myApplet);  
79
83
                                CD_APPLET_FINISH_DRAWING_MY_ICON;
80
84
                        }
81
85
                        else
82
86
                        {
83
 
                                cairo_dock_erase_cairo_context (myDrawContext);
84
 
                                cd_xkbd_render_step_cairo (myApplet);
 
87
                                cd_xkbd_render_step_cairo (myIcon, myApplet);
85
88
                                CD_APPLET_UPDATE_REFLECT_ON_MY_ICON;
86
89
                        }
87
90
                        CD_APPLET_REDRAW_MY_ICON;
99
102
}
100
103
 
101
104
 
102
 
gboolean cd_xkbd_render_step_opengl (CairoDockModuleInstance *myApplet)
 
105
gboolean cd_xkbd_render_step_opengl (Icon *pIcon, CairoDockModuleInstance *myApplet)
103
106
{
104
107
        CD_APPLET_ENTER;
105
108
        double f = CD_APPLET_GET_TRANSITION_FRACTION ();
150
153
        }
151
154
        
152
155
        CD_APPLET_LEAVE (TRUE);
153
 
        //return TRUE;
154
156
}
155
157
 
156
158
 
157
 
gboolean cd_xkbd_render_step_cairo (CairoDockModuleInstance *myApplet)
 
159
gboolean cd_xkbd_render_step_cairo (Icon *pIcon, CairoDockModuleInstance *myApplet)
158
160
{
159
161
        CD_APPLET_ENTER;
160
162
        double f = CD_APPLET_GET_TRANSITION_FRACTION ();
162
164
        //g_print ("%s (%.2f)\n", __func__, f);
163
165
        int iWidth, iHeight;
164
166
        CD_APPLET_GET_MY_ICON_EXTENT (&iWidth, &iHeight);
 
167
        CD_APPLET_LEAVE_IF_FAIL (iHeight != 0, TRUE);
 
168
        
 
169
        cairo_dock_erase_cairo_context (myDrawContext);
165
170
        
166
171
        if (myData.pBackgroundSurface != NULL)
167
172
        {
174
179
                cairo_dock_set_icon_surface_full (myDrawContext, myData.pBackgroundSurface, 1., 1., myIcon, myContainer);
175
180
        }
176
181
        
177
 
        double dx, dy, fScale=0;
 
182
        double dx, dy, fScale;
178
183
        if (myData.pOldSurface != NULL && 1-f > .01)
179
184
        {
180
185
                dx = (iWidth - myData.iOldTextWidth)/2;
182
187
                if (dy < 0)  // peut arriver si une police de la taille de l'icone n'existe pas.
183
188
                {
184
189
                        dy = 0;
185
 
                        fScale = 1.*iHeight / myData.iOldTextHeight;
 
190
                        fScale = (double)iHeight / myData.iOldTextHeight;
186
191
                        cairo_save (myDrawContext);
187
192
                        cairo_scale (myDrawContext, 1., fScale);  // a priori la difference n'est pas enorme, on laisse donc remplit en largeur.
188
193
                }
 
194
                else
 
195
                        fScale=0;
189
196
                cairo_set_source_surface (
190
197
                        myDrawContext,
191
198
                        myData.pOldSurface,
202
209
                if (dy < 0)
203
210
                {
204
211
                        dy = 0;
205
 
                        fScale = 1.*iHeight / myData.iCurrentTextHeight;
 
212
                        fScale = (double)iHeight / myData.iCurrentTextHeight;
206
213
                        cairo_save (myDrawContext);
207
214
                        cairo_scale (myDrawContext, 1., fScale);
208
215
                }
 
216
                else
 
217
                        fScale=0;
209
218
                cairo_set_source_surface (
210
219
                        myDrawContext,
211
220
                        myData.pCurrentSurface,
217
226
        }
218
227
        
219
228
        CD_APPLET_LEAVE (TRUE);
220
 
        //return TRUE;
221
229
}