clean up helpers and update more paths
This commit is contained in:
parent
83800af5d8
commit
b93ffb0d51
|
@ -32,18 +32,15 @@ namespace SparkleShare {
|
||||||
if (!Directory.Exists (AvatarPath)) {
|
if (!Directory.Exists (AvatarPath)) {
|
||||||
Directory.CreateDirectory (AvatarPath);
|
Directory.CreateDirectory (AvatarPath);
|
||||||
Console.WriteLine ("[Config] Created '" + AvatarPath + "'");
|
Console.WriteLine ("[Config] Created '" + AvatarPath + "'");
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
string AvatarFilePath = AvatarPath + Email;
|
string AvatarFilePath = AvatarPath + Email;
|
||||||
|
|
||||||
if (File.Exists (AvatarFilePath))
|
if (File.Exists (AvatarFilePath))
|
||||||
return AvatarFilePath;
|
return AvatarFilePath;
|
||||||
|
|
||||||
else {
|
else {
|
||||||
|
|
||||||
// Let's try to get the person's gravatar for next time
|
// Let's try to get the person's gravatar for next time
|
||||||
|
|
||||||
WebClient WebClient = new WebClient ();
|
WebClient WebClient = new WebClient ();
|
||||||
Uri GravatarUri = new Uri ("http://www.gravatar.com/avatar/" +
|
Uri GravatarUri = new Uri ("http://www.gravatar.com/avatar/" +
|
||||||
GetMD5 (Email) + ".jpg?s=" + Size + "&d=404");
|
GetMD5 (Email) + ".jpg?s=" + Size + "&d=404");
|
||||||
|
@ -66,26 +63,25 @@ namespace SparkleShare {
|
||||||
Size + "x" + Size,
|
Size + "x" + Size,
|
||||||
"status",
|
"status",
|
||||||
"avatar-default.png");
|
"avatar-default.png");
|
||||||
|
|
||||||
if (File.Exists (FallbackFileName))
|
if (File.Exists (FallbackFileName))
|
||||||
return FallbackFileName;
|
return FallbackFileName;
|
||||||
else
|
else
|
||||||
return "";
|
return "";
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Helper that creates an MD5 hash
|
// Creates an MD5 hash
|
||||||
public static string GetMD5 (string s) {
|
public static string GetMD5 (string s) {
|
||||||
|
|
||||||
MD5 md5 = new MD5CryptoServiceProvider ();
|
MD5 md5 = new MD5CryptoServiceProvider ();
|
||||||
Byte[] Bytes = ASCIIEncoding.Default.GetBytes (s);
|
Byte[] Bytes = ASCIIEncoding.Default.GetBytes (s);
|
||||||
Byte[] EncodedBytes = md5.ComputeHash (Bytes);
|
Byte[] EncodedBytes = md5.ComputeHash (Bytes);
|
||||||
|
|
||||||
return BitConverter.ToString(EncodedBytes).ToLower ().Replace ("-", "");
|
return BitConverter.ToString(EncodedBytes).ToLower ().Replace ("-", "");
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Makes it possible to combine more than
|
||||||
|
// two paths at once.
|
||||||
public static string CombineMore (params string [] Parts) {
|
public static string CombineMore (params string [] Parts) {
|
||||||
string NewPath = "";
|
string NewPath = "";
|
||||||
foreach (string Part in Parts)
|
foreach (string Part in Parts)
|
||||||
|
|
|
@ -41,7 +41,7 @@ namespace SparkleShare {
|
||||||
public string UserName;
|
public string UserName;
|
||||||
public bool MonitorOnly;
|
public bool MonitorOnly;
|
||||||
|
|
||||||
public SparkleRepo (string Path) {
|
public SparkleRepo (string RepoPath) {
|
||||||
|
|
||||||
MonitorOnly = false;
|
MonitorOnly = false;
|
||||||
|
|
||||||
|
@ -50,9 +50,9 @@ namespace SparkleShare {
|
||||||
Process.StartInfo.RedirectStandardOutput = true;
|
Process.StartInfo.RedirectStandardOutput = true;
|
||||||
Process.StartInfo.UseShellExecute = false;
|
Process.StartInfo.UseShellExecute = false;
|
||||||
|
|
||||||
// Get the repository's path, example: "/home/user/SparkleShare/repo/"
|
// Get the repository's path, example: "/home/user/SparkleShare/repo"
|
||||||
LocalPath = Path;
|
LocalPath = RepoPath;
|
||||||
Process.StartInfo.WorkingDirectory = LocalPath + "/";
|
Process.StartInfo.WorkingDirectory = LocalPath;
|
||||||
|
|
||||||
// Get user.name, example: "User Name"
|
// Get user.name, example: "User Name"
|
||||||
UserName = "Anonymous";
|
UserName = "Anonymous";
|
||||||
|
@ -75,9 +75,7 @@ namespace SparkleShare {
|
||||||
RemoteOriginUrl = Process.StandardOutput.ReadToEnd().Trim ();
|
RemoteOriginUrl = Process.StandardOutput.ReadToEnd().Trim ();
|
||||||
|
|
||||||
// Get the repository name, example: "Project"
|
// Get the repository name, example: "Project"
|
||||||
|
Name = Path.GetFileName (LocalPath);
|
||||||
string s = LocalPath.TrimEnd ( "/".ToCharArray ());
|
|
||||||
Name = LocalPath.Substring (s.LastIndexOf ("/") + 1);
|
|
||||||
|
|
||||||
// Get the domain, example: "github.com"
|
// Get the domain, example: "github.com"
|
||||||
Domain = RemoteOriginUrl;
|
Domain = RemoteOriginUrl;
|
||||||
|
|
|
@ -34,10 +34,12 @@ namespace SparkleShare {
|
||||||
public SparkleSpinner () : base () {
|
public SparkleSpinner () : base () {
|
||||||
|
|
||||||
Size = 48;
|
Size = 48;
|
||||||
Gdk.Pixbuf SpinnerGallery = new Gdk.Pixbuf ("/usr/share/icons/" +
|
string SpinnerFileName = SparkleHelpers.CombineMore (
|
||||||
"gnome/" + Size + "x" +
|
SparklePaths.SparkleIconPath,
|
||||||
Size + "/animations/" +
|
Size + "x" + Size, "animations",
|
||||||
"process-working.png");
|
"process-working.png");
|
||||||
|
|
||||||
|
Gdk.Pixbuf SpinnerGallery = new Gdk.Pixbuf (SpinnerFileName);
|
||||||
CycleDuration = 750;
|
CycleDuration = 750;
|
||||||
CurrentStep = 0;
|
CurrentStep = 0;
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue