[ui] only specifically remove/add to the repo list, instead of throwing everything out
This commit is contained in:
parent
2946c9d49b
commit
15005144a5
|
@ -75,18 +75,17 @@ namespace SparkleShare {
|
||||||
Filter = "*"
|
Filter = "*"
|
||||||
};
|
};
|
||||||
|
|
||||||
watcher.Deleted += delegate {
|
watcher.Deleted += delegate (object o, FileSystemEventArgs args) {
|
||||||
|
|
||||||
foreach (SparkleRepo repo in Repositories)
|
RemoveRepository (args.FullPath);
|
||||||
repo.Stop ();
|
Application.Invoke (delegate { NotificationIcon.CreateMenu (); });
|
||||||
|
|
||||||
Application.Invoke (delegate { UpdateRepositories (); } );
|
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
watcher.Created += delegate {
|
watcher.Created += delegate (object o, FileSystemEventArgs args) {
|
||||||
|
|
||||||
Application.Invoke (delegate {UpdateRepositories (); } );
|
AddRepository (args.FullPath);
|
||||||
|
Application.Invoke (delegate { NotificationIcon.CreateMenu (); });
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -323,19 +322,13 @@ namespace SparkleShare {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// Updates the list of repositories with all the
|
public void AddRepository (string folder_path) {
|
||||||
// folders in the SparkleShare folder
|
|
||||||
public void UpdateRepositories ()
|
|
||||||
{
|
|
||||||
|
|
||||||
Repositories = new List <SparkleRepo> ();
|
|
||||||
|
|
||||||
foreach (string folder in Directory.GetDirectories (SparklePaths.SparklePath)) {
|
|
||||||
|
|
||||||
// Check if the folder is a git repo
|
// Check if the folder is a git repo
|
||||||
if (Directory.Exists (SparkleHelpers.CombineMore (folder, ".git"))) {
|
if (!Directory.Exists (SparkleHelpers.CombineMore (folder_path, ".git")))
|
||||||
|
return;
|
||||||
|
|
||||||
SparkleRepo repo = new SparkleRepo (folder);
|
SparkleRepo repo = new SparkleRepo (folder_path);
|
||||||
|
|
||||||
repo.NewCommit += delegate (object o, NewCommitArgs args) {
|
repo.NewCommit += delegate (object o, NewCommitArgs args) {
|
||||||
Application.Invoke (delegate { ShowNewCommitBubble (args.Author, args.Email, args.Message); });
|
Application.Invoke (delegate { ShowNewCommitBubble (args.Author, args.Email, args.Message); });
|
||||||
|
@ -369,14 +362,44 @@ namespace SparkleShare {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public void RemoveRepository (string folder_path) {
|
||||||
|
|
||||||
|
string repo_name = Path.GetFileName (folder_path);
|
||||||
|
|
||||||
|
foreach (SparkleRepo repo in Repositories) {
|
||||||
|
|
||||||
|
if (repo.Name.Equals (repo_name)) {
|
||||||
|
|
||||||
|
repo.Stop ();
|
||||||
|
Repositories.Remove (repo);
|
||||||
|
break;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
// Updates the list of repositories with all the
|
||||||
|
// folders in the SparkleShare folder
|
||||||
|
public void UpdateRepositories ()
|
||||||
|
{
|
||||||
|
|
||||||
|
Repositories = new List <SparkleRepo> ();
|
||||||
|
|
||||||
|
foreach (string folder_path in Directory.GetDirectories (SparklePaths.SparklePath)) {
|
||||||
|
|
||||||
|
AddRepository (folder_path);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
// Update the list in the statusicon
|
// Update the list in the statusicon
|
||||||
if (NotificationIcon != null)
|
if (NotificationIcon != null)
|
||||||
NotificationIcon.CreateMenu ();
|
NotificationIcon.CreateMenu ();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
// Warns the user implicitly that unicorns are actually lethal creatures
|
// Warns the user implicitly that unicorns are actually lethal creatures
|
||||||
public static void CheckForUnicorns (string message) {
|
public static void CheckForUnicorns (string message) {
|
||||||
|
|
Loading…
Reference in a new issue