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
1=== modified file 'src/notification.vala'
2--- src/notification.vala 2012-06-30 14:45:47 +0000
3+++ src/notification.vala 2013-06-12 21:18:28 +0000
4@@ -1,5 +1,4 @@
5
6-
7 public class Notification : Clutter.Group {
8
9 public enum Urgency {
10@@ -232,35 +231,39 @@
11
12 public void set_pix (HashTable<string, Variant> hints, string app, string icon) {
13 /*decide on the icon, order:
14- image-data
15+ image-data (also supports deprecated version: image_data)
16 image-path
17 app_icon
18 icon_data
19 from app name?
20 fallback to dialog-information
21 */
22- if (hints.contains ("image_data")) { /*image-data*/
23+ if (hints.contains ("image_data") || hints.contains ("image-data")) {
24 debug ("Using image_data");
25-
26- int width;
27- int height;
28- int rowstride;
29+
30+ var image_data = hints.lookup ("image_data");
31+ if (image_data == null)
32+ image_data = hints.lookup ("image-data");
33+
34+ return_if_fail (image_data != null);
35+
36+ weak uchar[] dummy_data;
37 bool has_alpha;
38- int bits_per_sample;
39- int channels;
40- weak Array<uint8> data;
41- //weak uint8 [] pixel;
42-
43- 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);
44-
45- /*var size = (height - 1) * rowstride + width * ((channels * bits_per_sample + 7) / 8);
46- pixel = (uint8[])GLib.Memory.dup (data, size);*/
47-
48- debug ("datalen: %u, width: %i, height: %i\n", data.length, width, height);
49-
50- 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);
51+ int width, height, rowstride, bits_per_sample, n_channels;
52+
53+ image_data.get ("(iiibiiay)", out width, out height, out rowstride,
54+ out has_alpha, out bits_per_sample, out n_channels, out dummy_data);
55+
56+ var pixels = image_data.get_child_value (6);
57+ weak uchar[] pixel_data = (uchar[]) pixels.get_data ();
58+
59+ var pix = new Gdk.Pixbuf.from_data (pixel_data, Gdk.Colorspace.RGB,
60+ has_alpha, bits_per_sample, width, height, rowstride, null);
61+
62+ var scaled_pix = pix.scale_simple (48, 48, Gdk.InterpType.HYPER);
63+
64 try {
65- tex.set_from_pixbuf (pix);
66+ tex.set_from_pixbuf (scaled_pix);
67 } catch (Error e) { warning (e.message); }
68 } else if (hints.contains ("image-path")) { /*image-path*/
69 debug ("Using image-path");

Subscribers

People subscribed via source and target branches