[controller] Add OnQuitWhileSyncing event
This commit is contained in:
parent
b7cde079e5
commit
bf36cfe8d2
|
@ -31,6 +31,9 @@ namespace SparkleShare {
|
|||
public string FolderSize;
|
||||
|
||||
|
||||
public event OnQuitWhileSyncingEventHandler OnQuitWhileSyncing;
|
||||
public delegate void OnQuitWhileSyncingEventHandler ();
|
||||
|
||||
public event FolderFetchedEventHandler FolderFetched;
|
||||
public delegate void FolderFetchedEventHandler ();
|
||||
|
||||
|
@ -723,16 +726,38 @@ namespace SparkleShare {
|
|||
|
||||
|
||||
// Quits the program
|
||||
public void TryQuit ()
|
||||
{
|
||||
|
||||
foreach (SparkleRepo repo in Repositories) {
|
||||
|
||||
if (repo.IsSyncing) {
|
||||
|
||||
if (OnQuitWhileSyncing != null)
|
||||
OnQuitWhileSyncing ();
|
||||
|
||||
return;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Quit ();
|
||||
|
||||
}
|
||||
|
||||
|
||||
public void Quit ()
|
||||
{
|
||||
|
||||
// TODO: Pop up a warning when quitting whilst syncing
|
||||
|
||||
foreach (SparkleRepo repo in Repositories)
|
||||
repo.Dispose ();
|
||||
|
||||
string pid_file_path = SparkleHelpers.CombineMore (SparklePaths.SparkleTmpPath, "sparkleshare.pid");
|
||||
|
||||
// Remove the process ID file
|
||||
File.Delete (SparkleHelpers.CombineMore (SparklePaths.SparkleTmpPath, "sparkleshare.pid"));
|
||||
if (File.Exists (pid_file_path))
|
||||
File.Delete (pid_file_path);
|
||||
|
||||
Environment.Exit (0);
|
||||
|
||||
|
|
|
@ -61,6 +61,10 @@ namespace SparkleShare {
|
|||
|
||||
});
|
||||
};
|
||||
|
||||
SparkleShare.Controller.OnQuitWhileSyncing += delegate {
|
||||
// TODO: Pop up a warning when quitting whilst syncing
|
||||
};
|
||||
|
||||
SparkleShare.Controller.OnInvitation += delegate (string invitation_file_path) {
|
||||
Application.Invoke (delegate {
|
||||
|
|
Loading…
Reference in a new issue