Function MimeAppsListFile.setAddedAssocations
Set list of desktop ids as assocations for mimeType
. This overwrites existing assocations.
void setAddedAssocations(Range)
(
string mimeType,
Range desktopIds
) @trusted
if (isInputRange!Range && is(ElementType!Range : string));
Note
This only changes the object, but not file itself.
See Also
Example
MimeAppsListFile appsList = new MimeAppsListFile();
appsList .removeAssociation("text/plain", "geany.desktop");
assert(appsList .removedAssociations() !is null);
assert(appsList .removedAssociations() .appsForMimeType("text/plain") .equal(["geany.desktop"]));
appsList .removeAssociation("image/png", null);
assert(!appsList .removedAssociations() .contains("image/png"));
string contents =
`[Default Applications]
text/plain=geany.desktop
[Added Associations]
text/plain=emacs.desktop;geany.desktop;kde4-kate.desktop;`;
appsList = new MimeAppsListFile(iniLikeStringReader(contents));
appsList .removeAssociation("text/plain", "geany.desktop");
assert(appsList .removedAssociations() .appsForMimeType("text/plain") .equal(["geany.desktop"]));
assert(appsList .addedAssociations() .appsForMimeType("text/plain") .equal(["emacs.desktop", "kde4-kate.desktop"]));
assert(!appsList .defaultApplications() .contains("text/plain"));
contents =
`[Added Associations]
text/plain=geany.desktop;`;
appsList = new MimeAppsListFile(iniLikeStringReader(contents));
appsList .removeAssociation("text/plain", "geany.desktop");
assert(appsList .removedAssociations() .appsForMimeType("text/plain") .equal(["geany.desktop"]));
assert(!appsList .addedAssociations() .contains("text/plain"));