From cc1a6dccfa92a78d6a359c49037855b9ce156142 Mon Sep 17 00:00:00 2001 From: Till Kamppeter Date: Tue, 16 Aug 2005 16:47:41 +0000 Subject: - Improved the auto queue setup pop-up window display on the user's desktop according to the suggestions in bug #17370. - Ask the user whether he wants really have a new printer set up before doing the auto queue setup. - Do always a fully non-interactive auto queue setup when X is not installed - First-time dialog could show garbage as printer model name for some models. Fixed. - Separated "Print no test pages" entry on the wizard page for printing test pages. - Changed the defaults for automatic re-enabling of disabled queues to "no", due to the new CUPS backend wrapper queues should not get disabled automatically any more. - Typo corrections. --- perl-install/printer/main.pm | 8 +-- perl-install/printer/printerdrake.pm | 87 ++++++++++++++++++++++++---- perl-install/standalone/autosetupprintqueues | 11 +++- 3 files changed, 91 insertions(+), 15 deletions(-) diff --git a/perl-install/printer/main.pm b/perl-install/printer/main.pm index 951e6734a..808c8f6e5 100644 --- a/perl-install/printer/main.pm +++ b/perl-install/printer/main.pm @@ -756,16 +756,16 @@ sub get_auto_admin { my ($printer) = @_; $printer->{enablequeuesonnewprinter} = (!defined($sysconfig{ENABLE_QUEUES_ON_PRINTER_CONNECTED}) || - ($sysconfig{ENABLE_QUEUES_ON_PRINTER_CONNECTED} =~ /yes/i) ? - 1 : 0); + ($sysconfig{ENABLE_QUEUES_ON_PRINTER_CONNECTED} =~ /no/i) ? + 0 : 1); $printer->{autoqueuesetuponnewprinter} = (!defined($sysconfig{AUTO_SETUP_QUEUES_ON_PRINTER_CONNECTED}) || ($sysconfig{AUTO_SETUP_QUEUES_ON_PRINTER_CONNECTED} =~ /yes/i) ? 1 : 0); $printer->{enablequeuesonspoolerstart} = (!defined($sysconfig{ENABLE_QUEUES_ON_SPOOLER_START}) || - ($sysconfig{ENABLE_QUEUES_ON_SPOOLER_START} =~ /yes/i) ? - 1 : 0); + ($sysconfig{ENABLE_QUEUES_ON_SPOOLER_START} =~ /no/i) ? + 0 : 1); $printer->{autoqueuesetuponspoolerstart} = (!defined($sysconfig{AUTO_SETUP_QUEUES_ON_SPOOLER_START}) || ($sysconfig{AUTO_SETUP_QUEUES_ON_SPOOLER_START} =~ /yes/i) ? diff --git a/perl-install/printer/printerdrake.pm b/perl-install/printer/printerdrake.pm index 0be3e2fb4..32ef8f2d5 100644 --- a/perl-install/printer/printerdrake.pm +++ b/perl-install/printer/printerdrake.pm @@ -615,7 +615,8 @@ sub config_auto_admin { my $nogui = N("No pop-up windows, package installation not possible"); my $autoqueuesetupmode = - $printer->{autoqueuesetupgui} ? $waitforgui : $nogui; + ($printer->{autoqueuesetupgui} && -x "/usr/X11R6/bin/X") ? + $waitforgui : $nogui; if ($in->ask_from_ ({ title => N("Printer auto administration"), @@ -632,9 +633,11 @@ sub config_auto_admin { { text => N("when Printerdrake is started"), type => 'bool', val => \$printer->{autoqueuesetuponstart} }, - { val => N("Mode for automatic printer setup:") }, + if_(-x "/usr/X11R6/bin/X", + { val => N("Mode for automatic printer setup:") }), { val => \$autoqueuesetupmode, - list => [ $waitforgui, $nogui ], + list => [ if_(-x "/usr/X11R6/bin/X", $waitforgui), + $nogui ], not_edit => 1, sort => 0, type => 'list' }, { val => N("Re-enable disabled printers") }, @@ -822,7 +825,8 @@ sub first_time_dialog { my @printerlist = map { my $entry = $_->{val}{DESCRIPTION}; - $entry ||= "$_->{val}{MANUFACTURER} $_->{val}{MODEL}"; + $entry = "$_->{val}{MANUFACTURER} $_->{val}{MODEL}" + if (length($entry) < 5) or ($entry !~ /\S+\s+\S+/); if_($entry, " - $entry\n"); } @autodetected; my $unknown_printers = @autodetected - @printerlist; @@ -941,11 +945,73 @@ sub configure_new_printers { } } + my %printerselectedlist; + if (!$::noX) { + my @widgets; + foreach my $p (@autodetected) { + if (!member($p->{port}, @blacklist)) { + my $entry = $p->{val}{DESCRIPTION}; + $entry = "$p->{val}{MANUFACTURER} $p->{val}{MODEL}" + if (length($entry) < 5) or ($entry !~ /\S+\s+\S+/); + $entry = N("Unknown model") if $entry !~ /\S/; + $entry = N("%s on %s", $entry, $p->{port}); + $printerselectedlist{$p->{port}} = 1; + push (@widgets, + { text => $entry, + type => 'bool', + val => \$printerselectedlist{$p->{port}} }); + } + } + # Do not show empty dialog + return 1 if $#widgets < 0; + my $morethanone = ($#widgets > 0); + # Add entry to turn off auto queue setup + my $donotsetupagain = 0; + push (@widgets, { val => "__________" }); + push (@widgets, { text => + N("Do not do automatic printer setup again"), + type => 'bool', + val => \$donotsetupagain }); + undef $w; + if ($in->ask_from_ + ({ + title => ($morethanone ? + N("New printers found") : + N("New printer found")), + messages => ($morethanone ? + N("The following new printers were found and Printerdrake can automatically set them up for you. If you do not want to have all of them set up, unselect the ones which should be skipped, or click \"Cancel\" to set up none of them.\n") : + N("The following new printer was found and printerdrake can automatically set it up for you. If you do not want to have it set up, unselect it, or click \"Cancel\".\n")) . + N("Note that for certain printer models additional packages need to be installed. So keep your installation media handy.\n"), + }, + \@widgets )) { + # Turn off auto queue setup if the user wishes it + if ($donotsetupagain) { + # Read current configuration + printer::main::get_auto_admin($printer); + # Turn off automatic print queue setup + $printer->{autoqueuesetuponnewprinter} = 0; + $printer->{autoqueuesetuponspoolerstart} = 0; + $printer->{autoqueuesetuponstart} = 0; + # Save new settings + printer::main::set_auto_admin($printer); + # Tell the user what evil thing he has done and + # how he can fix it. + $in->ask_warn(N("Printerdrake"), + N("Now you have turned off automatic printer setup.\n\n") . + N("You can turn it back on again by choosing \"%s\" -> \"%s\" in Printerdrake's main menu. ", N("Options"), N("Configure Auto Administration")) . + N("There you can also choose in which situation automatic printer setup is done (On Printerdrake startup, on printing system startup, when connecting a new USB printer).")); + } + } else { + return 1; + } + } + # Now install queues for all auto-detected printers which have no queue # yet $printer->{noninteractive} = 1; # Suppress all interactive steps foreach my $p (@autodetected) { - if (!member($p->{port}, @blacklist)) { + if (!member($p->{port}, @blacklist) && + ($::noX || $printerselectedlist{$p->{port}})) { # Initialize some variables for queue setup $printer->{NEW} = 1; $printer->{TYPE} = "LOCAL"; @@ -966,7 +1032,7 @@ sub configure_new_printers { undef $w; $w = $::noX || $in->wait_message(N("Printerdrake"), - N("Found printer on %s...", + N("Configuring printer on %s...", $p->{port})); # Do configuration of multi-function devices and look up # model name in the printer database @@ -3218,11 +3284,11 @@ my %drv_x125_options = ( 'usb:/dev/usb/lp0' => " -o Device=usb_lp1", 'usb:/dev/usb/lp1' => " -o Device=usb_lp2", 'usb:/dev/usb/lp2' => " -o Device=usb_lp3", - 'usb:/dev/usb/lp3' => " -o Device=usb_lp3", + 'usb:/dev/usb/lp3' => " -o Device=usb_lp4", 'file:/dev/usb/lp0' => " -o Device=usb_lp1", 'file:/dev/usb/lp1' => " -o Device=usb_lp2", 'file:/dev/usb/lp2' => " -o Device=usb_lp3", - 'file:/dev/usb/lp3' => " -o Device=usb_lp3", + 'file:/dev/usb/lp3' => " -o Device=usb_lp4", ); sub get_printer_info { @@ -3864,8 +3930,9 @@ Note: the photo test page can take a rather long time to get printed and on lase #{ text => N("Plain text test page"), type => 'bool', # val => \$options{ascii} } if_($::isWizard, - { text => N("Do not print any test page"), type => 'bool', - val => \$res2 }) + ({ val => "__________" }, + { text => N("Do not print any test page"), type => 'bool', + val => \$res2 })) ]); $res2 = 1 if !($options{standard} || $options{altletter} || $options{alta4} || $options{photo} || $options{ascii}); if ($res1 && !$res2) { diff --git a/perl-install/standalone/autosetupprintqueues b/perl-install/standalone/autosetupprintqueues index 45684cfac..50e906e87 100755 --- a/perl-install/standalone/autosetupprintqueues +++ b/perl-install/standalone/autosetupprintqueues @@ -30,6 +30,8 @@ $commandline =~ /-(auto|nogui|gui|waitforgui)\b/; my $gui = $1; $gui ||= "auto"; +$gui = "nogui" if (! -x "/usr/X11R6/bin/X"); + if ($gui ne "nogui") { # Auto-detect whether we go in non-X mode or not my $desktopuser = `cat /var/run/console.lock 2>/dev/null`; @@ -58,8 +60,15 @@ if ($gui ne "nogui") { # Allow root's windows to be opened on the user's display and # start printerdrake then, in a mode to do nothing else than # automatically setting up print queues. + my $userhome = + `getent passwd $desktopuser|awk -F: '{print \$6}' 2>&1`; + chomp $userhome; my $errfile = "/dev/null"; - system "export DISPLAY=\"localhost:0.0\"; USER=$desktopuser; /bin/su $desktopuser -c \"/usr/X11R6/bin/xhost +localhost > $errfile 2>&1\"; /usr/sbin/printerdrake --onlyautoqueue >> $errfile 2>&1; /bin/su $desktopuser -c \"/usr/X11R6/bin/xhost -localhost >> $errfile 2>&1\""; + if (-r "$userhome/.Xauthority") { + system "export DISPLAY=\"localhost:0.0\"; export USER=$desktopuser; [ -r $userhome/.i18n ] >> $errfile 2>&1 && for l in `cat $userhome/.i18n`; do export \$l; done >> $errfile 2>&1; export XAUTHORITY=$userhome/.Xauthority; /usr/sbin/printerdrake --onlyautoqueue >> $errfile 2>&1;"; + } else { + system "export DISPLAY=\"localhost:0.0\"; export USER=$desktopuser; [ -r $userhome/.i18n ] >> $errfile 2>&1 && for l in `cat $userhome/.i18n`; do export \$l; done >> $errfile 2>&1; /bin/su $desktopuser -c \"/usr/X11R6/bin/xhost +localhost >> $errfile 2>&1\"; /usr/sbin/printerdrake --onlyautoqueue >> $errfile 2>&1; /bin/su $desktopuser -c \"/usr/X11R6/bin/xhost -localhost >> $errfile 2>&1\""; + } exit 0; } } -- cgit v1.2.1