eventlog: removing some now redundant threading logic

This commit is contained in:
Hylke Bons 2012-10-22 14:01:47 +01:00
parent 1530c9a9af
commit c7eefd9d4e
3 changed files with 87 additions and 134 deletions

View file

@ -262,52 +262,35 @@ namespace SparkleShare {
public void UpdateContent (string html)
{
Thread thread = new Thread (() => {
string pixmaps_path = IO.Path.Combine (SparkleUI.AssetsPath, "pixmaps");
string icons_path = new string [] {SparkleUI.AssetsPath, "icons",
"hicolor", "12x12", "status"}.Combine ();
string pixmaps_path = IO.Path.Combine (SparkleUI.AssetsPath, "pixmaps");
string icons_path = new string [] {SparkleUI.AssetsPath, "icons", "hicolor", "12x12", "status"}.Combine ();
html = html.Replace ("<!-- $body-font-size -->", (double) (Style.FontDescription.Size / 1024 + 3) + "px");
html = html.Replace ("<!-- $day-entry-header-font-size -->", (Style.FontDescription.Size / 1024 + 3) + "px");
html = html.Replace ("<!-- $a-color -->", "#0085cf");
html = html.Replace ("<!-- $a-hover-color -->", "#009ff8");
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 ("<!-- $small-font-size -->", "85%");
html = html.Replace ("<!-- $pixmaps-path -->", pixmaps_path);
html = html.Replace ("<!-- $document-added-background-image -->",
"file://" + IO.Path.Combine (icons_path, "document-added.png"));
html = html.Replace ("<!-- $body-font-size -->", (double) (Style.FontDescription.Size / 1024 + 3) + "px");
html = html.Replace ("<!-- $day-entry-header-font-size -->", (Style.FontDescription.Size / 1024 + 3) + "px");
html = html.Replace ("<!-- $a-color -->", "#0085cf");
html = html.Replace ("<!-- $a-hover-color -->", "#009ff8");
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 ("<!-- $small-font-size -->", "85%");
html = html.Replace ("<!-- $pixmaps-path -->", pixmaps_path);
html = html.Replace ("<!-- $document-added-background-image -->", "file://" + IO.Path.Combine (icons_path, "document-added.png"));
html = html.Replace ("<!-- $document-edited-background-image -->", "file://" + IO.Path.Combine (icons_path, "document-edited.png"));
html = html.Replace ("<!-- $document-deleted-background-image -->", "file://" + IO.Path.Combine (icons_path, "document-deleted.png"));
html = html.Replace ("<!-- $document-moved-background-image -->", "file://" + IO.Path.Combine (icons_path, "document-moved.png"));
this.spinner.Stop ();
html = html.Replace ("<!-- $document-edited-background-image -->",
"file://" + IO.Path.Combine (icons_path, "document-edited.png"));
html = html.Replace ("<!-- $document-deleted-background-image -->",
"file://" + IO.Path.Combine (icons_path, "document-deleted.png"));
html = html.Replace ("<!-- $document-moved-background-image -->",
"file://" + IO.Path.Combine (icons_path, "document-moved.png"));
Application.Invoke (delegate {
this.spinner.Stop ();
this.web_view.NavigationRequested -= WebViewNavigationRequested;
this.web_view.LoadHtmlString (html, "file://");
this.web_view.NavigationRequested += WebViewNavigationRequested;
this.web_view.NavigationRequested -= WebViewNavigationRequested;
this.web_view.LoadHtmlString (html, "file://");
this.web_view.NavigationRequested += WebViewNavigationRequested;
this.content_wrapper.Remove (this.content_wrapper.Child);
this.content_wrapper.Add (this.scrolled_window);
this.content_wrapper.ShowAll ();
});
});
thread.Start ();
this.content_wrapper.Remove (this.content_wrapper.Child);
this.content_wrapper.Add (this.scrolled_window);
this.content_wrapper.ShowAll ();
}
}
}

View file

