diff --git a/SparkleShare/Mac/SparkleEventLog.cs b/SparkleShare/Mac/SparkleEventLog.cs index b65801b6..b8d59df5 100755 --- a/SparkleShare/Mac/SparkleEventLog.cs +++ b/SparkleShare/Mac/SparkleEventLog.cs @@ -198,7 +198,7 @@ namespace SparkleShare { }); } }; - + Controller.UpdateChooserEvent += delegate (string [] folders) { using (var a = new NSAutoreleasePool ()) { @@ -208,6 +208,15 @@ namespace SparkleShare { } }; + Controller.UpdateChooserEnablementEvent += delegate (bool enabled) { + using (var a = new NSAutoreleasePool ()) + { + InvokeOnMainThread (delegate { + this.popup_button.Enabled = enabled; + }); + } + }; + Controller.UpdateContentEvent += delegate (string html) { using (var a = new NSAutoreleasePool ()) { diff --git a/SparkleShare/SparkleEventLogController.cs b/SparkleShare/SparkleEventLogController.cs index ffba7da5..68426464 100755 --- a/SparkleShare/SparkleEventLogController.cs +++ b/SparkleShare/SparkleEventLogController.cs @@ -34,10 +34,13 @@ namespace SparkleShare { public event UpdateContentEventEventHandler UpdateContentEvent = delegate { }; public delegate void UpdateContentEventEventHandler (string html); - + public event UpdateChooserEventHandler UpdateChooserEvent = delegate { }; public delegate void UpdateChooserEventHandler (string [] folders); + public event UpdateChooserEnablementEventHandler UpdateChooserEnablementEvent = delegate { }; + public delegate void UpdateChooserEnablementEventHandler (bool enabled); + public event UpdateSizeInfoEventHandler UpdateSizeInfoEvent = delegate { }; public delegate void UpdateSizeInfoEventHandler (string size, string history_size); @@ -258,81 +261,44 @@ namespace SparkleShare { } else if (url.StartsWith ("back://")) { this.history_view_active = false; SelectedFolder = this.selected_folder; // TODO: Return to the same position on the page - + + UpdateChooserEnablementEvent (true); + } else if (url.StartsWith ("history://")) { this.history_view_active = true; ContentLoadingEvent (); UpdateSizeInfoEvent ("…", "…"); + UpdateChooserEnablementEvent (false); - string html = ""; - string folder = url.Replace ("history://", "").Split ("/".ToCharArray ()) [0]; - string path = url.Replace ("history://" + folder + "/", ""); + string folder = url.Replace ("history://", "").Split ("/".ToCharArray ()) [0]; + string file_path = url.Replace ("history://" + folder + "/", ""); - // TODO: put html into page - - foreach (SparkleRepoBase repo in Program.Controller.Repositories) { - if (repo.Name.Equals (folder)) { - - new Thread (() => { - Stopwatch watch = new Stopwatch (); - - watch.Start (); - - List change_sets = repo.GetChangeSets (path, 30); - - html += "
« Back  |  "; - - if (change_sets.Count > 1) - html += "Revisions for “"; - else - html += "No revisions for “"; - - html += Path.GetFileName (path) + "”"; - html += "
"; - - int count = 0; - foreach (SparkleChangeSet change_set in change_sets) { - count++; - if (count == 1) - continue; - - string change_set_avatar = Program.Controller.GetAvatar (change_set.User.Email, 24); - - if (change_set_avatar != null) - change_set_avatar = "file://" + change_set_avatar.Replace ("\\", "/"); - else - change_set_avatar = "file:///user-icon-default.png"; - - html += "" + - "" + - "" + - "" + - "" + - "" + - ""; - - count++; - } - - html += "
" + change_set.User.Name + "" + change_set.Timestamp.ToString ("d MMM yyyy") + "" + change_set.Timestamp.ToString ("HH:mm") + "" + - "Restore…
"; - watch.Stop (); - - int delay = 500; - - if (watch.ElapsedMilliseconds < delay) - Thread.Sleep (delay - (int) watch.ElapsedMilliseconds); - - UpdateContentEvent (Program.Controller.EventLogHTML.Replace ("", html)); - }).Start (); + SparkleRepoBase repo; + foreach (SparkleRepoBase test_repo in Program.Controller.Repositories) { + if (test_repo.Name.Equals (folder)) { + repo = test_repo; break; } } + + new Thread (() => { + Stopwatch watch = new Stopwatch (); + watch.Start (); + + List change_sets = repo.GetChangeSets (file_path, 30); + string html = GetHistoryHTMLLog (change_sets, file_path); + + watch.Stop (); + int delay = 500; + + if (watch.ElapsedMilliseconds < delay) + Thread.Sleep (delay - (int) watch.ElapsedMilliseconds); + + UpdateContentEvent (html); + + }).Start (); } } @@ -396,6 +362,54 @@ namespace SparkleShare { } + public string GetHistoryHTMLLog (List change_sets, string file_path) + { + string html = "
« Back  |  "; + + if (change_sets.Count > 1) + html += "Revisions for “"; + else + html += "No revisions for “"; + + html += Path.GetFileName (file_path) + "”"; + html += "
"; + + int count = 0; + foreach (SparkleChangeSet change_set in change_sets) { + count++; + + if (count == 1) + continue; + + string change_set_avatar = Program.Controller.GetAvatar (change_set.User.Email, 24); + + if (change_set_avatar != null) + change_set_avatar = "file://" + change_set_avatar.Replace ("\\", "/"); + else + change_set_avatar = "file:///user-icon-default.png"; + + html += "" + + "" + + "" + + "" + + "" + + "" + + ""; + + count++; + } + + html += "
" + change_set.User.Name + "" + change_set.Timestamp.ToString ("d MMM yyyy") + "" + change_set.Timestamp.ToString ("HH:mm") + "" + + "Restore…" + + "
"; + + return Program.Controller.EventLogHTML.Replace ("", html); + } + + public string GetHTMLLog (List change_sets) { if (change_sets.Count == 0)