fix some issues with non existing repos

This commit is contained in:
Hylke Bons 2010-05-16 13:28:25 +01:00
parent 4b37ff93ed
commit f2815da626
4 changed files with 42 additions and 20 deletions

View file

@ -29,18 +29,15 @@ namespace SparkleShare {
private Button AddButton; private Button AddButton;
private ComboBoxEntry RemoteUrlCombo; private ComboBoxEntry RemoteUrlCombo;
private Entry NameEntry; private Entry NameEntry;
private SparkleWindow ParentSparkleWindow;
public SparkleDialog (SparkleWindow Parent) : base ("") { public SparkleDialog () : base ("") {
ParentSparkleWindow = Parent;
BorderWidth = 6; BorderWidth = 6;
IconName = "folder-sparkleshare"; IconName = "folder-sparkleshare";
Modal = true; Modal = true;
Resizable = false; Resizable = false;
SetPosition (WindowPosition.Center); SetPosition (WindowPosition.Center);
Title = "Add a Folder"; Title = "Add a Folder";
TransientFor = ParentSparkleWindow;
VBox VBox = new VBox (false, 0); VBox VBox = new VBox (false, 0);
@ -103,6 +100,7 @@ namespace SparkleShare {
VBox.PackStart (ButtonBox, false, false, 0); VBox.PackStart (ButtonBox, false, false, 0);
Add (VBox); Add (VBox);
ShowAll ();
} }
@ -141,8 +139,6 @@ namespace SparkleShare {
RepoName) RepoName)
); );
Destroy (); Destroy ();
ParentSparkleWindow.ToggleVisibility ();
ParentSparkleWindow.Notebook.CurrentPage = 1;
}; };
} }

View file

@ -132,7 +132,7 @@ namespace SparkleShare {
public void OnFileActivity (object o, FileSystemEventArgs args) { public void OnFileActivity (object o, FileSystemEventArgs args) {
WatcherChangeTypes wct = args.ChangeType; WatcherChangeTypes wct = args.ChangeType;
if (!ShouldIgnore (args.Name) && SyncChanges) { if (!ShouldIgnore (args.Name) && SyncChanges) {
Console.WriteLine("[Event][" + Name + "] " + wct.ToString() + Console.WriteLine ("[Event][" + Name + "] " + wct.ToString() +
" '" + args.Name + "'"); " '" + args.Name + "'");
StartBufferTimer (); StartBufferTimer ();
} }

View file

@ -15,6 +15,7 @@
// along with this program. If not, see <http://www.gnu.org/licenses/>. // along with this program. If not, see <http://www.gnu.org/licenses/>.
using Gtk; using Gtk;
using SparkleShare;
using System; using System;
using System.Diagnostics; using System.Diagnostics;
using System.IO; using System.IO;
@ -69,25 +70,34 @@ namespace SparkleShare {
} }
// Get all the repos in ~/SparkleShare // Get all the repos in ~/SparkleShare
string [] Repos = Directory.GetDirectories (SparklePath); SparkleRepo [] TmpRepos =
Repositories = new SparkleRepo [Repos.Length]; new SparkleRepo [Directory.GetDirectories (SparklePath).Length];
int i = 0; int i = 0;
foreach (string Folder in Repos) { foreach (string Folder in Directory.GetDirectories (SparklePath)) {
Repositories [i] = new SparkleRepo (Folder); // Check if the folder is a git repo
i++; if (Directory.Exists (SparkleHelpers.CombineMore (Folder,
".git"))) {
TmpRepos [i] = new SparkleRepo (Folder);
i++;
Console.WriteLine (Folder);
// Attach emblems // Attach emblems
if (SparklePlatform.Name.Equals ("GNOME")) { if (SparklePlatform.Name.Equals ("GNOME")) {
Process.StartInfo.FileName = "gvfs-set-attribute"; Process.StartInfo.FileName = "gvfs-set-attribute";
Process.StartInfo.Arguments = " file://" + Folder + Process.StartInfo.Arguments = " file://" + Folder +
" metadata::emblems " + " metadata::emblems " +
"[synced]"; "[synced]";
Process.Start(); Process.Start();
}
} }
} }
Repositories = new SparkleRepo [i];
Array.Copy (TmpRepos, Repositories, i);
// Don't create the window and status // Don't create the window and status
// icon when --disable-gui was given // 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 // Create place to store configuration user's home folder
string ConfigPath = SparklePaths.SparkleConfigPath; string ConfigPath = SparklePaths.SparkleConfigPath;

View file

@ -187,7 +187,8 @@ namespace SparkleShare {
Selection.GetSelected (out Iter); Selection.GetSelected (out Iter);
SparkleRepo SparkleRepo = (SparkleRepo)ReposStore.GetValue (Iter, 2); SparkleRepo SparkleRepo =
(SparkleRepo) ReposStore.GetValue (Iter, 2);
LayoutHorizontal.Remove (LayoutVerticalRight); LayoutHorizontal.Remove (LayoutVerticalRight);
LayoutVerticalRight = CreateDetailedView (SparkleRepo); LayoutVerticalRight = CreateDetailedView (SparkleRepo);