SVN: vfmg/trunk/VFMG/Icons.pm
sparky
sparky at pld-linux.org
Fri Jan 19 21:25:01 CET 2007
Author: sparky
Date: Fri Jan 19 21:25:01 2007
New Revision: 8177
Modified:
vfmg/trunk/VFMG/Icons.pm
Log:
- move repeated code to check_exec()
Modified: vfmg/trunk/VFMG/Icons.pm
==============================================================================
--- vfmg/trunk/VFMG/Icons.pm (original)
+++ vfmg/trunk/VFMG/Icons.pm Fri Jan 19 21:25:01 2007
@@ -39,7 +39,33 @@
return $file;
}
+sub check_exec($) {
+ my $opt = shift;
+ if ( $main::opt{$opt} =~ s/^\s*\$(\S+)// ) {
+ my $sect = $1;
+ my $exec = prepare_exec($sect);
+ if ( defined $exec and length $exec ) {
+ $main::opt{$opt} =~ s/^/$exec/;
+ return 1;
+ } else {
+ warn "Some error ocurred wile preparing '\$$sect' script\n";
+ delete $main::opt{$opt};
+ return 0;
+ }
+ } else {
+ my $exec = (split /\s/, $main::opt{$opt})[0];
+ if ( length `which $exec` ) {
+ return 1;
+ } else {
+ delete $main::opt{$opt};
+ warn "$opt: `$main::opt{$opt}' is not executable.\n";
+ return 0;
+ }
+ }
+}
+
sub preconf() {
+ return unless $main::opt{icons};
eval { $main::opt{icons_dir} = VFMG::Output::icons_dir() }
unless length $main::opt{icons_dir};
@@ -51,64 +77,14 @@
warn "Icons destination directory is not specified, not scaling.\n";
return;
}
- if ( $main::opt{convert} =~ s/^\s*\$(\S+)// ) {
- my $sect = $1;
- my $conv = prepare_exec($sect);
- if ( defined $conv and length $conv ) {
- $main::opt{convert} =~ s/^/$conv/;
- $main::opt{icons} = 1;
- } else {
- warn "Some error ocurred wile preparing '\$$sect' script\n";
- $main::opt{icons_scale} = 0;
- }
- } else {
- my $conv = (split /\s/, $main::opt{convert})[0];
- if ( length `which $conv` ) {
- $main::opt{icons} = 1;
- } else {
- $main::opt{icons_scale} = 0;
- warn "$conv is not executable, not scaling icons.\n";
- }
- }
+ $main::opt{icons_scale} = 0 unless check_exec("convert");
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";
+ push @del_files, "$tmp/icon.png" if check_exec("text_icon");
}
- return unless defined $main::opt{convert_post};
- if ( $main::opt{convert_post} =~ s/^\s*\$(\S+)// ) {
- my $sect = $1;
- my $post = prepare_exec($sect);
- if ( defined $post and length $post ) {
- $main::opt{convert_post} =~ s/^/$post/;
- } else {
- warn "Some error ocurred wile preparing post '\$$sect' script\n";
- delete $main::opt{convert_post};
- }
- } else {
- unless ( length `which $main::opt{convert_post}` ) {
- delete $main::opt{convert_post};
- warn "post: $main::opt{convert_post} is not executable.\n";
- }
- }
- return;
+ check_exec("convert_post") if defined $main::opt{convert_post};
}
our $scale_icon;
More information about the pld-cvs-commit
mailing list