KDE4/Mac: resources in application bundles?

Jonas Bähr jonas.baehr at web.de
Mon Nov 19 13:51:52 GMT 2007


Hi,

We're currently porting a our application to KDE4 and I also want to  
provide a Version for Mac OS X. Especially for 3rd party applications  
it would be usefull to provide the apps resources within an  
application bundle for Mac OS X. It would be quite simply if  
KStandardDirs would also search the application bundles content for  
the requested resources.

To achieve this I propose the following addition (#ifdef'ed Q_WS_MACX):
Test if the last path elements of argv[0] are "Contents/MacOS". If  
that's the case, add the dirname of "MacOS" to KStandardDirs' prefix  
(just after KDEHOME but before KDE's prefix)
So if my application is installed in (or better: just copied to) "/ 
Applications/MyApp.app" the real executable could be found in "/ 
Applications/MyApp/Contents/MacOS/myapp". I propose to add  
KStandardDirs::addPrefix("/Applications/MyApp/Contents/") in that case.
Inside of MyApp.app/Contents we would find the normal kde directory  
structure, stating with "share". Following [1] this would not clash  
with OS-X's bundle content.
This way I could for example deliver my myappui.rc as "MyApp.app/ 
Contents/share/apps/myapp/myappui.rc" or a default config as  
"MyApp.app/Contents/share/config/myapp.rc"

Do there already exists other ways I've not found? Is it already to  
late to develop a patch for KDElibs? I would put the code in kdeui/ 
kernel/kapplication_mac.cpp and call it from the end of  
KApplication's ctor. Would this be the right approach? Setting the  
prefix directly in my application works fine...

[1] http://developer.apple.com/documentation/CoreFoundation/ 
Conceptual/CFBundles/index.html#//apple_ref/doc/uid/10000123i

bye,
Jonas




More information about the kde-core-devel mailing list