Function lookupIcon

Lookup icon alternatives in icon themes. It uses icon theme cache wherever it's loaded. If searched icon is found in some icon theme all subsequent themes are ignored.

void lookupIcon(alias subdirFilter, IconThemes, BaseDirs, Exts, OutputRange) (
  string iconName,
  IconThemes iconThemes,
  BaseDirs searchIconDirs,
  Exts extensions,
  OutputRange sink,
  Flag!"reverse" reverse = No.reverse
)
if (isInputRange!IconThemes && isForwardRange!BaseDirs && isForwardRange!Exts && is(ElementType!IconThemes : const(IconThemeFile)) && is(ElementType!BaseDirs : string) && is(ElementType!Exts : string) && isOutputRange!(OutputRange, IconSearchResult!(ElementType!IconThemes)));

This function may require many stat calls, so beware. Use subdirFilter to filter icons by IconSubDir properties (e.g. by size or context) to decrease the number of searchable items and allocations. Loading IconThemeCache may also descrease the number of stats.

Parameters

NameDescription
iconName Icon name.
iconThemes Icon themes to search icon in.
searchIconDirs Case icon directories.
extensions Possible file extensions of needed icon file, in order of preference.
sink Output range accepting IconSearchResults.
reverse Iterate over icon theme sub-directories in reverse way. Usually directories with larger icon size are listed the last, so this parameter may speed up the search when looking for the largest icon.

Note

Specification says that extension must be ".png", ".xpm" or ".svg", though SVG is not required to be supported. Some icon themes also contain .svgz images.

Example

lookupIcon!(subdir => subdir.context == "Places" && subdir.size >= 32)(
    "folder", iconThemes, baseIconDirs(), [".png", ".xpm"],
    delegate void (IconSearchResult!IconThemeFile item) {
        writefln("Icon file: %s. Context: %s. Size: %s. Theme: %s", item.filePath, item.subdir.context, item.subdir.size, item.iconTheme.displayName);
    });

See Also

baseIconDirs, lookupNonThemedIcon