mac: only use notification center on Mountain Lion and above

This commit is contained in:
Hylke Bons 2012-11-05 23:07:35 +00:00
parent 6e35c81422
commit 621712a436
2 changed files with 34 additions and 29 deletions

View file

@ -31,6 +31,10 @@ namespace SparkleShare {
public SparkleBubbles () public SparkleBubbles ()
{ {
Controller.ShowBubbleEvent += delegate (string title, string subtext, string image_path) { Controller.ShowBubbleEvent += delegate (string title, string subtext, string image_path) {
// Notification center was introduced in Mountain Lion
if (Environment.OSVersion.Version.Major < 12)
return;
InvokeOnMainThread (delegate { InvokeOnMainThread (delegate {
NSUserNotification notification = new NSUserNotification () { NSUserNotification notification = new NSUserNotification () {
Title = title, Title = title,
@ -39,7 +43,7 @@ namespace SparkleShare {
}; };
NSUserNotificationCenter center = NSUserNotificationCenter.DefaultUserNotificationCenter; NSUserNotificationCenter center = NSUserNotificationCenter.DefaultUserNotificationCenter;
center.ShouldPresentNotification = (c, n) => { return true; }; center.ShouldPresentNotification = delegate { return true; };
center.DidActivateNotification += delegate { center.DidActivateNotification += delegate {
Controller.BubbleClicked (); Controller.BubbleClicked ();

View file

@ -28,7 +28,7 @@ using SparkleLib;
namespace SparkleShare { namespace SparkleShare {
public class SparkleController : SparkleControllerBase { public class SparkleController : SparkleControllerBase {
public override string PluginsPath { public override string PluginsPath {
get { get {
@ -70,8 +70,8 @@ namespace SparkleShare {
} }
public override void CreateStartupItem () public override void CreateStartupItem ()
{ {
// There aren't any bindings in MonoMac to support this yet, so // There aren't any bindings in MonoMac to support this yet, so
// we call out to an applescript to do the job // we call out to an applescript to do the job
Process process = new Process (); Process process = new Process ();
@ -84,7 +84,7 @@ namespace SparkleShare {
process.WaitForExit (); process.WaitForExit ();
SparkleLogger.LogInfo ("Controller", "Added " + NSBundle.MainBundle.BundlePath + " to login items"); SparkleLogger.LogInfo ("Controller", "Added " + NSBundle.MainBundle.BundlePath + " to login items");
} }
public override void InstallProtocolHandler () public override void InstallProtocolHandler ()
@ -93,9 +93,9 @@ namespace SparkleShare {
} }
// Adds the SparkleShare folder to the user's // Adds the SparkleShare folder to the user's
// list of bookmarked places // list of bookmarked places
public override void AddToBookmarks () public override void AddToBookmarks ()
{/* {/*
NSMutableDictionary sidebar_plist = NSMutableDictionary.FromDictionary ( NSMutableDictionary sidebar_plist = NSMutableDictionary.FromDictionary (
NSUserDefaults.StandardUserDefaults.PersistentDomainForName ("com.apple.sidebarlists")); NSUserDefaults.StandardUserDefaults.PersistentDomainForName ("com.apple.sidebarlists"));
@ -143,11 +143,11 @@ namespace SparkleShare {
} }
NSUserDefaults.StandardUserDefaults.SetPersistentDomain (sidebar_plist, "com.apple.sidebarlists");*/ NSUserDefaults.StandardUserDefaults.SetPersistentDomain (sidebar_plist, "com.apple.sidebarlists");*/
} }
public override bool CreateSparkleShareFolder () public override bool CreateSparkleShareFolder ()
{ {
this.watcher = new SparkleMacWatcher (Program.Controller.FoldersPath); this.watcher = new SparkleMacWatcher (Program.Controller.FoldersPath);
if (!Directory.Exists (Program.Controller.FoldersPath)) { if (!Directory.Exists (Program.Controller.FoldersPath)) {
@ -161,14 +161,15 @@ namespace SparkleShare {
} }
return false; return false;
} }
public override void OpenFolder (string path) public override void OpenFolder (string path)
{ {
NSWorkspace.SharedWorkspace.OpenFile (path); path = Uri.UnescapeDataString (path);
} NSWorkspace.SharedWorkspace.OpenFile (path);
}
public override void OpenFile (string path) public override void OpenFile (string path)
{ {
@ -184,9 +185,9 @@ namespace SparkleShare {
private string event_log_html; private string event_log_html;
public override string EventLogHTML public override string EventLogHTML
{ {
get { get {
if (string.IsNullOrEmpty (this.event_log_html)) { if (string.IsNullOrEmpty (this.event_log_html)) {
string html_file_path = Path.Combine (NSBundle.MainBundle.ResourcePath, "HTML", "event-log.html"); string html_file_path = Path.Combine (NSBundle.MainBundle.ResourcePath, "HTML", "event-log.html");
string jquery_file_path = Path.Combine (NSBundle.MainBundle.ResourcePath, "HTML", "jquery.js"); string jquery_file_path = Path.Combine (NSBundle.MainBundle.ResourcePath, "HTML", "jquery.js");
@ -196,23 +197,23 @@ namespace SparkleShare {
} }
return this.event_log_html; return this.event_log_html;
} }
} }
private string day_entry_html; private string day_entry_html;
public override string DayEntryHTML public override string DayEntryHTML
{ {
get { get {
if (string.IsNullOrEmpty (this.day_entry_html)) { if (string.IsNullOrEmpty (this.day_entry_html)) {
string html_file_path = Path.Combine (NSBundle.MainBundle.ResourcePath, "HTML", "day-entry.html"); string html_file_path = Path.Combine (NSBundle.MainBundle.ResourcePath, "HTML", "day-entry.html");
this.day_entry_html = File.ReadAllText (html_file_path); this.day_entry_html = File.ReadAllText (html_file_path);
} }
return this.day_entry_html; return this.day_entry_html;
} }
} }
private string event_entry_html; private string event_entry_html;
public override string EventEntryHTML public override string EventEntryHTML
@ -226,5 +227,5 @@ namespace SparkleShare {
return this.event_entry_html; return this.event_entry_html;
} }
} }
} }
} }