diff --git a/SparkleShare/SparkleShare.cs b/SparkleShare/SparkleShare.cs index 337b4021..ef492acb 100644 --- a/SparkleShare/SparkleShare.cs +++ b/SparkleShare/SparkleShare.cs @@ -27,7 +27,6 @@ namespace SparkleShare { public static void Main (string [] args) { - // Check if git is installed Process Process = new Process(); Process.StartInfo.RedirectStandardOutput = true; @@ -67,6 +66,8 @@ namespace SparkleShare { SparkleUI = new SparkleUI (HideUI); SparkleUI.StartMonitoring (); + + // The main loop Gtk.Application.Run (); diff --git a/SparkleShare/SparkleSpinner.cs b/SparkleShare/SparkleSpinner.cs index 6955bfb3..3bfe75ea 100644 --- a/SparkleShare/SparkleSpinner.cs +++ b/SparkleShare/SparkleSpinner.cs @@ -15,39 +15,63 @@ // along with this program. If not, see . using Gtk; -using System; using System.Timers; namespace SparkleShare { // This is a close implementation of GtkSpinner - public class SparkleSpinner : Gdk.Pixbuf { + public class SparkleSpinner : Image { - private int CycleDuration; - private int NumSteps; - private bool Active; + public bool Active; + private Gdk.Pixbuf [] Images; private Timer Timer; + private int CycleDuration; private int CurrentStep; + private int NumSteps; + private int Size; - public SparkleSpinner () : base ("") { - Timer = new Timer (); - CycleDuration = 1000; + public SparkleSpinner () : base () { + + Size = 48; + Gdk.Pixbuf SpinnerGallery = new Gdk.Pixbuf ("/usr/share/icons/" + + "gnome/" + Size + "x" + + Size + "/animations/" + + "process-working.png"); + CycleDuration = 750; CurrentStep = 0; - NumSteps = 20; + + int FramesInWidth = SpinnerGallery.Width / Size; + int FramesInHeight = SpinnerGallery.Height / Size; + NumSteps = FramesInWidth * FramesInHeight; + Images = new Gdk.Pixbuf [NumSteps - 1]; + + int i = 0; + for (int y = 0; y < FramesInHeight; y++) { + for (int x = 0; x < FramesInWidth; x++) { + if (!(y == 0 && x == 0)) { + Images [i] = new Gdk.Pixbuf (SpinnerGallery, + x * Size, y * Size, Size, Size); + i++; + } + } + } + + Timer = new Timer (); Timer.Interval = CycleDuration / NumSteps; Timer.Elapsed += delegate { NextImage (); }; Start (); + } - + private void NextImage () { - Console.WriteLine (CurrentStep); if (CurrentStep < NumSteps) CurrentStep++; else - CurrentStep = 0; + CurrentStep = 1; + Pixbuf = Images [CurrentStep]; } - + public bool IsActive () { return Active; } diff --git a/SparkleShare/SparkleUI.cs b/SparkleShare/SparkleUI.cs index 7d264f26..c91da5b8 100644 --- a/SparkleShare/SparkleUI.cs +++ b/SparkleShare/SparkleUI.cs @@ -36,18 +36,16 @@ namespace SparkleShare { Process.StartInfo.RedirectStandardOutput = true; Process.StartInfo.UseShellExecute = false; - // Get home folder, example: "/home/user/" - string UserHome = Environment.GetEnvironmentVariable("HOME") + "/"; - string ReposPath = UserHome + "SparkleShare"; + string SparkleDir = SparklePaths.SparkleDir; // Create 'SparkleShare' folder in the user's home folder // if it's not there already - if (!Directory.Exists (ReposPath)) { - Directory.CreateDirectory (ReposPath); - Console.WriteLine ("[Config] Created '" + ReposPath + "'"); + if (!Directory.Exists (SparkleDir)) { + Directory.CreateDirectory (SparkleDir); + Console.WriteLine ("[Config] Created '" + SparkleDir + "'"); Process.StartInfo.FileName = "gvfs-set-attribute"; - Process.StartInfo.Arguments = ReposPath + + Process.StartInfo.Arguments = SparkleDir + " metadata::custom-icon " + "file:///usr/share/icons/hicolor/" + "48x48/places/" + @@ -57,24 +55,21 @@ namespace SparkleShare { } // Create place to store configuration user's home folder - string ConfigPath = UserHome + ".config/sparkleshare/"; - if (!Directory.Exists (ConfigPath)) { + string ConfigDir = SparklePaths.SparkleConfigDir; + string AvatarDir = SparklePaths.SparkleAvatarsDir; + if (!Directory.Exists (ConfigDir)) { - Directory.CreateDirectory (ConfigPath); - Console.WriteLine ("[Config] Created '" + ConfigPath + "'"); - - // Create a first run file to show the intro message - File.Create (ConfigPath + "firstrun"); - Console.WriteLine ("[Config] Created '" + ConfigPath + "firstrun'"); + Directory.CreateDirectory (ConfigDir); + Console.WriteLine ("[Config] Created '" + ConfigDir + "'"); // Create a place to store the avatars - Directory.CreateDirectory (ConfigPath + "avatars/"); - Console.WriteLine ("[Config] Created '" + ConfigPath + "avatars'"); + Directory.CreateDirectory (AvatarDir); + Console.WriteLine ("[Config] Created '" + AvatarDir + "avatars'"); } // Get all the repos in ~/SparkleShare - string [] Repos = Directory.GetDirectories (ReposPath); + string [] Repos = Directory.GetDirectories (SparkleDir); Repositories = new SparkleRepo [Repos.Length]; int i = 0; diff --git a/SparkleShare/SparkleWindow.cs b/SparkleShare/SparkleWindow.cs index 48805b21..3d364f4d 100644 --- a/SparkleShare/SparkleWindow.cs +++ b/SparkleShare/SparkleWindow.cs @@ -200,6 +200,7 @@ namespace SparkleShare { CreateAddDialog (); }; + AddRemoveButtons.PackStart (AddButton, true, true, 0); Image RemoveImage = new Image ("/usr/share/icons/gnome/16x16/actions/list-remove.png"); @@ -492,7 +493,13 @@ namespace SparkleShare { AddButton.Clicked += delegate { AddDialog.Remove (AddDialog.Child); - AddDialog.Add (new Label ("Downloading files...\nPlease wait.")); + VBox Box = new VBox (false, 24); + SparkleSpinner Spinner = new SparkleSpinner (); + Label Label = new Label ("Downloading files,\nthis may take a while..."); + Box.PackStart (Spinner, false, false, 0); + Box.PackStart (Label, false, false, 0); + AddDialog.BorderWidth = 30; + AddDialog.Add (Box); AddDialog.ShowAll (); string RepoRemoteUrl = RemoteUrlCombo.Entry.Text; @@ -518,6 +525,7 @@ namespace SparkleShare { }; }; + ButtonBox.Add (CancelButton); ButtonBox.Add (AddButton);