extending mime-type def with generic-icon

Bastien Nocera hadess at hadess.net
Mon Oct 18 05:20:22 PDT 2010


On Sun, 2010-10-17 at 21:24 -0400, Matthew Monaco wrote:
> This is my first foray into mime-types. I am trying to add a new .xml file to
> /usr/share/mime/packages:
> 
> =====================================================================================
> <?xml version="1.0" encoding="UTF-8"?>
> <mime-info xmlns='http://www.freedesktop.org/standards/shared-mime-info'>
> 
>          <mime-type type="text/x-matlab">
>                  <comment>MATLAB script/function</comment>
>                  <sub-class-of type="text/plain"/>
>                  <magic priority="10">
>                          <match value="%" type="string" offset="0"/>
>                  </magic>
>                  <magic priority="50">
>                          <match value="function" type="string" offset="0"/>
>                  </magic>
>                  <glob pattern="*.m" weight="60"/>
>                  <alias type="text/x-octave"/>
>                  <generic-icon name="matlab-m"/>
>          </mime-type>
> 
>          <mime-type type="image/x-matlab-fig">
>                  <comment>MATLAB figure</comment>
>                  <magic priority="50">
>                          <match value="MATLAB" type="string" offset="0"/>
>                  </magic>
>                  <glob pattern="*.fig" weight="60"/>
>                  <generic-icon name="matlab-fig"/>
>          </mime-type>
> 
>          <mime-type type="application/x-matlab-data">
>                  <comment>MATLAB data file</comment>
>                  <magic priority="50">
>                          <match value="MATLAB" type="string" offset="0"/>
>                  </magic>
>                  <glob pattern="*.mat" weight="60"/>
>                  <generic-icon name="matlab-mat"/>
>          </mime-type>
> 
> </mime-info>
> =====================================================================================
> 
> 1) Is it "legal" to define text/x-matlab here since it's already in 
> freedesktop.org.xml? If so, am I adding to the definition, or completely 
> overriding it? Which def would take priority?

It should take over it (but that's not the problem here).

> 2) I'm having trouble with the generic-icon feature. My icon for the .mat file 
> works fine, but the icons for .m and .fig files are not working. The icons are 
> in /usr/share/icons/hicolor/{16x16...256x256}/mimetypes/*.png.

The generic-icon feature is not there to theme your mime-types. From:
http://specifications.freedesktop.org/shared-mime-info-spec/shared-mime-info-spec-0.20.html


>       * generic-icon elements specify the icon to use as a generic
>         icon for this particular mime-type, given by
>         the name attribute. This is used if there is no specific icon
>         (see icon for how these are found). These are used for
>         categories of similar types (like spreadsheets or archives)
>         that can use a common icon. The Icon Naming Specification
>         lists a set of such icon names. If this element is not
>         specified then the mimetype is used to generate the generic
>         icon by using the top-level media type (e.g. "video" in
>         "video/ogg") and appending "-x-generic" (i.e.
>         "video-x-generic" in the previous example). Only
>         one generic-icon element is allowed.

Your items will already be assigned the "text-x-generic" icon. Follow
the icon theme specification to assign icons to your mime-types.

Cheers



More information about the xdg mailing list