[osx] allow opening files from the event log

This commit is contained in:
Hylke Bons 2011-02-06 17:24:34 +00:00
parent f2c1a38cc3
commit a91c390af5
2 changed files with 34 additions and 10 deletions

View file

@ -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);
}
}
}

View file

@ -294,10 +294,13 @@ namespace SparkleShare {
event_entry += "<dt>Edited</dt>";
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 += "<dd><a href='#'>" + file_path + "</a></dd>";
event_entry += "<dd><a href='" + absolute_file_path + "'>" + file_path + "</a></dd>";
} else {
@ -315,11 +318,13 @@ namespace SparkleShare {
event_entry += "<dt>Added</dt>";
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 += "<dd><a href='#'>" + file_path + "</a></dd>";
event_entry += "<dd><a href='" + absolute_file_path + "'>" + file_path + "</a></dd>";
} else {
event_entry += "<dd>" + file_path + "</dd>";
@ -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 += "<dd><a href='#'>" + file_path + "</a></dd>";
string absolute_file_path = SparkleHelpers.CombineMore (SparklePaths.SparklePath,
name, file_path);
if (File.Exists (absolute_file_path)) {
event_entry += "<dd><a href='" + absolute_file_path + "'>" + file_path + "</a></dd>";
} else {
event_entry += "<dd>" + file_path + "</dd>";