summaryrefslogtreecommitdiffstats
path: root/perl-install
diff options
context:
space:
mode:
authorTill Kamppeter <tkamppeter@mandriva.com>2004-08-30 05:56:11 +0000
committerTill Kamppeter <tkamppeter@mandriva.com>2004-08-30 05:56:11 +0000
commit56e07e315562a6cdc391f0b460e629b9e1a45506 (patch)
tree16f4af056e346a39aabc7886cec1da9918704475 /perl-install
parenta8f6c2f237d1a98187a5440a1ce68215589a1f2b (diff)
downloaddrakx-backup-do-not-use-56e07e315562a6cdc391f0b460e629b9e1a45506.tar
drakx-backup-do-not-use-56e07e315562a6cdc391f0b460e629b9e1a45506.tar.gz
drakx-backup-do-not-use-56e07e315562a6cdc391f0b460e629b9e1a45506.tar.bz2
drakx-backup-do-not-use-56e07e315562a6cdc391f0b460e629b9e1a45506.tar.xz
drakx-backup-do-not-use-56e07e315562a6cdc391f0b460e629b9e1a45506.zip
- Added column to show whether the printers are enabled or disables to the list of available print queues in the main window.
- Added command to the edit-printer window to enable and disable print queues. - Fixed bug of "--expert" command line option of printerdrake not working.
Diffstat (limited to 'perl-install')
-rw-r--r--perl-install/printer/cups.pm9
-rw-r--r--perl-install/printer/main.pm13
-rw-r--r--perl-install/printer/printerdrake.pm27
-rwxr-xr-xperl-install/standalone/printerdrake32
4 files changed, 65 insertions, 16 deletions
diff --git a/perl-install/printer/cups.pm b/perl-install/printer/cups.pm
index 79ca291b3..64b0df045 100644
--- a/perl-install/printer/cups.pm
+++ b/perl-install/printer/cups.pm
@@ -133,4 +133,13 @@ sub get_remote_queues {
} lpstat_v();
}
+sub queue_enabled {
+ my ($queue) = @_;
+ 0 != grep {
+ /\b$queue\b.*\benabled\b/i
+ } run_program::rooted_get_stdout($::prefix, 'lpstat', '-p', $queue);
+}
+
+
+
1;
diff --git a/perl-install/printer/main.pm b/perl-install/printer/main.pm
index b7cebdc6c..185c17f8b 100644
--- a/perl-install/printer/main.pm
+++ b/perl-install/printer/main.pm
@@ -1854,7 +1854,7 @@ sub configure_queue($) {
}
# Make sure that queue is active
- if ($printer->{SPOOLER} ne "pdq") {
+ if ($printer->{NEW} && ($printer->{SPOOLER} ne "pdq")) {
run_program::rooted($::prefix, "foomatic-printjob",
"-s", $printer->{currentqueue}{spooler},
"-C", "up", $printer->{currentqueue}{queue});
@@ -1912,6 +1912,17 @@ sub configure_queue($) {
return 1;
}
+sub enable_disable_queue {
+ my ($printer, $queue, $state) = @_;
+
+ if (($printer->{SPOOLER} ne "pdq") &&
+ ($printer->{SPOOLER} ne "rcups")) {
+ run_program::rooted($::prefix, "foomatic-printjob",
+ "-s", $printer->{SPOOLER},
+ "-C", ($state ? "start" : "stop"), $queue);
+ }
+}
+
sub remove_queue($$) {
my ($printer, $queue) = @_;
run_program::rooted($::prefix, "foomatic-configure", "-R", "-q",
diff --git a/perl-install/printer/printerdrake.pm b/perl-install/printer/printerdrake.pm
index 3cdeb5dfe..da2904195 100644
--- a/perl-install/printer/printerdrake.pm
+++ b/perl-install/printer/printerdrake.pm
@@ -4674,14 +4674,17 @@ sub edit_printer {
if ($in->ask_from_(
{ title => N("Modify printer configuration"),
messages =>
- N("Printer %s
+ N("Printer %s%s
What do you want to modify on this printer?",
- $infoline),
+ $infoline,
+ if_(($printer->{SPOOLER} =~ /cups/) &&
+ !printer::cups::queue_enabled($queue),
+ "\n" . N("This printer is disabled"))),
cancel => N("Close"),
ok => N("Do it!")
},
[ { val => \$modify, format => \&translate,
- type => 'list',
+ type => 'list', separator => '|',
list => [ ($printer->{configured}{$queue} ?
(N("Printer connection type"),
N("Printer name, description, location"),
@@ -4694,6 +4697,14 @@ What do you want to modify on this printer?",
N("Printer options"))) : ()),
if_($queue ne $printer->{DEFAULT},
N("Set this printer as the default")),
+ if_(($printer->{SPOOLER} ne "pdq") &&
+ $printer->{configured}{$queue},
+ if_(($printer->{SPOOLER} !~ /cups/) ||
+ !printer::cups::queue_enabled($queue),
+ N("Enable Printer")),
+ if_(($printer->{SPOOLER} !~ /cups/) ||
+ printer::cups::queue_enabled($queue),
+ N("Disable Printer"))),
N("Print test pages"),
N("Learn how to use this printer"),
if_($printer->{configured}{$queue}, N("Remove printer")) ] } ])) {
@@ -4779,6 +4790,16 @@ What do you want to modify on this printer?",
# disappear if the printer is the default, so go back to the
# default entry
$modify = N("Printer options");
+ } elsif ($modify eq N("Enable Printer")) {
+ printer::main::enable_disable_queue($printer, $queue, 1) &&
+ $in->ask_warn(N("Enable Printer"),
+ N("Printer \"%s\" is now enabled.",
+ $queue));
+ } elsif ($modify eq N("Disable Printer")) {
+ printer::main::enable_disable_queue($printer, $queue, 0) &&
+ $in->ask_warn(N("Disable Printer"),
+ N("Printer \"%s\" is now disabled.",
+ $queue));
} elsif ($modify eq N("Print test pages")) {
print_testpages($printer, $in, $upNetwork);
} elsif ($modify eq N("Learn how to use this printer")) {
diff --git a/perl-install/standalone/printerdrake b/perl-install/standalone/printerdrake
index 53f49034a..91963856c 100755
--- a/perl-install/standalone/printerdrake
+++ b/perl-install/standalone/printerdrake
@@ -95,7 +95,7 @@ exit 0 unless printer::printerdrake::first_time_dialog($printer, $in);
$printer->{expert} = printer::main::get_usermode();
# Choose the spooler by command line options
-$commandline =~ /-expert/ and $printer->{expert} = 1;
+$::expert and $printer->{expert} = 1;
$commandline =~ /-cups/ and
$printer->{SPOOLER} = 'cups' and printer::main::read_configured_queues($printer);
$commandline =~ /-rcups/ and
@@ -135,8 +135,8 @@ if (!$::isEmbedded) {
$us->{wnd}{rwindow}->set_position('center');
}
$us->{wnd}{window}->signal_connect(delete_event => \&QuitGlobal);
-my $ltree_model = Gtk2::ListStore->new("Glib::String", "Glib::String", "Glib::String", "Glib::String", "Glib::String", "Glib::String");
-my $rtree_model = Gtk2::ListStore->new("Glib::String", "Glib::String", "Glib::String", "Glib::String", "Glib::String");
+my $ltree_model = Gtk2::ListStore->new("Glib::String", "Glib::String", "Glib::String", "Glib::String", "Glib::String", "Glib::String", "Glib::String");
+my $rtree_model = Gtk2::ListStore->new("Glib::String", "Glib::String", "Glib::String", "Glib::String", "Glib::String", "Glib::String");
my ($localtree, $remotetree);
$localtree = CreateTree($ltree_model);
$remotetree = CreateTree($rtree_model);
@@ -205,21 +205,21 @@ $us->{wnd}{window}->add(gtkpack_(Gtk2::VBox->new(0, 0),
0, $searchBox,
0, Gtk2::HSeparator->new,
1, $nb));
-my @lcolsize = (1, 1, 1, 1, 1, 1, -1);
-my @rcolsize = (1, 1, 1, 1, 1, -1);
+my @lcolsize = (1, 1, 1, 1, 1, 1, 1, -1);
+my @rcolsize = (1, 1, 1, 1, 1, 1, -1);
each_index {
my $col = Gtk2::TreeViewColumn->new_with_attributes($_, Gtk2::CellRendererText->new, 'text' => $::i);
$col->set_sort_column_id($::i);
$col->set_min_width($lcolsize[$::i]);
$localtree->append_column($col);
-} (N("Def."), N("Printer Name"), N("Model"), N("Connection Type"), N("Description"), N("Location"));
+} (N("Def."), N("Printer Name"), N("State"), N("Model"), N("Connection Type"), N("Description"), N("Location"));
each_index {
my $col = Gtk2::TreeViewColumn->new_with_attributes($_, Gtk2::CellRendererText->new, 'text' => $::i);
$col->set_sort_column_id($::i);
$col->set_min_width($rcolsize[$::i]);
$remotetree->append_column($col);
-} (N("Def."), N("Printer Name"), N("Server Name"), N("Description"), N("Location"));
+} (N("Def."), N("Printer Name"), N("State"), N("Server Name"), N("Description"), N("Location"));
my @toolbwg = map {
$toolb->append_item($_->[0], $_->[1], $_->[2],
Gtk2::Image->new_from_file($pixdir . $_->[2] . '.png'), $_->[3], $toolb);
@@ -302,15 +302,19 @@ sub RefreshLocalPrintersFull {
push(@LocalReal, $p) if $searchstr =~ /\Q$strfilt/i;
};
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')));
my $connect = printer::main::connectionstr($printer->{configured}{$p}{queuedata}{connect});
my $description = $printer->{configured}{$p}{queuedata}{desc};
my $location = $printer->{configured}{$p}{queuedata}{loc};
my $model = $printer->{configured}{$p}{queuedata}{make} . ' ' .
$printer->{configured}{$p}{queuedata}{model};
my $default = ($p eq $printer->{DEFAULT} ? "X" : "");
- $ltree_model->append_set([ 0 => $default, 1 => $p, 2 => $model,
- 3 => $connect, 4 => $description,
- 5 => $location ]);
+ $ltree_model->append_set([ 0 => $default, 1 => $p, 2 => $state,
+ 3 => $model,
+ 4 => $connect, 5 => $description,
+ 6 => $location ]);
}
}
@@ -336,14 +340,18 @@ sub RefreshRemotePrintersFull {
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 $server = ($p->{ipp} ?
$p->{ipp} : $printer->{remote_cups_server});
my $description = $p->{description};
my $location = $p->{location};
my $default = ($queue eq $printer->{DEFAULT} ? "X" : "");
$rtree_model->append_set([ 0 => $default, 1 => $queue,
- 2 => $server, 3 => $description,
- 4 => $location ]);
+ 2 => $state, 3 => $server,
+ 4 => $description,
+ 5 => $location ]);
}
}