diff options
author | Michael Hutchinson <m.j.hutchinson@gmail.com> | 2011-11-29 01:48:51 +0400 |
---|---|---|
committer | Michael Hutchinson <m.j.hutchinson@gmail.com> | 2011-11-29 02:20:49 +0400 |
commit | ada96964bb8ca0bde62be3820c7be1fc7cd3eb46 (patch) | |
tree | 946f114750118df3460f38c5cf0adf89a34b88bc | |
parent | 347a8855a6143e291b731982a4396bc70b330afb (diff) |
[Ide] Fix About dialog taking 3s to open
Also remove dead code.
-rw-r--r-- | main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Gui.Dialogs/VersionInformationTabPage.cs | 73 |
1 files changed, 40 insertions, 33 deletions
diff --git a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Gui.Dialogs/VersionInformationTabPage.cs b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Gui.Dialogs/VersionInformationTabPage.cs index 9b99613fe3..266cc0ef71 100644 --- a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Gui.Dialogs/VersionInformationTabPage.cs +++ b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Gui.Dialogs/VersionInformationTabPage.cs @@ -49,50 +49,50 @@ namespace MonoDevelop.Ide.Gui.Dialogs internal class VersionInformationTabPage: VBox { - static bool IsMono () + bool destroyed; + + public VersionInformationTabPage () { - return Type.GetType ("Mono.Runtime") != null; + SetLabel (GettextCatalog.GetString ("Loading...")); + + new System.Threading.Thread (() => { + try { + var text = SystemInformation.ToText (); + Gtk.Application.Invoke (delegate { + if (destroyed) + return; + SetText (text); + }); + } catch (Exception ex) { + Gtk.Application.Invoke (delegate { + if (destroyed) + return; + SetLabel (GettextCatalog.GetString ("Failed to load version information.")); + }); + } + }).Start (); } - static string GetMonoVersionNumber () + void Clear () { - var t = Type.GetType ("Mono.Runtime"); - if (t == null) - return "unknown"; - var mi = t.GetMethod ("GetDisplayName", BindingFlags.NonPublic | BindingFlags.Static); - if (mi == null) { - LoggingService.LogError ("No Mono.Runtime.GetDiplayName method found."); - return "error"; + foreach (var c in this.Children) { + this.Remove (c); } - return (string)mi.Invoke (null, null); } - static string GetGtkVersion () + void SetLabel (string text) { - uint v1 = 2, v2 = 0, v3 = 0; - - while (v1 < 99 && Gtk.Global.CheckVersion (v1, v2, v3) == null) - v1++; - v1--; - - while (v2 < 99 && Gtk.Global.CheckVersion (v1, v2, v3) == null) - v2++; - v2--; - - v3 = 0; - while (v3 < 99 && Gtk.Global.CheckVersion (v1, v2, v3) == null) - v3++; - v3--; - - if (v1 == 99 || v2 == 99 || v3 == 99) - return "unknown"; - return v1 +"." + v2 + "."+ v3; + Clear (); + var label = new Gtk.Label (text); + PackStart (label, true, true, 0); + ShowAll (); } - - public VersionInformationTabPage () + + void SetText (string text) { + Clear (); var buf = new TextBuffer (null); - buf.Text = SystemInformation.ToText (); + buf.Text = text; var sw = new ScrolledWindow () { BorderWidth = 6, @@ -108,6 +108,13 @@ namespace MonoDevelop.Ide.Gui.Dialogs sw.Child.ModifyFont (Pango.FontDescription.FromString (DesktopService.DefaultMonospaceFont)); PackStart (sw, true, true, 0); + ShowAll (); + } + + public override void Destroy () + { + base.Destroy (); + destroyed = true; } } } |