233
232
public void set_pix (HashTable<string, Variant> hints, string app, string icon) {
234
233
/*decide on the icon, order:
234
image-data (also supports deprecated version: image_data)
240
239
fallback to dialog-information
242
if (hints.contains ("image_data")) { /*image-data*/
241
if (hints.contains ("image_data") || hints.contains ("image-data")) {
243
242
debug ("Using image_data");
244
var image_data = hints.lookup ("image_data");
245
if (image_data == null)
246
image_data = hints.lookup ("image-data");
248
return_if_fail (image_data != null);
250
weak uchar[] dummy_data;
251
weak Array<uint8> data;
252
//weak uint8 [] pixel;
254
hints.lookup ("image_data").get ("(iiibiiay)", out width, out height, out rowstride, out has_alpha, out bits_per_sample, out channels, out data, uint.MAX);
256
/*var size = (height - 1) * rowstride + width * ((channels * bits_per_sample + 7) / 8);
257
pixel = (uint8[])GLib.Memory.dup (data, size);*/
259
debug ("datalen: %u, width: %i, height: %i\n", data.length, width, height);
261
var pix = new Gdk.Pixbuf.from_data ((uint8[])data, Gdk.Colorspace.RGB, has_alpha, bits_per_sample, width, height, rowstride, null).scale_simple (48, 48, Gdk.InterpType.HYPER);
252
int width, height, rowstride, bits_per_sample, n_channels;
254
image_data.get ("(iiibiiay)", out width, out height, out rowstride,
255
out has_alpha, out bits_per_sample, out n_channels, out dummy_data);
257
var pixels = image_data.get_child_value (6);
258
weak uchar[] pixel_data = (uchar[]) pixels.get_data ();
260
var pix = new Gdk.Pixbuf.from_data (pixel_data, Gdk.Colorspace.RGB,
261
has_alpha, bits_per_sample, width, height, rowstride, null);
263
var scaled_pix = pix.scale_simple (48, 48, Gdk.InterpType.HYPER);
263
tex.set_from_pixbuf (pix);
266
tex.set_from_pixbuf (scaled_pix);
264
267
} catch (Error e) { warning (e.message); }
265
268
} else if (hints.contains ("image-path")) { /*image-path*/
266
269
debug ("Using image-path");