GNOME Bugzilla – Bug 678944
gio returns the wrong default applications for some types
Last modified: 2012-06-28 13:40:01 UTC
Using glib 2.32.3 on Ubuntu precise (the same issue happens on a fedora 17 liveCD though):
$ gvfs-mime --query application/x-gnome-saved-search
Default application for 'application/x-gnome-saved-search': firefox.desktop
Only nautilus claims to handle "application/x-gnome-saved-search" in its desktop. The type is subclass of xml that's why the other choices are listed, but the "recommended" choice is nautilus.desktop and it should also be the default one since that's the only handle for the exact type...
gvfs-mime simply calls "g_app_info_get_default_for_type (mimetype, FALSE);"
that simple command shows the bug as well:
$ python -c 'import gio; print gio.app_info_get_default_for_type("application/x-gnome-saved-search", False).get_name()'
Firefox Web Browser
There is a similar issue described on https://bugs.launchpad.net/ubuntu/+source/gvfs/+bug/949823 with "application/x-java-jnlp-file" files (which is also a subclass of xml)
the issue is in gdesktopappinfo.c get_all_desktop_entries_for_mime_type()
for (i = 0; mime_types[i] != NULL; i++)
/* Pick the explicit default application if we got no result earlier
* (ie, for more specific mime types)
if (desktop_entries == NULL)
entry = g_hash_table_lookup (dir->mimeapps_list_defaults_map, mime_type);
if (entry != NULL)
/* Save the default entry if it's the first one we encounter */
if (default_entry == NULL)
default_entry = g_strdup (entry);
so the code goes through the mimetype and it's subclasses:
application/x-gnome-saved-search -> not in defaults.list, do nothing
text/xml -> ubuntu has firefox.xml listed, it uses it
it doesn't look right to pick the preferred handler for a subclassed mimetype over an available handler for the exact mimetype
would it be better to do something like
" if (entry != NULL)
entry_list = g_hash_table_lookup (dir->mime_info_cache_map, mime_type);
if (entry_list != NULL)
/* Just pick an handler for the type otherwise */
if (default_entry == NULL)
default_entry = g_strdup (entry_list->data);
i.e "try to get the default handler for the type and if there is none just pick the first handler in the list"?
Created attachment 217520 [details] [review]
Fix default app lookup wrt parent types and defaults.list
There was an issue when looking up the default handler
for a type where a supertype was listed in defaults.list.
We would pick the default for the parent type even if
there was a handler for the more specific type.
In the case of the new-style defaults marking (
"Default Applications" in mimeapps.list) we were already
checking for a more specific handler befor using a default,
but we also need to do a similar check for the defaults.list
the patch indeed fixes the issue!
There is a bug in this where it ignores the defaults.list contents wrongly in some cases, fixed in: