From bcf4e32f064d4f9f4b9041d25224910bbcd19275 Mon Sep 17 00:00:00 2001 From: Hylke Bons Date: Wed, 26 Sep 2012 16:07:59 +0200 Subject: [PATCH] eventlog: Fix some update logic --- News.txt | 4 ++-- SparkleShare/Mac/SparkleEventLog.cs | 16 ++++++-------- SparkleShare/SparkleEventLogController.cs | 24 ++++++++++++++++----- SparkleShare/SparkleStatusIconController.cs | 3 ++- 4 files changed, 29 insertions(+), 18 deletions(-) diff --git a/News.txt b/News.txt index 21d40a1b..fd50cf45 100755 --- a/News.txt +++ b/News.txt @@ -5,11 +5,11 @@ - Fix freeze when adding lots of files - Fix using hosts with a non-standard SSH port - Fix receiving of notification service message after the first one - - Use port 443 on the notification service to work better in - restricted networks - New non-animating status icons - More descriptive error reporting in the status icon - Add link to debug log in the about dialog + - Use port 443 on the notification service to work better in + restricted networks 0.9.2 for Linux, Mac and Windows (Wed Aug 29 2012) diff --git a/SparkleShare/Mac/SparkleEventLog.cs b/SparkleShare/Mac/SparkleEventLog.cs index fa79c3b5..34cd8b8e 100755 --- a/SparkleShare/Mac/SparkleEventLog.cs +++ b/SparkleShare/Mac/SparkleEventLog.cs @@ -66,10 +66,8 @@ namespace SparkleShare { new SizeF (min_width, (int) (NSScreen.MainScreen.Frame.Height * 0.85))), true); - StyleMask = (NSWindowStyle.Closable | - NSWindowStyle.Miniaturizable | - NSWindowStyle.Titled | - NSWindowStyle.Resizable); + StyleMask = (NSWindowStyle.Closable | NSWindowStyle.Miniaturizable | + NSWindowStyle.Titled | NSWindowStyle.Resizable); MinSize = new SizeF (min_width, min_height); HasShadow = true; @@ -185,7 +183,6 @@ namespace SparkleShare { using (var a = new NSAutoreleasePool ()) { InvokeOnMainThread (delegate { - this.web_view.Hidden = true; this.progress_indicator.Hidden = true; PerformClose (this); }); @@ -214,6 +211,7 @@ namespace SparkleShare { using (var a = new NSAutoreleasePool ()) { InvokeOnMainThread (delegate { + this.progress_indicator.Hidden = true; UpdateContent (html); }); } @@ -223,7 +221,7 @@ namespace SparkleShare { using (var a = new NSAutoreleasePool ()) { InvokeOnMainThread (delegate { - this.web_view.Hidden = true; + this.web_view.RemoveFromSuperview (); this.progress_indicator.Hidden = false; this.progress_indicator.StartAnimation (this); @@ -341,8 +339,7 @@ namespace SparkleShare { if (html == null) html = Controller.HTML; - string pixmaps_path = "file://" + Path.Combine ( - NSBundle.MainBundle.ResourcePath, "Pixmaps"); + string pixmaps_path = "file://" + Path.Combine (NSBundle.MainBundle.ResourcePath, "Pixmaps"); html = html.Replace ("", "Lucida Grande"); html = html.Replace ("", "13.6px"); @@ -376,7 +373,7 @@ namespace SparkleShare { this.web_view.MainFrame.LoadHtmlString (html, new NSUrl ("")); web_view.PolicyDelegate = new SparkleWebPolicyDelegate (); - ContentView.AddSubview (this.web_view); + ContentView.AddSubview (this.web_view); (this.web_view.PolicyDelegate as SparkleWebPolicyDelegate).LinkClicked += delegate (string href) { @@ -387,7 +384,6 @@ namespace SparkleShare { }; this.progress_indicator.Hidden = true; - this.web_view.Hidden = false; }); } } diff --git a/SparkleShare/SparkleEventLogController.cs b/SparkleShare/SparkleEventLogController.cs index 6083cd58..54c2d2bd 100755 --- a/SparkleShare/SparkleEventLogController.cs +++ b/SparkleShare/SparkleEventLogController.cs @@ -66,7 +66,7 @@ namespace SparkleShare { // A short delay is less annoying than // a flashing window - int delay = 1000; + int delay = 500; if (watch.ElapsedMilliseconds < delay) Thread.Sleep (delay - (int) watch.ElapsedMilliseconds); @@ -81,9 +81,7 @@ namespace SparkleShare { public string HTML { get { List change_sets = GetLog (this.selected_folder); - string html = GetHTMLLog (change_sets); - UpdateSizeInfoEvent (Size, HistorySize); return html; } @@ -147,6 +145,7 @@ namespace SparkleShare { Program.Controller.ShowEventLogWindowEvent += delegate { if (!WindowIsOpen) { ContentLoadingEvent (); + UpdateSizeInfoEvent ("…", "…"); if (this.selected_folder == null) { new Thread (() => { @@ -156,13 +155,14 @@ namespace SparkleShare { string html = HTML; watch.Stop (); - int delay = 1000; + int delay = 500; if (watch.ElapsedMilliseconds < delay) Thread.Sleep (delay - (int) watch.ElapsedMilliseconds); UpdateChooserEvent (Folders); UpdateContentEvent (html); + UpdateSizeInfoEvent (Size, HistorySize); }).Start (); } @@ -173,7 +173,21 @@ namespace SparkleShare { }; Program.Controller.OnIdle += delegate { - UpdateContentEvent (HTML); + ContentLoadingEvent (); + UpdateSizeInfoEvent ("…", "…"); + + Stopwatch watch = new Stopwatch (); + + watch.Start (); + string html = HTML; + watch.Stop (); + + int delay = 500; + + if (watch.ElapsedMilliseconds < delay) + Thread.Sleep (delay - (int) watch.ElapsedMilliseconds); + + UpdateContentEvent (html); UpdateSizeInfoEvent (Size, HistorySize); }; diff --git a/SparkleShare/SparkleStatusIconController.cs b/SparkleShare/SparkleStatusIconController.cs index db44d4c7..b217e70a 100755 --- a/SparkleShare/SparkleStatusIconController.cs +++ b/SparkleShare/SparkleStatusIconController.cs @@ -166,7 +166,8 @@ namespace SparkleShare { StateText = "Receiving changes…"; } - StateText += " " + ProgressPercentage + "% " + ProgressSpeed; + if (ProgressPercentage > 0) + StateText += " " + ProgressPercentage + "% " + ProgressSpeed; UpdateIconEvent (CurrentState); UpdateStatusItemEvent (StateText);