[log] Keep logs in memory at all time. Fixes crashes and increases speed.
This commit is contained in:
parent
95e94b326c
commit
0d765a4e72
|
@ -56,8 +56,10 @@ namespace SparkleShare {
|
|||
HasShadow = true;
|
||||
BackingType = NSBackingStore.Buffered;
|
||||
|
||||
CreateEventLog ();
|
||||
UpdateEventLog ();
|
||||
|
||||
ContentView.AddSubview (CreateEventLog ());
|
||||
ContentView.AddSubview (WebView);
|
||||
|
||||
OpenFolderButton = new NSButton (new RectangleF (16, 12, 120, 31)) {
|
||||
Title = "Open Folder",
|
||||
|
@ -90,20 +92,14 @@ namespace SparkleShare {
|
|||
|
||||
OrderFrontRegardless ();
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
public void UpdateEventLog ()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
|
||||
private WebView CreateEventLog ()
|
||||
{
|
||||
|
||||
RectangleF frame = new RectangleF (0, (12 + 31 + 16), 480, 618 - (12 + 31 + 16));
|
||||
|
||||
string folder_name = Path.GetFileName (LocalPath);
|
||||
string html = SparkleShare.Controller.GetHTMLLog (folder_name);
|
||||
|
||||
|
@ -113,9 +109,17 @@ namespace SparkleShare {
|
|||
html = html.Replace ("<!-- $day-entry-header-background-color -->", "#f5f5f5");
|
||||
html = html.Replace ("<!-- $a-color -->", "#0085cf");
|
||||
|
||||
WebView = new WebView (frame, "", "");
|
||||
WebView.MainFrame.LoadHtmlString (html, new NSUrl (""));
|
||||
WebView.PolicyDelegate = new SparkleWebPolicyDelegate ();
|
||||
|
||||
}
|
||||
|
||||
|
||||
private WebView CreateEventLog ()
|
||||
{
|
||||
|
||||
WebView = new WebView (new RectangleF (0, 59, 480, 559), "", ""){
|
||||
PolicyDelegate = new SparkleWebPolicyDelegate ()
|
||||
};
|
||||
|
||||
return WebView;
|
||||
|
||||
|
@ -126,12 +130,11 @@ namespace SparkleShare {
|
|||
|
||||
public class LogDelegate : NSWindowDelegate {
|
||||
|
||||
public override void WillClose (NSNotification notification)
|
||||
public override bool WindowShouldClose (NSObject sender)
|
||||
{
|
||||
|
||||
InvokeOnMainThread (delegate {
|
||||
SparkleUI.OpenLogs.Remove ((SparkleLog) notification.Object);
|
||||
});
|
||||
(sender as SparkleLog).OrderOut (this);
|
||||
return false;
|
||||
|
||||
}
|
||||
|
||||
|
@ -141,7 +144,8 @@ namespace SparkleShare {
|
|||
public class SparkleWebPolicyDelegate : WebPolicyDelegate {
|
||||
|
||||
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 ();
|
||||
file_path = file_path.Replace ("%20", "\\ ");
|
||||
|
|
|
@ -63,9 +63,16 @@ namespace SparkleShare {
|
|||
|
||||
Directory.CreateDirectory (SparklePaths.SparklePath);
|
||||
|
||||
NSWorkspace.SharedWorkspace.SetIconforFile (NSImage.ImageNamed ("sparkleshare.icns"),
|
||||
|
||||
string folder_icon_path = Path.Combine (NSBundle.MainBundle.ResourcePath,
|
||||
"Pixmaps", "sparkleshare-folder.icns");
|
||||
|
||||
NSImage folder_icon = new NSImage (folder_icon_path);
|
||||
|
||||
NSWorkspace.SharedWorkspace.SetIconforFile (folder_icon,
|
||||
SparklePaths.SparklePath, 0);
|
||||
|
||||
|
||||
return true;
|
||||
|
||||
} else {
|
||||
|
@ -82,11 +89,9 @@ namespace SparkleShare {
|
|||
{
|
||||
|
||||
string folder = Path.Combine (SparklePaths.SparklePath, subfolder);
|
||||
folder.Replace (" ", "\\ "); // Escape space-characters
|
||||
|
||||
Process process = new Process ();
|
||||
process.StartInfo.Arguments = folder.Replace (" ", "\\ "); // Escape space-characters
|
||||
process.StartInfo.FileName = "open";
|
||||
process.Start ();
|
||||
NSWorkspace.SharedWorkspace.OpenFile (folder);
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -161,8 +161,7 @@ namespace SparkleShare {
|
|||
SparkleShare.Controller.OpenSparkleShareFolder ();
|
||||
};
|
||||
|
||||
//FolderMenuItem.Image = new NSImage (NSBundle.MainBundle.ResourcePath + "/Pixmaps/sparkleshare.icns");
|
||||
FolderMenuItem.Image = NSImage.ImageNamed ("NSFolder");
|
||||
FolderMenuItem.Image = new NSImage (NSBundle.MainBundle.ResourcePath + "/Pixmaps/sparkleshare-mac-16.png");
|
||||
FolderMenuItem.Image.Size = new SizeF (16, 16);
|
||||
|
||||
Menu.AddItem (FolderMenuItem);
|
||||
|
@ -198,7 +197,13 @@ namespace SparkleShare {
|
|||
|
||||
} else {
|
||||
|
||||
// TODO: No Remote Folders Yet
|
||||
FolderMenuItems = new NSMenuItem [1];
|
||||
|
||||
FolderMenuItems [0] = new NSMenuItem () {
|
||||
Title = "No Remote Folders Yet"
|
||||
};
|
||||
|
||||
Menu.AddItem (FolderMenuItems [0]);
|
||||
|
||||
}
|
||||
|
||||
|
@ -251,7 +256,10 @@ namespace SparkleShare {
|
|||
};
|
||||
|
||||
AboutMenuItem.Activated += delegate {
|
||||
// TODO
|
||||
|
||||
NSUrl url = new NSUrl ("http://www.sparkleshare.org/");
|
||||
NSWorkspace.SharedWorkspace.OpenUrl (url);
|
||||
|
||||
};
|
||||
|
||||
Menu.AddItem (AboutMenuItem);
|
||||
|
@ -285,7 +293,7 @@ namespace SparkleShare {
|
|||
} else {
|
||||
|
||||
InvokeOnMainThread (delegate {
|
||||
log.OrderFrontRegardless ();
|
||||
log.OrderFront (this);
|
||||
});
|
||||
|
||||
}
|
||||
|
@ -383,9 +391,6 @@ namespace SparkleShare {
|
|||
|
||||
InvokeOnMainThread (delegate {
|
||||
|
||||
foreach (SparkleLog log in SparkleUI.OpenLogs)
|
||||
log.OrderFrontRegardless ();
|
||||
|
||||
SparkleUI.NewEvents = 0;
|
||||
NSApplication.SharedApplication.DockTile.BadgeLabel = null;
|
||||
|
||||
|
|
|
@ -18,6 +18,7 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Drawing;
|
||||
using System.IO;
|
||||
using System.Timers;
|
||||
using MonoMac.Foundation;
|
||||
using MonoMac.AppKit;
|
||||
|
@ -44,9 +45,12 @@ namespace SparkleShare {
|
|||
|
||||
NSApplication.Init ();
|
||||
|
||||
|
||||
// TODO: Getting crashes when I remove this
|
||||
NSApplication.SharedApplication.ApplicationIconImage
|
||||
= NSImage.ImageNamed ("sparkleshare.icns");
|
||||
|
||||
|
||||
OpenLogs = new List <SparkleLog> ();
|
||||
StatusIcon = new SparkleStatusIcon ();
|
||||
|
||||
|
|
BIN
data/sparkleshare-folder.icns
Normal file
BIN
data/sparkleshare-folder.icns
Normal file
Binary file not shown.
BIN
data/sparkleshare-mac-16.png
Normal file
BIN
data/sparkleshare-mac-16.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 3.2 KiB |
BIN
data/sparkleshare-mac-512.png
Normal file
BIN
data/sparkleshare-mac-512.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 313 KiB |
Loading…
Reference in a new issue