Hi,<div><br></div><div>I think I've reached a committable stage for the application bundle code I took over from Steven Edwards last summer. But there are some controversial parts so I figured I'd ask the list first.</div>

<div><br></div><div>The patch extracts all XDG specific parts of winemenubuilder into a separate file, and there is also a new file for app bundles. Which one is used is controlled by a dispatch table and is choosable in the registry. The new code reacts to the same events but instead of a .desktop file an app bundle is created, start menu is replicated at ~/Applications/Wine/.</div>

<div><br></div><div>Associations are handled by modifying start.exe to make it able to receive the file to open using AppleEvent, and an app bundle execing start.exe is put in ~/Library/Wine/Associations/. The actual file name contains the associated extension but the display name is modified to be the application that will be launched. It should work out of the box, after you've installed this patch and run winemenubuilder -a you should be able to right click a text file and choose "Open with notepad" (there's a cache involved as well so you might also need to remove the wine fileassociations key in the registry).</div>

<div><br></div><div>Commits can be found at <a href="https://github.com/morth/wine/commits/appbundle-proper" target="_blank">https://github.com/morth/wine/commits/appbundle-proper</a> (original commits are on the master branch).</div>
<div><br></div><div>The major controversity is in the start.exe code (commit <<a href="https://github.com/morth/wine/commit/ec68ac2b2abc0a1d4559eb5490b1f12b21000e59" target="_blank">https://github.com/morth/wine/commit/ec68ac2b2abc0a1d4559eb5490b1f12b21000e59</a>>). It uses a private API to access the AppleEvent containing the file to open. I choose this way because:</div>

<div><br></div><div>1. The only official way to access this information is by using Objective-C, building a proper Mac application.</div><div>2. Another option was to use the deprecated Carbon, but would also take a lot of code to finish.</div>

<div><br></div><div>IMO neither of the two are good options, which leaves either doing it this way or to ask Apple to open up the API. Unfortunately I don't think Apple will respond quickly to such a request. Now that 10.8 is close (maybe even GMed) it's very unlikely to happen before 10.9, and perhaps not even then without backing from a major developer (I suppose the wine project might count as a such). I've made sure to check with configure if the functions exist before calling, but it is of course not safe in case they change the signature. OTOH, I don't think that is overly likely to happen.</div>
<div><br></div><div>Another thing to note is that the app bundle script will copy some environment variables when created (commit <a href="https://github.com/morth/wine/commit/58773927eb7da431ba47923d66768cd129e4daff">https://github.com/morth/wine/commit/58773927eb7da431ba47923d66768cd129e4daff</a> generate_bundle_script function). The ones copied are:</div>
<div>PATH, DYLD_FALLBACK_LIBRARY_PATH and WINEPREFIX. DYLD_FALLBACK_LIBRARY_PATH is needed or wine won't work much at all. PATH is copied because the default one is only /bin and /usr/bin, and on OS X wine is rarely in one of those locations but rather installed with MacPorts of fink or similar, which use non-default paths.</div>
<meta charset="utf-8">
<div><br></div><div>Anyway, if I don't hear anything from the list I'll likely send in the commits. I suppose that will be a second chance to review them. Once again I'd like to mention that Steven Edwards did a major part of this code, thanks goes to him and also to the wine project as a whole, I really enjoy using it.</div>
<div><br></div><div>Finally, I only work on this code once every few months or so, so if it's deemed that there's too many problems, anyone should feel free to pick up this code and make it done (it'd be nice if you notified me though).</div>

<div><br></div><div>Regards,</div><div>-- </div><div>Per Johansson</div>