mac: add About entry to status menu

This commit is contained in:
Hylke Bons 2011-06-05 16:05:57 +01:00
parent efb2d2c878
commit aa9c5a17ff
4 changed files with 61 additions and 31 deletions

View file

@ -2,13 +2,13 @@
<archive type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="7.10"> <archive type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="7.10">
<data> <data>
<int key="IBDocument.SystemTarget">1060</int> <int key="IBDocument.SystemTarget">1060</int>
<string key="IBDocument.SystemVersion">10D2162</string> <string key="IBDocument.SystemVersion">10J869</string>
<string key="IBDocument.InterfaceBuilderVersion">762</string> <string key="IBDocument.InterfaceBuilderVersion">851</string>
<string key="IBDocument.AppKitVersion">1038.29</string> <string key="IBDocument.AppKitVersion">1038.35</string>
<string key="IBDocument.HIToolboxVersion">460.00</string> <string key="IBDocument.HIToolboxVersion">461.00</string>
<object class="NSMutableDictionary" key="IBDocument.PluginVersions"> <object class="NSMutableDictionary" key="IBDocument.PluginVersions">
<string key="NS.key.0">com.apple.InterfaceBuilder.CocoaPlugin</string> <string key="NS.key.0">com.apple.InterfaceBuilder.CocoaPlugin</string>
<string key="NS.object.0">762</string> <string key="NS.object.0">851</string>
</object> </object>
<object class="NSMutableArray" key="IBDocument.EditedObjectIDs"> <object class="NSMutableArray" key="IBDocument.EditedObjectIDs">
<bool key="EncodedWithXMLCoder">YES</bool> <bool key="EncodedWithXMLCoder">YES</bool>
@ -19,13 +19,8 @@
<string>com.apple.InterfaceBuilder.CocoaPlugin</string> <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
</object> </object>
<object class="NSMutableDictionary" key="IBDocument.Metadata"> <object class="NSMutableDictionary" key="IBDocument.Metadata">
<bool key="EncodedWithXMLCoder">YES</bool> <string key="NS.key.0">PluginDependencyRecalculationVersion</string>
<object class="NSArray" key="dict.sortedKeys" id="0"> <integer value="1" key="NS.object.0"/>
<bool key="EncodedWithXMLCoder">YES</bool>
</object>
<object class="NSMutableArray" key="dict.values">
<bool key="EncodedWithXMLCoder">YES</bool>
</object>
</object> </object>
<object class="NSMutableArray" key="IBDocument.RootObjects" id="1048"> <object class="NSMutableArray" key="IBDocument.RootObjects" id="1048">
<bool key="EncodedWithXMLCoder">YES</bool> <bool key="EncodedWithXMLCoder">YES</bool>
@ -666,14 +661,6 @@
</object> </object>
<int key="connectionID">39</int> <int key="connectionID">39</int>
</object> </object>
<object class="IBConnectionRecord">
<object class="IBActionConnection" key="connection">
<string key="label">orderFrontStandardAboutPanel:</string>
<reference key="source" ref="1021"/>
<reference key="destination" ref="238522557"/>
</object>
<int key="connectionID">142</int>
</object>
<object class="IBConnectionRecord"> <object class="IBConnectionRecord">
<object class="IBActionConnection" key="connection"> <object class="IBActionConnection" key="connection">
<string key="label">toggleContinuousSpellChecking:</string> <string key="label">toggleContinuousSpellChecking:</string>
@ -976,7 +963,9 @@
<bool key="EncodedWithXMLCoder">YES</bool> <bool key="EncodedWithXMLCoder">YES</bool>
<object class="IBObjectRecord"> <object class="IBObjectRecord">
<int key="objectID">0</int> <int key="objectID">0</int>
<reference key="object" ref="0"/> <object class="NSArray" key="object" id="0">
<bool key="EncodedWithXMLCoder">YES</bool>
</object>
<reference key="children" ref="1048"/> <reference key="children" ref="1048"/>
<nil key="parent"/> <nil key="parent"/>
</object> </object>

View file

