[osx] Implement elegant log window managing

This commit is contained in:
Hylke Bons 2010-12-21 18:28:30 +01:00
parent c75ac74764
commit a2eece8cd4
4 changed files with 29 additions and 26 deletions

View file

@ -32,12 +32,13 @@ namespace SparkleShare {
private NSButton CloseButton;
private NSButton OpenFolderButton;
public SparkleLog (string path) : base ()
{
LocalPath = path;
Delegate = new LogDelegate ();
SetFrame (new RectangleF (0, 0, 480, 640), true);
@ -73,7 +74,9 @@ namespace SparkleShare {
};
CloseButton.Activated += delegate {
PerformClose (this);
InvokeOnMainThread (delegate {
PerformClose (this);
});
};
ContentView.AddSubview (CloseButton);
@ -82,23 +85,10 @@ namespace SparkleShare {
string name = System.IO.Path.GetFileName (LocalPath);
Title = String.Format ("Recent Events in {0}", name);
NSApplication.SharedApplication.ActivateIgnoringOtherApps (true);
MakeKeyAndOrderFront (this);
OrderFrontRegardless ();
}
public override void PerformClose (NSObject sender)
{
InvokeOnMainThread (delegate {
Console.WriteLine ("!!!!!!!!!!");
SparkleUI.OpenLogs.Remove ((SparkleLog) this);
base.PerformClose (this);
});
}
public void UpdateEventLog ()
{
@ -119,5 +109,19 @@ 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);
}
}
}

View file

@ -81,6 +81,7 @@
<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>
@ -94,7 +95,4 @@
<ItemGroup>
<Folder Include="Pixmaps\" />
</ItemGroup>
<ItemGroup>
<EmbeddedResource Include="Pixmaps\sparkleshare.icns" />
</ItemGroup>
</Project>

View file

@ -270,15 +270,16 @@ namespace SparkleShare {
return delegate {
SparkleLog log = SparkleUI.OpenLogs.Find (delegate (SparkleLog l) { return l.LocalPath.Equals (path); });
SparkleLog log = SparkleUI.OpenLogs.Find (delegate (SparkleLog l) {
return l.LocalPath.Equals (path);
});
// 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) {
if (log == null)
SparkleUI.OpenLogs.Add (new SparkleLog (path));
}
else
log.OrderFrontRegardless ();
};

View file

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