let getavatar return pixbuf instead of string

This commit is contained in:
Hylke Bons 2010-05-10 23:20:17 +01:00
parent 19771e874a
commit fc4ca70d9d
3 changed files with 11 additions and 18 deletions

View file

@ -25,7 +25,7 @@ namespace SparkleShare {
public static class SparkleHelpers {
public static string GetAvatarFileName (string Email, int Size) {
public static Gdk.Pixbuf GetAvatar (string Email, int Size) {
string AvatarPath = Path.Combine (SparklePaths.SparkleAvatarPath,
Size + "x" + Size);
@ -38,7 +38,7 @@ namespace SparkleShare {
string AvatarFilePath = AvatarPath + Email;
if (File.Exists (AvatarFilePath))
return AvatarFilePath;
return new Gdk.Pixbuf (AvatarFilePath);
else {
// Let's try to get the person's gravatar for next time
@ -60,14 +60,10 @@ namespace SparkleShare {
}
string FallbackFileName = CombineMore (SparklePaths.SparkleIconPath,
Size + "x" + Size,
"status",
"avatar-default.png");
if (File.Exists (AvatarPath + Email))
return AvatarPath + Email;
return new Gdk.Pixbuf (AvatarPath + Email);
else
return FallbackFileName;
return GetIcon ("avatar-default", Size);
}
@ -95,7 +91,7 @@ namespace SparkleShare {
// Looks up an icon from the system's theme
public static Gdk.Pixbuf GetIcon (string Name, int Size) {
// SparkleTheme.AppendSearchPath (SparklePaths.SparkleInstallPath);
SparkleTheme.AppendSearchPath (SparklePaths.SparkleInstallPath);
return SparkleTheme.LoadIcon (Name, Size,
IconLookupFlags.GenericFallback);
}

View file

@ -200,7 +200,7 @@ namespace SparkleShare {
Process.StartInfo.Arguments = "commit -m \"" + Message + "\"";
Process.Start();
ShowEventBubble (UserName + " " + Message,
SparkleHelpers.GetAvatarFileName (UserEmail, 48),
SparkleHelpers.GetAvatar (UserEmail, 48),
true);
}
@ -246,7 +246,7 @@ namespace SparkleShare {
string LastCommitUserName = Process.StandardOutput.ReadToEnd().Trim ();
ShowEventBubble (LastCommitUserName + " " + LastCommitMessage,
SparkleHelpers.GetAvatarFileName (LastCommitEmail, 48),
SparkleHelpers.GetAvatar (LastCommitEmail, 48),
true);
}
@ -371,11 +371,11 @@ namespace SparkleShare {
// Shows a notification with text and image
public void ShowEventBubble (string Title,
string IconFileName,
bool ShowButtons) {
Gdk.Pixbuf Avatar,
bool ShowButtons) {
SparkleBubble StuffChangedBubble = new SparkleBubble (Title, "");
StuffChangedBubble.Icon = new Gdk.Pixbuf (IconFileName);
StuffChangedBubble.Icon = Avatar;
// Add a button to open the folder where the changed file is
if (ShowButtons)

View file

@ -408,13 +408,10 @@ namespace SparkleShare {
if (UserName.Equals (SparkleRepo.UserName))
UserName += " (thats you!)";
string AvatarFileName =
SparkleHelpers.GetAvatarFileName (UserEmail, 32);
// Actually add to the list
PeopleIter = PeopleStore.Prepend ();
PeopleStore.SetValue (PeopleIter, 0,
new Gdk.Pixbuf (AvatarFileName));
SparkleHelpers.GetAvatar (UserEmail , 32));
PeopleStore.SetValue (PeopleIter, 1, UserName + "\n" + UserEmail);
}