Padre

 view release on metacpan or  search on metacpan

lib/Padre/Wx/Icon.pm  view on Meta::CPAN

package Padre::Wx::Icon;

# It turns out that icon management needs to be more complex than just
# a few utility functions in Padre::Wx, and that it needs an entire
# library of its own.

# This library attempts to integrate padre with the freedesktop.org
# icon specifications using a highly limited and mostly
# wrong implementation of the algorithms they describe.
# http://standards.freedesktop.org/icon-naming-spec
# http://standards.freedesktop.org/icon-theme-spec

# Initially we only support the use of icons in directories bundled
# with Padre. Later, we'll probably be forced by distro-packagers and
# users to support integration with system icon themes.

use 5.008;
use strict;
use warnings;
use File::Spec   ();
use Params::Util ();
use Padre::Util  ();
use Padre::Wx    ();

our $VERSION = '1.02';

# For now apply a single common configuration
use constant SIZE   => '16x16';
use constant EXT    => '.png';
use constant THEMES => ( 'gnome218', 'padre' );
use constant ICONS  => Padre::Util::sharedir('icons');

# Supports the use of theme-specific "hints",
# when we want to substitute a technically incorrect
# icon on a theme by theme basis.
my %HINT = (
	'gnome218' => {},
);

# Lay down some defaults from our common
# constants
my %PREFS = (
	size  => SIZE,
	ext   => EXT,
	icons => ICONS,
);

our $DEFAULT_ICON_NAME = 'status/padre-fallback-icon';
our $DEFAULT_ICON;

# Convenience access to the official Padre icon
sub PADRE {
	return icon( 'logo', { size => '64x64' } );
}

# On windows, you actually need to provide it with a native icon file that
# contains multiple sizes so it can choose from it.
sub PADRE_ICON_FILE {
	my $ico = File::Spec->catfile( ICONS, 'padre', 'all', 'padre.ico' );
	return Wx::IconBundle->new($ico);
}




#####################################################################
# Icon Resolver

# Find an icon bitmap and convert to a real Wx::Icon in a single call
sub icon {
	my $image = find(@_);



( run in 2.072 seconds using v1.01-cache-2.11-cpan-cdf2f3d4e48 )