From a91c390af550785e30c3116267bb71994f545389 Mon Sep 17 00:00:00 2001 From: Hylke Bons Date: Sun, 6 Feb 2011 17:24:34 +0000 Subject: [PATCH] [osx] allow opening files from the event log --- SparkleShare/Mac/SparkleShare/SparkleLog.cs | 16 ++++++++++++ SparkleShare/SparkleController.cs | 28 +++++++++++++-------- 2 files changed, 34 insertions(+), 10 deletions(-) diff --git a/SparkleShare/Mac/SparkleShare/SparkleLog.cs b/SparkleShare/Mac/SparkleShare/SparkleLog.cs index dba344b5..a0ad2d99 100644 --- a/SparkleShare/Mac/SparkleShare/SparkleLog.cs +++ b/SparkleShare/Mac/SparkleShare/SparkleLog.cs @@ -115,6 +115,7 @@ namespace SparkleShare { WebView = new WebView (frame, "", ""); WebView.MainFrame.LoadHtmlString (html, new NSUrl ("")); + WebView.PolicyDelegate = new SparkleWebPolicyDelegate (); return WebView; @@ -135,5 +136,20 @@ namespace SparkleShare { } } + + + public class SparkleWebPolicyDelegate : WebPolicyDelegate { + + public override void DecidePolicyForNavigation (WebView web_view, NSDictionary action_info, + NSUrlRequest request, WebFrame frame, NSObject decision_token) { + + string file_path = request.Url.ToString (); + file_path = file_path.Replace ("%20", "\\ "); + + NSWorkspace.SharedWorkspace.OpenFile (file_path); + + } + + } } diff --git a/SparkleShare/SparkleController.cs b/SparkleShare/SparkleController.cs index 802554c7..cd66e41b 100644 --- a/SparkleShare/SparkleController.cs +++ b/SparkleShare/SparkleController.cs @@ -294,10 +294,13 @@ namespace SparkleShare { event_entry += "
Edited
"; foreach (string file_path in change_set.Edited) { + + string absolute_file_path = SparkleHelpers.CombineMore (SparklePaths.SparklePath, + name, file_path); + + if (File.Exists (absolute_file_path)) { - if (File.Exists (SparkleHelpers.CombineMore (SparklePaths.SparklePath, name, file_path))) { - - event_entry += "
" + file_path + "
"; + event_entry += "
" + file_path + "
"; } else { @@ -315,11 +318,13 @@ namespace SparkleShare { event_entry += "
Added
"; foreach (string file_path in change_set.Added) { + string absolute_file_path = SparkleHelpers.CombineMore (SparklePaths.SparklePath, + name, file_path); + + if (File.Exists (absolute_file_path)) { - if (File.Exists (SparkleHelpers.CombineMore (SparklePaths.SparklePath, name, file_path))) { - - event_entry += "
" + file_path + "
"; - + event_entry += "
" + file_path + "
"; + } else { event_entry += "
" + file_path + "
"; @@ -336,10 +341,13 @@ namespace SparkleShare { foreach (string file_path in change_set.Deleted) { - if (File.Exists (SparkleHelpers.CombineMore (SparklePaths.SparklePath, name, file_path))) { - - event_entry += "
" + file_path + "
"; + string absolute_file_path = SparkleHelpers.CombineMore (SparklePaths.SparklePath, + name, file_path); + + if (File.Exists (absolute_file_path)) { + event_entry += "
" + file_path + "
"; + } else { event_entry += "
" + file_path + "
";