QQ登录

只需一步,快速开始

 找回密码
 注册

QQ登录

只需一步,快速开始

查看: 2160|回复: 4

注册新文件类型的困惑

[复制链接]
发表于 2005-7-31 21:45:32 | 显示全部楼层 |阅读模式
系统:FC4
X-Windows:gnome 2.10.0

怎样注册一种新的文件类型(比如rmvb)让它们可以有专用图标表示?
谢谢!
发表于 2005-8-1 09:35:55 | 显示全部楼层
这个有一点麻烦,点击上面的“本版精华”,有一个topic比较完整地讨论了这个事情。
回复

使用道具 举报

发表于 2005-8-1 09:46:45 | 显示全部楼层
只知道gnome.2.10里可以任意注册一种新的文件类型,手工设置关联程序就能打开,还没注意过图标能不能显示出来.
回复

使用道具 举报

发表于 2005-8-7 05:51:09 | 显示全部楼层
这样做:
1.在nautilus中右键点击目标文件(这个文件可以在系统中注册过或没有注册过),选择Open with... -> Open with Other Applications..., 从列表中选择适当的应用程序.
2.观察~/.local/share/mime/application/中的文件名,应该为x-extension-xxx.xml,如x-extensio-rmvb.xml等等.
3.在当前使用的图标目录(如/usr/share/icons/Bluecurve/)的48x48/mimetypes/下,创建名为gnome-mime-application-x-extension-xxx.png,如gnome-mime-application-x-extension-rmvb.png.
4.更新当前的图标cache:gtk-update-icon-cache -f /usr/share/icons/Bluecurve.
5.重启nautilus,看看新的文件类型是否用了你定制的图标了.双击文件,看看是不是用你选择的程序打开了.
6.部分Gnome应用程序会用到不同尺寸的图标,你可能需要定制24x24和32x32的相应图标.
回复

使用道具 举报

发表于 2005-8-7 09:54:17 | 显示全部楼层
楼上的说的比较全了,其实官方faq上面就有的:
How do I add new MIME types to GNOME?

Since GNOME 2.10, MIME types are stored in the new FreeDesktop shared-mime-info database. However, gnome-control-center has not been updated to allow one to easily add MIME types to this database. Therefore, if applications such as Nautilus complain that there is no MIME type associated with a particular file, using the Open With tab under Properties not work.

New MIME types can be added in one of two places. They can either be added system-wide for all users, or added locally on a per-user basis. System-wide MIME types must be added to either ${LOCALBASE}/share/mime or ${X11BASE}/share/mime, where as local MIME types must be added to ~/.local/share/mime. In both cases, the procedure is the same.

To define a new MIME type, you must create an application and a packages file to describe it. The application file will be named for the MIME type, and contain its name and a brief comment describing it. The packages file will list all the extensions associated with this MIME type as well as any special file magic that can be used to identify files without an extension.

For example, if we wanted to add a new local MIME type for Windows HTML Help files (i.e. .chm files) called application/x-chm, we would do the following. First, we would create the directories ~/.local/share/mime/application and ~/.local/share/mime/packages if they did not already exist. Then, we create an application file called x-chm.xml that we will place in ~/.local/share/mime/application. The file looks like:

<xml version="1.0" encoding="UTF-8"?>
<mime-type
xmlns="http://www.freedesktop.org/standards/shared-mime-info"
type="application/x-chm">
  <comment>Windows HTML Help file</comment>
</mime-type>
      

Next, we create a packages file called chm.xml that we will place in ~/.local/share/mime/packages. The file looks like:

<xml version="1.0" encoding="UTF-8"?>
<mime-info
xmlns="http://www.freedesktop.org/standards/shared-mime-info">
  <mime-type type="application/x-chm">
    <comment>Windows HTML Help file</comment>
    <glob pattern="*.chm" />
  </mime-type>
</mime-info>
      

Once the files have been created, the MIME database must be updated. To do that, run the command:

% update-mime-database ~/.local/share/mime
      

Finally (and unfortunately), you must logout and log back in to GNOME for the changes to fully take effect. Nautilus' Properties->Open With interface can now be used to associate an application to this MIME type. Hopefully all of this will be made much easier in a future GNOME release.
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 注册

本版积分规则

GMT+8, 2024-11-25 14:17 , Processed in 0.047886 second(s), 15 queries .

© 2021 Powered by Discuz! X3.5.

快速回复 返回顶部 返回列表