[mono/monodevelop] 43c2f715: [Ide] Show messagebox on Windows if GTK# is missing or too old
"Michael Hutchinson (
[email protected])" <
[email protected]>
Thu, 14 Nov 2013 22:38:49 +0000
| Newsgroups |
gmane.comp.gnome.mono.patches |
| Message-ID |
<0000014258c44feb-17ab70f9-9c34-47bc-8942-b70fe67aaa90-000000@email.amazonses.com> |
Branch: refs/heads/master
Home: https://github.com/mono/monodevelop
Compare: https://github.com/mono/monodevelop/compare/6bb4a3c17491...43c2f7150cf4
Commit: 43c2f7150cf48ac73aac59dcb17f421bf120d1f1
Author: Michael Hutchinson <[email protected]> (mhutch)
Date: 2013-11-14 22:24:54 GMT
URL: https://github.com/mono/monodevelop/commit/43c2f7150cf48ac73aac59dcb17f421bf120d1f1
[Ide] Show messagebox on Windows if GTK# is missing or too old
Changed paths:
M main/src/core/MonoDevelop.Ide/MonoDevelop.Ide/IdeStartup.cs
Modified: main/src/core/MonoDevelop.Ide/MonoDevelop.Ide/IdeStartup.cs
===================================================================
@@ -46,12 +46,9 @@
using MonoDevelop.Core;
using MonoDevelop.Ide.Gui.Dialogs;
using MonoDevelop.Ide.Gui;
-using MonoDevelop.Core.Execution;
using MonoDevelop.Core.Instrumentation;
using System.Diagnostics;
-using MonoDevelop.Projects;
using System.Collections.Generic;
-using MonoDevelop.Core.LogReporting;
namespace MonoDevelop.Ide
{
@@ -88,9 +85,8 @@ int Run (MonoDevelopOptions options)
Platform.Initialize ();
Counters.Initialization.Trace ("Initializing GTK");
- if (Platform.IsWindows) {
- CheckWindowsGtk ();
- }
+ if (Platform.IsWindows && !CheckWindowsGtk ())
+ return 1;
SetupExceptionManager ();
try {
@@ -322,26 +318,61 @@ void SetupTheme ()
[return: System.Runtime.InteropServices.MarshalAs(System.Runtime.InteropServices.UnmanagedType.Bool)]
static extern bool SetDllDirectory (string lpPathName);
- static void CheckWindowsGtk ()
+ static bool CheckWindowsGtk ()
{
string location = null;
+ Version version = null;
+ Version minVersion = new Version (2, 12, 22);
+
using (var key = Microsoft.Win32.Registry.LocalMachine.OpenSubKey(@"SOFTWARE\Xamarin\GtkSharp\InstallFolder")) {
- if (key != null) {
+ if (key != null)
location = key.GetValue (null) as string;
- }
}
- if (location == null || !File.Exists (Path.Combine (location, "bin", "libgtk-win32-2.0-0.dll"))) {
- LoggingService.LogError ("Did not find registered GTK# installation");
- return;
+ using (var key = Microsoft.Win32.Registry.LocalMachine.OpenSubKey (@"SOFTWARE\Xamarin\GtkSharp\Version")) {
+ if (key != null)
+ Version.TryParse (key.GetValue (null) as string, out version);
}
+
+ //TODO: check build version of GTK# dlls in GAC
+ if (version == null || version < minVersion || location == null || !File.Exists (Path.Combine (location, "bin", "libgtk-win32-2.0-0.dll"))) {
+ LoggingService.LogError ("Did not find required GTK# installation");
+ string url = "http://monodevelop.com/Download";
+ string caption = "Fatal Error";
+ string message =
+ "{0} did not find the required version of GTK#. Please click OK to open the download page, where " +
+ "you can download and install the latest version.";
+ if (DisplayWindowsOkCancelMessage (
+ string.Format (message, BrandingService.ApplicationName, url), caption)
+ ) {
+ Process.Start (url);
+ }
+ return false;
+ }
+
var path = Path.Combine (location, @"bin");
try {
if (SetDllDirectory (path)) {
- return;
+ return true;
}
} catch (EntryPointNotFoundException) {
}
- LoggingService.LogError ("Unable to set GTK# dll directory");
+ // this shouldn't happen unless something is weird in Windows
+ LoggingService.LogError ("Unable to set GTK+ dll directory");
+ return true;
+ }
+
+ static bool DisplayWindowsOkCancelMessage (string message, string caption)
+ {
+ var name = typeof(int).Assembly.FullName.Replace ("mscorlib", "System.Windows.Forms");
+ var asm = Assembly.Load (name);
+ var md = asm.GetType ("System.Windows.Forms.MessageBox");
+ var mbb = asm.GetType ("System.Windows.Forms.MessageBoxButtons");
+ var okCancel = Enum.ToObject (mbb, 1);
+ var dr = asm.GetType ("System.Windows.Forms.DialogResult");
+ var ok = Enum.ToObject (dr, 1);
+
+ const BindingFlags flags = BindingFlags.InvokeMethod | BindingFlags.Public | BindingFlags.Static;
+ return md.InvokeMember ("Show", flags, null, null, new object[] { message, caption, okCancel }).Equals (ok);
}
public bool Initialized {
@@ -529,7 +560,7 @@ public static int Main (string[] args)
return options.Error != null? -1 : 0;
LoggingService.Initialize (options.RedirectOutput);
-
+
int ret = -1;
bool retry = false;
do {
_______________________________________________
Mono-patches maillist - [email protected]
http://lists.ximian.com/mailman/listinfo/mono-patches