From 6bc6b45a8ff6dc5858960cc3c802c041a694d23c Mon Sep 17 00:00:00 2001 From: Hylke Date: Fri, 24 Jun 2011 22:58:20 +0100 Subject: [PATCH] Integrate notes on linux --- SparkleShare/Mac/SparkleEventLog.cs | 2 +- SparkleShare/SparkleEventLog.cs | 28 +++++++++++++++++++++++++--- SparkleShare/SparkleLinController.cs | 7 ++++++- 3 files changed, 32 insertions(+), 5 deletions(-) diff --git a/SparkleShare/Mac/SparkleEventLog.cs b/SparkleShare/Mac/SparkleEventLog.cs index ce5b5fb1..9c8bd92a 100644 --- a/SparkleShare/Mac/SparkleEventLog.cs +++ b/SparkleShare/Mac/SparkleEventLog.cs @@ -113,7 +113,7 @@ namespace SparkleShare { if (this.selected_log != null && !SparkleShare.Controller.Folders.Contains (this.selected_log)) { - this.selected_log = null;// todo on linux + this.selected_log = null; } this.popup_button.Activated += delegate { diff --git a/SparkleShare/SparkleEventLog.cs b/SparkleShare/SparkleEventLog.cs index eb9695ba..4379e9a8 100644 --- a/SparkleShare/SparkleEventLog.cs +++ b/SparkleShare/SparkleEventLog.cs @@ -84,7 +84,6 @@ namespace SparkleShare { LinkStatus = args.Link; }; - // FIXME: Use the right event, waiting for newer webkit bindings: NavigationPolicyDecisionRequested WebView.NavigationRequested += delegate (object o, WebKit.NavigationRequestedArgs args) { if (args.Request.Uri == LinkStatus) { Process process = new Process (); @@ -92,9 +91,26 @@ namespace SparkleShare { process.StartInfo.Arguments = args.Request.Uri.Replace (" ", "\\ "); // Escape space-characters process.Start (); - // Don't follow HREFs (as this would cause a page refresh) - args.RetVal = 1; + } else { + Regex regex = new Regex (@"(.+)~(.+)~(.+)"); + Match match = regex.Match (args.Request.Uri); + + if (match.Success) { + string folder_name = match.Groups [1].Value; + string revision = match.Groups [2].Value; + string note = match.Groups [3].Value.Replace ("%20", " "); + + Thread thread = new Thread (new ThreadStart (delegate { + SparkleShare.Controller.AddNoteToFolder (folder_name, revision, note); + })); + + thread.Start (); + } } + + // Don't follow HREFs (as this would cause a page refresh) + if (!args.Request.Uri.Equals ("file:")) + args.RetVal = 1; }; ScrolledWindow.Add (WebView); @@ -142,6 +158,12 @@ namespace SparkleShare { return (item == "---"); }; + if (this.selected_log != null && + !SparkleShare.Controller.Folders.Contains (this.selected_log)) { + + this.selected_log = null; + } + this.combo_box.Changed += delegate { TreeIter iter; this.combo_box.GetActiveIter (out iter); diff --git a/SparkleShare/SparkleLinController.cs b/SparkleShare/SparkleLinController.cs index 7ffb0fc4..34e27385 100644 --- a/SparkleShare/SparkleLinController.cs +++ b/SparkleShare/SparkleLinController.cs @@ -166,8 +166,13 @@ namespace SparkleShare { get { string path = SparkleHelpers.CombineMore (Defines.PREFIX, "share", "sparkleshare", "html", "event-log.html"); + + string html = String.Join (Environment.NewLine, File.ReadAllLines (path)); + + html = html.Replace ("", "file://" + + SparkleHelpers.CombineMore (Defines.PREFIX, "share", "sparkleshare", "html", "jquery.js")); - return String.Join (Environment.NewLine, File.ReadAllLines (path)); + return html; } }