package scanner; # scanner.pm $Id$ # Yves Duret # Copyright (C) 2001-2002 MandrakeSoft # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2, or (at your option) # any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. # # pbs/TODO: # - scsi mis-configuration # - devfs use dev_is_devfs() # - with 2 scanners same manufacturer -> will overwrite previous conf -> only 1 conf !! # - lp: see printerdrake # - install: prefix --> done use standalone; use common; use detect_devices; use log; my $_sanedir = "$::prefix/etc/sane.d"; my $_scannerDBdir = "$::prefix$ENV{SHARE_PATH}/ldetect-lst"; my $scannerDB = readScannerDB("$_scannerDBdir/ScannerDB"); sub confScanner { my ($model, $port) = @_; $port ||= detect_devices::dev_is_devfs() ? "$::prefix/dev/usb/scanner0" : "$::prefix/dev/scanner"; my $a = $scannerDB->{$model}{server}; #print "file:[$a]\t[$model]\t[$port]\n| ", (join "\n| ", @{$scannerDB->{$model}{lines}}),"\n"; output("$_sanedir/$a.conf", (join "\n", @{$scannerDB->{$model}{lines}})); substInFile { s/\$DEVICE/$port/ } "$_sanedir/$a.conf"; add2dll($a); } sub add2dll { return if member($_[0], chomp_(cat_("$_sanedir/dll.conf"))); append_to_file("$_sanedir/dll.conf", "$_[0]\n"); } sub detect { my ($i, @res) = 0; foreach (grep { $_->{driver} =~ /scanner/ } detect_devices::usb_probe()) { #my ($manufacturer, $model) = split '\|', $_->{description}; #$_->{description} =~ s/Hewlett[-\s_]Packard/HP/; $_->{description} =~ s/Seiko\s+Epson/Epson/i; push @res, { port => "/dev/usb/scanner$i", val => { #CLASS => 'SCANNER', #MODEL => $model, #MANUFACTURER => $manufacturer, DESCRIPTION => $_->{description}, #id => $_->{id}, #vendor => $_->{vendor}, } }; ++$i; } foreach (grep { $_->{media_type} =~ /scanner/ } detect_devices::getSCSI()) { $_->{info} =~ s/Seiko\s+Epson/Epson/i; push @res, { port => "/dev/sg", val => { DESCRIPTION => $_->{info} }, }; ++$i; } @res; } sub readScannerDB { my ($file) = @_; my ($card, %cards); my $F = common::openFileMaybeCompressed($file); my ($lineno, $cmd, $val) = 0; my $fs = { LINE => sub { push @{$card->{lines}}, $val }, NAME => sub { #$cards{$card->{type}} = $card if ($card and !$card->{flags}{unsupported}); $cards{$card->{type}} = $card if $card; $val =~ s/Seiko\s+Epson/Epson/i; $card = { type => $val }; }, SEE => sub { $val =~ s/Seiko\s+Epson/Epson/i; my $c = $cards{$val} or die "Error in database, invalid reference $val at line $lineno"; push @{$card->{lines}}, @{$c->{lines} || []}; add2hash($card->{flags}, $c->{flags}); add2hash($card, $c); }, ASK => sub { $card->{ask} = $val }, SERVER => sub { $card->{server} = $val }, DRIVER => sub { $card->{driver} = $val }, UNSUPPORTED => sub { $card->{flags}{unsupported} = 1 }, COMMENT => sub {}, }; local $_; while (<$F>) { $lineno++; s/\s+$//; /^#/ and next; /^$/ and next; /^END/ and do { $cards{$card->{type}} = $card if $card; last }; ($cmd, $val) = /(\S+)\s*(.*)/ or next; #log::l("bad line $lineno ($_)"), next; my $f = $fs->{$cmd}; $f ? $f->() : log::l("unknown line $lineno ($_)"); } \%cards; } sub updateScannerDBfromUsbtable { substInFile { s/END// } "ScannerDB"; my $to_add = "# generated from usbtable by scannerdrake\n"; foreach (cat_("$ENV{SHARE_PATH}/ldetect-lst/usbtable")) { my ($vendor_id, $product_id, $mod, $name) = chomp_(split /\s/,$_,4); next if $mod ne '"scanner"'; $name =~ s/\"(.*)\"$/$1/; if (member($name, keys %$scanner::scannerDB)) { print "#[$name] already in ScannerDB!\n"; next; } $to_add .= "NAME $name\nDRIVER usb\nCOMMENT usb $vendor_id $product_id\nUNSUPPORTED\n\n"; } $to_add .= "END\n"; append_to_file("ScannerDB", $to_add); } sub updateScannerDBfromSane { my ($_sanesrcdir) = @_; substInFile { s/END// } "ScannerDB"; my $to_add = "# generated from Sane by scannerdrake\n"; # for compat with our usbtable my $sane2DB = { "Acer" => "Acer Peripherals Inc.", "AGFA" => "AGFA-Gevaert NV", "Agfa" => "AGFA-Gevaert NV", "Epson" => "Epson Corp.", "Fujitsu Computer Products of America" => "Fujitsu", "HP" => sub { $_[0] =~ s/HP\s/Hewlett-Packard|/; $_[0] =~ s/HP4200/Hewlett-Packard|ScanJet 4200C/; $_[0] }, "Hewlett-Packard" => sub { $_[0] =~ s/HP 3200 C/Hewlett-Packard|ScanJet 3200C/; $_[0] }, "Kodak" => "Kodak Co.", "Mustek" => "Mustek Systems Inc.", "NEC" => "NEC Systems", "Nikon" => "Nikon Corp.", "Plustek" => "Plustek, Inc.", "Primax" => "Primax Electronics", "Siemens" => "Siemens Information and Communication Products", "Trust" => "Trust Technologies", "UMAX" => "Umax", "Vobis/Highscreen" => "Vobis", }; foreach my $f (glob_("$_sanesrcdir/*.desc")) { my $F = common::openFileMaybeCompressed($f); $to_add .= "\n# from $f"; my ($lineno, $cmd, $val) = 0; my ($name, $intf, $comment, $mfg, $backend); my $fs = { backend => sub { $backend = $val }, mfg => sub { $mfg = $val; $name = undef },#bug when a new mfg comes. should called $fs->{ $name }(); but ?? model => sub { unless ($name) { $name = $val; next } $name = member($mfg, keys %$sane2DB) ? (ref $sane2DB->{$mfg}) ? $sane2DB->{$mfg}($name) : "$sane2DB->{ $mfg }|$name" : "$mfg|$name"; if (member($name, keys %$scanner::scannerDB)) { print "#[$name] already in ScannerDB!\n"; } else { $to_add .= "\nNAME $name\nSERVER $backend\nDRIVER $intf\n"; $to_add .= "COMMENT $comment\n" if $comment; $comment = undef; } $name = $val; }, interface => sub { $intf = $val }, comment => sub { $comment = $val }, }; local $_; while (<$F>) { $lineno++; s/\s+$//; /^\;/ and next; ($cmd, $val) = /:(\S+)\s*\"([^\;]*)\"/ or next; #log::l("bad line $lineno ($_)"), next; my $f = $fs->{$cmd}; $f ? $f->() : log::l("unknown line $lineno ($_)"); } $fs->{model}(); # the last one } $to_add .= "\nEND\n"; append_to_file("ScannerDB", $to_add); } 1; # option value='0' selected='selected'>includemode:
authorPascal Rigaux <pixel@mandriva.com>2007-04-25 12:26:16 +0000
committerPascal Rigaux <pixel@mandriva.com>2007-04-25 12:26:16 +0000
commit126777bc019a54afb4ec51299f2cf9d2841698aa (patch)
tree97f76e571902ead55ba138f1156a4b4f00b9b779 /perl-install/standalone/drakfloppy
parentf1f67448efc714873378dfeb8279fae68054a90a (diff)
downloaddrakx-backup-do-not-use-126777bc019a54afb4ec51299f2cf9d2841698aa.tar
drakx-backup-do-not-use-126777bc019a54afb4ec51299f2cf9d2841698aa.tar.gz
drakx-backup-do-not-use-126777bc019a54afb4ec51299f2cf9d2841698aa.tar.bz2
drakx-backup-do-not-use-126777bc019a54afb4ec51299f2cf9d2841698aa.tar.xz
drakx-backup-do-not-use-126777bc019a54afb4ec51299f2cf9d2841698aa.zip
re-sync after the big svn loss
Diffstat (limited to 'perl-install/standalone/drakfloppy')
-rwxr-xr-xperl-install/standalone/drakfloppy64
1 files changed, 32 insertions, 32 deletions
diff --git a/perl-install/standalone/drakfloppy b/perl-install/standalone/drakfloppy
index 9cdfb3e82..1dcc5b0d6 100755
--- a/perl-install/standalone/drakfloppy
+++ b/perl-install/standalone/drakfloppy
@@ -3,7 +3,7 @@
# DrakFloppy
# $Id$
#
-# Copyright (C) 2001-2005 Mandriva
+# Copyright (C) 2001-2006 Mandriva
# Yves Duret
# Thierry Vignaud
#
@@ -29,16 +29,16 @@ use lib qw(/usr/lib/libDrakX);
use standalone; #- warning, standalone must be loaded very first, for 'explanations'
use common;
+use mygtk2 qw(gtknew);
use ugtk2 qw(:create :dialogs :helpers :wrappers);
use detect_devices;
$ugtk2::wm_icon = "/usr/share/mcc/themes/default/drakfloppy-mdk.png";
require_root_capability();
-my $window = ugtk2->new('drakfloppy');
+my $window = ugtk2->new(N("Boot Floppy"));
unless ($::isEmbedded) {
$window->{rwindow}->signal_connect(delete_event => sub { ugtk2->exit(0) });
- $window->{rwindow}->set_title(N("drakfloppy"));
$window->{rwindow}->set_border_width(5);
### menus definition
@@ -63,38 +63,38 @@ eval { %options = getVarsFromSh($conffile) };
######## up part
# device part
-my $device_combo = Gtk2::ComboBox->new_with_strings([ map { "/dev/$_" } detect_devices::floppies_dev() ]);
+my $device_combo = gtknew('ComboBox', list => [ map { "/dev/$_" } detect_devices::floppies_dev() ]);
$device_combo->set_active(0);
# kernel part
-my $kernel_combo = Gtk2::ComboBox->new_with_strings([ sort grep { !/^\.\.?$/ } sort(all("/lib/modules")) ], chomp_(`uname -r`));
+my $kernel_combo = gtknew('ComboBox', text => chomp_(`uname -r`), list => [ sort grep { !/^\.\.?$/ } sort(all("/lib/modules")) ]);
##########################################################
### main window
$window->{window}->add(
- gtkpack_(Gtk2::VBox->new,
- if_($::isEmbedded, 0, Gtk2::Label->new(N("Boot disk creation"))),
- 0, gtkadd(Gtk2::Frame->new(N("General")),
- gtkpack__(Gtk2::VBox->new(0, 0),
- gtkpack__(Gtk2::HBox->new(1, 0),
- Gtk2::Label->new(N("Device")),
+ gtknew('VBox', children => [
+ if_($::isEmbedded, 0, gtknew('Label', text => N("Boot disk creation"))),
+ 0, gtknew('Frame', text => N("General"), child =>
+ gtknew('VBox', children_tight => [
+ gtknew('HBox', homogenous => 1, children_tight => [
+ gtknew('Label', text => N("Device")),
$device_combo,
- gtksignal_connect(Gtk2::Button->new(N("Default")),
+ gtknew('Button', text => N("Default"),
clicked => sub { $device_combo->entry->set_text("/dev/fd0") }),
- ),
- gtkpack__(Gtk2::HBox->new(1, 0),
- Gtk2::Label->new(N("Kernel version")),
+ ]),
+ gtknew('HBox', homogenous => 1, children_tight => [
+ gtknew('Label', text => N("Kernel version")),
$kernel_combo,
- gtksignal_connect(Gtk2::Button->new(N("Default")),
+ gtknew('Button', text => N("Default"),
clicked => sub {
$kernel_combo->entry->set_text(chomp_(`uname -r`));
}),
- ),
- ),
+ ]),
+ ]),
),
- 1, Gtk2::VBox->new,
+ 1, gtknew('VBox'),
0, create_okcancel({
cancel_clicked => sub { ugtk2->exit(0) },
ok_clicked => \&build_it,
@@ -102,7 +102,7 @@ $window->{window}->add(
undef, undef, '',
[ N("Preferences"), \&pref_dialog, 0 ],
),
- ),
+ ]),
);
$window->{rwindow}->show_all;
@@ -136,24 +136,24 @@ sub pref_dialog() {
} (N("Module name"), N("Size"));
gtkpack_($dialog->vbox,
- 0, gtkadd(Gtk2::Frame->new(N("Mkinitrd optional arguments")),
- gtkpack__(Gtk2::VBox->new(0, 5),
- $buttons{force} = Gtk2::CheckButton->new(N("force")),
- $buttons{raid} = Gtk2::CheckButton->new(N("omit raid modules")),
- $buttons{needed} = Gtk2::CheckButton->new(N("if needed")),
- $buttons{scsi} = Gtk2::CheckButton->new(N("omit scsi modules")),
- ),
+ 0, gtknew('Frame', text => N("Mkinitrd optional arguments"), child =>
+ gtknew('VBox', spacing => 5, children_tight => [
+ $buttons{force} = gtknew('CheckButton', text => N("force")),
+ $buttons{raid} = gtknew('CheckButton', text => N("omit raid modules")),
+ $buttons{needed} = gtknew('CheckButton', text => N("if needed")),
+ $buttons{scsi} = gtknew('CheckButton', text => N("omit scsi modules")),
+ ]),
),
- 1, gtkadd(Gtk2::Frame->new(N("Add a module")),
+ 1, gtknew('Frame', text => N("Add a module"), child =>
create_hpaned(
gtkset_size_request(
- create_scrolled_window($tree),
+ gtknew('ScrolledWindow', child => $tree),
200, $::isEmbedded ? 0 : 175),
- gtkpack_(Gtk2::VBox->new(0, 0),
+ gtknew('VBox', children => [
1, gtkadd(Gtk2::ScrolledWindow->new,
$list
),
- 0, gtksignal_connect($remove_but = Gtk2::Button->new(N("Remove a module")),
+ 0, $remove_but = gtknew('Button', text => N("Remove a module"),
clicked => sub {
my $iter = ($list->get_selection->get_selected)[1];
return unless $iter;
@@ -162,7 +162,7 @@ sub pref_dialog() {
@temp_modules = grep { $_ ne $removed } @temp_modules;
$remove_but->set_sensitive(scalar @temp_modules);
}),
- ),
+ ]),
),
),
);