Merge lp:~bigwhale/gwibber/DMs into lp:gwibber

Proposed by David Klasinc
Status: Merged
Merged at revision: 1258
Proposed branch: lp:~bigwhale/gwibber/DMs
Merge into: lp:gwibber
Diff against target: 169 lines (+43/-59)
1 file modified
libgwibber-gtk/stream-view-tile.vala (+43/-59)
To merge this branch: bzr merge lp:~bigwhale/gwibber/DMs
Reviewer Review Type Date Requested Status
Ken VanDine Approve
Review via email: mp+92695@code.launchpad.net

Description of the change

Avatars made pretty.

To post a comment you must log in.
Revision history for this message
Ken VanDine (ken-vandine) wrote :

Looks great, thanks!

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'libgwibber-gtk/stream-view-tile.vala'
2--- libgwibber-gtk/stream-view-tile.vala 2012-02-09 09:20:33 +0000
3+++ libgwibber-gtk/stream-view-tile.vala 2012-02-12 23:29:17 +0000
4@@ -62,6 +62,8 @@
5 private Gtk.Alignment ralignment;
6 private Gtk.EventBox _avatar_box;
7 private Gtk.Box _avatar_hbox;
8+ private Gtk.Box _overlay_avatar_hbox;
9+ private Gtk.Fixed _avatar_fixed;
10 private Gtk.Image private;
11 private Gtk.Box vbox;
12 private Gtk.Box comments_box;
13@@ -123,9 +125,12 @@
14
15 _avatar_box = new Gtk.EventBox ();
16 _avatar_box.set_visible_window (false);
17+ _avatar_fixed = new Gtk.Fixed ();
18 _avatar_hbox = new Gtk.Box (Gtk.Orientation.HORIZONTAL, 0);
19+ _overlay_avatar_hbox = new Gtk.Box (Gtk.Orientation.HORIZONTAL, 0);
20 _avatar_box.set_size_request (48, 48);
21- _avatar_box.add (_avatar_hbox);
22+ _avatar_fixed.add (_avatar_hbox);
23+ _avatar_box.add (_avatar_fixed);
24 lalignment.add (_avatar_box);
25
26 vbox = new Gtk.Box (Gtk.Orientation.VERTICAL, 0);
27@@ -457,6 +462,10 @@
28 if (_w is Gtk.Widget)
29 _w.destroy ();
30
31+ foreach (var _w in _overlay_avatar_hbox.get_children ())
32+ if (_w is Gtk.Widget)
33+ _w.destroy ();
34+
35 foreach (var _w in comments_box.get_children ())
36 if (_w is Gtk.Widget)
37 _w.destroy ();
38@@ -635,68 +644,47 @@
39 var _avatar_cache_image = utils.avatar_path (_icon_uri);
40 var _overlay_avatar_cache_image = "";
41
42- if (_stream != "private")
43+ if (_avatar_cache_image != null)
44 {
45- if (_avatar_cache_image != null)
46- {
47- _avatar.set_from_file (_avatar_cache_image);
48- _avatar_hbox.add (_avatar);
49- _avatar_hbox.show ();
50- _avatar.show ();
51- } else
52- {
53- ulong _cache_avatar_id = Timeout.add (200, () => {
54- load_avatar_async.begin (_icon_uri, _avatar_hbox);
55- return false;
56- });
57- _to_disconnect.append (_cache_avatar_id);
58- }
59+ _avatar.set_from_file (_avatar_cache_image);
60+ _avatar_hbox.add (_avatar);
61+ _avatar_hbox.show ();
62+ _avatar.show ();
63 } else
64 {
65+ ulong _cache_avatar_id = Timeout.add (200, () => {
66+ load_avatar_async.begin (_icon_uri, _avatar_hbox);
67+ return false;
68+ });
69+ _to_disconnect.append (_cache_avatar_id);
70+ }
71+
72+ if (_stream == "private")
73+ {
74 _overlay_avatar_cache_image = utils.avatar_path (_recipient_icon);
75
76- // Deal with the private streams and avatars, introduce new memory leaks ...
77- Gdk.Pixbuf first_buf;
78- Gdk.Pixbuf second_buf;
79-
80- _avatar.set_from_icon_name("stock-person", Gtk.IconSize.DIALOG);
81- _overlay_avatar.set_from_icon_name("stock-person", Gtk.IconSize.DIALOG);
82-
83- first_buf = _avatar.get_pixbuf();
84- second_buf = _overlay_avatar.get_pixbuf();
85-
86- if (_avatar_cache_image != null)
87- {
88- first_buf = new Gdk.Pixbuf.from_file(_avatar_cache_image);
89- } else
90- {
91- ulong _cache_avatar_id = Timeout.add (200, () => {
92- load_avatar_async.begin (_icon_uri, _avatar_hbox);
93- return false;
94- });
95- _to_disconnect.append (_cache_avatar_id);
96- }
97-
98 if (_overlay_avatar_cache_image != null)
99 {
100- second_buf = new Gdk.Pixbuf.from_file(_overlay_avatar_cache_image);
101+ _overlay_avatar.set_from_file (_overlay_avatar_cache_image);
102+ Gdk.Pixbuf orig;
103+ Gdk.Pixbuf scaled;
104+ orig = _overlay_avatar.get_pixbuf();
105+ scaled = orig.scale_simple(24, 24, Gdk.InterpType.BILINEAR);
106+ _overlay_avatar.set_from_pixbuf(scaled);
107+ _overlay_avatar_hbox.add (_overlay_avatar);
108+
109+ _avatar_fixed.put(_overlay_avatar_hbox, 22, 22);
110+ _overlay_avatar_hbox.show ();
111+ _overlay_avatar.show ();
112 } else
113 {
114 ulong _cache_overlay_avatar_id = Timeout.add (200, () => {
115- load_avatar_async.begin (_recipient_icon, _avatar_hbox, true);
116+ load_avatar_async.begin (_recipient_icon, _overlay_avatar_hbox, true);
117 return false;
118 });
119 _to_disconnect.append (_cache_overlay_avatar_id);
120 }
121-
122- second_buf.composite(first_buf, 24, 24, 24, 24, 24, 24, 0.5, 0.5, Gdk.InterpType.BILINEAR, 255);
123- _avatar.set_from_pixbuf(first_buf);
124- _avatar_hbox.add (_avatar);
125- _avatar_hbox.show ();
126- _avatar.show ();
127- }
128-
129-
130+ }
131
132 if (_stream == "user")
133 {
134@@ -832,7 +820,7 @@
135 var stream = yield file.read_async (Priority.DEFAULT);
136
137 Gdk.Pixbuf pixbuf = null;
138- Gdk.Pixbuf first_buf = null;
139+ Gdk.Pixbuf scaled = null;
140
141 pixbuf = new Gdk.Pixbuf.from_stream_at_scale (stream,
142 48,
143@@ -842,21 +830,17 @@
144 {
145 var avatar = new StreamViewAvatar ();
146 foreach (var _w in b.get_children ())
147- {
148- if (overlay && _w is StreamViewAvatar)
149- {
150- Gtk.Image _r = (Gtk.Image) _w;
151- first_buf = _r.get_pixbuf();
152- }
153 if (_w is Gtk.Widget)
154 _w.destroy ();
155- }
156+
157 if (overlay)
158 {
159- pixbuf.composite(first_buf, 24, 24, 24, 24, 24, 24, 0.5, 0.5, Gdk.InterpType.BILINEAR, 255);
160- avatar.set_from_pixbuf (first_buf);
161+ scaled = pixbuf.scale_simple(24, 24, Gdk.InterpType.BILINEAR);
162+ avatar.set_from_pixbuf (scaled);
163 } else
164+ {
165 avatar.set_from_pixbuf (pixbuf);
166+ }
167
168 b.add (avatar);
169 avatar.show ();