Ticket #23: gtkdPathTango.diff
| File gtkdPathTango.diff, 3.1 kB (added by Mike Wey, 10 months ago) |
|---|
-
gtkD-gen/wrap/paths.d
old new 6 6 * Added: John Reimer -- 2004-12-20 7 7 * Updated: 2005-02-21 changed names; added version(linux) 8 8 * Updated: 2005-05-05 updated Linux support 9 * Updated: 2008-02-16 Tango support 9 10 */ 10 11 11 12 module gtkc.paths; … … 93 94 ]; 94 95 } 95 96 96 // dmd 1.005 still makes private char[] public?!97 //private char[] libPath;98 // Specify the default path for the gtkD dll's99 100 97 version(Windows) 101 98 { 102 import std.windows.registry; 103 import std.stdio; 99 //version(Phobos) 100 version(Tango){} else 101 { 102 import std.windows.registry; 103 import std.stdio; 104 } 104 105 105 char[] libPath()106 extern (Windows) 106 107 { 107 // if ( libPath is null ) 108 // { 109 // libPath = "\\Program Files\\Common Files\\GTK\\2.0\\bin\\"; 110 // } 111 // return libPath; 108 private uint GetEnvironmentVariableA(char*, char*, uint); 109 } 112 110 113 Key k = Registry.localMachine(); 111 //Based on tango.sys.Environment.Environment.get 112 static char[] GetEnvironmentVariable(char[] variable) 113 { 114 var = variable ~ 0; 115 uint size = GetEnvironmentVariableA(var.ptr, cast(char*)null, 0); 116 117 if (size == 0) return ""; 114 118 119 char buf = new char[size]; 120 size = GetEnvironmentVariableA(var.ptr, buffer.ptr, size); 121 122 if (size == 0) return ""; 123 124 return buf[0 .. size]; 125 } 126 127 char[] libPath() 128 { 115 129 char[] libPath; 116 130 117 foreach ( Key key ; k.keys() ) 118 { 119 writefln("key = ", key.name()); 120 } 131 libPath = GetEnvironmentVariable("%GTK_BASEPATH%"); 121 132 122 try 123 { 124 k = k.getKey("SOFTWARE"); 125 //writefln("key.value = %s", k.name()); 126 k = k.getKey("GTK"); 127 //writefln("key.value = %s", k.name()); 128 k = k.getKey("2.0"); 129 //writefln("key.value = %s", k.name()); 130 Value v = k.getValue("DllPath"); 131 libPath = v.value_SZ() ~ "\\"; 132 } 133 catch ( Exception e ) 134 { 135 libPath = "\\Program Files\\Common Files\\GTK\\2.0\\bin\\"; 136 } 133 if(libPath.length > 0) 134 return libPath ~ "\\bin\\"; 137 135 138 if ( libPath is null ) 136 // version(Phobos) 137 version(Tango){} else 139 138 { 140 libPath = "\\Program Files\\Common Files\\GTK\\2.0\\bin\\"; 141 } 139 // When using phobos Also try the Register 142 140 141 Key k = Registry.localMachine(); 142 143 debug(register) foreach ( Key key ; k.keys() ) 144 { 145 writefln("key = ", key.name()); 146 } 147 148 try 149 { 150 k = k.getKey("SOFTWARE"); 151 //writefln("key.value = %s", k.name()); 152 k = k.getKey("GTK"); 153 //writefln("key.value = %s", k.name()); 154 k = k.getKey("2.0"); 155 //writefln("key.value = %s", k.name()); 156 Value v = k.getValue("DllPath"); 157 libPath = v.value_SZ() ~ "\\"; 158 } 159 catch ( Exception e ) 160 { 161 libPath = ""; 162 } 163 } 143 164 165 // Returns the found location or an empty string 166 // to load the libraries from the path. 167 // see http://msdn2.microsoft.com/en-us/library/ms682586(VS.85).aspx 144 168 return libPath; 145 169 } 146 170 } 147 171 148 // empty for linux because default path is known by ld172 // empty for linux because default path is known by ld 149 173 150 174 version(linux) 151 175 { 152 176 char[] libPath() 153 177 { 154 // if ( libPath is null )155 // {156 // libPath = "";157 // }158 // return libPath;159 178 return ""; 160 179 } 161 180 }
