diff --git a/SparkleLib/SparkleListener.cs b/SparkleLib/SparkleListener.cs index 2c57850f..dab3731d 100644 --- a/SparkleLib/SparkleListener.cs +++ b/SparkleLib/SparkleListener.cs @@ -15,13 +15,14 @@ // along with this program. If not, see . -using Meebey.SmartIrc4net; using System; using System.Collections.Generic; using System.Text; using System.Threading; using System.Security.Cryptography; +using Meebey.SmartIrc4net; + namespace SparkleLib { // A persistent connection to the server that diff --git a/SparkleShare/SparkleIntro.cs b/SparkleShare/SparkleIntro.cs index b5dfcc90..89bc1b74 100644 --- a/SparkleShare/SparkleIntro.cs +++ b/SparkleShare/SparkleIntro.cs @@ -363,7 +363,7 @@ namespace SparkleShare { Deletable = true; Application.Invoke (delegate { - ShowSuccessPage (name); + ShowSuccessPage (name); // FIXME: doesn't always get called on big repos }); }; @@ -371,7 +371,6 @@ namespace SparkleShare { SparkleShare.Controller.FolderFetchError += delegate { Deletable = true; - Application.Invoke (delegate { ShowErrorPage (); }); }; @@ -637,7 +636,7 @@ namespace SparkleShare { AddButton (button); - SparkleSpinner spinner = new SparkleSpinner (22); +// SparkleSpinner spinner = new SparkleSpinner (22); Table table = new Table (3, 2, false) { RowSpacing = 12, @@ -646,7 +645,7 @@ namespace SparkleShare { HBox box = new HBox (false, 0); - table.Attach (spinner, 0, 1, 0, 1); +// table.Attach (spinner, 0, 1, 0, 1); table.Attach (header, 1, 2, 0, 1); table.Attach (information, 1, 2, 1, 2); diff --git a/SparkleShare/SparkleLog.cs b/SparkleShare/SparkleLog.cs index 28f3b7e4..889bb0ac 100644 --- a/SparkleShare/SparkleLog.cs +++ b/SparkleShare/SparkleLog.cs @@ -19,6 +19,7 @@ using System; using System.Collections.Generic; using System.Diagnostics; using System.Text.RegularExpressions; +using System.Threading; using Gtk; using Mono.Unix; @@ -36,6 +37,8 @@ namespace SparkleShare { private MenuBar MenuBar; private WebView WebView; private string LinkStatus; + private SparkleSpinner Spinner; + private string HTML; // Short alias for the translations @@ -69,12 +72,44 @@ namespace SparkleShare { Title = String.Format(_("Events in ‘{0}’"), name); IconName = "folder-sparkleshare"; - DeleteEvent += Close; - - LayoutVertical = new VBox (false, 0); + DeleteEvent += Close; CreateEventLog (); + } + + + private void CreateEventLog () { + + LayoutVertical = new VBox (false, 0); + + ScrolledWindow = new ScrolledWindow (); + + WebView = new WebView () { + Editable = false + }; + + WebView.HoveringOverLink += delegate (object o, WebKit.HoveringOverLinkArgs args) { + LinkStatus = args.Link; + }; + + WebView.NavigationRequested += delegate (object o, WebKit.NavigationRequestedArgs args) { + + if (args.Request.Uri == LinkStatus) { + + Process process = new Process (); + process.StartInfo.FileName = "xdg-open"; + process.StartInfo.Arguments = args.Request.Uri.Replace (" ", "\\ "); // Escape space-characters + process.Start (); + + } + + // FIXME: webview should stay on the same page + + }; + + ScrolledWindow.AddWithViewport (WebView); + LayoutVertical.PackStart (ScrolledWindow, true, true, 0); UpdateEventLog (); @@ -115,65 +150,76 @@ namespace SparkleShare { } - public void CreateEventLog () { + public void UpdateEventLog () + { - WebView = new WebView () { - Editable = false - }; + if (HTML == null) { - WebView.HoveringOverLink += delegate (object o, WebKit.HoveringOverLinkArgs args) { - LinkStatus = args.Link; - }; + LayoutVertical.Remove (ScrolledWindow); + Spinner = new SparkleSpinner (22); + LayoutVertical.PackStart (Spinner, true, true, 0); - WebView.NavigationRequested += delegate (object o, WebKit.NavigationRequestedArgs args) { + } - if (args.Request.Uri == LinkStatus) { + Thread thread = new Thread (new ThreadStart (delegate { - Process process = new Process (); - process.StartInfo.FileName = "xdg-open"; - process.StartInfo.Arguments = args.Request.Uri.Replace (" ", "\\ "); // Escape space-characters - process.Start (); + GenerateHTML (); + AddHTML (); - } + })); - // FIXME: webview should stay on the same page - - }; - - ScrolledWindow = new ScrolledWindow (); - ScrolledWindow.AddWithViewport (WebView); + thread.Start (); } - public void UpdateEventLog () - { + private void GenerateHTML () { - string html = SparkleShare.Controller.GetHTMLLog (System.IO.Path.GetFileName (LocalPath)); + HTML = SparkleShare.Controller.GetHTMLLog (System.IO.Path.GetFileName (LocalPath)); - html = html.Replace ("", (Style.FontDescription.Size / 1024 + 0.5) + "pt"); - html = html.Replace ("", "\"" + Style.FontDescription.Family + "\""); - html = html.Replace ("", SparkleUIHelpers.GdkColorToHex (Style.Foreground (StateType.Normal))); - html = html.Replace ("", SparkleUIHelpers.GdkColorToHex (new TreeView ().Style.Base (StateType.Normal))); - html = html.Replace ("", SparkleUIHelpers.GdkColorToHex (Style.Background (StateType.Normal))); - html = html.Replace ("", SparkleUIHelpers.GdkColorToHex (Style.Foreground (StateType.Insensitive))); - html = html.Replace ("", SparkleUIHelpers.GdkColorToHex (Style.Foreground (StateType.Insensitive))); - html = html.Replace ("", "file://" + + HTML = HTML.Replace ("", (Style.FontDescription.Size / 1024 + 0.5) + "pt"); + HTML = HTML.Replace ("", "\"" + Style.FontDescription.Family + "\""); + HTML = HTML.Replace ("", SparkleUIHelpers.GdkColorToHex (Style.Foreground (StateType.Normal))); + HTML = HTML.Replace ("", SparkleUIHelpers.GdkColorToHex (new TreeView ().Style.Base (StateType.Normal))); + HTML = HTML.Replace ("", SparkleUIHelpers.GdkColorToHex (Style.Background (StateType.Normal))); + HTML = HTML.Replace ("", SparkleUIHelpers.GdkColorToHex (Style.Foreground (StateType.Insensitive))); + HTML = HTML.Replace ("", SparkleUIHelpers.GdkColorToHex (Style.Foreground (StateType.Insensitive))); + HTML = HTML.Replace ("", "file://" + SparkleHelpers.CombineMore (Defines.PREFIX, "share", "sparkleshare", "icons", "hicolor", "32x32", "status", "avatar-default.png")); - WebView.LoadString (html, null, null, "file://"); + } - LayoutVertical.Remove (ScrolledWindow); - ScrolledWindow = new ScrolledWindow (); - Viewport viewport = new Viewport (); - WebView.Reparent (viewport); - ScrolledWindow.Add (viewport); - (ScrolledWindow.Child as Viewport).ShadowType = ShadowType.None; - LayoutVertical.PackStart (ScrolledWindow, true, true, 0); - LayoutVertical.ReorderChild (ScrolledWindow, 0); - LayoutVertical.ShowAll (); + private void AddHTML () + { + + Application.Invoke (delegate { + + WebView.LoadString (HTML, null, null, "file://"); + + if (Spinner.Active) { + + LayoutVertical.Remove (Spinner); + Spinner.Stop (); + + } else { + + LayoutVertical.Remove (ScrolledWindow); + + } + + ScrolledWindow = new ScrolledWindow (); + Viewport viewport = new Viewport (); + WebView.Reparent (viewport); + ScrolledWindow.Add (viewport); + (ScrolledWindow.Child as Viewport).ShadowType = ShadowType.None; + LayoutVertical.PackStart (ScrolledWindow, true, true, 0); + LayoutVertical.ReorderChild (ScrolledWindow, 0); + + LayoutVertical.ShowAll (); + + }); } diff --git a/SparkleShare/SparkleSpinner.cs b/SparkleShare/SparkleSpinner.cs index c031ff12..b1a1f427 100644 --- a/SparkleShare/SparkleSpinner.cs +++ b/SparkleShare/SparkleSpinner.cs @@ -85,7 +85,7 @@ namespace SparkleShare { else CurrentStep = 0; -// Application.Invoke (delegate { SetImage (); }); + Application.Invoke (delegate { SetImage (); }); }