diff --git a/src/client/conversation-viewer/conversation-message.vala b/src/client/conversation-viewer/conversation-message.vala index efae4762..7c443b1f 100644 --- a/src/client/conversation-viewer/conversation-message.vala +++ b/src/client/conversation-viewer/conversation-message.vala @@ -77,9 +77,10 @@ public class ConversationMessage : Gtk.Box { internal ConversationWebView web_view { get; private set; } [GtkChild] - private Gtk.Revealer preview_revealer; + private Gtk.Image avatar; + [GtkChild] - private Gtk.Image preview_avatar; + private Gtk.Revealer preview_revealer; [GtkChild] private Gtk.Label preview_from; [GtkChild] @@ -90,8 +91,6 @@ public class ConversationMessage : Gtk.Box { [GtkChild] private Gtk.Revealer header_revealer; [GtkChild] - private Gtk.Image header_avatar; - [GtkChild] private Gtk.FlowBox from; [GtkChild] private Gtk.Label subject; @@ -289,7 +288,7 @@ public class ConversationMessage : Gtk.Box { } /** - * Starts loading the avatar for the sender of the message. + * Starts loading the avatar for the message's sender. */ public async void load_avatar(Soup.Session session, Cancellable load_cancellable) { // Queued messages are cancelled in ConversationViewer.clear() @@ -299,7 +298,7 @@ public class ConversationMessage : Gtk.Box { Geary.RFC822.MailboxAddress? primary = message.get_primary_originator(); if (primary != null) { int window_scale = get_scale_factor(); - int pixel_size = header_avatar.get_pixel_size(); + int pixel_size = this.avatar.get_pixel_size(); Soup.Message message = new Soup.Message( "GET", Gravatar.get_image_uri( @@ -541,36 +540,28 @@ public class ConversationMessage : Gtk.Box { } private void set_avatar(uint8[] image_data) { - Gdk.Pixbuf avatar = null; + Gdk.Pixbuf avatar_buf = null; Gdk.PixbufLoader loader = new Gdk.PixbufLoader(); try { loader.write(image_data); loader.close(); - avatar = loader.get_pixbuf(); + avatar_buf = loader.get_pixbuf(); } catch (Error err) { debug("Error loading Gravatar response: %s", err.message); } - if (avatar != null) { - Gdk.Window window = get_window(); + if (avatar_buf != null) { int window_scale = get_scale_factor(); - int preview_size = preview_avatar.pixel_size * window_scale; - preview_avatar.set_from_surface( - Gdk.cairo_surface_create_from_pixbuf( - avatar.scale_simple( - preview_size, preview_size, Gdk.InterpType.BILINEAR - ), - window_scale, - window) - ); - int header_size = header_avatar.pixel_size * window_scale; - if (avatar.width != header_size) { - avatar = avatar.scale_simple( - header_size, header_size, Gdk.InterpType.BILINEAR + int avatar_size = this.avatar.pixel_size * window_scale; + if (avatar_buf.width != avatar_size) { + avatar_buf = avatar_buf.scale_simple( + avatar_size, avatar_size, Gdk.InterpType.BILINEAR ); } - header_avatar.set_from_surface( - Gdk.cairo_surface_create_from_pixbuf(avatar, window_scale, window) + this.avatar.set_from_surface( + Gdk.cairo_surface_create_from_pixbuf( + avatar_buf, window_scale, get_window() + ) ); } } diff --git a/ui/conversation-message.ui b/ui/conversation-message.ui index 59e4e1bb..92a92e14 100644 --- a/ui/conversation-message.ui +++ b/ui/conversation-message.ui @@ -11,6 +11,22 @@ True False 6 + + + 18 + 18 + True + False + start + 32 + avatar-default-symbolic + + + False + False + 0 + + True @@ -27,22 +43,6 @@ True False 6 - - - 18 - 18 - True - False - start - 32 - avatar-default-symbolic - - - False - False - 0 - - True @@ -106,7 +106,7 @@ True True - 1 + 0 @@ -128,22 +128,6 @@ True False 6 - - - 18 - 18 - True - False - start - 48 - avatar-default-symbolic - - - False - False - 0 - - True @@ -352,7 +336,7 @@ True True - 1 + 0 @@ -368,7 +352,7 @@ True True - 0 + 1