[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 7aa6f92166
commit f7cf25dda6
5 changed files with 52 additions and 24 deletions

View file

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

View file

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

View file

@ -40,6 +40,9 @@ namespace SparkleShare {
private NSMenuItem SyncMenuItem;
private NSMenuItem NotificationsMenuItem;
private NSMenuItem AboutMenuItem;
private delegate void Task ();
private EventHandler [] Tasks;
// Short alias for the translations
@ -51,7 +54,7 @@ namespace SparkleShare {
public SparkleStatusIcon () : base ()
{
Animation = CreateAnimation ();
StatusItem = NSStatusBar.SystemStatusBar.CreateStatusItem (28);
@ -61,7 +64,8 @@ namespace SparkleShare {
SetNormalState ();
CreateMenu ();
Menu.Delegate = new SparkleStatusIconMenuDelegate ();
SparkleShare.Controller.FolderSizeChanged += delegate {
InvokeOnMainThread (delegate {
@ -259,15 +263,11 @@ namespace SparkleShare {
}
public delegate void Task();
EventHandler [] Tasks;
// A method reference that makes sure that opening the
// event log for each repository works correctly
private EventHandler OpenEventLogDelegate (string path)
{
return delegate {
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
// that's not the case or present it to the user if it is
if (log == null)
SparkleUI.OpenLogs.Add (new SparkleLog (path));
else
log.OrderFrontRegardless ();
if (log == null) {
InvokeOnMainThread (delegate {
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.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 ();
}