Re: Need help with mime types & file associations: SOLVED!



I'm not sure what the version numbers are, but by following a bunch of 2002-era mail threads, I did manage to get file associations working in JDS v3. The secret recipe:

1) The association between extension and mime type happens by adding an XML file to /usr/share/mime/packages and running update-mime-database. 2) The association between mime type and application name happens in a .keys file in /usr/share/mime-info/. 3) The associations between application name and the actual application (didn't see that level of abstraction coming, did you?!), happens with a .applications file in /usr/share/application-registry/.

Oh, and you have to run nautilus --quit in order to see any of these changes take effect.

I haven't figured out how to get my icon to show for the mime type yet, but I think it will be easy.

New question: If I did these things in a Linux installer, would file associations work (using some backward-compatibility rules), or do I need to create a .desktop file and do the update-desktop-database stuff for machines running up-to-date versions of gnome and nautilus?

Also: Is /usr/share standard? It seems to serve the function I recall /usr/local/ served in the old days. (Which is kind of ironic, if you think about it ;) The machine they provided me doesn't have a /usr/local at all.

Final question: Would someone on this list be willing to test-drive a Linux installer for me once I've got the Solaris/JDS thing worked out?

-Joshua

On Sep 11, 2006, at 6:01 AM, Alexander Larsson wrote:

On Fri, 2006-09-08 at 10:56 -0400, Joshua Smith wrote:
Nautilus Guri,

First, the caveats: I REALLY REALLY tried to figure this out myself,
and found lots of thoroughly unhelpful hints on the web.  I tried to
look in the Gnome FAQ Wiki, but the web server said "permission
denied", and I tried to search the archive of this mailing list, but
that is broken too.  If there is a better place to post this question,
please let me know.

Problem Summary:

I am trying to configure an installer for my software, such that when
the user tries to open a file with a particular extension, my program
runs and is given that file as it's argument.  (On Windows, I do this
through a bunch of cryptic registry entries; on the Mac, I put some
voodoo into an Info.plist file.)

Details:

1. My file format is really ZIP/JAR with a different extension, just
like OpenOffice docs.
2. I need this to work with Sun JDS, which uses some version of Gnome
and version 2.6.0 of Nautilus.  (I don't know how to find out what
version of Gnome is running.)
3. The desktop is ABSOLUTELY CONVINCED that my files are mime type
application/zip
4. I'm very comfortable with Unix, dating back decades, but I have no
experience whatsoever with modern Unix GUIs

What I think I know:

A) I need to convince the desktop that files ending in .mesonjar are
mime type application/x-meson
B) I need to convince the desktop to open application/x-meson files
using my program

I'm mostly focused on A, since B seems to be pretty well documented
(.desktop files seem to be the key), and I have to get A done before I
can start to think about getting B right.

I read the man page on mime magic, which says that file sniffing is
going to take priority over anything else I do.  That looked bad until
I looked at the magic file, and found the line for ZIP is commented out
because it would keep StarOffice from recognizing its own files
(according to a comment). This does leave me quite mystified as to how
it knows my files are really ZIPs... is there something else that does
the same thing as /etc/gnome-vfs-mime-magic?

This is a bit tricky, as the mime type handling has changed over the
years. If you were using the most recent code adding a shared-mime-info
xml snippet and running update-mime-database would be enough, because
gnome-vfs always prefers the extension magic over sniffing for files
that sniff as zip files these days (for this specific reason).

However, since you don't really know what version of gnome you're using
its a bit tricky. Not to mention that I don't remember in what versions
we changed what exactly.

=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- =-=-= Alexander Larsson Red Hat, Inc
                   alexl redhat com    alla lysator liu se
He's a gun-slinging playboy romance novelist who hides his scarred face behind a mask. She's a supernatural belly-dancing journalist with the soul of a
mighty warrior. They fight crime!






[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]