[osx] Implement elegant log window managing
This commit is contained in:
parent
116d5c5be2
commit
7aa6f92166
|
@ -32,12 +32,13 @@ namespace SparkleShare {
|
||||||
private NSButton CloseButton;
|
private NSButton CloseButton;
|
||||||
private NSButton OpenFolderButton;
|
private NSButton OpenFolderButton;
|
||||||
|
|
||||||
|
|
||||||
public SparkleLog (string path) : base ()
|
public SparkleLog (string path) : base ()
|
||||||
{
|
{
|
||||||
|
|
||||||
LocalPath = path;
|
LocalPath = path;
|
||||||
|
|
||||||
|
Delegate = new LogDelegate ();
|
||||||
|
|
||||||
SetFrame (new RectangleF (0, 0, 480, 640), true);
|
SetFrame (new RectangleF (0, 0, 480, 640), true);
|
||||||
|
|
||||||
|
@ -73,7 +74,9 @@ namespace SparkleShare {
|
||||||
};
|
};
|
||||||
|
|
||||||
CloseButton.Activated += delegate {
|
CloseButton.Activated += delegate {
|
||||||
PerformClose (this);
|
InvokeOnMainThread (delegate {
|
||||||
|
PerformClose (this);
|
||||||
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
ContentView.AddSubview (CloseButton);
|
ContentView.AddSubview (CloseButton);
|
||||||
|
@ -82,23 +85,10 @@ namespace SparkleShare {
|
||||||
string name = System.IO.Path.GetFileName (LocalPath);
|
string name = System.IO.Path.GetFileName (LocalPath);
|
||||||
Title = String.Format ("Recent Events in ‘{0}’", name);
|
Title = String.Format ("Recent Events in ‘{0}’", name);
|
||||||
|
|
||||||
NSApplication.SharedApplication.ActivateIgnoringOtherApps (true);
|
OrderFrontRegardless ();
|
||||||
MakeKeyAndOrderFront (this);
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public override void PerformClose (NSObject sender)
|
|
||||||
{
|
|
||||||
|
|
||||||
InvokeOnMainThread (delegate {
|
|
||||||
Console.WriteLine ("!!!!!!!!!!");
|
|
||||||
SparkleUI.OpenLogs.Remove ((SparkleLog) this);
|
|
||||||
base.PerformClose (this);
|
|
||||||
});
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
public void UpdateEventLog ()
|
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);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -81,6 +81,7 @@
|
||||||
<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>
|
||||||
|
@ -94,7 +95,4 @@
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<Folder Include="Pixmaps\" />
|
<Folder Include="Pixmaps\" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
|
||||||
<EmbeddedResource Include="Pixmaps\sparkleshare.icns" />
|
|
||||||
</ItemGroup>
|
|
||||||
</Project>
|
</Project>
|
|
@ -270,15 +270,16 @@ namespace SparkleShare {
|
||||||
|
|
||||||
return delegate {
|
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
|
// 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));
|
SparkleUI.OpenLogs.Add (new SparkleLog (path));
|
||||||
|
else
|
||||||
}
|
log.OrderFrontRegardless ();
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -43,7 +43,7 @@ namespace SparkleShare {
|
||||||
|
|
||||||
NSApplication.Init ();
|
NSApplication.Init ();
|
||||||
NSApplication.SharedApplication.ActivateIgnoringOtherApps (true);
|
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> ();
|
OpenLogs = new List <SparkleLog> ();
|
||||||
StatusIcon = new SparkleStatusIcon ();
|
StatusIcon = new SparkleStatusIcon ();
|
||||||
|
|
Loading…
Reference in a new issue