From aa9c5a17ffb8d5b3ab41b9fd06f265ae256860f3 Mon Sep 17 00:00:00 2001 From: Hylke Bons Date: Sun, 5 Jun 2011 16:05:57 +0100 Subject: [PATCH] mac: add About entry to status menu --- SparkleShare/Mac/MainMenu.xib | 31 +++++++-------------- SparkleShare/Mac/SparkleAbout.cs | 21 ++++++++++++--- SparkleShare/Mac/SparkleStatusIcon.cs | 39 ++++++++++++++++++++++----- SparkleShare/Mac/SparkleUI.cs | 1 + 4 files changed, 61 insertions(+), 31 deletions(-) diff --git a/SparkleShare/Mac/MainMenu.xib b/SparkleShare/Mac/MainMenu.xib index 54551193..adc6dd89 100644 --- a/SparkleShare/Mac/MainMenu.xib +++ b/SparkleShare/Mac/MainMenu.xib @@ -2,13 +2,13 @@ 1060 - 10D2162 - 762 - 1038.29 - 460.00 + 10J869 + 851 + 1038.35 + 461.00 com.apple.InterfaceBuilder.CocoaPlugin - 762 + 851 YES @@ -19,13 +19,8 @@ com.apple.InterfaceBuilder.CocoaPlugin - YES - - YES - - - YES - + PluginDependencyRecalculationVersion + YES @@ -666,14 +661,6 @@ 39 - - - orderFrontStandardAboutPanel: - - - - 142 - toggleContinuousSpellChecking: @@ -976,7 +963,9 @@ YES 0 - + + YES + diff --git a/SparkleShare/Mac/SparkleAbout.cs b/SparkleShare/Mac/SparkleAbout.cs index 45cb65f0..1f61f14b 100644 --- a/SparkleShare/Mac/SparkleAbout.cs +++ b/SparkleShare/Mac/SparkleAbout.cs @@ -44,7 +44,8 @@ namespace SparkleShare { { SetFrame (new RectangleF (0, 0, 360, 288), true); Center (); - + + Delegate = new SparkleAboutDelegate (); StyleMask = (NSWindowStyle.Closable | NSWindowStyle.Titled); Title = "About SparkleShare"; MaxSize = new SizeF (360, 288); @@ -71,6 +72,12 @@ namespace SparkleShare { }); }; + CheckForNewVersion (); + } + + + public void CheckForNewVersion () + { SparkleShare.Controller.CheckForNewVersion (); } @@ -137,10 +144,8 @@ namespace SparkleShare { }; WebsiteButton.Activated += delegate { - NSUrl url = new NSUrl ("http://www.sparkleshare.org/"); NSWorkspace.SharedWorkspace.OpenUrl (url); - }; CreditsButton = new NSButton () { @@ -166,4 +171,14 @@ namespace SparkleShare { ContentView.AddSubview (WebsiteButton); } } + + + public class SparkleAboutDelegate : NSWindowDelegate { + + public override bool WindowShouldClose (NSObject sender) + { + (sender as SparkleAbout).OrderOut (this); + return false; + } + } } diff --git a/SparkleShare/Mac/SparkleStatusIcon.cs b/SparkleShare/Mac/SparkleStatusIcon.cs index 6cc0072b..357c3f40 100644 --- a/SparkleShare/Mac/SparkleStatusIcon.cs +++ b/SparkleShare/Mac/SparkleStatusIcon.cs @@ -41,6 +41,7 @@ namespace SparkleShare { private NSMenuItem FolderMenuItem; private NSMenuItem [] FolderMenuItems; private NSMenuItem SyncMenuItem; + private NSMenuItem AboutMenuItem; private NSMenuItem NotificationsMenuItem; private delegate void Task (); @@ -214,15 +215,15 @@ namespace SparkleShare { SyncMenuItem.Activated += delegate { InvokeOnMainThread (delegate { NSApplication.SharedApplication.ActivateIgnoringOtherApps (true); - + if (SparkleUI.Intro == null) { SparkleUI.Intro = new SparkleIntro (); SparkleUI.Intro.ShowServerForm (true); } - + if (!SparkleUI.Intro.IsVisible) SparkleUI.Intro.ShowServerForm (true); - + SparkleUI.Intro.OrderFrontRegardless (); SparkleUI.Intro.MakeKeyAndOrderFront (this); }); @@ -232,16 +233,17 @@ namespace SparkleShare { Menu.AddItem (SyncMenuItem); Menu.AddItem (NSMenuItem.SeparatorItem); + NotificationsMenuItem = new NSMenuItem (); - + if (SparkleShare.Controller.NotificationsEnabled) NotificationsMenuItem.Title = "Turn Notifications Off"; else NotificationsMenuItem.Title = "Turn Notifications On"; - + NotificationsMenuItem.Activated += delegate { SparkleShare.Controller.ToggleNotifications (); - + InvokeOnMainThread (delegate { if (SparkleShare.Controller.NotificationsEnabled) NotificationsMenuItem.Title = "Turn Notifications Off"; @@ -251,7 +253,30 @@ namespace SparkleShare { }; Menu.AddItem (NotificationsMenuItem); - + Menu.AddItem (NSMenuItem.SeparatorItem); + + + AboutMenuItem = new NSMenuItem () { + Title = "About SparkleShare" + }; + + AboutMenuItem.Activated += delegate { + InvokeOnMainThread (delegate { + NSApplication.SharedApplication.ActivateIgnoringOtherApps (true); + + if (SparkleUI.About == null) + SparkleUI.About = new SparkleAbout (); + + SparkleUI.About.OrderFrontRegardless (); + SparkleUI.About.MakeKeyAndOrderFront (this); + SparkleUI.About.CheckForNewVersion (); + }); + }; + + + Menu.AddItem (AboutMenuItem); + + StatusItem.Menu = Menu; StatusItem.Menu.Update (); } diff --git a/SparkleShare/Mac/SparkleUI.cs b/SparkleShare/Mac/SparkleUI.cs index 2a970312..a923bce2 100644 --- a/SparkleShare/Mac/SparkleUI.cs +++ b/SparkleShare/Mac/SparkleUI.cs @@ -53,6 +53,7 @@ namespace SparkleShare { public static SparkleStatusIcon StatusIcon; public static List OpenLogs; public static SparkleIntro Intro; + public static SparkleAbout About; public static NSFont Font; private NSAlert alert;