Name of icon to search as defined by Icon Theme Specification (i.e. without path and extension parts).
Preferred icon size to get.
Range of icontheme.file.IconThemeFile objects.
Base icon directories.
Allowed file extensions.
Allow searching for non-themed icon if could not find icon in themes (non-themed icon can be any size).
Icon file path or empty string if 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 closer size. Therefore the icon found in the more preferred theme always has presedence over icons from other themes.
auto baseDirs = ["test"]; auto iconThemes = [openIconTheme("Tango", baseDirs), openIconTheme("hicolor", baseDirs)]; string found; //exact match found = findClosestIcon("folder", 32, iconThemes, baseDirs); assert(found == buildPath("test", "Tango", "32x32/places", "folder.png")); // with subdir filter found = findClosestIcon!(subdir => subdir.context == "Places")("folder", 32, iconThemes, baseDirs); assert(found == buildPath("test", "Tango", "32x32/places", "folder.png")); // not exact match found = findClosestIcon!(subdir => subdir.context == "Places")("folder", 24, iconThemes, baseDirs); assert(found == buildPath("test", "Tango", "32x32/places", "folder.png")); // no match, wrong subdir found = findClosestIcon!(subdir => subdir.context == "MimeTypes")("folder", 32, iconThemes, baseDirs); assert(found.empty); //hicolor has exact match, but Tango is more preferred. found = findClosestIcon("folder", 64, iconThemes, baseDirs); assert(found == buildPath("test", "Tango", "32x32/places", "folder.png")); //find xpm found = findClosestIcon("folder", 32, iconThemes, baseDirs, [".xpm"]); assert(found == buildPath("test", "Tango", "32x32/places", "folder.xpm")); //lookup non-themed found = findClosestIcon("pidgin", 96, iconThemes, baseDirs); assert(found == buildPath("test", "pidgin.png")); //don't lookup non-themed found = findClosestIcon("pidgin", 96, iconThemes, baseDirs, defaultIconExtensions, No.allowNonThemed); assert(found.empty);
findClosestThemedIcon, icontheme.paths.baseIconDirs, lookupIcon, findNonThemedIcon, iconSizeDistance
Find icon of the closest size. It uses icon theme cache wherever possible. The first perfect match is used. This is similar to findClosestThemedIcon, but returns file path only and allows to search for non-themed icons.