~ricotz/plank/hide-small-window-list

« back to all changes in this revision

Viewing changes to lib/Drawing/DrawingService.vala

  • Committer: Rico Tzschichholz
  • Date: 2014-11-19 14:39:22 UTC
  • Revision ID: ricotz@ubuntu.com-20141119143922-j162344wb6l2ohr4
Fallback on "application-default-icon" icon only or use internal default

Also Wnck is returning its default window-icon ignore it and use the our
fallback chain instead.

Show diffs side-by-side

added added

removed removed

Lines of Context:
22
22
         */
23
23
        public class DrawingService : GLib.Object
24
24
        {
25
 
                const string MISSING_ICONS = "application-default-icon;;application-x-executable";
 
25
                const string DEFAULT_ICON = "application-default-icon";
26
26
                
27
27
                const string FILE_ATTRIBUTE_CUSTOM_ICON = "metadata::custom-icon";
28
28
                const string FILE_ATTRIBUTE_CUSTOM_ICON_NAME = "metadata::custom-icon-name";
110
110
                        
111
111
                        foreach (unowned string s in names.split (";;"))
112
112
                                all_names.add (s);
113
 
                        foreach (unowned string s in MISSING_ICONS.split (";;"))
114
 
                                all_names.add (s);
 
113
                        all_names.add (DEFAULT_ICON);
115
114
                        
116
115
                        Gdk.Pixbuf? pbuf = null;
117
116
                        
131
130
                                        message ("Could not find icon '%s'", name);
132
131
                        }
133
132
                        
 
133
                        // Load internal default icon as last resort
 
134
                        if (pbuf == null)
 
135
                                try {
 
136
                                        pbuf = new Gdk.Pixbuf.from_resource_at_scale ("%s/img/application-default-icon.svg".printf (Plank.G_RESOURCE_PATH),
 
137
                                                width, height, true);
 
138
                                } catch (Error e) {
 
139
                                        critical (e.message);
 
140
                                }
 
141
                        
134
142
                        if (pbuf != null) {
135
143
                                if (width != -1 && height != -1 && (width != pbuf.width || height != pbuf.height))
136
144
                                        return ar_scale (pbuf, width, height);
218
226
                        
219
227
                        foreach (unowned string s in names.split (";;"))
220
228
                                all_names.add (s);
221
 
                        foreach (unowned string s in MISSING_ICONS.split (";;"))
222
 
                                all_names.add (s);
 
229
                        all_names.add (DEFAULT_ICON);
223
230
                        
224
231
                        Cairo.Surface? surface = null;
225
232
                        
245
252
                                        message ("Could not find icon '%s'", name);
246
253
                        }
247
254
                        
248
 
                        if (surface == null)
249
 
                                warning ("No icon found of '%s'", names);
 
255
                        // Load internal default icon as last resort
 
256
                        if (surface == null) {
 
257
                                try {
 
258
                                        var pbuf = new Gdk.Pixbuf.from_resource_at_scale ("%s/img/application-default-icon.svg".printf (Plank.G_RESOURCE_PATH),
 
259
                                                width, height, true);
 
260
                                        surface = new Cairo.ImageSurface (Cairo.Format.ARGB32, width, height);
 
261
                                        var cr = new Cairo.Context (surface);
 
262
                                        Gdk.cairo_set_source_pixbuf (cr, pbuf, (width - pbuf.width) / 2, (height - pbuf.height) / 2);
 
263
                                        cr.paint ();
 
264
                                        cairo_surface_set_device_scale (surface, scale, scale);
 
265
                                } catch (Error e) {
 
266
                                        critical (e.message);
 
267
                                }
 
268
                        }
250
269
                        
251
270
                        return surface;
252
271
                }