Desktop Actions and mimetypes

Jannis Pohlmann jannis at
Sun Feb 20 07:29:21 PST 2011

On Sun, 20 Feb 2011 00:05:05 +0100 (CET)
Pierre Wieser <pwieser at> wrote:

> Hi,
> In my small application, desktop actions are supposed to be displayed
> depending of the mimetype of files currently selected in the
> file-manager.
> I am able to find the mimetype of the file, but I feel it is not
> enough.
> I understand that mimetypes are organized as some sort of hierarchy,
> so I would need to have something like a is_of_mimetype() function,
> which would not only check _the_ mimetype of a file, but also (maybe
> recursively ?) all parent mimetypes.
> Google has not been my friend in this matter. Have someone an idea on
> how to do this ?

GIO does something like this in g_content_type_is_a():

As you can see it uses xdgmime which is shipped along with the GLib
source code (gio/xdgmime/ in the glib repository). That's not on
Windows though where g_content_type_is_a() is implemented differently
(also in gcontenttype.c).

Hope this helps,

More information about the xdg mailing list