diff --git a/SparkleShare/Mac/SparkleShare/SparkleLog.cs b/SparkleShare/Mac/SparkleShare/SparkleLog.cs index 2de73e0e..c24fe9f1 100644 --- a/SparkleShare/Mac/SparkleShare/SparkleLog.cs +++ b/SparkleShare/Mac/SparkleShare/SparkleLog.cs @@ -40,7 +40,7 @@ namespace SparkleShare { { LocalPath = path; - + Delegate = new LogDelegate (); SetFrame (new RectangleF (0, 0, 480, 640), true); @@ -56,8 +56,10 @@ namespace SparkleShare { HasShadow = true; BackingType = NSBackingStore.Buffered; - - ContentView.AddSubview (CreateEventLog ()); + CreateEventLog (); + UpdateEventLog (); + + 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); @@ -112,11 +108,19 @@ namespace SparkleShare { html = html.Replace ("", "#bbb"); html = html.Replace ("", "#f5f5f5"); html = html.Replace ("", "#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,13 +130,12 @@ namespace SparkleShare { public class LogDelegate : NSWindowDelegate { - public override void WillClose (NSNotification notification) + public override bool WindowShouldClose (NSObject sender) { + + (sender as SparkleLog).OrderOut (this); + return false; - InvokeOnMainThread (delegate { - SparkleUI.OpenLogs.Remove ((SparkleLog) notification.Object); - }); - } } @@ -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", "\\ "); diff --git a/SparkleShare/Mac/SparkleShare/SparkleMacController.cs b/SparkleShare/Mac/SparkleShare/SparkleMacController.cs index 34c1ab9c..8055dee1 100644 --- a/SparkleShare/Mac/SparkleShare/SparkleMacController.cs +++ b/SparkleShare/Mac/SparkleShare/SparkleMacController.cs @@ -61,11 +61,18 @@ namespace SparkleShare { if (!Directory.Exists (SparklePaths.SparklePath)) { - Directory.CreateDirectory (SparklePaths.SparklePath); + Directory.CreateDirectory (SparklePaths.SparklePath); + + + string folder_icon_path = Path.Combine (NSBundle.MainBundle.ResourcePath, + "Pixmaps", "sparkleshare-folder.icns"); - NSWorkspace.SharedWorkspace.SetIconforFile (NSImage.ImageNamed ("sparkleshare.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); - - Process process = new Process (); - process.StartInfo.Arguments = folder.Replace (" ", "\\ "); // Escape space-characters - process.StartInfo.FileName = "open"; - process.Start (); + folder.Replace (" ", "\\ "); // Escape space-characters + + NSWorkspace.SharedWorkspace.OpenFile (folder); } diff --git a/SparkleShare/Mac/SparkleShare/SparkleStatusIcon.cs b/SparkleShare/Mac/SparkleShare/SparkleStatusIcon.cs index dde6fcb6..c6239d9c 100644 --- a/SparkleShare/Mac/SparkleShare/SparkleStatusIcon.cs +++ b/SparkleShare/Mac/SparkleShare/SparkleStatusIcon.cs @@ -53,7 +53,7 @@ namespace SparkleShare { public SparkleStatusIcon () : base () - { + { Animation = CreateAnimation (); @@ -161,15 +161,14 @@ 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); if (SparkleShare.Controller.Folders.Count > 0) { - + FolderMenuItems = new NSMenuItem [SparkleShare.Controller.Folders.Count]; Tasks = new EventHandler [SparkleShare.Controller.Folders.Count]; @@ -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); @@ -269,7 +277,7 @@ namespace SparkleShare { { return delegate { - + SparkleLog log = SparkleUI.OpenLogs.Find (delegate (SparkleLog l) { return l.LocalPath.Equals (path); }); @@ -281,13 +289,13 @@ namespace SparkleShare { InvokeOnMainThread (delegate { SparkleUI.OpenLogs.Add (new SparkleLog (path)); }); - + } else { InvokeOnMainThread (delegate { - log.OrderFrontRegardless (); + log.OrderFront (this); }); - + } }; @@ -382,9 +390,6 @@ namespace SparkleShare { { InvokeOnMainThread (delegate { - - foreach (SparkleLog log in SparkleUI.OpenLogs) - log.OrderFrontRegardless (); SparkleUI.NewEvents = 0; NSApplication.SharedApplication.DockTile.BadgeLabel = null; diff --git a/SparkleShare/Mac/SparkleShare/SparkleUI.cs b/SparkleShare/Mac/SparkleShare/SparkleUI.cs index 0a452b91..ea6cbc82 100644 --- a/SparkleShare/Mac/SparkleShare/SparkleUI.cs +++ b/SparkleShare/Mac/SparkleShare/SparkleUI.cs @@ -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 (); StatusIcon = new SparkleStatusIcon (); diff --git a/data/sparkleshare-folder.icns b/data/sparkleshare-folder.icns new file mode 100644 index 00000000..7a6d8d2c Binary files /dev/null and b/data/sparkleshare-folder.icns differ diff --git a/data/sparkleshare-mac-16.png b/data/sparkleshare-mac-16.png new file mode 100644 index 00000000..09e3b3c4 Binary files /dev/null and b/data/sparkleshare-mac-16.png differ diff --git a/data/sparkleshare-mac-512.png b/data/sparkleshare-mac-512.png new file mode 100644 index 00000000..dd20cf5d Binary files /dev/null and b/data/sparkleshare-mac-512.png differ