MimeAppsListFile

Class represenation of single mimeapps.list file containing information about MIME type associations and default applications.

Constructors

this
this(string fileName)

Read mimeapps.list file.

this
this(IniLikeReader reader, string fileName)

Read MIME type associations from IniLikeReader, e.g. acquired from iniLikeFileReader or iniLikeStringReader.

Members

Functions

addCommentForGroup
void addCommentForGroup(string comment, IniLikeGroup currentGroup, string groupName)
Undocumented in source. Be warned that the author may not have intended to support it.
addKeyValueForGroup
void addKeyValueForGroup(string key, string value, IniLikeGroup currentGroup, string groupName)
Undocumented in source. Be warned that the author may not have intended to support it.
addedAssociations
inout(MimeAppsGroup) addedAssociations()

Access "Added Associations" group.

createGroup
IniLikeGroup createGroup(string groupName)
Undocumented in source. Be warned that the author may not have intended to support it.
defaultApplications
inout(MimeAppsGroup) defaultApplications()

Access "Desktop Applications" group.

removedAssociations
inout(MimeAppsGroup) removedAssociations()

Access "Removed Associations" group.

Examples

    string content = 
`[Added Associations]
text/plain=geany.desktop;kde4-kwrite.desktop;
image/png=kde4-gwenview.desktop;gthumb.desktop;

[Removed Associations]
text/plain=libreoffice-writer.desktop;

[Default Applications]
text/plain=kde4-kate.desktop
x-scheme-handler/http=chromium.desktop;iceweasel.desktop;
`;
    auto mimeAppsList = new MimeAppsListFile(iniLikeStringReader(content));
    assert(mimeAppsList.addedAssociations() !is null);
    assert(mimeAppsList.removedAssociations() !is null);
    assert(mimeAppsList.defaultApplications() !is null);
    
    assert(mimeAppsList.addedAssociations().appsForMimeType("text/plain").equal(["geany.desktop", "kde4-kwrite.desktop"]));
    assert(mimeAppsList.removedAssociations().appsForMimeType("text/plain").equal(["libreoffice-writer.desktop"]));
    assert(mimeAppsList.defaultApplications().appsForMimeType("x-scheme-handler/http").equal(["chromium.desktop", "iceweasel.desktop"]));

Meta