Info.plist and file association

classic Classic list List threaded Threaded
7 messages Options
Reply | Threaded
Open this post in threaded view
|

Info.plist and file association

Tom Fogg
Been looking at vim 7 binaries just posted on
macvim.org.

One things thats been annoying me for a while is not
being able to associate files with vim so was pleased
to see the note that this had been fixed.

Unfortunately, it still doesnt seem to be working.
Whether this is just me (the file association stuff
seems flaky at the best of times) or if there is a
problem with the Info.plist and PkgInfo files in the
app bundle I'm not sure.

What I have done though, is get the file association
working for me for the first time. Vim now appears in
the 'open this file with' menu which it has never done
before for me. I made some changes to the Info.plist
and PkgInfo files, removed all other copies of vim.app
and ran this command:

sudo
/System/Library/Frameworks/ApplicationServices.framework/Versions/A/Frameworks/LaunchServices.framework/Versions/Current/Support/lsregister
-kill -r -v -f /Applications/Vim.app/

I took the Info.plist file from Smultron, changed some
identifiers and removed some bits.

Heres what I have for Info.plist:

 <?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>
        <key>CFBundleDevelopmentRegion</key>
        <string>English</string>
        <key>CFBundleDocumentTypes</key>
        <array>
                <dict>
                        <key>CFBundleTypeIconFile</key>
                        <string>doc-txt</string>
                        <key>CFBundleTypeName</key>
                        <string>Vim Document</string>
                        <key>CFBundleTypeOSTypes</key>
                        <array>
                                <string>VIM7d</string>
                        </array>
                        <key>CFBundleTypeRole</key>
                        <string>Editor</string>
                        <key>LSItemContentTypes</key>
                        <array>
                                <string>org.vim.vim7.document</string>
                                <string>public.plain-text</string>
                                <string>public.html</string>
                                <string>public.xml</string>
                                <string>public.c-source</string>
                                <string>public.objective-c-source</string>
                                <string>public.c-plus-plus-source</string>
                       
<string>public.objective-c-plus-plus-source</string>
                                <string>public.c-header</string>
                                <string>public.c-plus-plus-header</string>
                                <string>com.sun.java-source</string>
                                <string>com.netscape.javascript-source</string>
                       
<string>com.apple.traditional-mac-plain-text</string>
                                <string>public.shell-script</string>
                                <string>public.csh-script</string>
                                <string>public.perl-script</string>
                                <string>public.python-script</string>
                                <string>public.ruby-script</string>
                                <string>public.php-script</string>
                                <string>com.apple.applescript.text</string>
                                <string>com.apple.applescript.script</string>
                        </array>
                        <key>LSTypeIsPackage</key>
                        <false/>
                </dict>
                <dict>
                        <key>CFBundleTypeExtensions</key>
                        <array>
                                <string>*</string>
                        </array>
                        <key>CFBundleTypeName</key>
                        <string>All documents</string>
                        <key>CFBundleTypeOSTypes</key>
                        <array>
                                <string>****</string>
                        </array>
                        <key>CFBundleTypeRole</key>
                        <string>Editor</string>
                        <key>LSTypeIsPackage</key>
                        <false/>
                </dict>
        </array>
        <key>CFBundleExecutable</key>
        <string>Vim</string>
        <key>CFBundleHelpBookFolder</key>
        <string>Vim Help</string>
        <key>CFBundleHelpBookName</key>
        <string>Vim Help</string>
        <key>CFBundleIconFile</key>
        <string>gui_mac.icns</string>
        <key>CFBundleIdentifier</key>
        <string>org.vim.Vim7</string>
        <key>CFBundleInfoDictionaryVersion</key>
        <string>6.0</string>
        <key>CFBundlePackageType</key>
        <string>APPL</string>
        <key>CFBundleSignature</key>
        <string>Vim7</string>
        <key>CFBundleVersion</key>
        <string>7.0</string>
        <key>NSAppleScriptEnabled</key>
        <string>NO</string>
        <key>NSMainNibFile</key>
        <string>MainMenu</string>
        <key>NSPrincipalClass</key>
        <string>NSApplication</string>
        <key>UTExportedTypeDeclarations</key>
        <array>
                <dict>
                        <key>UTTypeConformsTo</key>
                        <array>
                                <string>public.plain-text</string>
                                <string>public.text</string>
                                <string>public.data</string>
                        </array>
                        <key>UTTypeDescription</key>
                        <string>Vim document</string>
                        <key>UTTypeIconFile</key>
                        <string>doc-txt</string>
                        <key>UTTypeIdentifier</key>
                        <string>org.vim.vim7.document</string>
                        <key>UTTypeTagSpecification</key>
                        <dict>
                                <key>com.apple.ostype</key>
                                <string>VIM7d</string>
                        </dict>
                </dict>
        </array>
