mac about log: fix coding style and whitespace
This commit is contained in:
parent
dfa4ab4675
commit
e5fe9de192
|
@ -165,7 +165,5 @@ namespace SparkleShare {
|
||||||
ContentView.AddSubview (CreditsButton);
|
ContentView.AddSubview (CreditsButton);
|
||||||
ContentView.AddSubview (WebsiteButton);
|
ContentView.AddSubview (WebsiteButton);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -27,60 +27,55 @@ using MonoMac.WebKit;
|
||||||
|
|
||||||
namespace SparkleShare {
|
namespace SparkleShare {
|
||||||
|
|
||||||
public class SparkleLog : NSWindow {
|
public class SparkleLog : NSWindow {
|
||||||
|
|
||||||
public readonly string LocalPath;
|
public readonly string LocalPath;
|
||||||
|
|
||||||
private WebView WebView;
|
private WebView WebView;
|
||||||
private NSButton CloseButton;
|
private NSButton CloseButton;
|
||||||
private NSButton OpenFolderButton;
|
private NSButton OpenFolderButton;
|
||||||
private NSBox Separator;
|
private NSBox Separator;
|
||||||
private string HTML;
|
private string HTML;
|
||||||
private NSProgressIndicator ProgressIndicator;
|
private NSProgressIndicator ProgressIndicator;
|
||||||
|
|
||||||
|
|
||||||
public SparkleLog (IntPtr handle) : base (handle) { }
|
public SparkleLog (IntPtr handle) : base (handle) { }
|
||||||
|
|
||||||
public SparkleLog (string path) : base ()
|
public SparkleLog (string path) : base ()
|
||||||
{
|
{
|
||||||
|
LocalPath = path;
|
||||||
|
|
||||||
LocalPath = path;
|
Delegate = new SparkleLogDelegate ();
|
||||||
|
|
||||||
Delegate = new SparkleLogDelegate ();
|
SetFrame (new RectangleF (0, 0, 480, 640), true);
|
||||||
|
Center ();
|
||||||
|
|
||||||
SetFrame (new RectangleF (0, 0, 480, 640), true);
|
// Open slightly off center for each consecutive window
|
||||||
Center ();
|
if (SparkleUI.OpenLogs.Count > 0) {
|
||||||
|
RectangleF offset = new RectangleF (Frame.X + (SparkleUI.OpenLogs.Count * 20),
|
||||||
|
Frame.Y - (SparkleUI.OpenLogs.Count * 20), Frame.Width, Frame.Height);
|
||||||
|
|
||||||
// Open slightly off center for each consecutive window
|
SetFrame (offset, true);
|
||||||
if (SparkleUI.OpenLogs.Count > 0) {
|
}
|
||||||
|
|
||||||
RectangleF offset = new RectangleF (Frame.X + (SparkleUI.OpenLogs.Count * 20),
|
StyleMask = (NSWindowStyle.Closable |
|
||||||
Frame.Y - (SparkleUI.OpenLogs.Count * 20), Frame.Width, Frame.Height);
|
NSWindowStyle.Miniaturizable |
|
||||||
|
NSWindowStyle.Titled);
|
||||||
|
|
||||||
SetFrame (offset, true);
|
MaxSize = new SizeF (480, 640);
|
||||||
|
MinSize = new SizeF (480, 640);
|
||||||
|
HasShadow = true;
|
||||||
|
BackingType = NSBackingStore.Buffered;
|
||||||
|
|
||||||
}
|
CreateEventLog ();
|
||||||
|
UpdateEventLog ();
|
||||||
|
|
||||||
StyleMask = (NSWindowStyle.Closable |
|
OrderFrontRegardless ();
|
||||||
NSWindowStyle.Miniaturizable |
|
}
|
||||||
NSWindowStyle.Titled);
|
|
||||||
|
|
||||||
MaxSize = new SizeF (480, 640);
|
|
||||||
MinSize = new SizeF (480, 640);
|
|
||||||
HasShadow = true;
|
|
||||||
BackingType = NSBackingStore.Buffered;
|
|
||||||
|
|
||||||
CreateEventLog ();
|
|
||||||
UpdateEventLog ();
|
|
||||||
|
|
||||||
OrderFrontRegardless ();
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
private void CreateEventLog ()
|
private void CreateEventLog ()
|
||||||
{
|
{
|
||||||
|
|
||||||
OpenFolderButton = new NSButton (new RectangleF (16, 12, 120, 32)) {
|
OpenFolderButton = new NSButton (new RectangleF (16, 12, 120, 32)) {
|
||||||
Title = "Open Folder",
|
Title = "Open Folder",
|
||||||
BezelStyle = NSBezelStyle.Rounded ,
|
BezelStyle = NSBezelStyle.Rounded ,
|
||||||
|
@ -132,37 +127,27 @@ namespace SparkleShare {
|
||||||
};
|
};
|
||||||
|
|
||||||
Update ();
|
Update ();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public void UpdateEventLog ()
|
public void UpdateEventLog ()
|
||||||
{
|
{
|
||||||
|
|
||||||
InvokeOnMainThread (delegate {
|
InvokeOnMainThread (delegate {
|
||||||
|
|
||||||
if (HTML == null)
|
if (HTML == null)
|
||||||
ContentView.AddSubview (ProgressIndicator);
|
ContentView.AddSubview (ProgressIndicator);
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
Thread thread = new Thread (new ThreadStart (delegate {
|
Thread thread = new Thread (new ThreadStart (delegate {
|
||||||
|
|
||||||
GenerateHTML ();
|
GenerateHTML ();
|
||||||
AddHTML ();
|
AddHTML ();
|
||||||
|
|
||||||
}));
|
}));
|
||||||
|
|
||||||
thread.Start ();
|
thread.Start ();
|
||||||
|
}
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
private void GenerateHTML ()
|
private void GenerateHTML ()
|
||||||
{
|
{
|
||||||
|
|
||||||
|
|
||||||
string folder_name = Path.GetFileName (LocalPath);
|
string folder_name = Path.GetFileName (LocalPath);
|
||||||
HTML = SparkleShare.Controller.GetHTMLLog (folder_name);
|
HTML = SparkleShare.Controller.GetHTMLLog (folder_name);
|
||||||
|
|
||||||
|
@ -176,15 +161,12 @@ namespace SparkleShare {
|
||||||
HTML = HTML.Replace ("<!-- $a-hover-color -->", "#009ff8");
|
HTML = HTML.Replace ("<!-- $a-hover-color -->", "#009ff8");
|
||||||
HTML = HTML.Replace ("<!-- $no-buddy-icon-background-image -->",
|
HTML = HTML.Replace ("<!-- $no-buddy-icon-background-image -->",
|
||||||
"file://" + Path.Combine (NSBundle.MainBundle.ResourcePath, "Pixmaps", "avatar-default.png"));
|
"file://" + Path.Combine (NSBundle.MainBundle.ResourcePath, "Pixmaps", "avatar-default.png"));
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private void AddHTML ()
|
private void AddHTML ()
|
||||||
{
|
{
|
||||||
|
|
||||||
InvokeOnMainThread (delegate {
|
InvokeOnMainThread (delegate {
|
||||||
|
|
||||||
if (ProgressIndicator.Superview == ContentView)
|
if (ProgressIndicator.Superview == ContentView)
|
||||||
ProgressIndicator.RemoveFromSuperview ();
|
ProgressIndicator.RemoveFromSuperview ();
|
||||||
|
|
||||||
|
@ -192,40 +174,30 @@ namespace SparkleShare {
|
||||||
|
|
||||||
ContentView.AddSubview (WebView);
|
ContentView.AddSubview (WebView);
|
||||||
Update ();
|
Update ();
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
public class SparkleLogDelegate : NSWindowDelegate {
|
public class SparkleLogDelegate : NSWindowDelegate {
|
||||||
|
|
||||||
public override bool WindowShouldClose (NSObject sender)
|
public override bool WindowShouldClose (NSObject sender)
|
||||||
{
|
{
|
||||||
|
(sender as SparkleLog).OrderOut (this);
|
||||||
(sender as SparkleLog).OrderOut (this);
|
return false;
|
||||||
return false;
|
}
|
||||||
|
}
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
public class SparkleWebPolicyDelegate : WebPolicyDelegate {
|
public class SparkleWebPolicyDelegate : WebPolicyDelegate {
|
||||||
|
|
||||||
public override void DecidePolicyForNavigation (WebView web_view, NSDictionary action_info,
|
public override void DecidePolicyForNavigation (WebView web_view, NSDictionary action_info,
|
||||||
NSUrlRequest request, WebFrame frame, NSObject decision_token)
|
NSUrlRequest request, WebFrame frame, NSObject decision_token)
|
||||||
{
|
{
|
||||||
|
string file_path = request.Url.ToString ();
|
||||||
string file_path = request.Url.ToString ();
|
file_path = file_path.Replace ("%20", " ");
|
||||||
file_path = file_path.Replace ("%20", " ");
|
|
||||||
|
|
||||||
NSWorkspace.SharedWorkspace.OpenFile (file_path);
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
NSWorkspace.SharedWorkspace.OpenFile (file_path);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue