From fe89b373fe7000ff63319f9228495cf212b91bf1 Mon Sep 17 00:00:00 2001 From: Hylke Bons Date: Fri, 21 Nov 2014 11:31:58 +0000 Subject: [PATCH] mac bubbles: Clean up --- SparkleShare/Mac/SparkleBubbles.cs | 32 ++++++++++++++++-------------- 1 file changed, 17 insertions(+), 15 deletions(-) diff --git a/SparkleShare/Mac/SparkleBubbles.cs b/SparkleShare/Mac/SparkleBubbles.cs index 958f261b..1ac44e46 100755 --- a/SparkleShare/Mac/SparkleBubbles.cs +++ b/SparkleShare/Mac/SparkleBubbles.cs @@ -29,24 +29,26 @@ namespace SparkleShare { public SparkleBubbles () { - Controller.ShowBubbleEvent += delegate (string title, string subtext, string image_path) { - if (Environment.OSVersion.Version.Major < 12) - return; // The notification center was introduced in Mountain Lion + // The notification center was introduced in Mountain Lion + if (Environment.OSVersion.Version.Major >= 12) + Controller.ShowBubbleEvent += ShowBubbleEvent; + } - InvokeOnMainThread (() => { - NSUserNotification notification = new NSUserNotification () { - Title = title, - InformativeText = subtext, - DeliveryDate = DateTime.Now - }; - NSUserNotificationCenter center = NSUserNotificationCenter.DefaultUserNotificationCenter; - center.ShouldPresentNotification = delegate { return true; }; - center.DidActivateNotification += delegate { Controller.BubbleClicked (); }; + private void ShowBubbleEvent (string title, string subtext, string image_path) { + InvokeOnMainThread (() => { + NSUserNotification notification = new NSUserNotification () { + Title = title, + InformativeText = subtext, + DeliveryDate = DateTime.Now + }; - center.ScheduleNotification (notification); - }); - }; + NSUserNotificationCenter center = NSUserNotificationCenter.DefaultUserNotificationCenter; + center.ShouldPresentNotification = delegate { return true; }; + center.DidActivateNotification += delegate { Controller.BubbleClicked (); }; + + center.ScheduleNotification (notification); + }); } } }