Info.plist to *open* a file

Joined
Mar 22, 2009
Messages
6
Reaction score
0
Points
1
Hi all,

I do some development for an open source project called KeePassX (www.keepassx.org), which is built on top of the Qt platform. Up until recently we just let it automatically generate the Info.plist file but the file was insufficient so I have changed the profile (basically like a Makefile for Qt) and have it use an Info.plist file that I manually generated.

This is a vast improvement and one really nice thing about it is that double-clicking on a file now launches KeePassX. Furthermore, the files associated with KeePassX (.kdb files) all have the proper icon on them as well.

The problem is that double-clicking on a file only launches KeePassX, but it doesn't actually open the file once the application has launched. You still need to either press command+O or go to File -> Open database to actually get the program to open the file. Does this mean that I'm missing something from the Info.plist file?

Certainly this behavior is undesirable. When I click on a file with the extension .doc it launches Microsoft Word and then opens the document. It would be silly for it to launch Word and then still have to go to File -> Open in order to open the document that I had just double-clicked on; yet this is how KeePassX is currently behaving.

Below is the Info.plist file (taken from SVN revision 297 if you happen to checkout the code). Any ideas are appreciated as we are about to release version 0.4.0 and I was really hoping to have this fixed. Our Linux version now properly associates itself with .kdb files and it will properly open them when a database file is double-clicked. I would like to get the Mac release working as well. Thanks!

Code:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
  <dict>

    <!-- For a full list of properties, see
    http://developer.apple.com/documentation/MacOSX/Conceptual/BPRuntimeConfig/Articles/PListKeys.html
    -->



    <key>CFBundleIconFile</key>
    <string>icon.icns</string>

    <key>CFBundlePackageType</key>
    <string>APPL</string>

    <key>CFBundleGetInfoString</key>
    <string>KeePassX 0.4.0</string>

    <key>CFBundleSignature</key>
    <string>kpsx</string>

    <key>CFBundleExecutable</key>
    <string>KeePassX</string>

    <key>CFBundleVersion</key>
    <string>0.4.0</string>

    <key>CFBundleShortVersionString</key>
    <string>0.4.0</string>

    <key>CFBundleName</key>
    <string>KeePassX</string>

    <key>CFBundleInfoDictionaryVersion</key>
    <string>6.0</string>

    <key>CFBundleIdentifier</key>
    <string>com.apple.application-bundle</string>

    <key>CFBundleDocumentTypes</key>
    <array>
      <dict>
        <key>CFBundleTypeExtensions</key>
          <array>
            <string>kdb</string>
          </array>
        <key>CFBundleTypeIconFile</key>
        <string>icon</string>
        <key>CFBundleTypeName</key>
        <string>KeePassX Password Database</string>
        <key>CFBundleTypeOSTypes</key>
           <array>
             <string>kpsx</string>
           </array>
        <key>CFBundleTypeRole</key>
        <string>Editor</string>
      </dict>
    </array>

  </dict>
</plist>



Here is an update. I put some debug statements into the code and compiled it. If I launch the code from the command line by specifying the binary directly then it prints out the correct argument (and even correctly opens the application AND the file, like I would expect it to):

Code:
adamwest:keepassx bmayes$ /Applications/KeePassX.app/Contents/MacOS/KeePassX ~/Documents/Example.kdb 
"/Users/bmayes/Documents/Example.kdb"

However, if I use the open command from terminal it doesn't print anything and doesn't open the file -- it just opens the application and never opens the file:

Code:
adamwest:keepassx bmayes$ open ~/Documents/Example.kdb 
adamwest:keepassx bmayes$

I think this might have something to do with the fact that it's using the Cocoa framework and actually calling the application::eek:penFile function instead of passing the name of the file as an argument to argv?

NSApplication Class Reference
 
Joined
Jun 25, 2005
Messages
3,231
Reaction score
112
Points
63
Location
On the road
Your Mac's Specs
2011 MBP, i7, 16GB RAM, MBP 2.16Ghz Core Duo, 2GB ram, Dual 867Mhz MDD, 1.75GB ram, ATI 9800 Pro vid
I haven't played with that so I Googled it found this at O'Reilly.

There might also be the need to register the file extension with an application.
This link discusses that. In fact this may be the better link of the two.
 
OP
G
Joined
Mar 22, 2009
Messages
6
Reaction score
0
Points
1
Nevermind, we were able to get it working without using the Info.plist file. Thanks for looking though.
 

Shop Amazon


Shop for your Apple, Mac, iPhone and other computer products on Amazon.
We are a participant in the Amazon Services LLC Associates Program, an affiliate program designed to provide a means for us to earn fees by linking to Amazon and affiliated sites.
Top