New thread + spinner instead of freeze when opening big logs
This commit is contained in:
parent
3368d40ec8
commit
6c5bf06558
|
@ -15,13 +15,14 @@
|
|||
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
|
||||
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
|
||||
|
|
|
@ -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);
|
||||
|
||||
|
|
|
@ -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
|
||||
|
@ -71,9 +74,41 @@ namespace SparkleShare {
|
|||
|
||||
DeleteEvent += Close;
|
||||
|
||||
CreateEventLog ();
|
||||
|
||||
}
|
||||
|
||||
|
||||
private void CreateEventLog () {
|
||||
|
||||
LayoutVertical = new VBox (false, 0);
|
||||
|
||||
CreateEventLog ();
|
||||
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);
|
||||
|
||||
|
@ -115,56 +150,65 @@ namespace SparkleShare {
|
|||
}
|
||||
|
||||
|
||||
public void CreateEventLog () {
|
||||
|
||||
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 = new ScrolledWindow ();
|
||||
ScrolledWindow.AddWithViewport (WebView);
|
||||
|
||||
}
|
||||
|
||||
|
||||
public void UpdateEventLog ()
|
||||
{
|
||||
|
||||
string html = SparkleShare.Controller.GetHTMLLog (System.IO.Path.GetFileName (LocalPath));
|
||||
if (HTML == null) {
|
||||
|
||||
html = html.Replace ("<!-- $body-font-size -->", (Style.FontDescription.Size / 1024 + 0.5) + "pt");
|
||||
html = html.Replace ("<!-- $body-font-family -->", "\"" + Style.FontDescription.Family + "\"");
|
||||
html = html.Replace ("<!-- $body-color -->", SparkleUIHelpers.GdkColorToHex (Style.Foreground (StateType.Normal)));
|
||||
html = html.Replace ("<!-- $body-background-color -->", SparkleUIHelpers.GdkColorToHex (new TreeView ().Style.Base (StateType.Normal)));
|
||||
html = html.Replace ("<!-- $day-entry-header-background-color -->", SparkleUIHelpers.GdkColorToHex (Style.Background (StateType.Normal)));
|
||||
html = html.Replace ("<!-- $secondary-font-color -->", SparkleUIHelpers.GdkColorToHex (Style.Foreground (StateType.Insensitive)));
|
||||
html = html.Replace ("<!-- $small-color -->", SparkleUIHelpers.GdkColorToHex (Style.Foreground (StateType.Insensitive)));
|
||||
html = html.Replace ("<!-- $no-buddy-icon-background-image -->", "file://" +
|
||||
LayoutVertical.Remove (ScrolledWindow);
|
||||
Spinner = new SparkleSpinner (22);
|
||||
LayoutVertical.PackStart (Spinner, true, true, 0);
|
||||
|
||||
}
|
||||
|
||||
Thread thread = new Thread (new ThreadStart (delegate {
|
||||
|
||||
GenerateHTML ();
|
||||
AddHTML ();
|
||||
|
||||
}));
|
||||
|
||||
thread.Start ();
|
||||
|
||||
}
|
||||
|
||||
|
||||
private void GenerateHTML () {
|
||||
|
||||
HTML = SparkleShare.Controller.GetHTMLLog (System.IO.Path.GetFileName (LocalPath));
|
||||
|
||||
HTML = HTML.Replace ("<!-- $body-font-size -->", (Style.FontDescription.Size / 1024 + 0.5) + "pt");
|
||||
HTML = HTML.Replace ("<!-- $body-font-family -->", "\"" + Style.FontDescription.Family + "\"");
|
||||
HTML = HTML.Replace ("<!-- $body-color -->", SparkleUIHelpers.GdkColorToHex (Style.Foreground (StateType.Normal)));
|
||||
HTML = HTML.Replace ("<!-- $body-background-color -->", SparkleUIHelpers.GdkColorToHex (new TreeView ().Style.Base (StateType.Normal)));
|
||||
HTML = HTML.Replace ("<!-- $day-entry-header-background-color -->", SparkleUIHelpers.GdkColorToHex (Style.Background (StateType.Normal)));
|
||||
HTML = HTML.Replace ("<!-- $secondary-font-color -->", SparkleUIHelpers.GdkColorToHex (Style.Foreground (StateType.Insensitive)));
|
||||
HTML = HTML.Replace ("<!-- $small-color -->", SparkleUIHelpers.GdkColorToHex (Style.Foreground (StateType.Insensitive)));
|
||||
HTML = HTML.Replace ("<!-- $no-buddy-icon-background-image -->", "file://" +
|
||||
SparkleHelpers.CombineMore (Defines.PREFIX, "share", "sparkleshare", "icons",
|
||||
"hicolor", "32x32", "status", "avatar-default.png"));
|
||||
|
||||
WebView.LoadString (html, null, null, "file://");
|
||||
}
|
||||
|
||||
|
||||
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);
|
||||
|
@ -175,6 +219,8 @@ namespace SparkleShare {
|
|||
|
||||
LayoutVertical.ShowAll ();
|
||||
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -85,7 +85,7 @@ namespace SparkleShare {
|
|||
else
|
||||
CurrentStep = 0;
|
||||
|
||||
// Application.Invoke (delegate { SetImage (); });
|
||||
Application.Invoke (delegate { SetImage (); });
|
||||
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue