diff options
author | Mike Krüger <mkrueger@xamarin.com> | 2011-09-08 15:21:27 +0400 |
---|---|---|
committer | Mike Krüger <mkrueger@xamarin.com> | 2011-09-08 15:21:27 +0400 |
commit | 71b22e9e5dee9ebe60c0feecdc2287bc514e8fca (patch) | |
tree | f7e8b6f13e4b5cbe413cef86ad4ff38e1af6b633 /main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Gui.Dialogs | |
parent | cacbb705b6a0c7ee79ffecdfc9a156e56c787e46 (diff) |
Reworked the about box dialog.
Diffstat (limited to 'main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Gui.Dialogs')
3 files changed, 505 insertions, 361 deletions
diff --git a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Gui.Dialogs/AboutMonoDevelopTabPage.cs b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Gui.Dialogs/AboutMonoDevelopTabPage.cs index 24d499dd6d..cb5dfba505 100644 --- a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Gui.Dialogs/AboutMonoDevelopTabPage.cs +++ b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Gui.Dialogs/AboutMonoDevelopTabPage.cs @@ -2,8 +2,10 @@ // // Author: // Viktoria Dudka (viktoriad@remobjects.com) +// Mike Krüger <mkrueger@xamarin.com> // // Copyright (c) 2009 RemObjects Software +// Copyright (c) 2011 Xamarin Inc. (http://xamarin.com) // // Permission is hereby granted, free of charge, to any person obtaining a copy // of this software and associated documentation files (the "Software"), to deal @@ -24,43 +26,300 @@ // THE SOFTWARE. // // - using System; -using Gtk; +using System.IO; +using System.Text; + using MonoDevelop.Core; +using MonoDevelop.Ide.Gui; + +using Gdk; +using Gtk; +using GLib; +using Pango; namespace MonoDevelop.Ide.Gui.Dialogs { - internal class AboutMonoDevelopTabPage: VBox + class AboutMonoDevelopTabPage: VBox { - public AboutMonoDevelopTabPage () - { - Label label = new Label(); - label.Markup = String.Format ( - "<b>{0}</b>\n {1}", - GettextCatalog.GetString ("Version"), - BuildVariables.PackageVersion == BuildVariables.PackageVersionLabel ? BuildVariables.PackageVersionLabel : String.Format ("{0} ({1})", - BuildVariables.PackageVersionLabel, - BuildVariables.PackageVersion)); - HBox hBoxVersion = new HBox (); - hBoxVersion.PackStart (label, false, false, 5); - this.PackStart (hBoxVersion, false, true, 0); + ScrollBox aboutPictureScrollBox; + Pixbuf imageSep; - label = null; - label = new Label (); - label.Markup = GettextCatalog.GetString ("<b>License</b>\n {0}", GettextCatalog.GetString ("Released under the GNU Lesser General Public License.")); - HBox hBoxLicense = new HBox (); - hBoxLicense.PackStart (label, false, false, 5); - this.PackStart (hBoxLicense, false, true, 5); + public AboutMonoDevelopTabPage () + { + BorderWidth = 0; - label = null; - label = new Label (); - label.Markup = GettextCatalog.GetString ("<b>Copyright</b>\n (c) 2004-{0} by MonoDevelop contributors", DateTime.Now.Year); - HBox hBoxCopyright = new HBox (); - hBoxCopyright.PackStart (label, false, false, 5); - this.PackStart (hBoxCopyright, false, true, 5); + aboutPictureScrollBox = new ScrollBox (); - this.ShowAll (); - } + PackStart (aboutPictureScrollBox, false, false, 0); + imageSep = new Pixbuf (typeof(CommonAboutDialog).Assembly, "AboutImageSep.png"); + PackStart (new Gtk.Image (imageSep), false, false, 0); + + var label = new Label (); + label.Markup = string.Format ( + "<b>{0}</b>\n {1}", + GettextCatalog.GetString ("Version"), + BuildVariables.PackageVersion == BuildVariables.PackageVersionLabel ? BuildVariables.PackageVersionLabel : String.Format ("{0} ({1})", + BuildVariables.PackageVersionLabel, + BuildVariables.PackageVersion)); + + var hBoxVersion = new HBox (); + hBoxVersion.PackStart (label, false, false, 5); + this.PackStart (hBoxVersion, false, true, 0); + + label = null; + label = new Label (); + label.Markup = GettextCatalog.GetString ("<b>License</b>\n {0}", GettextCatalog.GetString ("Released under the GNU Lesser General Public License.")); + var hBoxLicense = new HBox (); + hBoxLicense.PackStart (label, false, false, 5); + this.PackStart (hBoxLicense, false, true, 5); + + label = null; + label = new Label (); + label.Markup = GettextCatalog.GetString ("<b>Copyright</b>\n (c) 2004-{0} by MonoDevelop contributors", DateTime.Now.Year); + var hBoxCopyright = new HBox (); + hBoxCopyright.PackStart (label, false, false, 5); + this.PackStart (hBoxCopyright, false, true, 5); + + this.ShowAll (); + } + + internal class ScrollBox : DrawingArea + { + Pixbuf image; + Pixbuf monoPowered; + int scroll; + Pango.Layout layout; + int monoLogoSpacing = 80; + int textTop; + int scrollPause; + int scrollStart; + Gdk.GC backGc; + internal uint TimerHandle; + string[] authors = new string[] { + "Lluis Sanchez Gual", + "Michael Hutchinson", + "Mike Krüger", + "Mike Kestner", + "Ankit Jain", + "Jonathan Pobst", + "Christian Hergert", + "Levi Bard", + "Carlo Kok", + "Viktoria Dudka", + "Marc Christensen", + "Andrew Jorgensen", + "Jérémie Laval", + "Luciano N. Callero", + "Zach Lute", + "Andrea Krüger", + "Jakub Steiner" + }; + string[] oldAuthors = new string[] { + "Aaron Bockover", + "Alberto Paro", + "Alejandro Serrano", + "Alexandre Gomes", + "Alex Graveley", + "Alfonso Santos Luaces", + "Andre Filipe de Assuncao e Brito", + "Andrea Krüger", + "Andrés G. Aragoneses", + "Andrew Jorgensen", + "Ankit Jain", + "Antonio Ognio", + "Ben Maurer", + "Ben Motmans", + "Carlo Kok", + "Christian Hergert", + "Daniel Kornhauser", + "Daniel Morgan", + "David Makovský", + "Eric Butler", + "Erik Dasque", + "Geoff Norton", + "Gustavo Giráldez", + "Iain McCoy", + "Inigo Illan", + "Jacob Ilsø Christensen", + "Jakub Steiner", + "James Fitzsimons", + "Jeff Stedfast", + "Jérémie Laval", + "Jeroen Zwartepoorte", + "John BouAnton", + "John Luke", + "Joshua Tauberer", + "Jonathan Hernández Velasco", + "Jonathan Pobst", + "Levi Bard", + "Lluis Sanchez Gual", + "Luciano N. Callero", + "Marc Christensen", + "Marcos David Marín Amador", + "Martin Willemoes Hansen", + "Marek Sieradzki", + "Matej Urbas", + "Maurício de Lemos Rodrigues Collares Neto", + "Michael Hutchinson", + "Miguel de Icaza", + "Mike Krüger", + "Mike Kestner", + "Mitchell Wheeler", + "Muthiah Annamalai", + "Nick Drochak", + "Nikhil Sarda", + "nricciar", + "Paco Martínez", + "Pawel Rozanski", + "Pedro Abelleira Seco", + "Peter Johanson", + "Philip Turnbull", + "Richard Torkar", + "Rolf Bjarne Kvinge", + "Rusty Howell", + "Sanjoy Das", + "Scott Ellington", + "Thomas Wiest", + "Todd Berman", + "Vincent Daron", + "Vinicius Depizzol", + "Viktoria Dudka", + "Wade Berrier", + "Yan-ren Tsai", + "Zach Lute" + }; + + public ScrollBox () + { + this.Realized += new EventHandler (OnRealized); + this.ModifyBg (Gtk.StateType.Normal, new Gdk.Color (49, 49, 74)); + + image = new Gdk.Pixbuf (GetType ().Assembly, "AboutImage.png"); + monoPowered = new Gdk.Pixbuf (GetType ().Assembly, "mono-powered.png"); + this.SetSizeRequest (450, image.Height - 1); + + TimerHandle = GLib.Timeout.Add (50, new TimeoutHandler (ScrollDown)); + } + + string CreditText { + get { + var sb = new StringBuilder (); + sb.Append (GettextCatalog.GetString ("<b>Contributors to this Release</b>\n\n")); + + for (int n = 0; n < authors.Length; n++) { + sb.Append (authors [n]); + if (n % 2 == 1) + sb.Append ("\n"); + else if (n < authors.Length - 1) + sb.Append (", "); + } + + sb.Append ("\n\n<b>" + GettextCatalog.GetString ("Previous Contributors") + "</b>\n\n"); + for (int n = 0; n < oldAuthors.Length; n++) { + sb.Append (oldAuthors [n]); + if (n % 2 == 1) + sb.Append ("\n"); + else if (n < oldAuthors.Length - 1) + sb.Append (", "); + } + + string trans = GettextCatalog.GetString ("translator-credits"); + if (trans != "translator-credits") { + sb.Append (GettextCatalog.GetString ("\n\n<b>Translated by:</b>\n\n")); + sb.Append (trans); + } + sb.AppendLine (); + sb.AppendLine (); + sb.AppendLine (GettextCatalog.GetString ("<b>Using some icons from:</b>")); + sb.AppendLine (); + sb.Append ("http://www.famfamfam.com/lab/icons/silk"); + return sb.ToString (); + } + } + + bool ScrollDown () + { + if (scrollPause > 0) { + if (--scrollPause == 0) + ++scroll; + } else + ++scroll; + int w, h; + this.GdkWindow.GetSize (out w, out h); + this.QueueDrawArea (0, 0, w, image.Height); + return true; + } + + void DrawImage () + { + if (image != null) { + int w, h; + this.GdkWindow.GetSize (out w, out h); + this.GdkWindow.DrawPixbuf (backGc, image, 0, 0, (w - image.Width) / 2, 0, -1, -1, RgbDither.Normal, 0, 0); + } + } + + void DrawText () + { + int width, height; + GdkWindow.GetSize (out width, out height); + + int widthPixel, heightPixel; + layout.GetPixelSize (out widthPixel, out heightPixel); + + GdkWindow.DrawLayout (Style.WhiteGC, 0, textTop - scroll, layout); + GdkWindow.DrawPixbuf (backGc, monoPowered, 0, 0, (width / 2) - (monoPowered.Width / 2), textTop - scroll + heightPixel + monoLogoSpacing, -1, -1, RgbDither.Normal, 0, 0); + + heightPixel = heightPixel - 80 + image.Height; + + if ((scroll == heightPixel) && (scrollPause == 0)) + scrollPause = 60; + if (scroll > heightPixel + monoLogoSpacing + monoPowered.Height) + scroll = scrollStart; + } + + protected override bool OnExposeEvent (Gdk.EventExpose evnt) + { + int w, h; + + this.GdkWindow.GetSize (out w, out h); + this.DrawText (); + this.DrawImage (); + // this.GdkWindow.DrawRectangle (backGc, true, 0, 210, w, 10); + return false; + } + + protected void OnRealized (object o, EventArgs args) + { + int x, y; + int w, h; + GdkWindow.GetOrigin (out x, out y); + GdkWindow.GetSize (out w, out h); + + textTop = y + image.Height - 30; + scrollStart = -(image.Height - textTop); + scroll = scrollStart; + + layout = new Pango.Layout (this.PangoContext); + // FIXME: this seems wrong but works + layout.Width = w * (int)Pango.Scale.PangoScale; + layout.Wrap = Pango.WrapMode.Word; + layout.Alignment = Pango.Alignment.Center; + FontDescription fd = FontDescription.FromString ("Tahoma 10"); + layout.FontDescription = fd; + layout.SetMarkup (CreditText); + + backGc = new Gdk.GC (GdkWindow); + backGc.RgbBgColor = new Gdk.Color (49, 49, 74); + } + + protected override void OnDestroyed () + { + base.OnDestroyed (); + backGc.Dispose (); + GLib.Source.Remove (TimerHandle); + } + } } } diff --git a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Gui.Dialogs/CommonAboutDialog.cs b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Gui.Dialogs/CommonAboutDialog.cs index cdc414e275..70e171a84d 100644 --- a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Gui.Dialogs/CommonAboutDialog.cs +++ b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Gui.Dialogs/CommonAboutDialog.cs @@ -5,10 +5,12 @@ // John Luke <jluke@cfl.rr.com> // Lluis Sanchez Gual <lluis@novell.com> // Viktoria Dudka <viktoriad@remobjects.com> +// Mike Krüger <mkrueger@xamarin.com> // // Copyright (c) 2004 Todd Berman // Copyright (c) 2004 John Luke // Copyright (C) 2008 Novell, Inc. +// Copyright (c) 2011 Xamarin Inc. (http://xamarin.com) // // Permission is hereby granted, free of charge, to any person obtaining a copy // of this software and associated documentation files (the "Software"), to deal @@ -29,7 +31,6 @@ // THE SOFTWARE. // // - using System; using System.Text; @@ -44,287 +45,26 @@ using System.IO; namespace MonoDevelop.Ide.Gui.Dialogs { - internal class ScrollBox : DrawingArea - { - Pixbuf image; - Pixbuf monoPowered; - int scroll; - Pango.Layout layout; - int monoLogoSpacing = 80; - int textTop; - int scrollPause; - int scrollStart; - Gdk.GC backGc; - - internal uint TimerHandle; - - string[] authors = new string[] { - "Lluis Sanchez Gual", - "Michael Hutchinson", - "Mike Krüger", - "Mike Kestner", - "Ankit Jain", - "Jonathan Pobst", - "Christian Hergert", - "Levi Bard", - "Carlo Kok", - "Viktoria Dudka", - "Marc Christensen", - "Andrew Jorgensen", - "Jérémie Laval", - "Luciano N. Callero", - "Zach Lute", - "Andrea Krüger", - "Jakub Steiner" - }; - - string[] oldAuthors = new string[] { - "Aaron Bockover", - "Alberto Paro", - "Alejandro Serrano", - "Alexandre Gomes", - "Alex Graveley", - "Alfonso Santos Luaces", - "Andre Filipe de Assuncao e Brito", - "Andrea Krüger", - "Andrés G. Aragoneses", - "Andrew Jorgensen", - "Ankit Jain", - "Antonio Ognio", - "Ben Maurer", - "Ben Motmans", - "Carlo Kok", - "Christian Hergert", - "Daniel Kornhauser", - "Daniel Morgan", - "David Makovský", - "Eric Butler", - "Erik Dasque", - "Geoff Norton", - "Gustavo Giráldez", - "Iain McCoy", - "Inigo Illan", - "Jacob Ilsø Christensen", - "Jakub Steiner", - "James Fitzsimons", - "Jeff Stedfast", - "Jérémie Laval", - "Jeroen Zwartepoorte", - "John BouAnton", - "John Luke", - "Joshua Tauberer", - "Jonathan Hernández Velasco", - "Jonathan Pobst", - "Levi Bard", - "Lluis Sanchez Gual", - "Luciano N. Callero", - "Marc Christensen", - "Marcos David Marín Amador", - "Martin Willemoes Hansen", - "Marek Sieradzki", - "Matej Urbas", - "Maurício de Lemos Rodrigues Collares Neto", - "Michael Hutchinson", - "Miguel de Icaza", - "Mike Krüger", - "Mike Kestner", - "Mitchell Wheeler", - "Muthiah Annamalai", - "Nick Drochak", - "Nikhil Sarda", - "nricciar", - "Paco Martínez", - "Pawel Rozanski", - "Pedro Abelleira Seco", - "Peter Johanson", - "Philip Turnbull", - "Richard Torkar", - "Rolf Bjarne Kvinge", - "Rusty Howell", - "Sanjoy Das", - "Scott Ellington", - "Thomas Wiest", - "Todd Berman", - "Vincent Daron", - "Vinicius Depizzol", - "Viktoria Dudka", - "Wade Berrier", - "Yan-ren Tsai", - "Zach Lute" - }; - - public ScrollBox () - { - this.Realized += new EventHandler (OnRealized); - this.ModifyBg (Gtk.StateType.Normal, new Gdk.Color (49, 49, 74)); - - image = new Gdk.Pixbuf (GetType ().Assembly, "AboutImage.png"); - monoPowered = new Gdk.Pixbuf (GetType ().Assembly, "mono-powered.png"); - this.SetSizeRequest (450, image.Height - 1); - - TimerHandle = GLib.Timeout.Add (50, new TimeoutHandler (ScrollDown)); - } - - string CreditText { - get { - StringBuilder sb = new StringBuilder (); - sb.Append (GettextCatalog.GetString ("<b>Contributors to this Release</b>\n\n")); - - for (int n = 0; n < authors.Length; n++) { - sb.Append (authors[n]); - if (n % 2 == 1) - sb.Append ("\n"); - else if (n < authors.Length - 1) - sb.Append (", "); - } - - sb.Append ("\n\n<b>" + GettextCatalog.GetString ("Previous Contributors") + "</b>\n\n"); - for (int n = 0; n < oldAuthors.Length; n++) { - sb.Append (oldAuthors[n]); - if (n % 2 == 1) - sb.Append ("\n"); - else if (n < oldAuthors.Length - 1) - sb.Append (", "); - } - - string trans = GettextCatalog.GetString ("translator-credits"); - if (trans != "translator-credits") { - sb.Append (GettextCatalog.GetString ("\n\n<b>Translated by:</b>\n\n")); - sb.Append (trans); - } - sb.AppendLine (); - sb.AppendLine (); - sb.AppendLine (GettextCatalog.GetString ("<b>Using some icons from:</b>")); - sb.AppendLine (); - sb.Append ("http://www.famfamfam.com/lab/icons/silk"); - return sb.ToString (); - } - } - - bool ScrollDown () - { - if (scrollPause > 0) { - if (--scrollPause == 0) - ++scroll; - } else - ++scroll; - int w, h; - this.GdkWindow.GetSize (out w, out h); - this.QueueDrawArea (0, 0, w, image.Height); - return true; - } - - private void DrawImage () - { - if (image != null) { - int w, h; - this.GdkWindow.GetSize (out w, out h); - this.GdkWindow.DrawPixbuf (backGc, image, 0, 0, (w - image.Width) / 2, 0, -1, -1, RgbDither.Normal, 0, - 0); - } - } - -// int GetTextHeight () -// { -// int w, h; -// layout.GetPixelSize (out w, out h); -// return h; -// } - - private void DrawText () - { - int width, height; - GdkWindow.GetSize (out width, out height); - - int widthPixel, heightPixel; - layout.GetPixelSize (out widthPixel, out heightPixel); - - GdkWindow.DrawLayout (Style.WhiteGC, 0, textTop - scroll, layout); - GdkWindow.DrawPixbuf (backGc, monoPowered, 0, 0, (width / 2) - (monoPowered.Width / 2), textTop - scroll + heightPixel + monoLogoSpacing, -1, -1, RgbDither.Normal, 0, - 0); - - heightPixel = heightPixel - 80 + image.Height; - - if ((scroll == heightPixel) && (scrollPause == 0)) - scrollPause = 60; - if (scroll > heightPixel + monoLogoSpacing + monoPowered.Height) - scroll = scrollStart; - } - - protected override bool OnExposeEvent (Gdk.EventExpose evnt) - { - int w, h; - - this.GdkWindow.GetSize (out w, out h); - this.DrawText (); - this.DrawImage (); -// this.GdkWindow.DrawRectangle (backGc, true, 0, 210, w, 10); - return false; - } - - protected void OnRealized (object o, EventArgs args) - { - int x, y; - int w, h; - GdkWindow.GetOrigin (out x, out y); - GdkWindow.GetSize (out w, out h); - - textTop = y + image.Height - 30; - scrollStart = -(image.Height - textTop); - scroll = scrollStart; - - layout = new Pango.Layout (this.PangoContext); - // FIXME: this seems wrong but works - layout.Width = w * (int)Pango.Scale.PangoScale; - layout.Wrap = Pango.WrapMode.Word; - layout.Alignment = Pango.Alignment.Center; - FontDescription fd = FontDescription.FromString ("Tahoma 10"); - layout.FontDescription = fd; - layout.SetMarkup (CreditText); - - backGc = new Gdk.GC (GdkWindow); - backGc.RgbBgColor = new Gdk.Color (49, 49, 74); - } - - protected override void OnDestroyed () - { - base.OnDestroyed (); - backGc.Dispose (); - } - - } - internal class CommonAboutDialog : Dialog { - ScrollBox aboutPictureScrollBox; - Pixbuf imageSep; - public CommonAboutDialog () { Title = GettextCatalog.GetString ("About MonoDevelop"); TransientFor = IdeApp.Workbench.RootWindow; AllowGrow = false; HasSeparator = false; - - VBox.BorderWidth = 0; - - aboutPictureScrollBox = new ScrollBox (); - - VBox.PackStart (aboutPictureScrollBox, false, false, 0); - imageSep = new Pixbuf (typeof(CommonAboutDialog).Assembly, "AboutImageSep.png"); - VBox.PackStart (new Gtk.Image (imageSep), false, false, 0); - - Notebook notebook = new Notebook (); - notebook.BorderWidth = 6; + + var notebook = new Notebook (); + notebook.BorderWidth = 0; notebook.AppendPage (new AboutMonoDevelopTabPage (), new Label (Title)); notebook.AppendPage (new VersionInformationTabPage (), new Label (GettextCatalog.GetString ("Version Info"))); var buildInfo = LoadBuildInfo (); if (buildInfo != null) notebook.AppendPage (buildInfo, new Label (GettextCatalog.GetString ("Build Info"))); - VBox.PackStart (notebook, true, true, 4); - + VBox.PackStart (notebook, true, true, 0); + AddButton (Gtk.Stock.Close, (int)ResponseType.Close); - + ShowAll (); } @@ -342,13 +82,6 @@ namespace MonoDevelop.Ide.Gui.Dialogs } } - public new int Run () - { - int tmp = base.Run (); - GLib.Source.Remove (aboutPictureScrollBox.TimerHandle); - return tmp; - } - Widget LoadBuildInfo () { var biFile = System.IO.Path.Combine (System.IO.Path.GetDirectoryName (GetType ().Assembly.Location), "buildinfo"); 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 124d3c3c54..794a821ffc 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 @@ -2,8 +2,10 @@ // // Author: // Viktoria Dudka (viktoriad@remobjects.com) +// Mike Krüger <mkrueger@xamarin.com> // // Copyright (c) 2009 RemObjects Software +// Copyright (c) 2011 Xamarin Inc. (http://xamarin.com) // // Permission is hereby granted, free of charge, to any person obtaining a copy // of this software and associated documentation files (the "Software"), to deal @@ -29,67 +31,217 @@ using System; using Gtk; using MonoDevelop.Core; using System.Reflection; +using System.Text; +using System.IO; + namespace MonoDevelop.Ide.Gui.Dialogs { internal class VersionInformationTabPage: VBox { - private ListStore data = null; - private CellRenderer cellRenderer = new CellRendererText (); - - public VersionInformationTabPage () - { - TreeView treeView = new TreeView (); - - TreeViewColumn treeViewColumnTitle = new TreeViewColumn (GettextCatalog.GetString ("Title"), cellRenderer, "text", 0); - treeViewColumnTitle.FixedWidth = 200; - treeViewColumnTitle.Sizing = TreeViewColumnSizing.Fixed; - treeViewColumnTitle.Resizable = true; - treeView.AppendColumn (treeViewColumnTitle); - - TreeViewColumn treeViewColumnVersion = new TreeViewColumn (GettextCatalog.GetString ("Version"), cellRenderer, "text", 1); - treeView.AppendColumn (treeViewColumnVersion); - - TreeViewColumn treeViewColumnPath = new TreeViewColumn (GettextCatalog.GetString ("Path"), cellRenderer, "text", 2); - treeView.AppendColumn (treeViewColumnPath); - - treeView.RulesHint = true; - - data = new ListStore (typeof (string), typeof (string), typeof (string)); - treeView.Model = data; - - ScrolledWindow scrolledWindow = new ScrolledWindow (); - scrolledWindow.Add (treeView); - scrolledWindow.ShadowType = ShadowType.In; - - BorderWidth = 6; - - PackStart (scrolledWindow, true, true, 0); - - foreach (Assembly assembly in AppDomain.CurrentDomain.GetAssemblies ()) { - try { - AssemblyName assemblyName = assembly.GetName (); - data.AppendValues (assemblyName.Name, assemblyName.Version.ToString (), System.IO.Path.GetFullPath (assembly.Location)); - } - catch { } - } - - data.SetSortColumnId (0, SortType.Ascending); - } - - protected override void OnDestroyed () - { - if (cellRenderer != null) { - cellRenderer.Destroy (); - cellRenderer = null; - } - - if (data != null) { - data.Dispose (); - data = null; - } - - base.OnDestroyed (); - } + string VersionInformation { + get { + var sb = new StringBuilder (); + sb.AppendLine ("Operating System:"); + sb.Append ("\t"); + if (Platform.IsMac) { + sb.Append ("Mac OS X "); + } else if (Platform.IsWindows) { + sb.Append ("Windows "); + } else { + sb.Append ("Linux "); + } + sb.AppendLine (" version " + Environment.OSVersion.Version.ToString ()); + + sb.Append ("\t.NET runtime "); + if (IsMicrosoftCLR ()) { + sb.Append (".NET " + Environment.Version); + } else { + sb.Append ("Mono " + GetMonoVersionNumber ()); + } + sb.AppendLine (); + + sb.Append ("\tGTK " + GetGtkVersion ()); + sb.AppendLine (" (GTK# " + typeof(VBox).Assembly.GetName ().Version + ")"); + + var mtVersion = GetMonotouchVersion (); + + if (mtVersion != null) + sb.AppendLine ("\tMonoTouch: " + mtVersion); +// TODO:Get mono droid version. +// var droidVersion = GetMonoDroidVersion (); +// if (droidVersion != null) +// sb.AppendLine ("\tMono for Android: " + droidVersion); + + sb.AppendLine (); + string version = BuildVariables.PackageVersion == BuildVariables.PackageVersionLabel ? BuildVariables.PackageVersionLabel : string.Format ("{0} ({1})", + BuildVariables.PackageVersionLabel, + BuildVariables.PackageVersion); + sb.Append ("MonoDevelop: "); + sb.AppendLine (version); + var biFile = System.IO.Path.Combine (System.IO.Path.GetDirectoryName (GetType ().Assembly.Location), "buildinfo"); + if (File.Exists (biFile)) + sb.AppendLine (File.ReadAllText (biFile).TrimEnd ()); + + + return sb.ToString (); + } + } + + static bool IsMicrosoftCLR () + { + return Type.GetType ("Mono.Runtime") == null; + } + + static string GetMonoVersionNumber () + { + 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"; + } + return (string)mi.Invoke (null, null); + } + + static string GetGtkVersion () + { + uint v1 = 0, v2 = 0, v3 = 0; + + v1 = 99; + while (v1 > 0 && Gtk.Global.CheckVersion (v1, v2, v3) != null) + v1--; + v2 = 99; + while (v2 > 0 && Gtk.Global.CheckVersion (v1, v2, v3) != null) + v2--; + v3 = 99; + while (v3 > 0 && Gtk.Global.CheckVersion (v1, v2, v3) != null) + v3--; + if (v1 == 0 || v2 == 0 || v3 == 0) + return "unknown"; + return v1 +"." + v2 + "."+ v3; + } + + #region Monotouch + static string GetMonotouchVersion () + { + var mtdir = GetMonotouchLocation (); + var mtouch = System.IO.Path.Combine (mtdir, "usr/bin/mtouch"); + if (!File.Exists (mtouch)) + return mtouch + "not found."; + var version = System.IO.Path.Combine (mtdir, "Version"); + if (!File.Exists (version)) + return "unknown version"; + bool isEvaluation = !File.Exists (System.IO.Path.Combine (mtdir, "usr/bin/arm-darwin-mono")); + if (isEvaluation) + return File.ReadAllText (version).Trim () + " (Evaluation)"; + return File.ReadAllText (version); + } + + static string GetMonotouchLocation () + { + const string DefaultLocation = "/Developer/MonoTouch"; + const string MTOUCH_LOCATION_ENV_VAR = "MD_MTOUCH_SDK_ROOT"; + var mtRoot = Environment.GetEnvironmentVariable (MTOUCH_LOCATION_ENV_VAR); + return mtRoot ?? GetConfiguredMonoTouchSdkRoot () ?? DefaultLocation; + } + + static string GetConfiguredMonoTouchSdkRoot () + { + const string MTOUCH_SDK_KEY = "MonoDevelop.IPhone.MonoTouchSdkRoot"; + return PropertyService.Get<string> (MTOUCH_SDK_KEY, null); + } + #endregion + + #region MonoDroid + static string GetMonoDroidVersion () + { + string monoDroidBinDir; + string monoDroidFrameworkDir; + GetMonoDroidSdk (out monoDroidBinDir, out monoDroidFrameworkDir); + return monoDroidBinDir; + } + + static void GetMonoDroidSdk (out string monoDroidBinDir, out string monoDroidFrameworkDir) + { + monoDroidBinDir = monoDroidFrameworkDir = null; + + if (Platform.IsWindows) { + // Find user's \Program Files + var programFilesX86 = GetProgramFilesX86 (); + + // We keep our tools in: + // \Program Files\MSBuild\Novell + monoDroidBinDir = programFilesX86 + @"\MSBuild\Novell"; + + // This will probably never be used on Windows + var fxDir = programFilesX86 + @"\Reference Assemblies\Microsoft\Framework\MonoAndroid\v1.0"; + + if (System.IO.File.Exists (fxDir + @"\mscorlib.dll")) + monoDroidFrameworkDir = fxDir; + else + monoDroidFrameworkDir = null; + + return; + } + + string monoAndroidPath = Environment.GetEnvironmentVariable ("MONO_ANDROID_PATH"); + string libmandroid = System.IO.Path.Combine ("lib", "mandroid"); + string debugRuntime = "Mono.Android.DebugRuntime-debug.apk"; + + foreach (var loc in new[]{ + new { D = monoAndroidPath, L = libmandroid, E = debugRuntime }, + new { D = "/Developer/MonoAndroid/usr", L = libmandroid, E = debugRuntime }, + new { D = "/opt/mono-android", L = libmandroid, E = debugRuntime }}) + if (CheckMonoDroidPath (loc.D, loc.L, loc.E, out monoDroidBinDir, out monoDroidFrameworkDir)) + return; + } + + static bool CheckMonoDroidPath (string monoDroidPath, string relBinPath, string mandroid, out string monoDroidBinDir, out string monoDroidFrameworkDir) + { + monoDroidBinDir = monoDroidFrameworkDir = null; + + if (string.IsNullOrEmpty (monoDroidPath)) + return false; + + var bin = System.IO.Path.Combine (monoDroidPath, relBinPath); + if (!System.IO.File.Exists (System.IO.Path.Combine (bin, mandroid))) + return false; + + monoDroidBinDir = bin; + monoDroidFrameworkDir = System.IO.Path.Combine (monoDroidPath, "lib", "mono", "2.1"); + return true; + } + + static string GetProgramFilesX86 () + { + if (IntPtr.Size == 8 || !string.IsNullOrEmpty (Environment.GetEnvironmentVariable ("PROCESSOR_ARCHITEW6432"))) + return Environment.GetEnvironmentVariable ("PROGRAMFILES(X86)"); + else + return Environment.GetEnvironmentVariable ("PROGRAMFILES"); + } + #endregion + + public VersionInformationTabPage () + { + var buf = new TextBuffer (null); + buf.Text = VersionInformation; + + var sw = new ScrolledWindow () { + BorderWidth = 6, + ShadowType = ShadowType.EtchedIn, + Child = new TextView (buf) { + Editable = false, + LeftMargin = 4, + RightMargin = 4, + PixelsAboveLines = 4, + PixelsBelowLines = 4 + } + }; + + PackStart (sw, true, true, 0); + } } } |