clean up helpers and update more paths

This commit is contained in:
Hylke Bons 2010-05-08 15:38:21 +01:00
parent 83800af5d8
commit b93ffb0d51
3 changed files with 15 additions and 19 deletions

View file

@ -32,18 +32,15 @@ namespace SparkleShare {
if (!Directory.Exists (AvatarPath)) {
Directory.CreateDirectory (AvatarPath);
Console.WriteLine ("[Config] Created '" + AvatarPath + "'");
}
string AvatarFilePath = AvatarPath + Email;
if (File.Exists (AvatarFilePath))
return AvatarFilePath;
else {
// Let's try to get the person's gravatar for next time
WebClient WebClient = new WebClient ();
Uri GravatarUri = new Uri ("http://www.gravatar.com/avatar/" +
GetMD5 (Email) + ".jpg?s=" + Size + "&d=404");
@ -66,26 +63,25 @@ namespace SparkleShare {
Size + "x" + Size,
"status",
"avatar-default.png");
if (File.Exists (FallbackFileName))
return FallbackFileName;
else
return "";
}
}
// Helper that creates an MD5 hash
// Creates an MD5 hash
public static string GetMD5 (string s) {
MD5 md5 = new MD5CryptoServiceProvider ();
Byte[] Bytes = ASCIIEncoding.Default.GetBytes (s);
Byte[] EncodedBytes = md5.ComputeHash (Bytes);
return BitConverter.ToString(EncodedBytes).ToLower ().Replace ("-", "");
}
// Makes it possible to combine more than
// two paths at once.
public static string CombineMore (params string [] Parts) {
string NewPath = "";
foreach (string Part in Parts)

View file

@ -41,7 +41,7 @@ namespace SparkleShare {
public string UserName;
public bool MonitorOnly;
public SparkleRepo (string Path) {
public SparkleRepo (string RepoPath) {
MonitorOnly = false;
@ -50,9 +50,9 @@ namespace SparkleShare {
Process.StartInfo.RedirectStandardOutput = true;
Process.StartInfo.UseShellExecute = false;
// Get the repository's path, example: "/home/user/SparkleShare/repo/"
LocalPath = Path;
Process.StartInfo.WorkingDirectory = LocalPath + "/";
// Get the repository's path, example: "/home/user/SparkleShare/repo"
LocalPath = RepoPath;
Process.StartInfo.WorkingDirectory = LocalPath;
// Get user.name, example: "User Name"
UserName = "Anonymous";
@ -75,9 +75,7 @@ namespace SparkleShare {
RemoteOriginUrl = Process.StandardOutput.ReadToEnd().Trim ();
// Get the repository name, example: "Project"
string s = LocalPath.TrimEnd ( "/".ToCharArray ());
Name = LocalPath.Substring (s.LastIndexOf ("/") + 1);
Name = Path.GetFileName (LocalPath);
// Get the domain, example: "github.com"
Domain = RemoteOriginUrl;

View file

@ -34,10 +34,12 @@ namespace SparkleShare {
public SparkleSpinner () : base () {
Size = 48;
Gdk.Pixbuf SpinnerGallery = new Gdk.Pixbuf ("/usr/share/icons/" +
"gnome/" + Size + "x" +
Size + "/animations/" +
"process-working.png");
string SpinnerFileName = SparkleHelpers.CombineMore (
SparklePaths.SparkleIconPath,
Size + "x" + Size, "animations",
"process-working.png");
Gdk.Pixbuf SpinnerGallery = new Gdk.Pixbuf (SpinnerFileName);
CycleDuration = 750;
CurrentStep = 0;