diff --git a/SparkleShare/SparkleHelpers.cs b/SparkleShare/SparkleHelpers.cs index c70fd9a6..4cfd5c57 100644 --- a/SparkleShare/SparkleHelpers.cs +++ b/SparkleShare/SparkleHelpers.cs @@ -26,8 +26,8 @@ namespace SparkleShare { public static string GetAvatarFileName (string Email, int Size) { - string AvatarPath = SparklePaths.SparkleAvatarsDir + - Size + "x" + Size + "/"; + string AvatarPath = Path.Combine (SparklePaths.SparkleAvatarPath, + Size + "x" + Size); if (!Directory.Exists (AvatarPath)) { Directory.CreateDirectory (AvatarPath); @@ -35,10 +35,10 @@ namespace SparkleShare { } - string AvatarFile = AvatarPath + Email; + string AvatarFilePath = AvatarPath + Email; - if (File.Exists (AvatarFile)) - return AvatarFile; + if (File.Exists (AvatarFilePath)) + return AvatarFilePath; else { @@ -48,7 +48,7 @@ namespace SparkleShare { Uri GravatarUri = new Uri ("http://www.gravatar.com/avatar/" + GetMD5 (Email) + ".jpg?s=" + Size + "&d=404"); - string TmpFile = SparklePaths.SparkleTmpDir + Email + Size; + string TmpFile = SparklePaths.SparkleTmpPath + Email + Size; if (!File.Exists (TmpFile)) { @@ -62,14 +62,15 @@ namespace SparkleShare { } - string FallbackFileName = "/usr/share/icons/hicolor/" + - Size + "x" + Size + - "/status/avatar-default.png"; + string FallbackFileName = CombineMore (SparklePaths.SparkleIconPath, + Size + "x" + Size, + "status", + "avatar-default.png"); if (File.Exists (FallbackFileName)) return FallbackFileName; else - return "/usr/share/icons/hicolor/16x16/status/avatar-default.png"; + return ""; } } @@ -84,6 +85,13 @@ namespace SparkleShare { return BitConverter.ToString(EncodedBytes).ToLower ().Replace ("-", ""); } + + public static string CombineMore (params string [] Parts) { + string NewPath = ""; + foreach (string Part in Parts) + NewPath = Path.Combine(NewPath, Part); + return NewPath; + } } diff --git a/SparkleShare/SparklePaths.cs b/SparkleShare/SparklePaths.cs index bb1214ab..576bf167 100644 --- a/SparkleShare/SparklePaths.cs +++ b/SparkleShare/SparklePaths.cs @@ -15,27 +15,26 @@ // along with this program. If not, see . using System; +using System.IO; namespace SparkleShare { public static class SparklePaths { - public static string SparkleTmpDir = "/tmp/sparkleshare"; + public static string SparkleTmpPath = "/tmp/sparkleshare"; - public static string SparkleDir = - Environment.GetEnvironmentVariable("HOME") + - "/" + "SparkleShare/"; + public static string HomePath = + Environment.GetEnvironmentVariable("HOME"); + + public static string SparklePath = Path.Combine (HomePath ,"SparkleShare"); - public static string SparkleConfigDir = - Environment.GetEnvironmentVariable("HOME") + - "/" + ".config/sparkleshare/"; + public static string SparkleConfigPath = + Path.Combine (HomePath, Path.Combine (".config", "sparkleshare")); - public static string SparkleAvatarsDir = - Environment.GetEnvironmentVariable("HOME") + - "/" + ".config/sparkleshare/" + - "avatars/"; + public static string SparkleAvatarPath = + Path.Combine (SparkleConfigPath, "avatars"); - public static string SparkleIconsDir = "/usr/share/icons/hicolor/"; + public static string SparkleIconPath = "/usr/share/icons/hicolor"; } diff --git a/SparkleShare/SparkleUI.cs b/SparkleShare/SparkleUI.cs index c91da5b8..d22abede 100644 --- a/SparkleShare/SparkleUI.cs +++ b/SparkleShare/SparkleUI.cs @@ -36,16 +36,16 @@ namespace SparkleShare { Process.StartInfo.RedirectStandardOutput = true; Process.StartInfo.UseShellExecute = false; - string SparkleDir = SparklePaths.SparkleDir; + string SparklePath = SparklePaths.SparklePath; // Create 'SparkleShare' folder in the user's home folder // if it's not there already - if (!Directory.Exists (SparkleDir)) { - Directory.CreateDirectory (SparkleDir); - Console.WriteLine ("[Config] Created '" + SparkleDir + "'"); + if (!Directory.Exists (SparklePath)) { + Directory.CreateDirectory (SparklePath); + Console.WriteLine ("[Config] Created '" + SparklePath + "'"); Process.StartInfo.FileName = "gvfs-set-attribute"; - Process.StartInfo.Arguments = SparkleDir + + Process.StartInfo.Arguments = SparklePath + " metadata::custom-icon " + "file:///usr/share/icons/hicolor/" + "48x48/places/" + @@ -55,21 +55,21 @@ namespace SparkleShare { } // Create place to store configuration user's home folder - string ConfigDir = SparklePaths.SparkleConfigDir; - string AvatarDir = SparklePaths.SparkleAvatarsDir; - if (!Directory.Exists (ConfigDir)) { + string ConfigPath = SparklePaths.SparkleConfigPath; + string AvatarPath = SparklePaths.SparkleAvatarPath; + if (!Directory.Exists (ConfigPath)) { - Directory.CreateDirectory (ConfigDir); - Console.WriteLine ("[Config] Created '" + ConfigDir + "'"); + Directory.CreateDirectory (ConfigPath); + Console.WriteLine ("[Config] Created '" + ConfigPath + "'"); // Create a place to store the avatars - Directory.CreateDirectory (AvatarDir); - Console.WriteLine ("[Config] Created '" + AvatarDir + "avatars'"); + Directory.CreateDirectory (AvatarPath); + Console.WriteLine ("[Config] Created '" + AvatarPath + "avatars'"); } // Get all the repos in ~/SparkleShare - string [] Repos = Directory.GetDirectories (SparkleDir); + string [] Repos = Directory.GetDirectories (SparklePath); Repositories = new SparkleRepo [Repos.Length]; int i = 0; diff --git a/SparkleShare/SparkleWindow.cs b/SparkleShare/SparkleWindow.cs index 6306ce86..0a849e77 100644 --- a/SparkleShare/SparkleWindow.cs +++ b/SparkleShare/SparkleWindow.cs @@ -92,6 +92,7 @@ namespace SparkleShare { LayoutVertical.PackStart (Notebook, true, true, 0); HButtonBox DialogButtons = new HButtonBox (); + DialogButtons.Layout = ButtonBoxStyle.End; DialogButtons.BorderWidth = 6; Button CloseButton = new Button (Stock.Close); @@ -507,7 +508,7 @@ namespace SparkleShare { Process.StartInfo.UseShellExecute = false; Process.StartInfo.FileName = "git"; Process.StartInfo.WorkingDirectory = - SparklePaths.SparkleTmpDir; + SparklePaths.SparkleTmpPath; Process.StartInfo.Arguments = "clone " + RepoRemoteUrl + " " + @@ -515,8 +516,8 @@ namespace SparkleShare { Process.Start (); Process.Exited += delegate { - Directory.Move (SparklePaths.SparkleTmpDir + RepoName, - SparklePaths.SparkleDir + "Sticky"); + Directory.Move (SparklePaths.SparkleTmpPath + RepoName, + SparklePaths.SparklePath + "Sticky"); AddDialog.Destroy (); }; @@ -557,7 +558,7 @@ namespace SparkleShare { } public void Quit (object o, EventArgs args) { - File.Delete (SparklePaths.SparkleTmpDir + "sparkleshare.pid"); + File.Delete (SparklePaths.SparkleTmpPath + "sparkleshare.pid"); Application.Quit (); }