[tomboy] On Windows, manipulate PATH and GTK_BASEPATH environment variables to ensure the correct GTK+ is use



commit 9c3f56e939aeb8382ace739d2e7f57064c80d53e
Author: Sandy Armstrong <sanfordarmstrong gmail com>
Date:   Mon May 25 09:33:59 2009 -0700

    On Windows, manipulate PATH and GTK_BASEPATH environment variables to ensure the correct GTK+ is used. Fixes bug #558314.
    
    The value prepended to PATH can be overridden by setting the TOMBOY_PATH_PREFIX environment variable, and the value set to GTK_BASEPATH can be overridden with the TOMBOY_GTK_BASEPATH environment variable.
---
 Tomboy/Tomboy.cs |   29 +++++++++++++++++++++++++++++
 1 files changed, 29 insertions(+), 0 deletions(-)

diff --git a/Tomboy/Tomboy.cs b/Tomboy/Tomboy.cs
index 8147d76..89020bd 100644
--- a/Tomboy/Tomboy.cs
+++ b/Tomboy/Tomboy.cs
@@ -31,6 +31,35 @@ namespace Tomboy
 
 		public static void Main (string [] args)
 		{
+			// TODO: Extract to a PreInit in Application, or something
+#if WIN32
+			string tomboy_path =
+				Environment.GetEnvironmentVariable ("TOMBOY_PATH_PREFIX");
+			string tomboy_gtk_basepath =
+				Environment.GetEnvironmentVariable ("TOMBOY_GTK_BASEPATH");
+			Environment.SetEnvironmentVariable ("GTK_BASEPATH",
+				tomboy_gtk_basepath ?? string.Empty);
+			if (string.IsNullOrEmpty (tomboy_path)) {
+				string gtk_lib_path = null;
+				try {
+					gtk_lib_path = (string)
+						Microsoft.Win32.Registry.GetValue (@"HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\.NETFramework\AssemblyFolders\GtkSharp",
+						                                   string.Empty,
+						                                   string.Empty);
+				} catch (Exception e) {
+					Console.WriteLine ("Exception while trying to get GTK# install path: " +
+					                   e.ToString ());
+				}
+				if (!string.IsNullOrEmpty (gtk_lib_path))
+					tomboy_path =
+						gtk_lib_path.Replace ("lib\\gtk-sharp-2.0", "bin");
+			}
+			if (!string.IsNullOrEmpty (tomboy_path))
+				Environment.SetEnvironmentVariable ("PATH",
+				                                    tomboy_path +
+				                                    Path.PathSeparator +
+				                                    Environment.GetEnvironmentVariable ("PATH"));
+#endif
 			// Initialize GETTEXT
 			Catalog.Init ("tomboy", Defines.GNOME_LOCALE_DIR);
 



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]