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