Main content type is not honored over aliases.
Submitted by A.G.
Link to original bug (#734459)
Description
Let say, I have in ~/.local/share/applications/mimeapps.list next statement:
[Default Applications] application/xml=kate.desktop text/xml=leafpad.desktop
In this case the g_app_info_get_default_for_type("application/xml") will return leafpad. If ~/.local/share/applications/mimeapps.list have that:
[Default Applications] text/xml=leafpad.desktop application/xml=kate.desktop
then g_app_info_get_default_for_type("application/xml") will return kate. And text/xml is defined as alias for application/xml so g_content_type_guess() for some-file.xml will return application/xml, not text/xml, so when you change default association for the file, the content of application/xml=... line is changed, leaving text/xml=... line intact. In result in the first case above it becomes impossible to set real association for application/xml without manual intervention into ~/.local/share/applications/mimeapps.list file contents because text/xml=leafpad.desktop statement will always override actual setting.
To avoid that issue I believe the main content type should have priority over any aliases in calculating values returned by g_app_info_get_default_for_type() or g_app_info_get_all_for_type().