controller: Allow for platform-specific quit methods and implement on Mac
This commit is contained in:
parent
2913e1142d
commit
9b3064684a
|
@ -180,7 +180,10 @@ namespace SparkleShare {
|
||||||
|
|
||||||
// Copies text to the clipboard
|
// Copies text to the clipboard
|
||||||
public abstract void CopyToClipboard (string text);
|
public abstract void CopyToClipboard (string text);
|
||||||
|
|
||||||
|
// Allows for platform-specific quit and cleanup methods to be called on exit
|
||||||
|
public abstract void PlatformQuit ();
|
||||||
|
|
||||||
public abstract string EventLogHTML { get; }
|
public abstract string EventLogHTML { get; }
|
||||||
public abstract string DayEntryHTML { get; }
|
public abstract string DayEntryHTML { get; }
|
||||||
public abstract string EventEntryHTML { get; }
|
public abstract string EventEntryHTML { get; }
|
||||||
|
@ -715,14 +718,14 @@ namespace SparkleShare {
|
||||||
int suffix = 2 + Directory.GetDirectories (folder_group_path, folder_name + " (*").Length;
|
int suffix = 2 + Directory.GetDirectories (folder_group_path, folder_name + " (*").Length;
|
||||||
return string.Format ("{0} ({1})", folder_path, suffix);
|
return string.Format ("{0} ({1})", folder_path, suffix);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public virtual void Quit ()
|
public void Quit ()
|
||||||
{
|
{
|
||||||
foreach (BaseRepository repo in Repositories)
|
foreach (BaseRepository repo in Repositories)
|
||||||
repo.Dispose ();
|
repo.Dispose ();
|
||||||
|
|
||||||
Environment.Exit (0);
|
PlatformQuit ();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -29,8 +29,7 @@ namespace SparkleShare {
|
||||||
|
|
||||||
public class Controller : BaseController {
|
public class Controller : BaseController {
|
||||||
|
|
||||||
public Controller (Configuration config)
|
public Controller (Configuration config) : base (config)
|
||||||
: base (config)
|
|
||||||
{
|
{
|
||||||
if (InstallationInfo.IsFlatpak)
|
if (InstallationInfo.IsFlatpak)
|
||||||
GitCommand.ExecPath = Path.Combine ("/app", "libexec", "git-core");
|
GitCommand.ExecPath = Path.Combine ("/app", "libexec", "git-core");
|
||||||
|
@ -142,5 +141,11 @@ namespace SparkleShare {
|
||||||
return Path.Combine (InstallationInfo.Directory, "presets");
|
return Path.Combine (InstallationInfo.Directory, "presets");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public override void PlatformQuit ()
|
||||||
|
{
|
||||||
|
Environment.Exit (0);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -224,5 +224,13 @@ namespace SparkleShare {
|
||||||
new NSObject ().InvokeOnMainThread (() => code ());
|
new NSObject ().InvokeOnMainThread (() => code ());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public override void PlatformQuit ()
|
||||||
|
{
|
||||||
|
watcher.Dispose ();
|
||||||
|
NSRunningApplication.CurrentApplication.Terminate ();
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -71,13 +71,7 @@ namespace SparkleShare {
|
||||||
|
|
||||||
|
|
||||||
public partial class AppDelegate : NSApplicationDelegate {
|
public partial class AppDelegate : NSApplicationDelegate {
|
||||||
|
|
||||||
public override void WillTerminate (NSNotification notification)
|
|
||||||
{
|
|
||||||
SparkleShare.Controller.Quit ();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
public override bool ApplicationShouldHandleReopen (NSApplication sender, bool has_visible_windows)
|
public override bool ApplicationShouldHandleReopen (NSApplication sender, bool has_visible_windows)
|
||||||
{
|
{
|
||||||
if (!has_visible_windows)
|
if (!has_visible_windows)
|
||||||
|
|
Loading…
Reference in a new issue