~ubuntu-branches/ubuntu/oneiric/docky/oneiric

« back to all changes in this revision

Viewing changes to Docky.Services/Docky.Services/DrawingService.cs

  • Committer: Bazaar Package Importer
  • Author(s): Rico Tzschichholz
  • Date: 2010-07-01 21:21:50 UTC
  • mfrom: (1.1.5 upstream)
  • Revision ID: james.westby@ubuntu.com-20100701212150-1dqehqxey8rrvtlo
Tags: 2.0.5-1
* New upstream release 2.0.5 "Be proud of your dock",
  changes include:
  + remove --debug flag from launcher for lower memory usage
  + update the about dialog credits to list documenters and make translation 
    tab easier to read
  + change url in about dialog to the launchpad project page
  + Window-Matching
    - fix for applications commandline
    - properly match qt creator (LP: #594814)
    - prefer local over global launchers (LP: #588073) (LP: #592841)
    - match prefix for gksudo (LP: #516433)
    - fix nautilus items showing active indicator when desktop 
      is focused (LP: #487113)
    - fix matching wine apps that use a prefixed launcher (LP: #596092)
  + Memory Leaks
    - dispose of calendar painter when the clock item is disposed
    - fix leak in AutoHideManager
    - several fixes using Cairo.Context.Target and Pango.Layout
    - fix leak in PagingPainters
    - fix leak in recursive file-deletion
    - fix leaking SeparatorItems, WnckDockItems
    - fix leaks with FileEmblems
    - fix Pixbuf related leaks
    - fix some leaks regarding FileMonitors
    - fix leaks regarding Tiles and AbtractTileObjects
    - fix leaking Glib.FileAdapter caused by unreferenced Action in 
      FileDockItem
  + Handle invalid desktopfile entry and UriFormatException in 
    FileApplicationProvider (LP: #595921)
  + fix potential crash for invalid HelperMetadata
  + handle drops correctly
  + fix handling of Helpers in HelperService
  + make the sliders in preferences behave better
  + fix drawing of rotated items
  + fix HoveredItem click-position
  + avoids fatal errors on console when loading embedded icons when no 
    height or width is specified and when dock items have a null Icon
  + fix icon theme change not refreshing the dock icons (LP: #590205)
  + fix SVG rendering bug
  + fix iconsize temporarily getting large when adding to full dock 
    (LP: #579576)
  + fix the 'crash in PinToDock' (LP: #588073)
  + make 3d background height more consistent and a tad larger (LP: #503038)
  + fix dragging multiple files to a folder on the dock, which caused 
    a crash and data corruption (LP: #579049)
  + don't request animations if urgent state is removed from a window and 
    fix glow location (LP: #596422)
  + fix window previews being offset (LP: #495065)
  + fix broken zoom after shrinking icon size (LP: #598924)
  + fix problem with hovers still visible when painters show
  + fix displaying default icon in place of missing file emblem (LP: #534651)
  + fix crash when gconf key for menus_have_icons is not set (LP: #573751)
  + make sure painters fit on screen (LP: #589978)
  + fix icon minimize animations not working immediately for some newly 
    opened windows
  + don't dispose our static DockyItem
  + fix CurrentDesktopOnly not working when dragging a window across desktops
    (LP: #600290)
  + GMail: 
    - fix thread-guards and remove deprecated code
    - fix problem with feeds that don't have an author entry (LP: #595530)
  + NPR: fix bug where removing your last NPR station unloaded the docklet
    and fix station icon
  + NetworkManager: fix crash caused when NM goes away
    and fix icons and add another fallback icon (LP: #588581)
  + Mounter:
    - fixed some leaks
    - only remove mounted items if they were successfully unmounted 
      (LP: #597637)
    - fix duplicate icons showing in mounter (LP: #525306)
  + Weather: fix feels like temp showing incorrect for metric (LP: #597670)
  + RecentDocuments: 
    - fixed some leaks
    - fix sensitivity of recent docs clear menu item - even if docky shows 
      the list as empty does not mean it cant be cleared
* debian/patches/01_use_cli_for_wrapper.patch:
  + patch wrapper script to meet the Debian CLI Policy
* debian/control:
  + Bump Standards version to 3.9.0 (no changes needed)

Show diffs side-by-side

added added

removed removed

Lines of Context:
70
70
                // http://developer.gimp.org/api/2.0/gdk-pixbuf/gdk-pixbuf-gdk-pixbuf.html#GdkPixbuf--bits-per-sample
71
71
                
72
72
                /// <summary>
73
 
                /// Applies a color transformation to each pixel in a pixbuf.
74
 
                /// </summary>
75
 
                /// <param name="source">
76
 
                /// A <see cref="Gdk.Pixbuf"/>
77
 
                /// </param>
78
 
                /// <param name="colorTransform">
79
 
                /// A <see cref="Func<Cairo.Color, Cairo.Color>"/>
80
 
                /// </param>
81
 
                /// <returns>
82
 
                /// A <see cref="Gdk.Pixbuf"/>
83
 
                /// </returns>
84
 
                public Gdk.Pixbuf PixelColorTransform (Gdk.Pixbuf source, Func<Cairo.Color, Cairo.Color> colorTransform)
85
 
                {
86
 
                        try {
87
 
                                int offset = (source.HasAlpha) ? 4 : 3;
88
 
                                Gdk.Pixbuf transform = source.Copy ();
89
 
                                unsafe {
90
 
                                        double r, g, b;
91
 
                                        byte* pixels = (byte*) transform.Pixels;
92
 
                                        for (int i = 0; i < transform.Height * transform.Width; i++) {
93
 
                                                r = (double) pixels[0];
94
 
                                                g = (double) pixels[1];
95
 
                                                b = (double) pixels[2];
96
 
                                                
97
 
                                                Cairo.Color color = new Cairo.Color (r / byte.MaxValue, 
98
 
                                                                                     g / byte.MaxValue, 
99
 
                                                                                     b / byte.MaxValue);
100
 
                                                
101
 
                                                color = colorTransform.Invoke (color);
102
 
                                                                                                
103
 
                                                pixels[0] = (byte) (color.R * byte.MaxValue);
104
 
                                                pixels[1] = (byte) (color.G * byte.MaxValue);
105
 
                                                pixels[2] = (byte) (color.B * byte.MaxValue);
106
 
                                                
107
 
                                                pixels += offset;
108
 
                                        }
109
 
                                }
110
 
                                source = transform.Copy ();
111
 
                                transform.Dispose ();
112
 
                        } catch (Exception e) {
113
 
                                Log<DrawingService>.Error ("Error transforming pixbuf: {0}", e.Message);
114
 
                                Log<DrawingService>.Debug (e.StackTrace);
115
 
                        }
116
 
                        
117
 
                        return source;
118
 
                }
119
 
                
120
 
                /// <summary>
121
73
                /// Determines whether or not the icon is light or dark.
122
74
                /// </summary>
123
75
                /// <param name="icon">
152
104
                        
153
105
                        return light > 0;
154
106
                }
 
107
                
155
108
                #endregion
156
 
 
157
 
                /// <summary>
158
 
                /// Returns a monochrome version of the supplied pixbuf.
159
 
                /// </summary>
160
 
                /// <param name="pbuf">
161
 
                /// A <see cref="Gdk.Pixbuf"/>
162
 
                /// </param>
163
 
                /// <returns>
164
 
                /// A <see cref="Gdk.Pixbuf"/>
165
 
                /// </returns>
166
 
                public Gdk.Pixbuf MonochromePixbuf (Gdk.Pixbuf source)
167
 
                {
168
 
                        return PixelColorTransform (source, (c) => c.DarkenBySaturation (0.5).SetSaturation (0));
169
 
                }
170
 
                
171
 
                /// <summary>
172
 
                /// Adds a hue shift to the supplpied pixbuf.
173
 
                /// </summary>
174
 
                /// <param name="source">
175
 
                /// A <see cref="Gdk.Pixbuf"/>
176
 
                /// </param>
177
 
                /// <param name="shift">
178
 
                /// A <see cref="System.Double"/>
179
 
                /// </param>
180
 
                /// <returns>
181
 
                /// A <see cref="Gdk.Pixbuf"/>
182
 
                /// </returns>
183
 
                public Gdk.Pixbuf AddHueShift (Gdk.Pixbuf source, double shift)
184
 
                {
185
 
                        if (shift != 0)
186
 
                                return PixelColorTransform (source, (c) => c.AddHue (shift));
187
 
                        return source;
188
 
                }
189
109
                
190
110
                /// <summary>
191
111
                /// Load an icon specifying the width and height.
252
172
                        
253
173
                        if (pixbuf != null) {
254
174
                                if (width != -1 && height != -1 && (width != pixbuf.Width || height != pixbuf.Height))
255
 
                                        pixbuf = ARScale (width, height, pixbuf);
 
175
                                        pixbuf = pixbuf.ARScale (width, height);
256
176
                                return pixbuf;
257
177
                        }               
258
178
                        
293
213
                }
294
214
                
295
215
                /// <summary>
296
 
                /// Scale a pixbuf to the desired width or height maintaining the aspect ratio of the supplied pixbuf.
297
 
                /// Note that due to maintaining the aspect ratio, the returned pixbuf may not have the exact width AND height as is specified.
298
 
                /// Though it is guaranteed that one of these measurements will be correct.
299
 
                /// </summary>
300
 
                /// <param name="width">
301
 
                /// A <see cref="System.Int32"/>
302
 
                /// </param>
303
 
                /// <param name="height">
304
 
                /// A <see cref="System.Int32"/>
305
 
                /// </param>
306
 
                /// <param name="pixbuf">
307
 
                /// A <see cref="Pixbuf"/>
308
 
                /// </param>
309
 
                /// <returns>
310
 
                /// A <see cref="Pixbuf"/>
311
 
                /// </returns>
312
 
                public Pixbuf ARScale (int width, int height, Pixbuf pixbuf)
313
 
                {                       
314
 
                        double xScale = (double) width / (double) pixbuf.Width;
315
 
                        double yScale = (double) height / (double) pixbuf.Height;
316
 
                        double scale = Math.Min (xScale, yScale);
317
 
                        
318
 
                        if (scale == 1) return pixbuf;
319
 
                        
320
 
                        Pixbuf temp = pixbuf;
321
 
                        pixbuf = temp.ScaleSimple ((int) (temp.Width * scale),
322
 
                                                   (int) (temp.Height * scale),
323
 
                                                   InterpType.Hyper);
324
 
                        temp.Dispose ();
325
 
                        
326
 
                        return pixbuf;
327
 
                }
328
 
                
329
 
                /// <summary>
330
216
                /// Returns the string name of the supplied icon.
331
217
                /// </summary>
332
218
                /// <param name="icon">
419
305
                                if (asm == null)
420
306
                                        throw new ArgumentNullException ("Could not find assembly '{0}'.", assemblyName);
421
307
                                
422
 
                                pixbuf = new Pixbuf (asm, resource);
423
 
                                
424
 
                                // now scale the pixbuf but keep the aspect ratio
425
 
                                if (width > 0 && height > 0)
426
 
                                        pixbuf = ARScale (width, height, pixbuf);
427
 
                                
 
308
                                if (width <= 0 || height <= 0)
 
309
                                        pixbuf = new Pixbuf (asm, resource);
 
310
                                else
 
311
                                        pixbuf = new Pixbuf (asm, resource, width, height);
428
312
                        } catch (Exception e) {
429
313
                                Log<DrawingService>.Warn ("Failed to load icon resource {0} from assembly {1}: {2}",
430
314
                                                         resource, assemblyName, e.Message);