d9e13ed064
GitOrigin-RevId: a930f7da84786807bb105df40e76b541604c3e72
55 lines
2.4 KiB
Diff
55 lines
2.4 KiB
Diff
From 9e61e9493e78b83b9599886561ee596c096030ed Mon Sep 17 00:00:00 2001
|
|
From: Bobby Rong <rjl931189261@126.com>
|
|
Date: Thu, 29 Jul 2021 13:57:21 +0800
|
|
Subject: [PATCH] Partly revert "Fix Warnings in Vala Code (#600)"
|
|
|
|
This partly reverts commit 9477c24201d3c9c3c7bcc650e0290daa0ee1ab21.
|
|
---
|
|
src/MessageList/MessageListItem.vala | 27 ++++++++++++++++++++++++++-
|
|
1 file changed, 26 insertions(+), 1 deletion(-)
|
|
|
|
diff --git a/src/MessageList/MessageListItem.vala b/src/MessageList/MessageListItem.vala
|
|
index 96b61027..a7ef8f9e 100644
|
|
--- a/src/MessageList/MessageListItem.vala
|
|
+++ b/src/MessageList/MessageListItem.vala
|
|
@@ -290,7 +290,7 @@ public class Mail.MessageListItem : Gtk.ListBoxRow {
|
|
expanded = false;
|
|
show_all ();
|
|
|
|
- avatar.set_loadable_icon (new GravatarIcon (parsed_address, get_style_context ().get_scale ()));
|
|
+ download_gravatar.begin (parsed_address, avatar.size);
|
|
|
|
/* Override default handler to stop event propagation. Otherwise clicking the menu will
|
|
expand or collapse the MessageListItem. */
|
|
@@ -348,6 +348,31 @@ public class Mail.MessageListItem : Gtk.ListBoxRow {
|
|
});
|
|
}
|
|
|
|
+ private async void download_gravatar (string address, int size) {
|
|
+ if (avatars[address] == null) {
|
|
+ var uri = "https://secure.gravatar.com/avatar/%s?d=404&s=%d".printf (
|
|
+ Checksum.compute_for_string (ChecksumType.MD5, address.strip ().down ()),
|
|
+ size * get_style_context ().get_scale ()
|
|
+ );
|
|
+
|
|
+ var server_file = File.new_for_uri (uri);
|
|
+ var path = Path.build_filename (Environment.get_tmp_dir (), server_file.get_basename ());
|
|
+ var local_file = File.new_for_path (path);
|
|
+
|
|
+ try {
|
|
+ yield server_file.copy_async (local_file, FileCopyFlags.OVERWRITE, Priority.DEFAULT, null);
|
|
+ avatars[address] = new Gdk.Pixbuf.from_file_at_scale (path, size, size, true);
|
|
+ } catch (Error e) {
|
|
+ debug ("Unable to fetch gravatar: %s", e.message);
|
|
+ return;
|
|
+ }
|
|
+ }
|
|
+
|
|
+ avatar.set_image_load_func (() => {
|
|
+ return avatars[address];
|
|
+ });
|
|
+ }
|
|
+
|
|
private void add_inline_composer (ComposerWidget.Type composer_type) {
|
|
var message_list_box = (MessageListBox) get_parent ();
|
|
message_list_box.add_inline_composer.begin (composer_type, this);
|