App bundle patches for OS X

Per Johansson per at morth.org
Sun Jul 8 10:13:54 CDT 2012


Hi,

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.

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/.

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).

Commits can be found at
https://github.com/morth/wine/commits/appbundle-proper (original commits
are on the master branch).

The major controversity is in the start.exe code (commit <
https://github.com/morth/wine/commit/ec68ac2b2abc0a1d4559eb5490b1f12b21000e59>).
It uses a private API to access the AppleEvent containing the file to open.
I choose this way because:

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

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.

Another thing to note is that the app bundle script will copy some
environment variables when created (commit
https://github.com/morth/wine/commit/58773927eb7da431ba47923d66768cd129e4daffgenerate_bundle_script
function). The ones copied are:
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.

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.

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).

Regards,
-- 
Per Johansson
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.winehq.org/pipermail/wine-devel/attachments/20120708/4ec36d54/attachment.html>


More information about the wine-devel mailing list