Wednesday, July 18, 2012

Geany in Windows

Updated 2012-07-20

Geany, a lightweight IDE for Java, Python, C/C++ and other computer languages, is available for MS-Windows. You can install it with or without the GTK libraries, which is a nice option, if you already have either GTK+ or PyGTK installed. But, and there's always a "but" isn't there, the executable and shortcuts won't work because they will require GTK to be part of your  MS-Windows PATH, which it probably won't be. Honestly, I can't remember if I was given an option to add GTK to the PATH during install, but it's not on my PATH now. Conveniently, though, GTK was nice enough to add a batch file that starts a shell with their environmental variables preset, such as adding <path to GTK runtime>\bin to %PATH%. You need to fix setenv.cmd first, though. See this post. So, to get the Geany shortcuts to run, all you need to do is edit the "Target:" field to include the nice batch file from GTK. Right click on the Geany shortcut and select properties. On my machine I typed ...
C:\WINDOWS\system32\cmd.exe /C ""C:\Python27\Lib\site-packages\gtk-2.0\runtime\bin\setenv.cmd"&&"C:\Program Files\Geany\bin\Geany.exe""
... into the "Target:" field since I have PyGTK which installs the GTK binaries in the Python directory.

BTW: %COMSPEC% is usually a shortcut for "C:\WINDOWS\system32\cmd.exe" and %PROGRAMFILES% does the same for "C:\Program Files, so you could also use this.
%COMSPEC% /C ""C:\Python27\Lib\site-packages\gtk-2.0\runtime\bin\setenv.cmd"&&" %PROGRAMFILES% \Geany\bin\Geany.exe""
(Update 2012-07-20) One more place you will have to make this change is to your explorer shell. Now if you are uncomfortable with changes to your registry, then you should backup your entire registry before doing this. From the start menu type regedit, and the registry editor opens. Click file and export and select the All radio button to backup the entire registry. Now go to each of the following keys:
and change the value to include the GTK setenv batch file.
C:\WINDOWS\system32\cmd.exe /C ""C:\Python27\Lib\site-packages\gtk-2.0\runtime\bin\setenv.cmd"&&"C:\Program Files\Geany\bin\Geany.exe" "%1""
Alternately you can copy the text below and import the keys using import under the file menu option in regedit, or from a command line, type REG IMPORT <filename.reg> where filename is a file saved with the keys below. Or use REGEDIT <filename.reg>. Also you can just double click on the file and it will automatically import your keys, or right-click on them and select merge. Note you must be an administrator to import these keys. Also note that quotes and backslashes in the value must be "escaped" with a backslash, and then the entire value should be enclosed in quotes.
Windows Registry Editor Version 5.00
[HKEY_CLASSES_ROOT\Geany.ProjectFile\Shell\open\command]@="C:\\WINDOWS\\system32\\cmd.exe /C \"\"C:\\Python27\\Lib\\site-packages\\gtk-2.0\\runtime\\bin\\setenv.cmd\"&&\"C:\\Program Files\\Geany\\bin\\Geany.exe\" \"%1\"\""
[HKEY_CLASSES_ROOT\*\Shell\OpenWithGeany\command]@="C:\\WINDOWS\\system32\\cmd.exe /C \"\"C:\\Python27\\Lib\\site-packages\\gtk-2.0\\runtime\\bin\\setenv.cmd\"&&\"C:\\Program Files\\Geany\\bin\\Geany.exe\" \"%1\"\""
If you have the standalone version of GTK, you may not have the convenient setenv.cmd file, so here are the settings that it gives you. Of course you could just add your GTK bin folder to your MS-Windows PATH, but maybe there was a reason you didn't do that when you installed GTK. Hm, maybe there's some conflict? A .dll namesake lurking around somewhere? If you choose the option I present here, you'll have to do this everywhere you have a shortcut, or just create a shortcut or batch file once in the Geany bin folder and point all your shortcuts to that.
set RUNTIME_BIN="<the bin file that has libglib-2.0.0.dll, a bunch of .exe's and .dll's>" set RUNTIME_PKGCONFIG="%RUNTIME_BIN%\..\lib\pkgconfig\"
set PYTHON_ROOT="<where ever your python directory is>"

Sadly, one thing you'll miss is the terminal screen, if you are used to the Linux version.
Fork me on GitHub