summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--perl-install/printer/main.pm83
-rw-r--r--perl-install/printer/printerdrake.pm32
2 files changed, 96 insertions, 19 deletions
diff --git a/perl-install/printer/main.pm b/perl-install/printer/main.pm
index 529224fe2..6ff1163eb 100644
--- a/perl-install/printer/main.pm
+++ b/perl-install/printer/main.pm
@@ -1483,20 +1483,61 @@ sub poll_ppd_base {
my $key = ppd_entry_str($mf, $descr, $lang);
$key =~ /^[^\|]+\|([^\|]+)\|(.*)$/;
my ($model, $driver) = ($1, $2);
+ # Remove language tag
+ $driver =~ s/\s*\([a-z]{2}(|_[A-Z]{2})\s*$//;
+ # Remove trailing white space
$driver =~ s/\s+$//;
+ # Foomatic PPD? Extract driver name
+ my $isfoomatic =
+ ($driver =~ s/^\s*(GhostScript|Foomatic)\s*\+\s*//i);
+ # Recommended Foomatic PPD? Extract "(recommended)"
+ my $isrecommended = ($driver =~ s/^\s+\(rcommended\)$//i);
+ # Foomatic PostScript driver?
+ $isfoomatic ||= ($driver =~ /^PostScript$/i);
+ # Native CUPS?
+ my $isnativecups = ($driver =~ /CUPS/i);
+ # Native PostScript
+ my $isnativeps = (!$isfoomatic and !$isnativecups);
+ print "#####$key###|$driver|$isnativeps|$isrecommended|\n";
+ if (!$isfoomatic) {
+ $driver = "PPD";
+ }
+ # Key without language tag (key as it was produced for the
+ # entries from the Foomatic XML database)
+ my $keynolang = $key;
+ $keynolang =~ s/\s*\([a-z]{2}(|_[A-Z]{2})\s*$//;
if (!$::expert) {
# Remove driver from printer list entry when in
# recommended mode
$key =~ s/^([^\|]+\|[^\|]+)\|.*$/$1/;
- # Only replace the printer entry when it uses a
- # "Foomatic + Postscript" driver
- next if (defined($thedb{$key}) &&
- ($thedb{$key}{driver} !~ /PostScript/i));
- # Remove the old entry
- delete $thedb{$key};
+ # Only replace an existing printer entry if
+ # - its driver is not the same as the driver of the
+ # new one
+ # AND if one of the following items is true
+ # - The existing entry uses a "Foomatic + Postscript"
+ # driver and the new one is native PostScript
+ # - The existing entry is a Foomatic entry and the new
+ # one is "recommended"
+ # - The existing entry is a native PostScript entry
+ # and the new entry is a "recommended" driver other
+ # then "Foomatic + Postscript"
+ if (defined($thedb{$key})) {
+ next unless (lc($thedb{$key}{driver}) ne
+ lc($driver));
+ next unless (($isnativeps &&
+ ($thedb{$key}{driver} =~
+ /^PostScript$/i)) ||
+ (($thedb{$key}{driver} ne "PPD") &&
+ $isrecommended) ||
+ (($thedb{$key}{driver} eq "PPD") &&
+ ($driver ne "PostScript") &&
+ $isrecommended));
+ # Remove the old entry
+ delete $thedb{$key};
+ }
} elsif (defined
$thedb{"$mf|$model|PostScript (recommended)"} &&
- ($driver =~ /PostScript/i)) {
+ ($isnativeps)) {
# Expert mode: "Foomatic + Postscript" driver is
# recommended and this is a PostScript PPD? Make
# this PPD the recommended one
@@ -1508,6 +1549,27 @@ sub poll_ppd_base {
delete
$thedb{"$mf|$model|PostScript (recommended)"};
$key .= " (recommended)";
+ } elsif (($key =~ /PostScript\s*\(recommended\)/i) &&
+ (my @nativepskeys = grep {
+ /^$mf\|$model\|/ && !/CUPS/i &&
+ $thedb{$_}{driver} eq "PPD"
+ } keys %thedb)) {
+ # Expert mode: "Foomatic + Postscript" driver is
+ # recommended and there was a PostScript PPD? Make
+ # this PPD the recommended one
+ my $firstnativeps = $nativepskeys[0];
+ for (keys %{$thedb{$firstnativeps}}) {
+ $thedb{"$firstnativeps (recommended)"}{$_} =
+ $thedb{$firstnativeps}{$_};
+ }
+ delete $thedb{$firstnativeps};
+ $key =~ s/\s*\(recommended\)//;
+ } elsif (defined $thedb{"$keynolang"} && ($isfoomatic)) {
+ # Expert mode: There is already an entry for the
+ # same printer/driver combo produced by the
+ # Foomatic XML database, so do not make a second
+ # entry
+ next;
}
$thedb{$key}{ppd} = $ppd;
$thedb{$key}{make} = $mf;
@@ -1523,9 +1585,12 @@ sub poll_ppd_base {
scalar(keys %thedb) - $driversthere > 5 and last;
#- we have to try again running the program, wait here a little
#- before.
- sleep 1;
+ sleep 1;
}
-
+# Only for debugging, will be removed before MDK 9.1
+# print map {
+# "##### |$_|$thedb{$_}{make}|$thedb{$_}{model}|$thedb{$_}{driver}|\n";
+# } keys %thedb
#scalar(keys %descr_to_ppd) > 5 or
# die "unable to connect to cups server";
diff --git a/perl-install/printer/printerdrake.pm b/perl-install/printer/printerdrake.pm
index 611bd8f5b..56d214eb1 100644
--- a/perl-install/printer/printerdrake.pm
+++ b/perl-install/printer/printerdrake.pm
@@ -3390,7 +3390,12 @@ sub main {
val => N("Change the printing system") } :
()),
{ clicked_may_quit =>
- sub { $menuchoice = "\@usermode"; 1 },
+ sub {
+ # Save the cursor position
+ $cursorpos = $menuchoice;
+ $menuchoice = "\@usermode";
+ 1
+ },
val => ($::expert ? N("Normal Mode") :
N("Expert Mode")) },
{ clicked_may_quit =>
@@ -3404,16 +3409,23 @@ sub main {
printer::main::set_usermode(!$::expert);
# Read printer database for the new user mode
%printer::main::thedb = ();
- #my $_w = $in->wait_message(N("Printerdrake"),
- # N("Reading printer database..."));
- #printer::main::read_printer_db($printer->{SPOOLER});
- # Re-read printer queues to switch the tree
+ # Modify menu entries to switch the tree
# structure between expert/normal mode.
- my $_w = $in->wait_message(
- N("Printerdrake"),
- N("Reading printer data..."));
- printer::main::read_configured_queues($printer);
- $cursorpos = "::";
+ my $spooler =
+ $spoolers{$printer->{SPOOLER}}{short_name};
+ if ($::expert) {
+ map {
+ $printer->{configured}{$_}{queuedata}{menuentry} =~
+ s/^/$spooler!/;
+ } keys(%{$printer->{configured}});
+ $cursorpos =~ s/^/$spooler!/;
+ } else {
+ map {
+ $printer->{configured}{$_}{queuedata}{menuentry} =~
+ s/^$spooler!//;
+ } keys(%{$printer->{configured}});
+ $cursorpos =~ s/^$spooler!//;
+ }
next;
}
} else {