SVN: vfmg/trunk/VFMG/Icons.pm
sparky
sparky at pld-linux.org
Mon Dec 4 04:26:00 CET 2006
Author: sparky
Date: Mon Dec 4 04:25:59 2006
New Revision: 8054
Modified:
vfmg/trunk/VFMG/Icons.pm
Log:
- look for icons only if using them
Modified: vfmg/trunk/VFMG/Icons.pm
==============================================================================
--- vfmg/trunk/VFMG/Icons.pm (original)
+++ vfmg/trunk/VFMG/Icons.pm Mon Dec 4 04:25:59 2006
@@ -3,6 +3,17 @@
use strict;
use warnings;
+my @icondirs = (
+ grep (-d,
+ "$ENV{'HOME'}/.icons/",
+ map({"$_/icons/"} @main::xdg_data_dirs),
+ qw(/usr/share/pixmaps/
+ /usr/share/icons/default.kde/48x48/apps/
+ /usr/share/icons/hicolor/48x48/apps/)
+ ),
+ '',
+);
+
sub preconf() {
eval { $main::opt{icons_dir} = VFMG::Output::icons_dir() }
unless length $main::opt{icons_dir};
@@ -14,8 +25,6 @@
my $conv = (split /\s/, $main::opt{convert})[0];
if ( length `which $conv` ) {
$main::opt{icons} = 1;
- $main::opt{icons_full} = 1;
- $main::opt{icons_ext} = 1;
} else {
$main::opt{icons_scale} = 0;
warn "$conv is not executable, not scaling icons.\n";
@@ -28,9 +37,28 @@
our $scale_icon;
+sub find_icon {
+ my $desk = shift;
+ my $full = shift || $main::opt{icons_full};
+ my @ico = ($desk->{file});
+ unshift @ico, $desk->{Icon} if length $desk->{Icon} and
+ $desk->{Icon} ne $desk->{file};
+ foreach my $ico (@ico) {
+ foreach my $dir (@icondirs) {
+ foreach my $ext ('', qw(.png .svg .xpm)) {
+ if (-f $dir.$ico.$ext) {
+ return $dir.$ico.$ext if $full;
+ return $ico.$ext;
+ }
+ }
+ }
+ }
+ return "";
+}
+
my @scale;
sub scale_icon {
- my $icon_in = $_[0];
+ my $icon_in = find_icon($_[0], 1);
return $icon_in unless -r $icon_in;
$icon_in =~ m#^(.*/)?(.*?)(\.[^\.]*)?$#;
@@ -56,7 +84,11 @@
return;
}
unless ($main::opt{icons_scale}) {
- $scale_icon = sub { return $_[0] };
+ if ( $main::opt{icons_ext} ) {
+ $scale_icon = \&find_icon;
+ } else {
+ $scale_icon = sub { return $_[0]->{Icon} };
+ }
return;
}
$scale_icon = \&scale_icon;
More information about the pld-cvs-commit
mailing list