findLargestThemedIcon

Find icon of the largest size. It uses icon theme cache wherever possible.

  1. auto findLargestThemedIcon(string iconName, IconThemes iconThemes, BaseDirs searchIconDirs, Exts extensions)
    findLargestThemedIcon
    (
    alias subdirFilter = (a => true)
    IconThemes
    BaseDirs
    Exts
    )
    (
    string iconName
    ,
    IconThemes iconThemes
    ,,)
  2. auto findLargestThemedIcon(string iconName, IconThemes iconThemes, BaseDirs searchIconDirs)

Parameters

iconName string

Name of icon to search as defined by Icon Theme Specification (i.e. without path and extension parts).

iconThemes IconThemes
searchIconDirs BaseDirs

Base icon directories.

extensions Exts

Allowed file extensions.

Return Value

Type: auto

IconSearchResult. filePath will be empty if icon is not found. Note: If icon of some size was found in the icon theme, this algorithm does not check following themes, even if they contain icons with larger size. Therefore the icon found in the most preferred theme always has presedence over icons from other themes.

Examples

auto baseDirs = ["test"];
auto iconThemes = [openIconTheme("Tango", baseDirs), openIconTheme("hicolor", baseDirs)];

auto found = findLargestThemedIcon("folder", iconThemes, baseDirs);
assert(found.filePath == buildPath("test", "Tango", "128x128/places", "folder.png"));
assert(found.subdir.size == 128);
assert(found.subdir.context == "Places");
assert(found.iconTheme.internalName == "Tango");

found = findLargestThemedIcon!(subdir => subdir.context == "Places")("folder", iconThemes, baseDirs);
assert(found.filePath == buildPath("test", "Tango", "128x128/places", "folder.png"));

found = findLargestThemedIcon!(subdir => subdir.context == "Actions")("folder", iconThemes, baseDirs);
assert(found.filePath.empty);

found = findLargestThemedIcon("desktop", iconThemes, baseDirs);
assert(found.filePath == buildPath("test", "Tango", "32x32/places", "desktop.png"));
assert(found.subdir.size == 32);

found = findLargestThemedIcon("desktop", iconThemes, baseDirs, [".svg", ".png"]);
assert(found.filePath == buildPath("test", "Tango", "scalable/places", "desktop.svg"));
assert(found.subdir.type == IconSubDir.Type.Scalable);

See Also

findLargestIcon, icontheme.paths.baseIconDirs, lookupIcon, findNonThemedIcon

Meta