From 2913e1142d35ebf39bef522d1493db05914f4149 Mon Sep 17 00:00:00 2001 From: Hylke Bons Date: Thu, 8 Mar 2018 10:19:00 +0000 Subject: [PATCH 1/3] mac controller: Clean up folder icon method --- SparkleShare/Mac/Controller.cs | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/SparkleShare/Mac/Controller.cs b/SparkleShare/Mac/Controller.cs index 67eae500..45d580b2 100644 --- a/SparkleShare/Mac/Controller.cs +++ b/SparkleShare/Mac/Controller.cs @@ -80,16 +80,12 @@ namespace SparkleShare { public override void SetFolderIcon () { - if (Environment.OSVersion.Version.Major >= 14) { - NSWorkspace.SharedWorkspace.SetIconforFile ( - NSImage.ImageNamed ("sparkleshare-folder-yosemite.icns"), - SparkleShare.Controller.FoldersPath, 0); + string folder_icon_name = "sparkleshare-folder.icns"; - } else { - NSWorkspace.SharedWorkspace.SetIconforFile ( - NSImage.ImageNamed ("sparkleshare-folder.icns"), - SparkleShare.Controller.FoldersPath, 0); - } + if (Environment.OSVersion.Version.Major >= 14) + folder_icon_name = "sparkleshare-folder-yosemite.icns"; + + NSWorkspace.SharedWorkspace.SetIconforFile (NSImage.ImageNamed (folder_icon_name), SparkleShare.Controller.FoldersPath, 0); } From 9b3064684ae7048d76677e05be656b04fae25a72 Mon Sep 17 00:00:00 2001 From: Hylke Bons Date: Thu, 8 Mar 2018 10:20:22 +0000 Subject: [PATCH 2/3] controller: Allow for platform-specific quit methods and implement on Mac --- SparkleShare/Common/BaseController.cs | 15 +++++++++------ SparkleShare/Linux/Controller.cs | 9 +++++++-- SparkleShare/Mac/Controller.cs | 8 ++++++++ SparkleShare/Mac/UserInterface/UserInterface.cs | 6 ------ 4 files changed, 24 insertions(+), 14 deletions(-) diff --git a/SparkleShare/Common/BaseController.cs b/SparkleShare/Common/BaseController.cs index 7cae39f6..ec4d48c2 100644 --- a/SparkleShare/Common/BaseController.cs +++ b/SparkleShare/Common/BaseController.cs @@ -180,7 +180,10 @@ namespace SparkleShare { // Copies text to the clipboard 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 DayEntryHTML { get; } public abstract string EventEntryHTML { get; } @@ -715,14 +718,14 @@ namespace SparkleShare { int suffix = 2 + Directory.GetDirectories (folder_group_path, folder_name + " (*").Length; return string.Format ("{0} ({1})", folder_path, suffix); } - - - public virtual void Quit () + + + public void Quit () { foreach (BaseRepository repo in Repositories) repo.Dispose (); - - Environment.Exit (0); + + PlatformQuit (); } diff --git a/SparkleShare/Linux/Controller.cs b/SparkleShare/Linux/Controller.cs index e46b5812..9f92491c 100644 --- a/SparkleShare/Linux/Controller.cs +++ b/SparkleShare/Linux/Controller.cs @@ -29,8 +29,7 @@ namespace SparkleShare { public class Controller : BaseController { - public Controller (Configuration config) - : base (config) + public Controller (Configuration config) : base (config) { if (InstallationInfo.IsFlatpak) GitCommand.ExecPath = Path.Combine ("/app", "libexec", "git-core"); @@ -142,5 +141,11 @@ namespace SparkleShare { return Path.Combine (InstallationInfo.Directory, "presets"); } } + + + public override void PlatformQuit () + { + Environment.Exit (0); + } } } diff --git a/SparkleShare/Mac/Controller.cs b/SparkleShare/Mac/Controller.cs index 45d580b2..bdd01134 100644 --- a/SparkleShare/Mac/Controller.cs +++ b/SparkleShare/Mac/Controller.cs @@ -224,5 +224,13 @@ namespace SparkleShare { new NSObject ().InvokeOnMainThread (() => code ()); } } + + + public override void PlatformQuit () + { + watcher.Dispose (); + NSRunningApplication.CurrentApplication.Terminate (); + } + } } diff --git a/SparkleShare/Mac/UserInterface/UserInterface.cs b/SparkleShare/Mac/UserInterface/UserInterface.cs index 876a1785..05dd05a0 100755 --- a/SparkleShare/Mac/UserInterface/UserInterface.cs +++ b/SparkleShare/Mac/UserInterface/UserInterface.cs @@ -71,13 +71,7 @@ namespace SparkleShare { public partial class AppDelegate : NSApplicationDelegate { - - public override void WillTerminate (NSNotification notification) - { - SparkleShare.Controller.Quit (); - } - public override bool ApplicationShouldHandleReopen (NSApplication sender, bool has_visible_windows) { if (!has_visible_windows) From 3212986ca76c1e4e7116a1579a89b4f79ad3f033 Mon Sep 17 00:00:00 2001 From: Hylke Bons Date: Thu, 8 Mar 2018 10:29:48 +0000 Subject: [PATCH 3/3] sparkles: Make sure watcher exists befor disposing --- Sparkles/BaseRepository.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Sparkles/BaseRepository.cs b/Sparkles/BaseRepository.cs index efe95e79..08832922 100644 --- a/Sparkles/BaseRepository.cs +++ b/Sparkles/BaseRepository.cs @@ -664,7 +664,7 @@ namespace Sparkles { // this.listener.Dispose (); - if (!UseCustomWatcher) + if (!UseCustomWatcher && this.watcher != null) this.watcher.Dispose (); } }