Skip to content

Commit

Permalink
Update examples
Browse files Browse the repository at this point in the history
  • Loading branch information
FreeSlave committed Apr 25, 2016
1 parent e8645c1 commit b9b6220
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 5 deletions.
1 change: 1 addition & 0 deletions README.md
Expand Up @@ -145,6 +145,7 @@ By default search only in hicolor theme:
You can specify additional theme:

dub run :findicon -- --theme=gnome folder
dub run :findicon -- --theme=oxygen text-plain

And preferred size:

Expand Down
10 changes: 7 additions & 3 deletions examples/findicon/source/app.d
Expand Up @@ -2,6 +2,7 @@ import std.stdio;
import std.getopt;
import std.algorithm;
import std.array;
import std.typecons;

import isfreedesktop;
import icontheme;
Expand All @@ -13,19 +14,22 @@ int main(string[] args)
string[] baseDirs;
string extensionsStr;
bool useCache;
auto allowFallbackFlag = Yes.allowFallbackIcon;

try {
getopt(args, "theme", "Icon theme to search icon in. If not set it tries to find fallback.", &theme,
"size", "Preferred size of icon. If not set it will look for biggest icon.", &size,
"baseDir", "Base icon path to search themes. This option can be repeated to specify multiple paths.", &baseDirs,
"extensions", "Possible icon files extensions to search separated by ':'. By default .png and .xpm will be used.", &extensionsStr,
"useCache", "Use icon theme cache when possible", &useCache
"useCache", "Use icon theme cache when possible", &useCache,
"allowFallback", "Allow non-themed fallback icon if could not find in themes", &allowFallbackFlag
);

if (args.length < 2) {
throw new Exception("Icon is not set");
}


string iconName = args[1];

string[] searchIconDirs;
Expand Down Expand Up @@ -74,9 +78,9 @@ int main(string[] args)

string iconPath;
if (size) {
iconPath = findClosestIcon(iconName, size, iconThemes, searchIconDirs, extensions);
iconPath = findClosestIcon(iconName, size, iconThemes, searchIconDirs, extensions, allowFallbackFlag);
} else {
iconPath = findLargestIcon(iconName, iconThemes, searchIconDirs, extensions);
iconPath = findLargestIcon(iconName, iconThemes, searchIconDirs, extensions, allowFallbackFlag);
}

if (iconPath.length) {
Expand Down
2 changes: 1 addition & 1 deletion examples/test/source/app.d
Expand Up @@ -55,7 +55,7 @@ int main(string[] args)
writeln("Reading icon theme file: ", path);
}
try {
theme = new IconThemeFile(path, IconThemeFile.ReadOptions.ignoreGroupDuplicates);
theme = new IconThemeFile(path, IconThemeFile.ReadOptions.noOptions);
}
catch(IniLikeException e) {
stderr.writefln("Error reading %s: at %s: %s", path, e.lineNumber, e.msg);
Expand Down
2 changes: 1 addition & 1 deletion source/icontheme/file.d
Expand Up @@ -293,7 +293,7 @@ final class IconThemeFile : IniLikeFile
/**
* Default options for desktop file reading.
*/
enum defaultReadOptions = ReadOptions.ignoreUnknownGroups | ReadOptions.skipUnknownGroups | ReadOptions.preserveComments;
enum defaultReadOptions = ReadOptions.ignoreUnknownGroups | ReadOptions.skipUnknownGroups | ReadOptions.preserveComments | IconThemeFile.ReadOptions.ignoreGroupDuplicates;

protected:
@trusted bool isDirectoryName(string groupName)
Expand Down

0 comments on commit b9b6220

Please sign in to comment.