From bf14f1e0317f02904356a33b35612d7a96623210 Mon Sep 17 00:00:00 2001 From: Ryan Lortie Date: Sun, 9 Nov 2014 11:59:28 -0500 Subject: [PATCH] mime-apps: change rules for default apps Reverse the earlier language that selecting default apps has nothing to do with associations. We now require that an app is associated with a particular type before it can be considered as the default for that type. This resolves a couple of tricky cases in terms of expected behaviour when removing the association between an app and a particular type. - there is no need to explicitly select a "new default" at this point which may become uninstalled in the future (which would result in fallback to the application that we removed the association for) - it is now possible to have 'no default app' in case the only app for a given mime type had its association manually removed This does add an additional requirement on implementations, however: - implementations should ensure that a type association exists when between an app and a type when setting that app as the default --- mime-apps/mime-apps-spec.xml | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/mime-apps/mime-apps-spec.xml b/mime-apps/mime-apps-spec.xml index 19349be..d61214b 100644 --- a/mime-apps/mime-apps-spec.xml +++ b/mime-apps/mime-apps-spec.xml @@ -101,23 +101,24 @@ mimetype1=foo5.desktop; Default Application Indicating the default application for a given mimetype is done by writing into the group [Default Applications] in the file mimeapps.list. The [Default Applications] group indicates the default application to be used for a given mimetype. This is for instance the one that will be started when double-clicking on a file in a file manager. If the application is no longer installed, the next application in the list is attempted, and so on. - This example ensures that the application default1.desktop will be used for mimetype1, if it's installed, and otherwise default2.desktop if it's installed: + This example ensures that the application default1.desktop will be used for mimetype1, if it's installed and associated with the type, and otherwise default2.desktop if it's installed and associated: [Default Applications] mimetype1=default1.desktop;default2.desktop; The value is a semicolon-separated list of desktop file IDs (as defined in the desktop entry spec). - In the absence of such an entry, the next mimeapps.list is checked. Once all levels have been checked, if no entry could be found, the implementations should pick the most-preferred .desktop files associated with the mimetype, taking into account added and removed associations as per the previous section. + In the absence of such an entry, the next mimeapps.list is checked. Once all levels have been checked, if no entry could be found, the implementation should pick the most-preferred .desktop files associated with the mimetype, taking into account added and removed associations as per the previous section. The suggested algorithm for determining the default application for a given mimetype is: get the list of desktop ids for the given mimetype under the "Default Applications" group in the first mimeapps.list for each desktop ID in the list, attempt to load the named desktop file, using the normal rules - if a valid desktop file is found, we have found the default application + if a valid desktop file is found, verify that it is associated with the type (as in the previous section) + if a valid association is found, we have found the default application if after all list items are handled, we have not yet found a default application, proceed to the next mimeapps.list file in the search order and repeat if after all files are handled, we have not yet found a default application, select the most-preferred application (according to associations) that supports the type Note that, unlike adding and removing associations, a desktop ID set as the default for an application can refer to a desktop file of the same name found in a directory of higher precedence. - Note as well that the default application for a given type can be an application that is not associated with this type (ie: neither by MimeType= or an added association, or even in the case that the association was specifically removed). Such configurations should be regarded as unusual, however, and implementations should not write mimeapps.list files that create this circumstance. + Note as well that the default application for a given type must be an application that is associated with the type. This means that implementations should either ensure that such an association exists or add one explicitly when setting an application as the default for a type. -- 2.1.0