summaryrefslogtreecommitdiffstats
path: root/perl-install/printer
diff options
context:
space:
mode:
authorTill Kamppeter <tkamppeter@mandriva.com>2005-08-26 15:18:50 +0000
committerTill Kamppeter <tkamppeter@mandriva.com>2005-08-26 15:18:50 +0000
commit8e0f23f79128c9074a6c8a9747e54f7c77ef901b (patch)
tree6fa8a8fcf3ad1cdecf7406f9989ef74b7a2f92a1 /perl-install/printer
parentc29edc6e7a60eca4002fb426df0334f890f11fcc (diff)
downloaddrakx-8e0f23f79128c9074a6c8a9747e54f7c77ef901b.tar
drakx-8e0f23f79128c9074a6c8a9747e54f7c77ef901b.tar.gz
drakx-8e0f23f79128c9074a6c8a9747e54f7c77ef901b.tar.bz2
drakx-8e0f23f79128c9074a6c8a9747e54f7c77ef901b.tar.xz
drakx-8e0f23f79128c9074a6c8a9747e54f7c77ef901b.zip
- Gutenprint does not print correctly when margins are set in the CUPS
configuration, so do not set margins when creating a queue with Gutenprint, or remove the margins when switching the driver of an existing queue to Gutenprint.
Diffstat (limited to 'perl-install/printer')
-rw-r--r--perl-install/printer/main.pm64
1 files changed, 45 insertions, 19 deletions
diff --git a/perl-install/printer/main.pm b/perl-install/printer/main.pm
index 413eb5431..a0ec64f84 100644
--- a/perl-install/printer/main.pm
+++ b/perl-install/printer/main.pm
@@ -742,25 +742,49 @@ sub read_ppd_options ($) {
}
sub set_cups_special_options {
- my ($queue) = @_;
+ my ($printer, $queue) = @_;
# Set some special CUPS options
- my @lpoptions = chomp_(cat_("$::prefix/etc/cups/lpoptions"));
- # If nothing is already configured, set text file borders of half an inch
- # and decrease the font size a little bit, so nothing of the text gets
- # cut off by unprintable borders.
- if (!any { /$queue.*\s(page-(top|bottom|left|right)|lpi|cpi)=/ } @lpoptions) {
- run_program::rooted($::prefix, "lpoptions",
- "-p", $queue,
- "-o", "page-top=36", "-o", "page-bottom=36",
- "-o", "page-left=36", "-o page-right=36",
- "-o", "cpi=12", "-o", "lpi=7", "-o", "wrap");
+ my @lpoptions = cat_("$::prefix/etc/cups/lpoptions");
+ # If nothing is already configured, set text file borders of half
+ # an inch so nothing of the text gets cut off by unprintable
+ # borders. Do this only when the driver is not Gutenprint, as with
+ # Gutenprint this will break PostScript printing
+ if ((($queue eq $printer->{currentqueue}{$queue}) &&
+ (($printer->{currentqueue}{driver} =~ /guten.*print/i) ||
+ ($printer->{currentqueue}{ppd} =~ /guten.*print/i))) ||
+ ((defined($printer->{configured}{$queue})) &&
+ (($printer->{configured}{$queue}{queuedata}{driver} =~
+ /guten.*print/i) ||
+ ($printer->{configured}{$queue}{queuedata}{ppd} =~
+ /guten.*print/i))) ||
+ (($printer->{SPOOLER} eq "cups") &&
+ (-r "$::prefix/etc/cups/ppd/$queue.ppd") &&
+ (`grep -ic gutenprint $::prefix/etc/cups/ppd/$queue.ppd` > 2))) {
+ # Remove page margin settings
+ foreach (@lpoptions) {
+ s/\s*page-(top|bottom|left|right)=\S+//g if /$queue/;
+ }
+ output("$::prefix/etc/cups/lpoptions", @lpoptions);
+ } else {
+ if (!any { /$queue.*\spage-(top|bottom|left|right)=/ } @lpoptions) {
+ run_program::rooted($::prefix, "lpoptions",
+ "-p", $queue,
+ "-o", "page-top=36", "-o", "page-bottom=36",
+ "-o", "page-left=36", "-o page-right=36");
+ }
}
- # Let images fill the whole page by default
+ # Let images fill the whole page by default and let text be word-wrapped
+ # and printed in a slightly smaller font
if (!any { /$queue.*\s(scaling|natural-scaling|ppi)=/ } @lpoptions) {
run_program::rooted($::prefix, "lpoptions",
"-p", $queue,
"-o", "scaling=100");
}
+ if (!any { /$queue.*\s(cpi|lpi)=/ } @lpoptions) {
+ run_program::rooted($::prefix, "lpoptions",
+ "-p", $queue,
+ "-o", "cpi=12", "-o", "lpi=7", "-o", "wrap");
+ }
return 1;
}
@@ -2127,12 +2151,6 @@ sub configure_queue($) {
"-C", "up", $printer->{currentqueue}{queue});
}
- # In case of CUPS set some more useful defaults for text and image
- # printing
- if ($printer->{SPOOLER} eq "cups") {
- set_cups_special_options($printer->{currentqueue}{queue});
- }
-
# Check whether a USB printer is configured and activate USB printing if so
my $useUSB = 0;
foreach (values %{$printer->{configured}}) {
@@ -2169,6 +2187,14 @@ sub configure_queue($) {
$printer->{configured}{$printer->{currentqueue}{queue}}{args} = {};
$printer->{configured}{$printer->{currentqueue}{queue}}{args} =
$printer->{ARGS};
+
+ # In case of CUPS set some more useful defaults for text and image
+ # printing
+ if ($printer->{SPOOLER} eq "cups") {
+ set_cups_special_options($printer,
+ $printer->{currentqueue}{queue});
+ }
+
# Clean up
delete($printer->{ARGS});
$printer->{OLD_CHOICE} = "";
@@ -2369,7 +2395,7 @@ sub copy_foomatic_queue {
"-C", $oldspooler, $oldqueue);
# In case of CUPS set some more useful defaults for text and image printing
if ($printer->{SPOOLER} eq "cups") {
- set_cups_special_options($newqueue);
+ set_cups_special_options($printer, $newqueue);
}
}