Re: How to launch user's preferred application for a file



On Sun, Sep 07, 2003 at 12:47:48PM +0200, Christophe Fergeau wrote:
> > 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.
> 
> gnome_url_show should do what you want (this is defined in libgnome) :)
> Alternatively, if you are using gnome 2.3, libgnome ships a gnome-open
> binary which can be useful in scripts

This is not how I read the documentation for gnome_url_show():

    Displays the given URL in an appropriate viewer. The appropriate
    viewer is user definable. It is determined by extracting the
    protocol from the url, then seeing if the
    /desktop/gnome/url-handlers/<protocol>/command key exists in the
    configuration database. It it does, this entry is used as the
    template for the command.

    If no protocol specific handler exists, the
    /desktop/gnome/url-handlers/unknown/command key is used to determine
    the viewer.

    Once a viewer is determined, it is called with the url as a
    parameter. If any errors occur, they are returned in the error
    parameter. These errors will either be in the GNOME_URL_ERROR,
    GNOME_SHELL_ERROR, or G_SPAWN_ERROR domains.

When I look up handlers in /desktop/gnome/url-handlers/ I get

file  -> nautilus
unknown -> mozilla
application -> nautilus

In neither case will I get gnumeric started for a .gnumeric file, at
least not immediately.   A gnome-open program will solve the problem,
because it can be set up as a handler for unknown or application urls.

I have tried out a program that uses gnome_url_show to show a gnumeric
file or an image, and in both cases I get a nautilus window showing the
file, not my preferred application as I get when double clicking on the
file in nautilus.


-- 
René Seindal (rene seindal dk)			http://sights.seindal.dk/



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