NAME
FreeDesktop::Icons - Use icon libraries quick & easy
SYNOPSIS
my $iconlib = new FreeDeskTop::Icons;
$iconlib->theme('Oxygen');
$iconlib->size('16');
my $imagefile = $iconlib->get('edit-copy');
DESCRIPTION
This module gives access to icon libraries on your system. It more ore less conforms to the Free Desktop specifications here: https://specifications.freedesktop.org/icon-theme-spec/icon-theme-spec-latest.html
Furthermore it allows you to add your own icon folders through the rawpath method.
We have made provisions to make it work on Windows as well.
The constructor takes a list of folders where it finds the icons libraries. If you specify nothing, it will assign default values for:
Windows: $ENV{ALLUSERSPROFILE} . '\Icons'. This package will not create the folder if it does not exist. See also the README.md included in this distribution.
Others: $ENV{HOME} . '/.local/share/icons', and the folder 'icons' in $ENV{XDG_DATA_DIRS}.
METHODS
- availableContexts($theme, [ $name, $size ] );
-
Returns a list of available contexts. If you set $name to undef if will return all contexts of size $size. If you set $size to undef it will return all contexts associated with icon $name. If you set $name and $size to undef it will return all known contexts in the theme. out $size it returns a list of all contexts found in $theme.
- availableIcons($theme, [ $size, $context ] );
-
Returns a list of available icons. If you set $size to undef the list will contain names it found in all sizes. If you set $context to undef it will return names it found in all contexts. If you leave out both then you get a list of all available icons. Watch out, it might be pretty long.
- availableThemes
-
Returns a list of available themes it found while initiating the module.
- availableSizes($theme, [ $name, $context ] );
-
Returns a list of available contexts. If you leave out $size it returns a list of all contexts found in $theme.
- context(?$context?)
-
Set and return the preferred context to search in.
- get($name, ?$size?, ?$context?, ?\$resize?)
-
Returns the full filename of an image in the library. Finds the best suitable version of the image in the library according to $size and $context. If you specify \$resize get will attempt to return an icon of a different size if it cannot find the requested size. If it eventually returns an image of another size, it sets $resize to 1. This gives the opportunity to scale the image to the requested icon size. All parameters except $name are optional.
- getFolders($theme)
-
Returns a reference to the folders hash defined in the theme.index of $theme.
- getGeneral($theme, ?$key?)
-
Returns a reference to the folders hash defined in the theme.index of $theme. If you specify $key it will return the value of that key in the hash.
- getPath($theme)
-
Returns the full path of the theme folder of $theme.
- getTheme($theme)
-
Returns the theme data hash of $theme. Returns undef if $theme is not found.
- rawpath(?\@folders?)
-
Sets and returns a reference to a list of folders where raw icons can be found.
- size(?$size?)
-
Sets and returns the preferred size to search for.
- themeExists(?$theme?)
-
returns a boolean.
- theme(?$theme?)
-
Sets and returns the theme to search in.
LICENSE
Same as Perl.
AUTHOR
Hans Jeuken (hanje at cpan dot org)
BUGS
Unknown. If you find any, please contact the author.