[osx] Fix some bugs an use sparkleshare.icns for the .app

This commit is contained in:
Hylke Bons 2010-12-21 20:59:53 +01:00
parent 7502358d69
commit a6b80ab723
5 changed files with 52 additions and 24 deletions

View file

@ -32,7 +32,8 @@ namespace SparkleShare {
private NSButton CloseButton; private NSButton CloseButton;
private NSButton OpenFolderButton; private NSButton OpenFolderButton;
public SparkleLog (IntPtr handle) : base (handle) { }
public SparkleLog (string path) : base () public SparkleLog (string path) : base ()
{ {
@ -109,17 +110,17 @@ namespace SparkleShare {
} }
} }
public class LogDelegate : NSWindowDelegate { public class LogDelegate : NSWindowDelegate {
public override void WillClose (NSNotification notification) public override void WillClose (NSNotification notification)
{ {
Console.WriteLine ("CLOSING " + (notification.Object as SparkleLog).LocalPath); InvokeOnMainThread (delegate {
SparkleUI.OpenLogs.Remove ((SparkleLog) notification.Object);
SparkleUI.OpenLogs.Remove ((SparkleLog) notification.Object); });
} }
} }

View file

@ -81,10 +81,10 @@
<Content Include="Pixmaps\idle3.png" /> <Content Include="Pixmaps\idle3.png" />
<Content Include="Pixmaps\sparkleshare-idle.png" /> <Content Include="Pixmaps\sparkleshare-idle.png" />
<Content Include="Pixmaps\sparkleshare-idle-focus.png" /> <Content Include="Pixmaps\sparkleshare-idle-focus.png" />
<Content Include="Pixmaps\sparkleshare.icns" />
<Content Include="..\..\..\data\side-splash.png"> <Content Include="..\..\..\data\side-splash.png">
<Link>Pixmaps\side-splash.png</Link> <Link>Pixmaps\side-splash.png</Link>
</Content> </Content>
<Content Include="sparkleshare.icns" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<ProjectReference Include="..\..\..\SparkleLib\SparkleLib.csproj"> <ProjectReference Include="..\..\..\SparkleLib\SparkleLib.csproj">

View file

@ -40,6 +40,9 @@ namespace SparkleShare {
private NSMenuItem SyncMenuItem; private NSMenuItem SyncMenuItem;
private NSMenuItem NotificationsMenuItem; private NSMenuItem NotificationsMenuItem;
private NSMenuItem AboutMenuItem; private NSMenuItem AboutMenuItem;
private delegate void Task ();
private EventHandler [] Tasks;
// Short alias for the translations // Short alias for the translations
@ -51,7 +54,7 @@ namespace SparkleShare {
public SparkleStatusIcon () : base () public SparkleStatusIcon () : base ()
{ {
Animation = CreateAnimation (); Animation = CreateAnimation ();
StatusItem = NSStatusBar.SystemStatusBar.CreateStatusItem (28); StatusItem = NSStatusBar.SystemStatusBar.CreateStatusItem (28);
@ -61,7 +64,8 @@ namespace SparkleShare {
SetNormalState (); SetNormalState ();
CreateMenu (); CreateMenu ();
Menu.Delegate = new SparkleStatusIconMenuDelegate ();
SparkleShare.Controller.FolderSizeChanged += delegate { SparkleShare.Controller.FolderSizeChanged += delegate {
InvokeOnMainThread (delegate { InvokeOnMainThread (delegate {
@ -259,15 +263,11 @@ namespace SparkleShare {
} }
public delegate void Task();
EventHandler [] Tasks;
// A method reference that makes sure that opening the // A method reference that makes sure that opening the
// event log for each repository works correctly // event log for each repository works correctly
private EventHandler OpenEventLogDelegate (string path) private EventHandler OpenEventLogDelegate (string path)
{ {
return delegate { return delegate {
SparkleLog log = SparkleUI.OpenLogs.Find (delegate (SparkleLog l) { SparkleLog log = SparkleUI.OpenLogs.Find (delegate (SparkleLog l) {
@ -276,10 +276,19 @@ namespace SparkleShare {
// Check whether the log is already open, create a new one if // Check whether the log is already open, create a new one if
// that's not the case or present it to the user if it is // that's not the case or present it to the user if it is
if (log == null) if (log == null) {
SparkleUI.OpenLogs.Add (new SparkleLog (path));
else InvokeOnMainThread (delegate {
log.OrderFrontRegardless (); SparkleUI.OpenLogs.Add (new SparkleLog (path));
});
} else {
InvokeOnMainThread (delegate {
log.OrderFrontRegardless ();
});
}
}; };
@ -363,6 +372,27 @@ namespace SparkleShare {
} }
} }
public class SparkleStatusIconMenuDelegate : NSMenuDelegate {
public override void MenuWillHighlightItem (NSMenu menu, NSMenuItem item) { }
public override void MenuWillOpen (NSMenu menu)
{
Console.WriteLine ("OPENED");
InvokeOnMainThread (delegate {
foreach (SparkleLog log in SparkleUI.OpenLogs)
log.OrderFrontRegardless ();
});
}
}
} }

View file

@ -42,14 +42,11 @@ namespace SparkleShare {
{ {
NSApplication.Init (); NSApplication.Init ();
NSApplication.SharedApplication.ActivateIgnoringOtherApps (true);
NSApplication.SharedApplication.applicationIconImage = new NSImage (NSBundle.MainBundle.ResourcePath + "/Pixmaps/sparkeshare.icns"); NSApplication.SharedApplication.applicationIconImage = NSImage.ImageNamed ("sparkleshare.icns");
OpenLogs = new List <SparkleLog> (); OpenLogs = new List <SparkleLog> ();
StatusIcon = new SparkleStatusIcon (); StatusIcon = new SparkleStatusIcon ();
} }