@ -368,59 +368,45 @@ namespace SparkleShare {
public void UpdateContent (string html)
{
new Thread (() => {
using (var a = new NSAutoreleasePool ())
{
string pixmaps_path = "file://" + Path.Combine (NSBundle.MainBundle.ResourcePath, "Pixmaps");
html = html.Replace ("<!-- $body-font-family -->", "Lucida Grande");
html = html.Replace ("<!-- $day-entry-header-font-size -->", "13.6px");
html = html.Replace ("<!-- $body-font-size -->", "13.4px");
html = html.Replace ("<!-- $secondary-font-color -->", "#bbb");
html = html.Replace ("<!-- $small-color -->", "#ddd");
html = html.Replace ("<!-- $small-font-size -->", "10px");
html = html.Replace ("<!-- $day-entry-header-background-color -->", "#f5f5f5");
html = html.Replace ("<!-- $a-color -->", "#0085cf");
html = html.Replace ("<!-- $a-hover-color -->", "#009ff8");
html = html.Replace ("<!-- $pixmaps-path -->", pixmaps_path);
html = html.Replace ("<!-- $document-added-background-image -->",
pixmaps_path + "/document-added-12.png");
html = html.Replace ("<!-- $document-deleted-background-image -->",
pixmaps_path + "/document-deleted-12.png");
html = html.Replace ("<!-- $document-edited-background-image -->",
pixmaps_path + "/document-edited-12.png");
using (var a = new NSAutoreleasePool ())
{
string pixmaps_path = "file://" + Path.Combine (NSBundle.MainBundle.ResourcePath, "Pixmaps");
html = html.Replace ("<!-- $body-font-family -->", "Lucida Grande");
html = html.Replace ("<!-- $day-entry-header-font-size -->", "13.6px");
html = html.Replace ("<!-- $body-font-size -->", "13.4px");
html = html.Replace ("<!-- $secondary-font-color -->", "#bbb");
html = html.Replace ("<!-- $small-color -->", "#ddd");
html = html.Replace ("<!-- $small-font-size -->", "10px");
html = html.Replace ("<!-- $day-entry-header-background-color -->", "#f5f5f5");
html = html.Replace ("<!-- $a-color -->", "#0085cf");
html = html.Replace ("<!-- $a-hover-color -->", "#009ff8");
html = html.Replace ("<!-- $pixmaps-path -->", pixmaps_path);
html = html.Replace ("<!-- $document-added-background-image -->", pixmaps_path + "/document-added-12.png");
html = html.Replace ("<!-- $document-deleted-background-image -->", pixmaps_path + "/document-deleted-12.png");
html = html.Replace ("<!-- $document-edited-background-image -->", pixmaps_path + "/document-edited-12.png");
html = html.Replace ("<!-- $document-moved-background-image -->", pixmaps_path + "/document-moved-12.png");
this.web_view = new WebView (new RectangleF (0, 0, 481, 579), "", "") {
Frame = new RectangleF (new PointF (0, 0),
new SizeF (ContentView.Frame.Width, ContentView.Frame.Height - 39))
};
html = html.Replace ("<!-- $document-moved-background-image -->",
pixmaps_path + "/document-moved-12.png");
InvokeOnMainThread (delegate {
this.web_view = new WebView (new RectangleF (0, 0, 481, 579), "", "") {
Frame = new RectangleF (new PointF (0, 0),
new SizeF (ContentView.Frame.Width, ContentView.Frame.Height - 39))
};
this.web_view.MainFrame.LoadHtmlString (html, new NSUrl (""));
this.web_view.MainFrame.LoadHtmlString (html, new NSUrl (""));
this.web_view.PolicyDelegate = new SparkleWebPolicyDelegate ();
ContentView.AddSubview (this.web_view);
this.web_view.PolicyDelegate = new SparkleWebPolicyDelegate ();
ContentView.AddSubview (this.web_view);
(this.web_view.PolicyDelegate as SparkleWebPolicyDelegate).LinkClicked +=
delegate (string href) {
if (href.StartsWith ("file:///"))
href = href.Substring (7);
(this.web_view.PolicyDelegate as SparkleWebPolicyDelegate).LinkClicked +=
delegate (string href) {
if (href.StartsWith ("file:///"))
href = href.Substring (7);
Controller.LinkClicked (href);
};
Controller.LinkClicked (href);
};
this.progress_indicator.Hidden = true;
});
}
}).Start ();
this.progress_indicator.Hidden = true;
}
}

View file

@ -273,51 +273,35 @@ namespace SparkleShare {
public void UpdateContent (string html)
{
new Thread (() => {
string pixmaps_path = Path.Combine (
SparkleLib.SparkleConfig.DefaultConfig.TmpPath, "Pixmaps");
pixmaps_path = pixmaps_path.Replace ("\\", "/");
html = html.Replace ("<a href=", "<a class='windows' href=");
html = html.Replace ("<!-- $body-font-family -->", "'Segoe UI', sans-serif");
html = html.Replace ("<!-- $day-entry-header-font-size -->", "13px");
html = html.Replace ("<!-- $body-font-size -->", "12px");
html = html.Replace ("<!-- $secondary-font-color -->", "#bbb");
html = html.Replace ("<!-- $small-color -->", "#ddd");
html = html.Replace ("<!-- $small-font-size -->", "90%");
html = html.Replace ("<!-- $day-entry-header-background-color -->", "#f5f5f5");
html = html.Replace ("<!-- $a-color -->", "#0085cf");
html = html.Replace ("<!-- $a-hover-color -->", "#009ff8");
string pixmaps_path = Path.Combine (SparkleLib.SparkleConfig.DefaultConfig.TmpPath, "Pixmaps");
pixmaps_path = pixmaps_path.Replace ("\\", "/");
html = html.Replace ("<!-- $pixmaps-path -->", pixmaps_path);
html = html.Replace ("<!-- $document-added-background-image -->",
pixmaps_path + "/document-added-12.png");
html = html.Replace ("<!-- $document-edited-background-image -->",
pixmaps_path + "/document-edited-12.png");
html = html.Replace ("<!-- $document-deleted-background-image -->",
pixmaps_path + "/document-deleted-12.png");
html = html.Replace ("<!-- $document-moved-background-image -->",
pixmaps_path + "/document-moved-12.png");
html = html.Replace ("<a href=", "<a class='windows' href=");
html = html.Replace ("<!-- $body-font-family -->", "'Segoe UI', sans-serif");
html = html.Replace ("<!-- $day-entry-header-font-size -->", "13px");
html = html.Replace ("<!-- $body-font-size -->", "12px");
html = html.Replace ("<!-- $secondary-font-color -->", "#bbb");
html = html.Replace ("<!-- $small-color -->", "#ddd");
html = html.Replace ("<!-- $small-font-size -->", "90%");
html = html.Replace ("<!-- $day-entry-header-background-color -->", "#f5f5f5");
html = html.Replace ("<!-- $a-color -->", "#0085cf");
html = html.Replace ("<!-- $a-hover-color -->", "#009ff8");
html = html.Replace ("<!-- $pixmaps-path -->", pixmaps_path);
html = html.Replace ("<!-- $document-added-background-image -->", pixmaps_path + "/document-added-12.png");
html = html.Replace ("<!-- $document-edited-background-image -->", pixmaps_path + "/document-edited-12.png");
html = html.Replace ("<!-- $document-deleted-background-image -->", pixmaps_path + "/document-deleted-12.png");
html = html.Replace ("<!-- $document-moved-background-image -->", pixmaps_path + "/document-moved-12.png");
Dispatcher.BeginInvoke ((Action) delegate {
this.spinner.Stop ();
this.web_browser.ObjectForScripting = new SparkleScriptingObject ();
this.web_browser.NavigateToString (html);
if (!this.canvas.Children.Contains (this.web_browser)) {
this.canvas.Children.Add (this.web_browser);
Canvas.SetLeft (this.web_browser, 0);
Canvas.SetTop (this.web_browser, 36);
}
});
}).Start ();
this.spinner.Stop ();
this.web_browser.ObjectForScripting = new SparkleScriptingObject ();
this.web_browser.NavigateToString (html);
if (!this.canvas.Children.Contains (this.web_browser)) {
this.canvas.Children.Add (this.web_browser);
Canvas.SetLeft (this.web_browser, 0);
Canvas.SetTop (this.web_browser, 36);
}
}