New To Mac-Forums?

Welcome to our community! Join the discussion today by registering your FREE account. If you have any problems with the registration process, please contact us!

Get your questions answered by community gurus Advice and insight from world-class Apple enthusiasts Exclusive access to members-only contests, giveaways and deals

Join today!

 
Start a Discussion
 

Mac-Forums Brief

Subscribe to Mac-Forums Brief to receive special offers from Mac-Forums partners and sponsors

Join the conversation RSS
OS X - Development and Darwin Discussion and questions about development for Mac OS X.

Info.plist to *open* a file


Post Reply New Thread Subscribe

 
Thread Tools
gamblor01

 
Member Since: Mar 22, 2009
Posts: 6
gamblor01 is on a distinguished road

gamblor01 is offline
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::openFile function instead of passing the name of the file as an argument to argv?

NSApplication Class Reference
QUOTE Thanks
xstep

 
xstep's Avatar
 
Member Since: Jun 25, 2005
Location: On the road
Posts: 3,231
xstep is a name known to allxstep is a name known to allxstep is a name known to allxstep is a name known to allxstep is a name known to allxstep is a name known to allxstep is a name known to all
Mac Specs: 2011 MBP, i7, 16GB RAM, MBP 2.16Ghz Core Duo, 2GB ram, Dual 867Mhz MDD, 1.75GB ram, ATI 9800 Pro vid

xstep is offline
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.

CameraTime - Time lapse photography for novice and advanced users.

When asking questions, post the version of your software. You'll receive better answers.

Please post your results to the thread as it is good feedback.
QUOTE Thanks
gamblor01

 
Member Since: Mar 22, 2009
Posts: 6
gamblor01 is on a distinguished road

gamblor01 is offline
Nevermind, we were able to get it working without using the Info.plist file. Thanks for looking though.
QUOTE Thanks

Post Reply New Thread Subscribe


« noob shell scripting question | Dashcode open formular over JavaScript »
Thread Tools

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off
Forum Jump

Similar Threads
Thread
Thread Starter
Forum
Replies
Last Post
VCD, .dat file - trying to save to disc jakenoble Movies and Video 1 09-15-2007 05:10 PM
Not too pleased with new iMac JunMacTech Apple Desktops 14 12-05-2005 07:13 PM
Show Item Info inflexion OS X - Operating System 15 10-24-2005 10:34 PM

All times are GMT -4. The time now is 10:42 PM.

Powered by vBulletin
Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
X

Welcome to Mac-Forums.com

Create your username to jump into the discussion!

New members like you have made this community the ultimate source for your Mac since 2003!


(4 digit year)

Already a member?