Merge lp:~victored/pantheon-notify/lp-991557 into lp:pantheon-notify

Proposed by Victor Martinez
Status: Merged
Merged at revision: 26
Proposed branch: lp:~victored/pantheon-notify/lp-991557
Merge into: lp:pantheon-notify
Diff against target: 69 lines (+24/-21)
1 file modified
src/notification.vala (+24/-21)
To merge this branch: bzr merge lp:~victored/pantheon-notify/lp-991557
Reviewer Review Type Date Requested Status
Tom Beckmann (community) Approve
Review via email: mp+169058@code.launchpad.net

Commit message

Properly load image corresponding to "image_data". Also add support for "image-data" since the former has been deprecated. Fixes lp:991557

Description of the change

Properly load image corresponding to "image_data". Also add support for "image-data" since the former has been deprecated. Fixes lp:991557

To post a comment you must log in.
Revision history for this message
Tom Beckmann (tombeckmann) wrote :

Awesome!!! Finally this bug is solved, I cannot thank you enough!

I had to set the size of 48px on the GtkClutterTexture manually here on 13.04 in order to make the image show up, not sure why, now it's working perfectly. Anyway, I will push this fix right after I merged this awesomeness.

review: Approve
Revision history for this message
Victor Martinez (victored) wrote :

Fantastic, thanks for the review :)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'src/notification.vala'
--- src/notification.vala 2012-06-30 14:45:47 +0000
+++ src/notification.vala 2013-06-12 21:18:28 +0000
@@ -1,5 +1,4 @@
11
2
3public class Notification : Clutter.Group {2public class Notification : Clutter.Group {
4 3
5 public enum Urgency {4 public enum Urgency {
@@ -232,35 +231,39 @@
232 231
233 public void set_pix (HashTable<string, Variant> hints, string app, string icon) {232 public void set_pix (HashTable<string, Variant> hints, string app, string icon) {
234 /*decide on the icon, order:233 /*decide on the icon, order:
235 image-data234 image-data (also supports deprecated version: image_data)
236 image-path235 image-path
237 app_icon236 app_icon
238 icon_data237 icon_data
239 from app name?238 from app name?
240 fallback to dialog-information239 fallback to dialog-information
241 */240 */
242 if (hints.contains ("image_data")) { /*image-data*/241 if (hints.contains ("image_data") || hints.contains ("image-data")) {
243 debug ("Using image_data");242 debug ("Using image_data");
244 243
245 int width;244 var image_data = hints.lookup ("image_data");
246 int height;245 if (image_data == null)
247 int rowstride;246 image_data = hints.lookup ("image-data");
247
248 return_if_fail (image_data != null);
249
250 weak uchar[] dummy_data;
248 bool has_alpha;251 bool has_alpha;
249 int bits_per_sample;252 int width, height, rowstride, bits_per_sample, n_channels;
250 int channels;253
251 weak Array<uint8> data;254 image_data.get ("(iiibiiay)", out width, out height, out rowstride,
252 //weak uint8 [] pixel;255 out has_alpha, out bits_per_sample, out n_channels, out dummy_data);
253 256
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);257 var pixels = image_data.get_child_value (6);
255 258 weak uchar[] pixel_data = (uchar[]) pixels.get_data ();
256 /*var size = (height - 1) * rowstride + width * ((channels * bits_per_sample + 7) / 8);259
257 pixel = (uint8[])GLib.Memory.dup (data, size);*/260 var pix = new Gdk.Pixbuf.from_data (pixel_data, Gdk.Colorspace.RGB,
258 261 has_alpha, bits_per_sample, width, height, rowstride, null);
259 debug ("datalen: %u, width: %i, height: %i\n", data.length, width, height);262
260 263 var scaled_pix = pix.scale_simple (48, 48, Gdk.InterpType.HYPER);
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);264
262 try {265 try {
263 tex.set_from_pixbuf (pix);266 tex.set_from_pixbuf (scaled_pix);
264 } catch (Error e) { warning (e.message); }267 } catch (Error e) { warning (e.message); }
265 } else if (hints.contains ("image-path")) { /*image-path*/268 } else if (hints.contains ("image-path")) { /*image-path*/
266 debug ("Using image-path");269 debug ("Using image-path");

Subscribers

People subscribed via source and target branches