summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTill Kamppeter <tkamppeter@mandriva.com>2002-08-28 16:25:22 +0000
committerTill Kamppeter <tkamppeter@mandriva.com>2002-08-28 16:25:22 +0000
commitc49ae686d5b9770861fbdaa860c81022808c3881 (patch)
tree31f6fc316ea6aa0d4cfc2505d6337afb98ae8675
parent27fd3d851753ac9e25ae7c6ee4ac38c02d3bca97 (diff)
downloaddrakx-c49ae686d5b9770861fbdaa860c81022808c3881.tar
drakx-c49ae686d5b9770861fbdaa860c81022808c3881.tar.gz
drakx-c49ae686d5b9770861fbdaa860c81022808c3881.tar.bz2
drakx-c49ae686d5b9770861fbdaa860c81022808c3881.tar.xz
drakx-c49ae686d5b9770861fbdaa860c81022808c3881.zip
Printerdrake remembers now whether it was in normal mode or in expert
mode last time.
-rw-r--r--perl-install/printer.pm51
-rw-r--r--perl-install/printerdrake.pm6
-rwxr-xr-xperl-install/standalone/printerdrake9
3 files changed, 62 insertions, 4 deletions
diff --git a/perl-install/printer.pm b/perl-install/printer.pm
index fc2e0bc6f..145dac96a 100644
--- a/perl-install/printer.pm
+++ b/perl-install/printer.pm
@@ -1150,7 +1150,7 @@ sub set_cups_autoconf {
# Remove all valid "CUPS_CONFIG" lines
(/^\s*CUPS_CONFIG/ and $_ = "") foreach @file_content;
- # Insert the new "Printcap" line
+ # Insert the new "CUPS_CONFIG" line
if ($autoconf) {
push @file_content, "CUPS_CONFIG=automatic\n";
} else {
@@ -1170,7 +1170,7 @@ sub set_cups_autoconf {
sub get_cups_autoconf {
local *F;
- open F, ("< $prefix/etc/sysconfig/printing") || return 1;
+ open F, "< $prefix/etc/sysconfig/printing" or return 1;
my $line;
while ($line = <F>) {
if ($line =~ m!^[^\#]*CUPS_CONFIG=manual!) {
@@ -1180,6 +1180,53 @@ sub get_cups_autoconf {
return 1;
}
+sub set_usermode {
+ my $usermode = $_[0];
+ $::expert = $usermode;
+
+ # Read config file
+ local *F;
+ my $file = "$prefix/etc/sysconfig/printing";
+ if (!(-f $file)) {
+ @file_content = ();
+ } else {
+ open F, "< $file" or die "Cannot open $file!";
+ @file_content = <F>;
+ close F;
+ }
+
+ # Remove all valid "USER_MODE" lines
+ (/^\s*USER_MODE/ and $_ = "") foreach @file_content;
+
+ # Insert the new "USER_MODE" line
+ if ($usermode) {
+ push @file_content, "USER_MODE=expert\n";
+ } else {
+ push @file_content, "USER_MODE=recommended\n";
+ }
+
+ # Write back modified file
+ open F, "> $file" or die "Cannot open $file!";
+ print F @file_content;
+ close F;
+
+ return 1;
+}
+
+sub get_usermode {
+ local *F;
+ open F, "< $prefix/etc/sysconfig/printing" or return 0;
+ my $line;
+ while ($line = <F>) {
+ if ($line =~ m!^[^\#]*USER_MODE=expert!) {
+ $::expert = 1;
+ return 1;
+ }
+ }
+ $::expert = 0;
+ return 0;
+}
+
sub set_default_printer {
my ($printer) = $_[0];
run_program::rooted($prefix, "foomatic-configure",
diff --git a/perl-install/printerdrake.pm b/perl-install/printerdrake.pm
index 64945a796..ebba01ed2 100644
--- a/perl-install/printerdrake.pm
+++ b/perl-install/printerdrake.pm
@@ -2916,6 +2916,10 @@ sub wizard_close {
sub main {
my ($printer, $in, $ask_multiple_printer, $upNetwork) = @_;
+ # Save the user mode, so that the same one is used on the next start
+ # of Printerdrake
+ printer::set_usermode($::expert);
+
# Default printer name, we do not use "lp" so that one can switch the
# default printer under LPD without needing to rename another printer.
# Under LPD the alias "lp" will be given to the default printer.
@@ -3133,7 +3137,7 @@ sub main {
);
# Toggle expert mode and standard mode
if ($menuchoice eq "\@usermode") {
- $::expert = !$::expert;
+ printer::set_usermode(!$::expert);
# Read printer database for the new user mode
%printer::thedb = ();
#my $w = $in->wait_message(_("Printerdrake"),
diff --git a/perl-install/standalone/printerdrake b/perl-install/standalone/printerdrake
index a4190f1e1..f31ca3e68 100755
--- a/perl-install/standalone/printerdrake
+++ b/perl-install/standalone/printerdrake
@@ -31,7 +31,14 @@ local $_ = join '', @ARGV;
/-h/ and die "usage: printerdrake [--beginner] [--expert] [--auto] [--noauto] [--skiptest] [--testing] [--cups] [--lprng] [--lpd] [--pdq]\n";
-$::expert = /-expert/;
+$::expert = 0;
+if (/-expert/) {
+ $::expert = 1;
+} elsif (/-beginner/) {
+ $::expert = 0;
+} else {
+ printer::get_usermode ();
+}
$::noauto = /-noauto/;
$::testing = /-testing/;