Skip to content

Commit

Permalink
Remove trailing spaces in examples
Browse files Browse the repository at this point in the history
  • Loading branch information
FreeSlave committed Oct 18, 2017
1 parent ebc67cc commit ccc490b
Show file tree
Hide file tree
Showing 4 changed files with 40 additions and 40 deletions.
12 changes: 6 additions & 6 deletions examples/describe/source/app.d
Expand Up @@ -12,12 +12,12 @@ int main(string[] args)
writeln("Usage: %s <icontheme>", args[0]);
return 0;
}

string themePath = args[1];

try {
IconThemeFile iconTheme;

if (themePath.isAbsolute() && themePath.exists) {
if (themePath.isDir) {
themePath = buildPath(themePath, "index.theme");
Expand All @@ -30,9 +30,9 @@ int main(string[] args)
if (!iconTheme) {
throw new Exception("Could not find theme");
}

}

writeln("Path: ", iconTheme.fileName);
writeln("Internal name: ", iconTheme.internalName);
writeln("Name: ", iconTheme.displayName);
Expand All @@ -46,6 +46,6 @@ int main(string[] args)
stderr.writefln("Error occured: %s", e.msg);
return 1;
}

return 0;
}
28 changes: 14 additions & 14 deletions examples/findicon/source/app.d
Expand Up @@ -15,23 +15,23 @@ int main(string[] args)
string extensionsStr;
bool useCache;
auto allowNonThemed = Yes.allowNonThemed;

try {
getopt(args, "theme", "Icon theme to search icon in. If not set it tries to find fallback.", &theme,
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,
"allowNonThemed", "Allow non-themed fallback icon if could not find in themes", &allowNonThemed
);

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


string iconName = args[1];

string[] searchIconDirs;
if (baseDirs.empty) {
static if (isFreedesktop) {
Expand All @@ -45,13 +45,13 @@ int main(string[] args)
stderr.writefln("Usage: %s [DIRECTORY]...", args[0]);
return 1;
}

string[] extensions = extensionsStr.empty ? [".png", ".xpm"] : extensionsStr.splitter(':').array;


debug writefln("Using directories: %-(%s, %)", searchIconDirs);
debug writeln("Using extensions: ", extensions);

IconThemeFile[] iconThemes;
if (!theme.length) {
theme = currentIconThemeName();
Expand All @@ -65,24 +65,24 @@ int main(string[] args)
iconThemes ~= fallbackTheme;
}
}

debug writeln("Using icon theme files: ", iconThemes.map!(iconTheme => iconTheme.fileName()));

if (useCache) {
foreach(iconTheme; iconThemes) {
if (iconTheme.tryLoadCache()) {
debug writeln("Using icon theme cache for ", iconTheme.internalName());
}
}
}

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

if (iconPath.length) {
writeln(iconPath);
} else {
Expand Down
22 changes: 11 additions & 11 deletions examples/print/source/app.d
Expand Up @@ -14,16 +14,16 @@ int main(string[] args)
string theme;
string[] baseDirs;
string extensionsStr;

try {
getopt(args, "theme", "Icon theme to search icon in. If not set it tries to find fallback.", &theme,
getopt(args, "theme", "Icon theme to search icon in. If not set it tries to find fallback.", &theme,
"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,
"include-hicolor", "Whether to include hicolor theme in results or not. By default false.", &includeHicolor,
"include-nonthemed", "Whether to print icons out of themes or not. By default false.", &includeNonThemed,
"include-base", "Whether to include base themes or not. By default false.", &includeBase
);

string[] searchIconDirs;
if (baseDirs.empty) {
version(OSX) {} else version(Posix) {
Expand All @@ -37,15 +37,15 @@ int main(string[] args)
stderr.writefln("Usage: %s [DIRECTORY]...", args[0]);
return 1;
}

string[] extensions = extensionsStr.empty ? defaultIconExtensions : extensionsStr.splitter(':').array;

IconThemeFile[] iconThemes;
if (theme.length) {
IconThemeFile iconTheme = openIconTheme(theme, searchIconDirs);
if (iconTheme) {
iconThemes ~= iconTheme;

if(includeBase) {
string fallbackThemeName = includeHicolor ? "hicolor" : string.init;
iconThemes ~= openBaseThemes(iconTheme, searchIconDirs, fallbackThemeName);
Expand All @@ -59,14 +59,14 @@ int main(string[] args)
}
}
}

IconSearchResult!(IconThemeFile)[][string][string] results;

foreach(item; lookupThemeIcons(iconThemes, searchIconDirs, extensions)) {
string iconName = item.filePath.baseName.stripExtension;
results[iconName][item.iconTheme.displayName] ~= item;
}

writefln("%s different icon names found", results.length);
foreach(iconName, iconResult; results) {
writefln("%s: ", iconName);
Expand All @@ -78,14 +78,14 @@ int main(string[] args)
}
writeln();
}

if (includeNonThemed) {
writeln("\nNon themed icons:");
foreach(path; lookupNonThemedIcons(searchIconDirs, extensions)) {
writeln(path);
}
}

} catch(Exception e) {
stderr.writeln(e.msg);
return 1;
Expand Down
18 changes: 9 additions & 9 deletions examples/test/source/app.d
Expand Up @@ -11,15 +11,15 @@ int main(string[] args)
{
string[] searchIconDirs;
bool verbose;

try {
getopt(args, "verbose", "Print name of each examined file to standard output", &verbose);
} catch(Exception e) {
stderr.writeln(e.msg);
return 1;
}


if (args.length > 1) {
searchIconDirs = args[1..$];
} else {
Expand All @@ -35,20 +35,20 @@ int main(string[] args)
searchIconDirs = [buildPath(kdeDir, `icons`)];
}
} catch(Exception e) {

}
}
}

if (searchIconDirs.empty) {
stderr.writeln("No icon theme directories given nor could be detected");
stderr.writefln("Usage: %s [DIRECTORY]...", args[0]);
return 1;
}

debug writefln("Using directories: %-(%s, %)", searchIconDirs);
foreach(path; iconThemePaths(searchIconDirs)) {

IconThemeFile theme;
string cachePath;
if (verbose) {
Expand All @@ -63,7 +63,7 @@ int main(string[] args)
catch(Exception e) {
stderr.writefln("Error reading %s: %s", path, e.msg);
}

try {
if (theme) {
cachePath = theme.cachePath;
Expand All @@ -82,6 +82,6 @@ int main(string[] args)
stderr.writefln("Error reading %s: %s", cachePath, e.msg);
}
}

return 0;
}

0 comments on commit ccc490b

Please sign in to comment.