summaryrefslogtreecommitdiffstats
path: root/perl-install/printer
diff options
context:
space:
mode:
Diffstat (limited to 'perl-install/printer')
-rw-r--r--perl-install/printer/main.pm123
-rw-r--r--perl-install/printer/printerdrake.pm78
2 files changed, 82 insertions, 119 deletions
diff --git a/perl-install/printer/main.pm b/perl-install/printer/main.pm
index 9c51cbbb3..b92aff0f1 100644
--- a/perl-install/printer/main.pm
+++ b/perl-install/printer/main.pm
@@ -280,8 +280,6 @@ sub read_configured_queues($) {
}
$printer->{configured}{$QUEUES[$i]{queuedata}{queue}}{queuedata}{driver} = 'CUPS/PPD';
$printer->{OLD_QUEUE} = "";
- # Read out the printer's options
- $printer->{configured}{$QUEUES[$i]{queuedata}{queue}}{args} = read_cups_options($QUEUES[$i]{queuedata}{queue});
}
$printer->{configured}{$QUEUES[$i]{queuedata}{queue}}{queuedata}{make} ||= "";
$printer->{configured}{$QUEUES[$i]{queuedata}{queue}}{queuedata}{model} ||= N("Unknown model");
@@ -529,102 +527,37 @@ sub read_foomatic_options ($) {
local *F;
open F, ($::testing ? $::prefix : "chroot $::prefix/ ") .
"foomatic-configure -P -q -p $printer->{currentqueue}{printer}" .
- " -d $printer->{currentqueue}{driver}" .
- ($printer->{OLD_QUEUE} ?
- " -s $printer->{SPOOLER} -n $printer->{OLD_QUEUE}" : "") .
- ($printer->{SPECIAL_OPTIONS} ?
- " $printer->{SPECIAL_OPTIONS}" : "")
- . " |" or
- die "Could not run foomatic-configure";
+ " -d $printer->{currentqueue}{driver}" .
+ ($printer->{OLD_QUEUE} ?
+ " -s $printer->{SPOOLER} -n $printer->{OLD_QUEUE}" : "") .
+ ($printer->{SPECIAL_OPTIONS} ?
+ " $printer->{SPECIAL_OPTIONS}" : "")
+ . " |" or
+ die "Could not run foomatic-configure";
eval join('', (<F>));
close F;
# Return the arguments field
return $COMBODATA->{args};
}
-sub read_cups_options ($) {
- my ($queue_or_file) = @_;
- # Generate the option data from a CUPS PPD file/a CUPS queue
- # Use the same Perl data structure as Foomatic uses to be able to
- # reuse the dialog
+sub read_ppd_options ($) {
+ my ($printer) = @_;
+ # Generate the option data for a given PPD file
+ my $COMBODATA;
local *F;
- if ($queue_or_file =~ /.ppd.gz$/) { # compressed PPD file
- open F, ($::testing ? $::prefix : "chroot $::prefix/ ") . #-#
- "gunzip -cd $queue_or_file | lphelp - |" or return 0;
- } else { # PPD file not compressed or queue
- open F, ($::testing ? $::prefix : "chroot $::prefix/ ") . #-#
- "lphelp $queue_or_file |" or return 0;
- }
- my $i;
- my $j;
- my @args;
- my $line;
- my $inoption = 0;
- my $inchoices = 0;
-# my $innumerical = 0;
- while ($line = <F>) {
- chomp $line;
- if ($inoption) {
- if ($inchoices) {
- if ($line =~ /^\s*(\S+)\s+(\S.*)$/) {
- push(@{$args[$i]{vals}}, {});
- $j = $#{$args[$i]{vals}};
- $args[$i]{vals}[$j]{value} = $1;
- my $comment = $2;
- # Did we find the default setting?
- if ($comment =~ /default\)\s*$/) {
- $args[$i]{default} = $args[$i]{vals}[$j]{value};
- $comment =~ s/,\s*default\)\s*$//;
- } else {
- $comment =~ s/\)\s*$//;
- }
- # Remove opening paranthese
- $comment =~ s/^\(//;
- # Remove page size info
- $comment =~ s/,\s*size:\s*[0-9\.]+x[0-9\.]+in$//;
- $args[$i]{vals}[$j]{comment} = $comment;
- } elsif ($line =~ /^\s*$/ && $#{$args[$i]{vals}} > -1) {
- $inchoices = 0;
- $inoption = 0;
- }
-# } elsif ($innumerical == 1) {
-# if ($line =~ /^\s*The default value is ([0-9\.]+)\s*$/) {
-# $args[$i]{default} = $1;
-# $innumerical = 0;
-# $inoption = 0;
-# }
- } else {
- if ($line =~ /^\s*<choice>/) {
- $inchoices = 1;
-# } elsif ($line =~ /^\s*<value> must be a(.*) number in the range ([0-9\.]+)\.\.([0-9\.]+)\s*$/) {
-# delete($args[$i]{vals});
-# $args[$i]{min} = $2;
-# $args[$i]{max} = $3;
-# my $type = $1;
-# if ($type =~ /integer/) {
-# $args[$i]{type} = 'int';
-# } else {
-# $args[$i]{type} = 'float';
-# }
-# $innumerical = 1;
- }
- }
- } else {
- if ($line =~ /^\s*([^\s:][^:]*):\s+-o\s+([^\s=]+)=<choice>\s*$/) {
-# if ($line =~ /^\s*([^\s:][^:]*):\s+-o\s+([^\s=]+)=<.*>\s*$/) {
- $inoption = 1;
- push(@args, {});
- $i = $#args;
- $args[$i]{comment} = $1;
- $args[$i]{name} = $2;
- $args[$i]{type} = 'enum';
- @{$args[$i]{vals}} = ();
- }
- }
- }
+ open F, ($::testing ? $::prefix : "chroot $::prefix/ ") .
+ "foomatic-configure -P -q" .
+ " --ppd /usr/share/cups/model/$printer->{currentqueue}{ppd}" .
+ ($printer->{OLD_QUEUE} ?
+ " -s $printer->{SPOOLER} -n $printer->{OLD_QUEUE}" : "") .
+ ($printer->{SPECIAL_OPTIONS} ?
+ " $printer->{SPECIAL_OPTIONS}" : "")
+ . " |" or
+ die "Could not run foomatic-configure";
+ eval join('', (<F>));
close F;
# Return the arguments field
- return \@args;
+ return $COMBODATA->{args};
}
sub set_cups_special_options {
@@ -1685,16 +1618,8 @@ sub configure_queue($) {
# Store the default option settings
$printer->{configured}{$printer->{currentqueue}{queue}}{args} = {};
- if ($printer->{currentqueue}{foomatic}) {
- my $tmp = $printer->{OLD_QUEUE};
- $printer->{OLD_QUEUE} = $printer->{currentqueue}{queue};
- $printer->{configured}{$printer->{currentqueue}{queue}}{args} =
- read_foomatic_options($printer);
- $printer->{OLD_QUEUE} = $tmp;
- } elsif ($printer->{currentqueue}{ppd}) {
- $printer->{configured}{$printer->{currentqueue}{queue}}{args} =
- read_cups_options($printer->{currentqueue}{queue});
- }
+ $printer->{configured}{$printer->{currentqueue}{queue}}{args} =
+ $printer->{ARGS};
# Clean up
delete($printer->{ARGS});
$printer->{OLD_CHOICE} = "";
diff --git a/perl-install/printer/printerdrake.pm b/perl-install/printer/printerdrake.pm
index fac2852fd..c8393f05d 100644
--- a/perl-install/printer/printerdrake.pm
+++ b/perl-install/printer/printerdrake.pm
@@ -2163,14 +2163,18 @@ The first command can be given by any normal user, the second must be given as r
if (!$printer->{DBENTRY} || !$oldchoice ||
$printer->{DBENTRY} eq $oldchoice) {
# ... and the user didn't change the printer/driver
- $printer->{ARGS} = printer::main::read_cups_options($queue);
+ $printer->{ARGS} = $printer->{configured}{$queue}{args};
+ use Data::Dumper;
+ print Dumper($printer->{ARGS});
} else {
# ... and the user has chosen another printer/driver
- $printer->{ARGS} = printer::main::read_cups_options("/usr/share/cups/model/$printer->{currentqueue}{ppd}");
+ $printer->{ARGS} =
+ printer::main::read_ppd_options($printer);
}
} else {
# The queue was not configured before
- $printer->{ARGS} = printer::main::read_cups_options("/usr/share/cups/model/$printer->{currentqueue}{ppd}");
+ $printer->{ARGS} =
+ printer::main::read_ppd_options($printer);
}
}
}
@@ -2201,6 +2205,7 @@ sub setup_options {
"DoubleSided",
"Resolution", # Resolution/Quality
"GSResolution",
+ "HWResolution",
"JCLResolution",
"Quality",
"PrintQuality",
@@ -2208,6 +2213,10 @@ sub setup_options {
"QualityType",
"ImageType",
"stpImageType",
+ "EconoMode",
+ "JCLEconoMode",
+ "FastRes",
+ "JCLFastRes",
"InkType", # Colour/Gray/BW, 4-ink/6-ink
"stpInkType",
"Mode",
@@ -2274,8 +2283,28 @@ sub setup_options {
my @choicelists;
my @shortchoicelists;
my $i;
+ my @oldgroup = ("", "");
for ($i = 0; $i <= $#{$printer->{ARGS}}; $i++) {
my $optshortdefault = $printer->{ARGS}[$i]{default};
+ # Should the option only show when the "Advanced" button was
+ # clicked?
+ my $advanced = ((defined($printer->{ARGS}[$i]{group}) and
+ ($printer->{ARGS}[$i]{group} !~
+ /^(|General|.*install.*)$/i)) or
+ (!($printer->{ARGS}[$i]{group}) and
+ !member($printer->{ARGS}[$i]{name},
+ @simple_options)) ? 1 : 0);
+ # Group header
+ if ($printer->{ARGS}[$i]{group} ne $oldgroup[$advanced]) {
+ my $level = $#{$printer->{ARGS}[$i]{grouptrans}};
+ $oldgroup[$advanced] = $printer->{ARGS}[$i]{group};
+ if ($printer->{ARGS}[$i]{group}) {
+ push(@widgets,
+ { val => join
+ (" / ", @{$printer->{ARGS}[$i]{grouptrans}}),
+ advanced => $advanced });
+ }
+ }
if ($printer->{ARGS}[$i]{type} eq 'enum') {
# enumerated option
push(@choicelists, []);
@@ -2292,24 +2321,27 @@ sub setup_options {
val => \$userinputs[$i],
not_edit => 1,
list => \@{$choicelists[$i]},
- advanced => (defined($printer->{ARGS}[$i]{group}) and
- ($printer->{ARGS}[$i]{group} !~
- /^(|General|.*install.*)$/i)) })
+ sort => 0,
+ advanced => $advanced })
if ($printer->{ARGS}[$i]{name} ne 'PageRegion');
} elsif ($printer->{ARGS}[$i]{type} eq 'bool') {
# boolean option
- push(@choicelists, [$printer->{ARGS}[$i]{name},
- $printer->{ARGS}[$i]{name_false}]);
+ push(@choicelists, [($printer->{ARGS}[$i]{comment_true} ||
+ $printer->{ARGS}[$i]{name}),
+ ($printer->{ARGS}[$i]{comment_false} ||
+ $printer->{ARGS}[$i]{name_false})]);
push(@shortchoicelists, []);
- push(@userinputs, $choicelists[$i][1-$optshortdefault]);
+ my $numdefault =
+ ($optshortdefault =~ m!^\s*(true|on|yes|1)\s*$! ?
+ "1" : "0");
+ push(@userinputs, $choicelists[$i][1-$numdefault]);
push(@widgets,
{ label => $printer->{ARGS}[$i]{comment},
val => \$userinputs[$i],
not_edit => 1,
list => \@{$choicelists[$i]},
- advanced => (defined($printer->{ARGS}[$i]{group}) and
- ($printer->{ARGS}[$i]{group} !~
- /^(|General|.*install.*)$/i)) });
+ sort => 0,
+ advanced => $advanced });
} else {
# numerical option
push(@choicelists, []);
@@ -2323,10 +2355,7 @@ sub setup_options {
#min => $printer->{ARGS}[$i]{min},
#max => $printer->{ARGS}[$i]{max},
val => \$userinputs[$i],
- advanced =>
- (defined($printer->{ARGS}[$i]{group}) and
- ($printer->{ARGS}[$i]{group} !~
- /^(|General|.*install.*)$/i)) });
+ advanced => $advanced });
}
}
# Show the options dialog. The call-back function does a
@@ -2401,16 +2430,25 @@ You should make sure that the page size and the ink type/printing mode (if avail
my $j;
for ($j = 0; $j <= $#{$choicelists[$i]}; $j++) {
if ($choicelists[$i][$j] eq $userinputs[$i]) {
- push(@{$printer->{currentqueue}{options}}, $printer->{ARGS}[$i]{name} . "=" . $shortchoicelists[$i][$j]);
+ $printer->{ARGS}[$i]{default} =
+ $shortchoicelists[$i][$j];
+ push(@{$printer->{currentqueue}{options}},
+ $printer->{ARGS}[$i]{name} . "=" .
+ $shortchoicelists[$i][$j]);
}
}
} elsif ($printer->{ARGS}[$i]{type} eq 'bool') {
# boolean option
- push(@{$printer->{currentqueue}{options}}, $printer->{ARGS}[$i]{name} . "=" .
- ($choicelists[$i][0] eq $userinputs[$i] ? "1" : "0"));
+ my $v =
+ ($choicelists[$i][0] eq $userinputs[$i] ? "1" : "0");
+ $printer->{ARGS}[$i]{default} = $v;
+ push(@{$printer->{currentqueue}{options}},
+ $printer->{ARGS}[$i]{name} . "=" . $v);
} else {
# numerical option
- push(@{$printer->{currentqueue}{options}}, $printer->{ARGS}[$i]{name} . "=" . $userinputs[$i]);
+ $printer->{ARGS}[$i]{default} = $userinputs[$i];
+ push(@{$printer->{currentqueue}{options}},
+ $printer->{ARGS}[$i]{name} . "=" . $userinputs[$i]);
}
}
}