[log] pass avatars to the new webkit view

This commit is contained in:
Hylke Bons 2010-11-07 22:53:12 +00:00 committed by Łukasz Jernaś
parent e2ad57d3ea
commit 27f687ff23
5 changed files with 25 additions and 15 deletions

View file

@ -37,7 +37,7 @@ namespace SparkleLib {
public static string SparkleInstallPath = SparkleHelpers.CombineMore (Defines.PREFIX, "sparkleshare");
public static string SparkleLocalIconPath = SparkleHelpers.CombineMore (HomePath, ".icons", "sparkleshare");
public static string SparkleLocalIconPath = SparkleHelpers.CombineMore (SparkleConfigPath, "icons", "hicolor");
public static string SparkleIconPath = SparkleHelpers.CombineMore (Defines.PREFIX, "share", "sparkleshare",
"icons");

View file

@ -222,6 +222,8 @@ namespace SparkleShare {
foreach (SparkleCommit commit in commits) {
SparkleUIHelpers.GetAvatar (commit.UserEmail, 32);
bool commit_inserted = false;
foreach (ActivityDay stored_activity_day in activity_days) {
@ -365,10 +367,11 @@ namespace SparkleShare {
}
}
Console.WriteLine(SparkleUIHelpers.GetAvatar (change_set.UserEmail, 32));
event_entry += "</dl>";
event_entries += event_entry_html.Replace ("<!-- $event-entry-content -->", event_entry)
.Replace ("<!-- $event-user-name -->", change_set.UserName)
.Replace ("<!-- $event-avatar-url -->", "file://" + SparkleUIHelpers.GetAvatar (change_set.UserEmail, 32))
.Replace ("<!-- $event-time -->", change_set.DateTime.ToString ("H:mm"));
}
@ -445,7 +448,7 @@ Console.WriteLine ("CLICKED!:" + Status);
// wrapper.ModifyBg (StateType.Normal, background_color);
WebView.LoadHtmlString (html, "");
WebView.LoadHtmlString (html, "file://");
WebView.HoveringOverLink += delegate {};
ScrolledWindow.AddWithViewport (WebView);

View file

@ -120,9 +120,14 @@ namespace SparkleShare {
Application.Invoke (delegate {
SparkleBubble bubble = new SparkleBubble (commit.UserName, message) {
Icon = SparkleUIHelpers.GetAvatar (commit.UserEmail, 32)
};
SparkleBubble bubble = new SparkleBubble (commit.UserName, message);
string avatar_file_path = SparkleUIHelpers.GetAvatar (commit.UserEmail, 32);
if (avatar_file_path != null)
bubble.Icon = new Gdk.Pixbuf (avatar_file_path);
else
bubble.Icon = SparkleUIHelpers.GetIcon ("avatar-default", 32);
bubble.AddAction ("", "Show Events", delegate {

View file

@ -37,7 +37,7 @@ namespace SparkleShare {
// Gets the avatar for a specific email address and size
public static Gdk.Pixbuf GetAvatar (string email, int size)
public static string GetAvatar (string email, int size)
{
string avatar_path = SparkleHelpers.CombineMore (SparklePaths.SparkleLocalIconPath,
@ -54,12 +54,12 @@ namespace SparkleShare {
if (File.Exists (avatar_file_path)) {
return new Gdk.Pixbuf (avatar_file_path);
return avatar_file_path;
} else {
// Let's try to get the person's gravatar for next time
WebClient WebClient = new WebClient ();
WebClient web_client = new WebClient ();
Uri uri = new Uri ("http://www.gravatar.com/avatar/" + GetMD5 (email) +
".jpg?s=" + size + "&d=404");
@ -67,11 +67,13 @@ namespace SparkleShare {
if (!File.Exists (tmp_file_path)) {
WebClient.DownloadFileAsync (uri, tmp_file_path);
web_client.DownloadFileAsync (uri, tmp_file_path);
WebClient.DownloadFileCompleted += delegate {
web_client.DownloadFileCompleted += delegate {
if (File.Exists (avatar_file_path))
File.Delete (avatar_file_path);
File.Delete (avatar_file_path);
FileInfo tmp_file_info = new FileInfo (tmp_file_path);
if (tmp_file_info.Length > 255)
@ -83,9 +85,9 @@ namespace SparkleShare {
// Fall back to a generic icon if there is no gravatar
if (File.Exists (avatar_file_path))
return new Gdk.Pixbuf (avatar_file_path);
return avatar_file_path;
else
return GetIcon ("avatar-default", size);
return null;
}

View file

@ -4,7 +4,7 @@
<table>
<tr>
<td><img src='http://www.gravatar.com/avatar/3e8eee17a5d6c6a20b073af0d2b2b48b.png' width='32'></td>
<td><img src='<!-- $event-avatar-url -->'></td>
<td width='100%'>
<b><!-- $event-user-name --></b><br>
<!-- $event-entry-content -->