</dict>
</plist>

----------

And here is what I have in PkgInfo:

APPLVIM7

----------

The trick for me seemed to be changing the various
identifiers from vim to vim7, which probably suggests
there was something messed up in previous vim
applications ive had on my machine that was getting
remembered.

Anyway, hope this is helpful for someone

Thanks

Tom



               
___________________________________________________________
To help you stay safe and secure online, we've developed the all new Yahoo! Security Centre. http://uk.security.yahoo.com
Reply | Threaded
Open this post in threaded view
|

Re: Info.plist and file association

Benji Fisher
On Thu, Mar 30, 2006 at 10:45:36AM +0100, Tom Fogg wrote:

> Been looking at vim 7 binaries just posted on
> macvim.org.
>
> One things thats been annoying me for a while is not
> being able to associate files with vim so was pleased
> to see the note that this had been fixed.
>
> Unfortunately, it still doesnt seem to be working.
> Whether this is just me (the file association stuff
> seems flaky at the best of times) or if there is a
> problem with the Info.plist and PkgInfo files in the
> app bundle I'm not sure.
>
> What I have done though, is get the file association
> working for me for the first time. Vim now appears in
> the 'open this file with' menu which it has never done
> before for me. I made some changes to the Info.plist
> and PkgInfo files, removed all other copies of vim.app
> and ran this command:
>
> sudo
> /System/Library/Frameworks/ApplicationServices.framework/Versions/A/Frameworks/LaunchServices.framework/Versions/Current/Support/lsregister
> -kill -r -v -f /Applications/Vim.app/

     That looks like a useful thing to know.

     There are at least three things that affect file association:

1. the bundle structure of Vim.app/
2. Info.plist and PkgInfo
3. Finder caching

I think we have fixed #1.  From my testing, #2 is not a problem (at
least, not by itself) but #3 is.  Not knowing about the lsregister
utility, I searched for old versions of Vim.app on my syste, (and there
were a lot!) and deleted them.

     I agree that it is a good idea to update Info.plist, but it is not
high on my personal priority list unless I know that it is actually
causing problems.  Can you try using the Info.plist included in the
distribution and use lsregister to solve the caching problems?

> I took the Info.plist file from Smultron, changed some
> identifiers and removed some bits.
>
> Heres what I have for Info.plist:
>
[snip]
> ----------
>
> And here is what I have in PkgInfo:
>
> APPLVIM7
>
> ----------

     Does anyone else want to test this?

                                        --Benji Fisher
Reply | Threaded
Open this post in threaded view
|

Re: Info.plist and file association

Chris Fonnesbecck
On 3/30/06, Benji Fisher <[hidden email]> wrote:

>
> On Thu, Mar 30, 2006 at 10:45:36AM +0100, Tom Fogg wrote:
> >
> > Heres what I have for Info.plist:
> >
> [snip]
> > ----------
> >
> > And here is what I have in PkgInfo:
> >
> > APPLVIM7
> >
> > ----------
>
>      Does anyone else want to test this?
>

I gave it a try. I updated all of the version-related strings in info.plistto
7.0, and after registering Vim with the lsregister command, it appears to be
working (i.e. files are associating with Vim as you would expect).

C.

--
Chris Fonnesbeck + Atlanta, GA + http://trichech.us
Reply | Threaded
Open this post in threaded view
|

Re: Info.plist and file association

Benji Fisher
On Thu, Mar 30, 2006 at 10:00:16AM -0500, Chris Fonnesbeck wrote:

> On 3/30/06, Benji Fisher <[hidden email]> wrote:
> >
> > On Thu, Mar 30, 2006 at 10:45:36AM +0100, Tom Fogg wrote:
> > >
> > > Heres what I have for Info.plist:
> > >
> > [snip]
> > > ----------
> > >
> > > And here is what I have in PkgInfo:
> > >
> > > APPLVIM7
> > >
> > > ----------
> >
> >      Does anyone else want to test this?
> >
>
> I gave it a try. I updated all of the version-related strings in info.plistto
> 7.0, and after registering Vim with the lsregister command, it appears to be
> working (i.e. files are associating with Vim as you would expect).

     Thanks.  I only see one "6.0".  Did I miss something?  That is
