diff options
author | Till Kamppeter <tkamppeter@mandriva.com> | 2005-09-02 21:43:38 +0000 |
---|---|---|
committer | Till Kamppeter <tkamppeter@mandriva.com> | 2005-09-02 21:43:38 +0000 |
commit | 1f72116762d7547f35959189dae3145c1cc74cc1 (patch) | |
tree | 96eccc2f5a4d86e7f262e36ab3daca810b07e20d | |
parent | 474ef6367025b193d13a29f650cd5a1c920c2c91 (diff) | |
download | drakx-1f72116762d7547f35959189dae3145c1cc74cc1.tar drakx-1f72116762d7547f35959189dae3145c1cc74cc1.tar.gz drakx-1f72116762d7547f35959189dae3145c1cc74cc1.tar.bz2 drakx-1f72116762d7547f35959189dae3145c1cc74cc1.tar.xz drakx-1f72116762d7547f35959189dae3145c1cc74cc1.zip |
- Make building of main window of printerdrake much faster.
-rw-r--r-- | perl-install/printer/cups.pm | 4 | ||||
-rwxr-xr-x | perl-install/standalone/printerdrake | 28 |
2 files changed, 17 insertions, 15 deletions
diff --git a/perl-install/printer/cups.pm b/perl-install/printer/cups.pm index 0ddff19f0..eb443482e 100644 --- a/perl-install/printer/cups.pm +++ b/perl-install/printer/cups.pm @@ -29,13 +29,15 @@ sub lpstat_lpv() { for my $line (@lpstat) { chomp($line); if ($line !~ m!^\s*$!) { - if ($line =~ m!^printer\s+(\S+)\s+(\S.*)$!) { + if ($line =~ m!^printer\s+(\S+)\s+.*\b(enabled|disabled)\b!) { # Beginning of new printer's entry my $name = $1; + my $state = $2; push(@items, {}); $currentitem = $#items; $itemshash->{$name} = $currentitem; $items[$currentitem]{queuename} ||= $name; + $items[$currentitem]{state} ||= $state; } elsif ($line =~ m!^\s+Description:\s+(\S.*)$!) { # Description field if ($currentitem != -1) { diff --git a/perl-install/standalone/printerdrake b/perl-install/standalone/printerdrake index 10380f8e9..d8b462148 100755 --- a/perl-install/standalone/printerdrake +++ b/perl-install/standalone/printerdrake @@ -288,13 +288,13 @@ sub NotebookSwitch() { } sub RefreshLocalPrintersFull { - my ($strfilt) = @_; + my ($strfilt, @allprinters) = @_; my @printers; defined $printer and @printers = keys %{$printer->{configured}}; $ltree_model->clear; return if $printer->{SPOOLER} eq "rcups"; my @LocalReal; - LOOP: foreach my $p (@printers) { + foreach my $p (@printers) { # Apply string search to all fields, not only the printer name my $connect = printer::main::connectionstr($printer->{configured}{$p}{queuedata}{connect}); my $model = $printer->{configured}{$p}{queuedata}{make} . ' ' . @@ -304,11 +304,12 @@ sub RefreshLocalPrintersFull { my $searchstr = "$p|$model|$connect|$description|$location"; push(@LocalReal, $p) if $searchstr =~ /\Q$strfilt/i; } - printer::services::wait_for_cups(); foreach my $p (sort { lc($a) cmp lc($b) } @LocalReal) { my $state = ($printer->{SPOOLER} !~ /cups/ ? N("Unknown") : - (printer::cups::queue_enabled($p) ? N("Enabled") : - N("Disabled"))); + ((grep { + ($_->{queuename} eq $p) && + ($_->{state} eq "enabled"); + } @allprinters) ? N("Enabled") : N("Disabled"))); my $connect = printer::main::connectionstr($printer->{configured}{$p}{queuedata}{connect}); my $description = $printer->{configured}{$p}{queuedata}{desc}; my $location = $printer->{configured}{$p}{queuedata}{loc}; @@ -323,9 +324,7 @@ sub RefreshLocalPrintersFull { } sub RefreshRemotePrintersFull { - my ($strfilt) = @_; - my @printers; - defined $printer and @printers = printer::cups::lpstat_lpv(); + my ($strfilt, @printers) = @_; $rtree_model->clear; my @RemoteReal; LOOP: foreach my $p (@printers) { @@ -340,13 +339,11 @@ sub RefreshRemotePrintersFull { # All remaining to which the search term applies push(@RemoteReal, $p) if $searchstr =~ /\Q$strfilt/i; } - printer::services::wait_for_cups(); foreach my $p (sort { lc($a->{queuename}) cmp lc($b->{queuename}) } @RemoteReal) { my $queue = $p->{queuename}; - my $state = ($printer->{SPOOLER} !~ /cups/ ? N("Unknown") : - (printer::cups::queue_enabled($queue) ? N("Enabled") : - N("Disabled"))); + my $state = ($p->{state} eq "enabled" ? + N("Enabled") : N("Disabled")); my $server = $p->{ipp} || $printer->{remote_cups_server}; my $description = $p->{description}; my $location = $p->{location}; @@ -361,8 +358,11 @@ sub RefreshRemotePrintersFull { sub Refresh { my ($strfilt) = @_; my $selection = get_selection(); - RefreshLocalPrintersFull($strfilt); - RefreshRemotePrintersFull($strfilt); + printer::services::wait_for_cups(); + my @printers; + defined $printer and @printers = printer::cups::lpstat_lpv(); + RefreshLocalPrintersFull($strfilt, @printers); + RefreshRemotePrintersFull($strfilt, @printers); GrayDelEdit(); set_selection($selection); } |