From f2815da6265d2b051d0197186008fa250dac065f Mon Sep 17 00:00:00 2001 From: Hylke Bons Date: Sun, 16 May 2010 13:28:25 +0100 Subject: [PATCH] fix some issues with non existing repos --- SparkleShare/SparkleDialog.cs | 8 ++---- SparkleShare/SparkleRepo.cs | 2 +- SparkleShare/SparkleUI.cs | 49 ++++++++++++++++++++++++++--------- SparkleShare/SparkleWindow.cs | 3 ++- 4 files changed, 42 insertions(+), 20 deletions(-) diff --git a/SparkleShare/SparkleDialog.cs b/SparkleShare/SparkleDialog.cs index 24965797..d8743e83 100644 --- a/SparkleShare/SparkleDialog.cs +++ b/SparkleShare/SparkleDialog.cs @@ -29,18 +29,15 @@ namespace SparkleShare { private Button AddButton; private ComboBoxEntry RemoteUrlCombo; private Entry NameEntry; - private SparkleWindow ParentSparkleWindow; - public SparkleDialog (SparkleWindow Parent) : base ("") { + public SparkleDialog () : base ("") { - ParentSparkleWindow = Parent; BorderWidth = 6; IconName = "folder-sparkleshare"; Modal = true; Resizable = false; SetPosition (WindowPosition.Center); Title = "Add a Folder"; - TransientFor = ParentSparkleWindow; VBox VBox = new VBox (false, 0); @@ -103,6 +100,7 @@ namespace SparkleShare { VBox.PackStart (ButtonBox, false, false, 0); Add (VBox); + ShowAll (); } @@ -141,8 +139,6 @@ namespace SparkleShare { RepoName) ); Destroy (); - ParentSparkleWindow.ToggleVisibility (); - ParentSparkleWindow.Notebook.CurrentPage = 1; }; } diff --git a/SparkleShare/SparkleRepo.cs b/SparkleShare/SparkleRepo.cs index 22c3b090..2d90f62b 100644 --- a/SparkleShare/SparkleRepo.cs +++ b/SparkleShare/SparkleRepo.cs @@ -132,7 +132,7 @@ namespace SparkleShare { public void OnFileActivity (object o, FileSystemEventArgs args) { WatcherChangeTypes wct = args.ChangeType; if (!ShouldIgnore (args.Name) && SyncChanges) { - Console.WriteLine("[Event][" + Name + "] " + wct.ToString() + + Console.WriteLine ("[Event][" + Name + "] " + wct.ToString() + " '" + args.Name + "'"); StartBufferTimer (); } diff --git a/SparkleShare/SparkleUI.cs b/SparkleShare/SparkleUI.cs index a4e95bed..5d88ce6f 100644 --- a/SparkleShare/SparkleUI.cs +++ b/SparkleShare/SparkleUI.cs @@ -15,6 +15,7 @@ // along with this program. If not, see . using Gtk; +using SparkleShare; using System; using System.Diagnostics; using System.IO; @@ -69,25 +70,34 @@ namespace SparkleShare { } // Get all the repos in ~/SparkleShare - string [] Repos = Directory.GetDirectories (SparklePath); - Repositories = new SparkleRepo [Repos.Length]; + SparkleRepo [] TmpRepos = + new SparkleRepo [Directory.GetDirectories (SparklePath).Length]; int i = 0; - foreach (string Folder in Repos) { + foreach (string Folder in Directory.GetDirectories (SparklePath)) { - Repositories [i] = new SparkleRepo (Folder); - i++; + // Check if the folder is a git repo + if (Directory.Exists (SparkleHelpers.CombineMore (Folder, + ".git"))) { + TmpRepos [i] = new SparkleRepo (Folder); + i++; + Console.WriteLine (Folder); - // Attach emblems - if (SparklePlatform.Name.Equals ("GNOME")) { - Process.StartInfo.FileName = "gvfs-set-attribute"; - Process.StartInfo.Arguments = " file://" + Folder + - " metadata::emblems " + - "[synced]"; - Process.Start(); + // Attach emblems + if (SparklePlatform.Name.Equals ("GNOME")) { + Process.StartInfo.FileName = "gvfs-set-attribute"; + Process.StartInfo.Arguments = " file://" + Folder + + " metadata::emblems " + + "[synced]"; + Process.Start(); + } + } } + + Repositories = new SparkleRepo [i]; + Array.Copy (TmpRepos, Repositories, i); // Don't create the window and status // icon when --disable-gui was given @@ -104,6 +114,21 @@ namespace SparkleShare { }; } + + // Watch the SparkleShare folder and pop up the + // Add dialog when a new folder is created + FileSystemWatcher Watcher = new FileSystemWatcher (SparklePaths.SparklePath); + Watcher.IncludeSubdirectories = false; + Watcher.EnableRaisingEvents = true; + Watcher.Created += delegate (object o, FileSystemEventArgs args) { + WatcherChangeTypes wct = args.ChangeType; + Console.WriteLine ("[Event][SparkleShare] " + wct.ToString() + + " '" + args.Name + "'"); + SparkleDialog SparkleDialog = new SparkleDialog (); + SparkleDialog.ShowAll (); +//Window Window = new Window (""); +//Window.ShowAll (); + }; // Create place to store configuration user's home folder string ConfigPath = SparklePaths.SparkleConfigPath; diff --git a/SparkleShare/SparkleWindow.cs b/SparkleShare/SparkleWindow.cs index ff80e77f..12bdaad6 100644 --- a/SparkleShare/SparkleWindow.cs +++ b/SparkleShare/SparkleWindow.cs @@ -187,7 +187,8 @@ namespace SparkleShare { Selection.GetSelected (out Iter); - SparkleRepo SparkleRepo = (SparkleRepo)ReposStore.GetValue (Iter, 2); + SparkleRepo SparkleRepo = + (SparkleRepo) ReposStore.GetValue (Iter, 2); LayoutHorizontal.Remove (LayoutVerticalRight); LayoutVerticalRight = CreateDetailedView (SparkleRepo);