IconThemeFile

Class representation of index.theme file containing an icon theme description.

Constructors

this
this(string fileName, IconThemeReadOptions options)

Reads icon theme from file.

this
this(IniLikeReader reader, IconThemeReadOptions options, string fileName)
this(IniLikeReader reader, string fileName, IconThemeReadOptions options)

Reads icon theme file from range of IniLikeReader, e.g. acquired from iniLikeFileReader or iniLikeStringReader.

this
this()

Constructs IconThemeFile with empty "Icon Theme" group.

Alias This

iconTheme

This alias allows to call functions related to "Icon Theme" group without need to call iconTheme explicitly.

Members

Enums

ExtensionGroupPolicy
enum ExtensionGroupPolicy

Policy about reading extension groups (those start with 'X-').

UnknownGroupPolicy
enum UnknownGroupPolicy

Policy about reading groups with names which meaning is unknown, i.e. it's not extension nor relative directory path.

Functions

bySubdir
auto bySubdir()

Iterating over subdirectories of icon theme.

cache
IconThemeCache cache(IconThemeCache setCache)

Set cache object.

cache
inout(IconThemeCache) cache()

The object of loaded cache.

cachePath
string cachePath()

Path of icon theme cache file.

createGroupByName
IniLikeGroup createGroupByName(string groupName)
Undocumented in source. Be warned that the author may not have intended to support it.
iconTheme
inout(IconThemeGroup) iconTheme()

Icon Theme group in underlying file.

internalName
string internalName()

The name of the subdirectory index.theme was loaded from.

removeGroup
bool removeGroup(string groupName)

Removes group by name. This function will not remove "Icon Theme" group.

tryLoadCache
auto tryLoadCache(Flag!"allowOutdated" allowOutdated)

Try to load icon cache. Loaded icon cache will be used on icon lookup.

unloadCache
void unloadCache()

Unset loaded cache.

Static functions

isDirectoryName
bool isDirectoryName(string groupName)
Undocumented in source. Be warned that the author may not have intended to support it.
joinValues
string joinValues(Range values)

Join range of multiple values into a string using comma as separator. If range is empty, then the empty string is returned.

splitValues
auto splitValues(string values)

Some keys can have multiple values, separated by comma. This function helps to parse such kind of strings into the range.

Structs

IconThemeReadOptions
struct IconThemeReadOptions

Options to manage icon theme file reading

Examples

1     string contents =
2 `# First comment
3 [Icon Theme]
4 Name=Hicolor
5 Name[ru]=Стандартная тема
6 Comment=Fallback icon theme
7 Comment[ru]=Резервная тема
8 Hidden=true
9 Directories=16x16/actions,32x32/animations,scalable/emblems
10 Example=folder
11 Inherits=gnome,hicolor
12 
13 [16x16/actions]
14 Size=16
15 Context=Actions
16 Type=Threshold
17 
18 [32x32/animations]
19 Size=32
20 Context=Animations
21 Type=Fixed
22 
23 [scalable/emblems]
24 Context=Emblems
25 Size=64
26 MinSize=8
27 MaxSize=512
28 Type=Scalable
29 
30 # Will be saved.
31 [X-NoName]
32 Key=Value`;
33 
34     string path = buildPath(".", "test", "Tango", "index.theme");
35 
36     auto iconTheme = new IconThemeFile(iniLikeStringReader(contents), path);
37     assert(equal(iconTheme.leadingComments(), ["# First comment"]));
38     assert(iconTheme.displayName() == "Hicolor");
39     assert(iconTheme.localizedDisplayName("ru") == "Стандартная тема");
40     assert(iconTheme.comment() == "Fallback icon theme");
41     assert(iconTheme.localizedComment("ru") == "Резервная тема");
42     assert(iconTheme.hidden());
43     assert(equal(iconTheme.directories(), ["16x16/actions", "32x32/animations", "scalable/emblems"]));
44     assert(equal(iconTheme.inherits(), ["gnome", "hicolor"]));
45     assert(iconTheme.internalName() == "Tango");
46     assert(iconTheme.example() == "folder");
47     assert(iconTheme.group("X-NoName") !is null);
48 
49     iconTheme.removeGroup("Icon Theme");
50     assert(iconTheme.group("Icon Theme") !is null);
51 
52     assert(iconTheme.cachePath() == buildPath(".", "test", "Tango", "icon-theme.cache"));
53 
54     assert(equal(iconTheme.bySubdir().map!(subdir => tuple(subdir.name(), subdir.size(), subdir.minSize(), subdir.maxSize(), subdir.context(), subdir.type() )),
55                  [tuple("16x16/actions", 16, 16, 16, "Actions", IconSubDir.Type.Threshold),
56                  tuple("32x32/animations", 32, 32, 32, "Animations", IconSubDir.Type.Fixed),
57                  tuple("scalable/emblems", 64, 8, 512, "Emblems", IconSubDir.Type.Scalable)]));
58 
59     version(iconthemeFileTest)
60     {
61         string cachePath = iconTheme.cachePath();
62         assert(cachePath.exists);
63 
64         auto cache = new IconThemeCache(cachePath);
65 
66         assert(iconTheme.cache is null);
67         iconTheme.cache = cache;
68         assert(iconTheme.cache is cache);
69         iconTheme.unloadCache();
70         assert(iconTheme.cache is null);
71 
72         assert(iconTheme.tryLoadCache(Flag!"allowOutdated".yes));
73     }
74 
75     iconTheme.removeGroup("scalable/emblems");
76     assert(iconTheme.group("scalable/emblems") is null);
77 
78     auto itf = new IconThemeFile();
79     itf.displayName = "Oxygen";
80     itf.comment = "Oxygen theme";
81     itf.hidden = true;
82     itf.directories = ["actions", "places"];
83     itf.inherits = ["locolor", "hicolor"];
84     assert(itf.displayName() == "Oxygen");
85     assert(itf.comment() == "Oxygen theme");
86     assert(itf.hidden());
87     assert(equal(itf.directories(), ["actions", "places"]));
88     assert(equal(itf.inherits(), ["locolor", "hicolor"]));

Meta