[Xfce4-commits] <postler:master> Fallback to Gravatar if there is no avatar
Christian Dywan
noreply at xfce.org
Thu Jul 7 23:54:01 CEST 2011
Updating branch refs/heads/master
to 7466ba49c2be923410ee7d8526b39d5c728ef5b1 (commit)
from 8132867118177c74f6f09c906e667697413c5625 (commit)
commit 7466ba49c2be923410ee7d8526b39d5c728ef5b1
Author: Christian Dywan <christian at twotoasts.de>
Date: Thu Jul 7 23:45:06 2011 +0200
Fallback to Gravatar if there is no avatar
postler/postler-content.vala | 8 +++-----
postler/postler-message.vala | 10 +++++++++-
postler/postler-viewer.vala | 2 ++
3 files changed, 14 insertions(+), 6 deletions(-)
diff --git a/postler/postler-content.vala b/postler/postler-content.vala
index 931beca..6c61753 100644
--- a/postler/postler-content.vala
+++ b/postler/postler-content.vala
@@ -55,8 +55,9 @@ public class Postler.Content : WebKit.WebView {
.avatar {
display: none;
}
- .avatar[src^=file] {
+ .avatar[src^=file], .avatar[src^=http] {
display: inline;
+ width: 48px; height: 48px;
float: right;
}
.button, .button[href] {
@@ -809,10 +810,7 @@ public class Postler.Content : WebKit.WebView {
/* Do inherit colors, to match Adium and Empathy */
reply_markup = reply_markup.replace ("%sender%", linkify_address (child.sender, true));
reply_markup = reply_markup.replace ("%time{%X}%", format_date (child.date));
- string avatar_uri = "Incoming/buddy_icon.png";
- if (child.avatar != null && child.avatar.get_path () != null) {
- avatar_uri = child.avatar.get_uri ();
- }
+ string avatar_uri = child.get_avatar_uri () ?? "Incoming/buddy_icon.png";
reply_markup = reply_markup.replace ("%userIconPath%", avatar_uri);
foreach (var attachment_part in child.parts) {
diff --git a/postler/postler-message.vala b/postler/postler-message.vala
index d9e3bee..347514c 100644
--- a/postler/postler-message.vala
+++ b/postler/postler-message.vala
@@ -94,7 +94,7 @@ namespace Postler {
public int64 get_timestamp () { return date != null ? date.to_unix () : 0; }
public string? subject { public get; set; }
public string? sender { public get; internal set; }
- public GLib.File? avatar { public get; internal set; }
+ public GLib.File? avatar { get; internal set; }
public string? recipients { public get; set; }
public string? reply_to { public get; set; }
public bool can_reply_personally { public get; set; default = true; }
@@ -115,6 +115,14 @@ namespace Postler {
public MessagePart? html_part = null;
public MessagePart? text_part = null;
+ public string get_avatar_uri () {
+ if (avatar != null && avatar.get_uri () != null)
+ return avatar.get_uri ();
+ string sender_checksum = GLib.Checksum.compute_for_string (
+ GLib.ChecksumType.MD5, Contact.address_from_string (sender));
+ return "http://www.gravatar.com/avatar/%s?d=identicon".printf (sender_checksum);
+ }
+
bool init (GLib.Cancellable? cancellable = null) throws GLib.Error {
return false;
}
diff --git a/postler/postler-viewer.vala b/postler/postler-viewer.vala
index 7a929ce..e518223 100644
--- a/postler/postler-viewer.vala
+++ b/postler/postler-viewer.vala
@@ -93,6 +93,8 @@ public class Postler.Viewer : Gtk.VBox {
void resource_request (WebKit.WebFrame frame, WebKit.WebResource resouce,
WebKit.NetworkRequest request, WebKit.NetworkResponse? response) {
+ if (request.uri.has_prefix ("http://www.gravatar.com/avatar/"))
+ return;
if (!allow_external_images && request.uri.has_prefix ("http")) {
request.uri = "about:blank";
infobar.set_no_show_all (false);
More information about the Xfce4-commits
mailing list