Re: [Nautilus-list] Open with Other -- how does this work, anyway?



On Thu, 2001-11-01 at 13:21, Darin Adler wrote:
> 
> The "File Types and Programs" panel, under the "Document Handlers" category
> in the GNOME Control Center is what allows you to configure which programs
> are offered for which MIME types. It also allows you to associate extensions
> with particular MIME types.

This is what, as far as I can tell, doesn't exist any more in 
control-center-1.5.9-ximian.1. (It now has two sections, "Main",
which contains "Background", "Default Applications", "HTML Viewer",
"Keyboard", "Mouse", "Screensaver", "Sound", and "Startup Hint",
and "System", which contains the Ximian setup tools -- X, network,
etc.) Like I said, I'll take that up with Ximian as soon as I figure
out the right channel for doing that.

> Nautilus determines file types using an API that's in gnome-vfs. There are
> three parts to this process in gnome-vfs:
> 
>     a) "magic number" checking of file contents
>     b) hard-coded rules in gnome-vfs code
>     a) mapping file types based on extension
> 
> Part (a) is similar to what file(1) does, but it uses a separate database
> that's part of gnome-vfs, not the one from file(1). Note that this entire
> file typing scheme is not new to gnome-vfs. It was a set of calls from
> gnome-libs that was moved into gnome-vfs and enhanced for use with Nautilus.

Okay. I guess what I need to do is hunt down some gnome-vfs
documentation, or else (groan) the source code.

> I'll leave it up to you to decide if there's a "messier problem" here. It
> seems to me that the main problem is that you couldn't fine the "File Types
> and Programs" panel.

That's the main problem, certainly. :) (Though it never seemed to work
quite properly even when I *was* able to find it. But that's not a Nautilus issue either.)

It's helpful to know now where (gnome-vfs) Nautilus is getting this
information and how (as you explained above) gnome-vfs makes those
decisions. I still think it's icky from a usability perspective --
icky as in unpredictable and confusing -- but it's not a Nautilus
problem except inasmuch as I think it would be helpful to be able
to access some of the file-types-capplet functionality directly 
from within Nautilus, e.g. being able to just associate an app with
the type of the selected file, without having to open up the whole
list of file types, necessarily, and manually enter everything.

Also, it would be nice if, when "Do you want to go [to the File
Types control panel] now?" fails, Nautilus would provide some kind
of error dialog rather than failing silently.

> > For instance, LyX files are easily
> > identified by either their extension or by the fact that they
> > start with the string "#LyX", but I have no idea how to inform
> > Nautilus (or any other part of the system) about that.
> 
> The way to do this as an end user is to use the "File Types and Programs"
> panel.

Can you add to the magic database that way, or can you only create
MIME types based on extensions?

> As a programmer contributing to gnome-vfs, it can be added to the MIME magic
> database. The magic database is not extensible the way the MIME types and
> extensions database is, so we have to update the gnome-vfs distribution
> itself if we want to add "#LyX" as a magic number -- that's something we
> inherited from file(1) and should improve.
> 
> I bet the gnome-vfs maintainers would be happy to add this magic number.

Okay. I will try to figure out who they are and suggest it to them.
Maybe I should subscribe to the gnome-vfs mailing list and complain
there instead. :)

> > Earlier,
> > I ran into the problem that StarOffice 6.0b .sxw files just look
> > like a ZIP archive to Nautilus -- and the same problem, I assume,
> > will arise with any other file format that uses ZIP or gzip or
> > tar+gzip as the last action in its save chain...
> 
> That's a separate problem, a mistake in the design of part (b) of the
> gnome-vfs MIME type system. It has been fixed on HEAD for the next release
> of gnome-vfs. In general, we could use some fancier ways for the extension
> rules to interact with the magic number and hard-coded rules. The question
> is, if a file's contents look like one thing, but it's extension says
> another, which wins?

Interesting question. Maybe there should be some concept of combinations
of extensions and magic numbers? E.g., if I have a ZIP archive with a
.sxw extension, it's a StarOffice document, but if I have, oh, a TIFF
image or something, the fact that it's called foo.sxw can probably be
ignored?

> > Anyway, for LyX and file(1), I suppose I can hack /usr/share/magic,
> > but Joe Home User is going to want a better way.
> 
> As far as file(1) is concerned, there's no interface for changing the magic
> numbers database other than editing the magic file, which will probably be
> overwritten the next time you install a newer file(1).

I guess that doesn't really surprise me. :)

> Nautilus and gnome-vfs don't look at /etc/mailcap.

That's also good to know -- one more thing not to waste time on. 
Thanks. :)

> > but I also see I have files
> > in .gnome/mime-info that say "this file was autogenerated by
> > gnome-vfs-mime-info, DO NOT EDIT". I'm tempted, though, since
> > neither gnome-vfs nor gnome-vfs-extras seems to have any executable
> > files associated with it. Any ideas?
> 
> If you want to add MIME info by hand editing, you can put other files in
> that directory with ".keys" and ".mime" extensions. All files in that
> directory with those extensions will are looked at by gnome-vfs for end-user
> additions.
> 
> You can also edit the files if you like despite the warning. Those are the
> end-user files that are edited by "File Types and Programs". The
> gnome-vfs-mime-info that's referred to in the comments is a part of the
> gnome-vfs library, not the name of a program. The program is the "File Types
> and Programs" panel, which I think is called file-types-capplet.
> 
> There's some documentation of how this works in the gnome-vfs doc directory.
> Specifically, mime-data-specification.txt.

Thanks very much -- I'll have a look.

--David






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