@ -44,7 +44,8 @@ namespace SparkleShare {
{ {
SetFrame (new RectangleF (0, 0, 360, 288), true); SetFrame (new RectangleF (0, 0, 360, 288), true);
Center (); Center ();
Delegate = new SparkleAboutDelegate ();
StyleMask = (NSWindowStyle.Closable | NSWindowStyle.Titled); StyleMask = (NSWindowStyle.Closable | NSWindowStyle.Titled);
Title = "About SparkleShare"; Title = "About SparkleShare";
MaxSize = new SizeF (360, 288); MaxSize = new SizeF (360, 288);
@ -71,6 +72,12 @@ namespace SparkleShare {
}); });
}; };
CheckForNewVersion ();
}
public void CheckForNewVersion ()
{
SparkleShare.Controller.CheckForNewVersion (); SparkleShare.Controller.CheckForNewVersion ();
} }
@ -137,10 +144,8 @@ namespace SparkleShare {
}; };
WebsiteButton.Activated += delegate { WebsiteButton.Activated += delegate {
NSUrl url = new NSUrl ("http://www.sparkleshare.org/"); NSUrl url = new NSUrl ("http://www.sparkleshare.org/");
NSWorkspace.SharedWorkspace.OpenUrl (url); NSWorkspace.SharedWorkspace.OpenUrl (url);
}; };
CreditsButton = new NSButton () { CreditsButton = new NSButton () {
@ -166,4 +171,14 @@ namespace SparkleShare {
ContentView.AddSubview (WebsiteButton); ContentView.AddSubview (WebsiteButton);
} }
} }
public class SparkleAboutDelegate : NSWindowDelegate {
public override bool WindowShouldClose (NSObject sender)
{
(sender as SparkleAbout).OrderOut (this);
return false;
}
}
} }

View file

@ -41,6 +41,7 @@ namespace SparkleShare {
private NSMenuItem FolderMenuItem; private NSMenuItem FolderMenuItem;
private NSMenuItem [] FolderMenuItems; private NSMenuItem [] FolderMenuItems;
private NSMenuItem SyncMenuItem; private NSMenuItem SyncMenuItem;
private NSMenuItem AboutMenuItem;
private NSMenuItem NotificationsMenuItem; private NSMenuItem NotificationsMenuItem;
private delegate void Task (); private delegate void Task ();
@ -214,15 +215,15 @@ namespace SparkleShare {
SyncMenuItem.Activated += delegate { SyncMenuItem.Activated += delegate {
InvokeOnMainThread (delegate { InvokeOnMainThread (delegate {
NSApplication.SharedApplication.ActivateIgnoringOtherApps (true); NSApplication.SharedApplication.ActivateIgnoringOtherApps (true);
if (SparkleUI.Intro == null) { if (SparkleUI.Intro == null) {
SparkleUI.Intro = new SparkleIntro (); SparkleUI.Intro = new SparkleIntro ();
SparkleUI.Intro.ShowServerForm (true); SparkleUI.Intro.ShowServerForm (true);
} }
if (!SparkleUI.Intro.IsVisible) if (!SparkleUI.Intro.IsVisible)
SparkleUI.Intro.ShowServerForm (true); SparkleUI.Intro.ShowServerForm (true);
SparkleUI.Intro.OrderFrontRegardless (); SparkleUI.Intro.OrderFrontRegardless ();
SparkleUI.Intro.MakeKeyAndOrderFront (this); SparkleUI.Intro.MakeKeyAndOrderFront (this);
}); });
@ -232,16 +233,17 @@ namespace SparkleShare {
Menu.AddItem (SyncMenuItem); Menu.AddItem (SyncMenuItem);
Menu.AddItem (NSMenuItem.SeparatorItem); Menu.AddItem (NSMenuItem.SeparatorItem);
NotificationsMenuItem = new NSMenuItem (); NotificationsMenuItem = new NSMenuItem ();
if (SparkleShare.Controller.NotificationsEnabled) if (SparkleShare.Controller.NotificationsEnabled)
NotificationsMenuItem.Title = "Turn Notifications Off"; NotificationsMenuItem.Title = "Turn Notifications Off";
else else
NotificationsMenuItem.Title = "Turn Notifications On"; NotificationsMenuItem.Title = "Turn Notifications On";
NotificationsMenuItem.Activated += delegate { NotificationsMenuItem.Activated += delegate {
SparkleShare.Controller.ToggleNotifications (); SparkleShare.Controller.ToggleNotifications ();
InvokeOnMainThread (delegate { InvokeOnMainThread (delegate {
if (SparkleShare.Controller.NotificationsEnabled) if (SparkleShare.Controller.NotificationsEnabled)
NotificationsMenuItem.Title = "Turn Notifications Off"; NotificationsMenuItem.Title = "Turn Notifications Off";
@ -251,7 +253,30 @@ namespace SparkleShare {
}; };
Menu.AddItem (NotificationsMenuItem); 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 = Menu;
StatusItem.Menu.Update (); StatusItem.Menu.Update ();
} }

View file

@ -53,6 +53,7 @@ namespace SparkleShare {
public static SparkleStatusIcon StatusIcon; public static SparkleStatusIcon StatusIcon;
public static List <SparkleLog> OpenLogs; public static List <SparkleLog> OpenLogs;
public static SparkleIntro Intro; public static SparkleIntro Intro;
public static SparkleAbout About;
public static NSFont Font; public static NSFont Font;
private NSAlert alert; private NSAlert alert;