obviously an error, and this patch should fix it.  (This is so simple a
fix that I did not test it.  Living on the edge ...)

*** src/vim7c/src/infplist.xml 2004-06-07 10:32:29.000000000 -0400
--- temp/infplist.xml 2006-03-30 10:49:57.695714484 -0500
***************
*** 5,11 ****
  <dict>
 
  <key>CFBundleInfoDictionaryVersion</key>
! <string>6.0</string>
 
  <key>CFBundleExecutable</key>
  <string>APP_EXE</string>
--- 5,11 ----
  <dict>
 
  <key>CFBundleInfoDictionaryVersion</key>
! <string>APP_VER</string>
 
  <key>CFBundleExecutable</key>
  <string>APP_EXE</string>

I still think that updating Info.plist is a good idea, but (for me) a
low-priority one.

                                        --Benji Fisher
Reply | Threaded
Open this post in threaded view
|

Re: Info.plist and file association

Chris Fonnesbecck
On 3/30/06, Benji Fisher <[hidden email]> wrote:
>
> On Thu, Mar 30, 2006 at 10:00:16AM -0500, Chris Fonnesbeck wrote:
>
> I still think that updating Info.plist is a good idea, but (for me) a
> low-priority one.
>
>
I agree that its not a show-stopper, by any means, but its a usability
hassle that users shouldnt have to mess with. By the way, I think I located
the exact entry that determines whether association works or not. It appears
to be the CFBundleIdentifier key, and not making sure the versions are 7.0.
If I add the missing key, and change nothing else, then run lsregister, it
appears to fix the problem.

C.

--
Chris Fonnesbeck + Atlanta, GA + http://trichech.us
Reply | Threaded
Open this post in threaded view
|

Re: Info.plist and file association

Benji Fisher
On Thu, Mar 30, 2006 at 11:57:40AM -0500, Chris Fonnesbeck wrote:

> On 3/30/06, Benji Fisher <[hidden email]> wrote:
> >
> > On Thu, Mar 30, 2006 at 10:00:16AM -0500, Chris Fonnesbeck wrote:
> >
> > I still think that updating Info.plist is a good idea, but (for me) a
> > low-priority one.
> >
> I agree that its not a show-stopper, by any means, but its a usability
> hassle that users shouldnt have to mess with. By the way, I think I located
> the exact entry that determines whether association works or not. It appears
> to be the CFBundleIdentifier key, and not making sure the versions are 7.0.
> If I add the missing key, and change nothing else, then run lsregister, it
> appears to fix the problem.

     Maybe I was not clear.  If it actually affects file association,
then I give it pretty high priority.  In my testing, the existing
Info.plist is good enough.

     I think my previous suggested patch was wrong-headed.  Please send
it to the bit bucket.

     In your previous post, you had

        <key>CFBundleIdentifier</key>
        <string>org.vim.Vim7</string>

Would it be all right to change this to

        <key>CFBundleIdentifier</key>
        <string>org.vim.Vim-7.0c</string>

Did I miss any other places where the version string should be used?  If
that is the only change we need, then this patch (tested!) should do it:


*** src/vim70c03/src/infplist.xml 2004-06-07 10:32:29.000000000 -0400
--- temp/infplist.xml 2006-03-30 12:35:45.863600293 -0500
***************
*** 4,9 ****
--- 4,11 ----
  <plist version="0.9">
  <dict>
 
+ <key>CFBundleIdentifier</key>
+ <string>org.vim.Vim-APP_VER</string>
  <key>CFBundleInfoDictionaryVersion</key>
  <string>6.0</string>
 

(I tested it as far as checking that this leads to the two lines I
suggested adding to Info.plist, which is generated from infplist.xml .
I did not test that this affected file association.)

                                        --Benji Fisher
Reply | Threaded
Open this post in threaded view
|

Re: Info.plist and file association

Chris Fonnesbecck
On 3/30/06, Benji Fisher <[hidden email]> wrote:

>
> On Thu, Mar 30, 2006 at 11:57:40AM -0500, Chris Fonnesbeck wrote:
> > On 3/30/06, Benji Fisher <[hidden email]> wrote:
>
>
> Would it be all right to change this to
>
>         <key>CFBundleIdentifier</key>
>         <string>org.vim.Vim-7.0c</string>
>
> Did I miss any other places where the version string should be used?
>

That works on my machine, both on my own builds and on the posted beta
binary.

C.

--
Chris Fonnesbeck + Atlanta, GA + http://trichech.us