SVN: vfmg/trunk: VFMG/Icons.pm vfmg
sparky
sparky at pld-linux.org
Fri Jan 19 21:23:35 CET 2007
Author: sparky
Date: Fri Jan 19 21:23:35 2007
New Revision: 8176
Modified:
vfmg/trunk/VFMG/Icons.pm
vfmg/trunk/vfmg
Log:
- text icon support (create icon using app name if none exist)
Modified: vfmg/trunk/VFMG/Icons.pm
==============================================================================
--- vfmg/trunk/VFMG/Icons.pm (original)
+++ vfmg/trunk/VFMG/Icons.pm Fri Jan 19 21:23:35 2007
@@ -14,6 +14,9 @@
'',
);
+my $tmp = (grep {defined and length and -d and -w}
+ ($ENV{TMPDIR}, $ENV{TMP}, "/tmp"))[0];
+
my @del_files;
sub prepare_exec($) {
my $sect = shift;
@@ -22,8 +25,6 @@
return undef;
}
- my $tmp = (grep {defined and length and -d and -w}
- ($ENV{TMPDIR}, $ENV{TMP}, "/tmp"))[0];
return undef unless ($tmp);
my $file = "$tmp/$sect";
@@ -71,6 +72,26 @@
}
return unless $main::opt{icons_scale};
+ if ( defined $main::opt{text_icon} ) {
+ if ( $main::opt{text_icon} =~ s/^\s*\$(\S+)// ) {
+ my $sect = $1;
+ my $post = prepare_exec($sect);
+ if ( defined $post and length $post ) {
+ $main::opt{text_icon} =~ s/^/$post/;
+ } else {
+ warn "Some error ocurred wile preparing post '\$$sect' script\n";
+ delete $main::opt{text_icon};
+ }
+ } else {
+ my $exec = (split /\s/, $main::opt{text_icon})[0];
+ unless ( length `which $exec` ) {
+ delete $main::opt{text_icon};
+ warn "post: $main::opt{text_icon} is not executable.\n";
+ }
+ }
+ push @del_files, "$tmp/icon.png";
+ }
+
return unless defined $main::opt{convert_post};
if ( $main::opt{convert_post} =~ s/^\s*\$(\S+)// ) {
my $sect = $1;
@@ -114,10 +135,20 @@
my @scale;
sub scale_icon {
my $icon_in = find_icon($_[0], 1);
- return $icon_in unless -r $icon_in;
+ return $icon_in unless -r $icon_in or defined $main::opt{text_icon};
$icon_in =~ m#^(.*/)?(.*?)(\.[^\.]*)?$#;
my $icon_out = "$main::opt{icons_dir}/$2.$main::opt{icons_oext}";
+
+ my @ti = ();
+ unless ( -r $icon_in ) {
+ $_ = $main::opt{text_icon};
+ s/\%name/$_[0]->{Name}/g;
+ $icon_in = "$tmp/icon.png";
+ s/\%out/$icon_in/g;
+ $icon_out = "$main::opt{icons_dir}/$_[0]->{file}.$main::opt{icons_oext}";
+ push @ti, $_;
+ }
unless (-f $icon_out) {
$_ = $main::opt{convert};
@@ -125,8 +156,9 @@
s/\%out/$icon_out/g;
if ( $main::opt{icons_fork} ) {
- push @scale, $_;
+ push @scale, @ti, $_;
} else {
+ system($ti[0]) if @ti;
system($_);
}
}
Modified: vfmg/trunk/vfmg
==============================================================================
--- vfmg/trunk/vfmg (original)
+++ vfmg/trunk/vfmg Fri Jan 19 21:23:35 2007
@@ -37,6 +37,7 @@
only_in => "",
xterm => "xterm -name xterm-%1 -e %2",
convert => "convert -geometry 16x16 \%in \%out",
+ text_icon => "",
full_regen => 0,
destdir => "",
More information about the pld-cvs-commit
mailing list