How to launch user's preferred application for a file

I'm not an expert in Gnome programming and I have run into a problem I
cannot find the solution of.

If I in a program have the name of a local file, and nothing more, how
do I launch the user's default or preferred application for that file?

There must be something in the gnome libraries that can do that for me,
more or less. Nautilus does it, but just running "nautilus $FILE"
doesn't work as I want it, because nautilus gives precedence to its own
internal viewers first. If I run "nautilus xx.gnumeric", I don't get
gnumeric launched with the file, but a Gnumeric View within nautilus.
If I double click on the file in nautilus, gnumeric is launched, not the
nautilus view for gnumeric files.

So, what's the magic needed? I think I have been through all the gnome
API reference and google must be tired of me by now.  To be honest, I
expected something simple, like gnome_show_url, which deduces the mime
type of the file, looks up the preferred application for that mime type,
and launches the application with the file.

René Seindal (rene seindal dk)

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