diff options
Diffstat (limited to 'perl-install/standalone/printerdrake')
| -rwxr-xr-x | perl-install/standalone/printerdrake | 110 |
1 files changed, 77 insertions, 33 deletions
diff --git a/perl-install/standalone/printerdrake b/perl-install/standalone/printerdrake index e9dde3564..013905069 100755 --- a/perl-install/standalone/printerdrake +++ b/perl-install/standalone/printerdrake @@ -37,7 +37,6 @@ use Gtk2::Gdk::Keysyms; use modules; use c; -my $companyname = "Mandrakesoft"; my $distroname = "Mandrakelinux"; my $domainname = "mandrakesoft.com"; @@ -47,15 +46,15 @@ local $_ = join '', @ARGV; my $printer; +$ugtk2::wm_icon = "printerdrake"; my $in = 'interactive'->vnew('su', if_(!$::isEmbedded, 'printer-mdk')); -my $commandline = $_; -exit 0 unless printer::printerdrake::first_time_dialog($printer, $in); +my $commandline = $_; # Data structure for GTK2 main window my $us = {}; -$us->{VERSION} = '0.1'; +$us->{VERSION} = '10.1'; # GTK2 splash screen my $window_splash; @@ -88,13 +87,19 @@ my $w = $in->wait_message(N("Printerdrake"), # Get what was installed before eval { $printer = printer::main::getinfo('') }; +undef $w; + +exit 0 unless printer::printerdrake::first_time_dialog($printer, $in, undef); + # Were we in expert mode last time? $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 + $printer->{SPOOLER} = 'rcups' and printer::main::read_configured_queues($printer); $commandline =~ /-lpr/ and $printer->{SPOOLER} = 'lpd' and printer::main::read_configured_queues($printer); $commandline =~ /-lpd/ and @@ -103,21 +108,21 @@ $commandline =~ /-lprng/ and $printer->{SPOOLER} = 'lprng' and printer::main::read_configured_queues($printer); $commandline =~ /-pdq/ and $printer->{SPOOLER} = 'pdq' and printer::main::read_configured_queues($printer); -modules::mergein_conf(); - -undef $w; if ($::isInstall) { # Interactive main window for installation - printer::printerdrake::main($printer, $in, 1); + printer::printerdrake::main($printer, $::o->{security}, $in, 1, undef); exit(); } +require security::level; +my $security = security::level::get(); + # Do not let printerdrake ask for the spooler $printer->{SPOOLER} ||= 'cups'; # Initialization -printer::printerdrake::init($printer, $in); +printer::printerdrake::init($printer, $security, $in, undef); # GTK2 main window @@ -133,13 +138,14 @@ 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); # slightly verbatimed from control-center my %options = ( + 'add' => [ N("/_Actions"), N("/_Add Printer") ], 'default' => [ N("/_Actions"), N("/Set as _Default") ], 'edit' => [ N("/_Actions"), N("/_Edit") ], 'delete' => [ N("/_Actions"), N("/_Delete") ], @@ -169,14 +175,14 @@ my ($menu, $factory) = create_factory_menu($::isEmbedded ? $::Plug : $us->{wnd}{ (); }, undef, '<CheckItem>' ], [ N("/_Help"), undef, undef, undef, '<Branch>' ], - [ N("/_Help").N("/_Help"), undef, sub { HelpSystem() }, undef, '<StockItem>', 'gtk-help' ], - [ N("/_Help").N("/_Report Bug"), undef, sub { system("$ENV{BROWSER} https://qa.$domainname &") }, undef, '<StockItem>', 'gtk-stop' ], - [ N("/_Help").N("/_About..."), undef, \&About, undef, '<StockItem>', 'gtk-preferences' ] + [ N("/_Help") . N("/_Help"), undef, sub { HelpSystem() }, undef, '<StockItem>', 'gtk-help' ], + [ N("/_Help") . N("/_Report Bug"), undef, sub { system("$ENV{BROWSER} https://qa.$domainname &") }, undef, '<StockItem>', 'gtk-stop' ], + [ N("/_Help") . N("/_About..."), undef, \&About, undef, '<StockItem>', 'gtk-preferences' ] ) ); %buttorcheck = map { $_ => $factory->get_widget("<main>" . join '', map { s/_//; $_ } @{$options{$_}}) -}('default', 'edit', 'delete', 'expert'); +}('add', 'default', 'edit', 'delete', 'expert'); if (defined $buttorcheck{expert}) { $buttorcheck{expert}->set_active($printer->{expert}); @@ -202,26 +208,26 @@ $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); # $toolb->append_space; -} ( [ +} ([ # FIXME: then "add printer" should be a simple verb as suggested in Human Guidelines!!! #-PO: "Add Printer" is a button text and the translation has to be AS SHORT AS POSSIBLE N("Add Printer"), N("Add a new printer to the system"), 'printer_add', \&AddPrinter ], @@ -241,8 +247,11 @@ my @toolbwg = map { #-PO: "Configure CUPS" is a button text and the translation has to be AS SHORT AS POSSIBLE N("Configure CUPS"), N("Configure CUPS printing system"), 'cups_config', \&ConfigCUPS ] ); -my ($_tbadd, $tbdefault, $tbedit, $tbdel, $_tbref, $_tbconfig) = @toolbwg; +my ($tbadd, $tbdefault, $tbedit, $tbdel, $_tbref, $_tbconfig) = @toolbwg; GrayDelEdit(); +foreach ($tbadd, $buttorcheck{add}) { defined $_ and $_->set_sensitive($printer->{SPOOLER} ne "rcups")}; +$localtree->parent->parent->set_sensitive($printer->{SPOOLER} ne "rcups"); +$nb->set_current_page(1) if $printer->{SPOOLER} eq "rcups"; $fbut->signal_connect('clicked', sub { $stringsearch = $filter->get_text; Refresh($stringsearch) }); Refresh($stringsearch); @@ -283,6 +292,7 @@ sub RefreshLocalPrintersFull { 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) { # Apply string search to all fields, not only the printer name @@ -295,15 +305,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 ]); } } @@ -318,7 +332,8 @@ sub RefreshRemotePrintersFull { next LOOP if defined($printer->{configured}{$p->{queuename}}); # Apply string search to all fields, not only the printer name my $queue = $p->{queuename}; - my $server = $p->{ipp}; + my $server = ($p->{ipp} ? + $p->{ipp} : $printer->{remote_cups_server}); my $description = $p->{description}; my $location = $p->{location}; my $searchstr = "$queue|$server|$description|$location"; @@ -328,13 +343,18 @@ sub RefreshRemotePrintersFull { foreach my $p (sort { lc($a->{queuename}) cmp lc($b->{queuename}) } @RemoteReal) { my $queue = $p->{queuename}; - my $server = $p->{ipp}; + 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 ]); } } @@ -349,7 +369,7 @@ sub Refresh { sub AddPrinter() { deactivate_mainwindow(); - if (printer::printerdrake::add_printer($printer, $in)) { + if (printer::printerdrake::add_printer($printer, $in, undef)) { Refresh($stringsearch); set_selection($printer->{QUEUE}); } else { @@ -393,7 +413,10 @@ sub Delete() { sub ConfigCUPS() { deactivate_mainwindow(); - printer::printerdrake::config_cups($printer, $in); + printer::printerdrake::config_cups($printer, $security, $in, undef); + foreach ($tbadd, $buttorcheck{add}) { defined $_ and $_->set_sensitive($printer->{SPOOLER} ne "rcups")}; + $localtree->parent->parent->set_sensitive($printer->{SPOOLER} ne "rcups"); + $nb->set_current_page(1) if $printer->{SPOOLER} eq "rcups"; Refresh($stringsearch); activate_mainwindow(); } @@ -482,7 +505,23 @@ sub CreateTree { $tree->get_selection->set_mode('browse'); $tree->set_headers_visible(1); $tree->set_rules_hint(1); - $tree->get_selection->signal_connect('changed' => sub { foreach ($tbdefault, $tbedit, $tbdel, $buttorcheck{default}, $buttorcheck{edit}, $buttorcheck{delete}) { $_->set_sensitive(1) } }); + $tree->get_selection->signal_connect('changed' => sub { + my (undef, $_event) = @_; + my (undef, $iter) = $tree->get_selection->get_selected; + return unless $iter; + foreach ($tbdefault, $tbedit, $tbdel, $buttorcheck{default}, $buttorcheck{edit}, $buttorcheck{delete}) { $_->set_sensitive(1) } + my $queue = $tree_model->get($iter, 1); + if (!defined($printer->{configured}{$queue})) { + foreach ($tbdel, $buttorcheck{delete}) { + $_->set_sensitive(0); + } + } + if ($queue eq $printer->{DEFAULT}) { + foreach ($tbdefault, $buttorcheck{default}) { + $_->set_sensitive(0); + } + } + }); $tree->signal_connect(button_press_event => sub { my (undef, $event) = @_; my (undef, $iter) = $tree->get_selection->get_selected; @@ -494,6 +533,11 @@ sub CreateTree { $_->set_sensitive(0); } } + if ($queue eq $printer->{DEFAULT}) { + foreach ($tbdefault, $buttorcheck{default}) { + $_->set_sensitive(0); + } + } Edit() if $event->type eq '2button-press'; }); $tree->signal_connect(key_press_event => sub { @@ -525,7 +569,7 @@ sub About() { $list->can_focus(0); each_index { $list->append_column(Gtk2::TreeViewColumn->new_with_attributes(undef, Gtk2::CellRendererText->new, 'text' => $::i)) } 0..2; $list->set_headers_visible(0); - foreach my $row ([ '', '', ''], [ N("Authors: "), 'Till Kamppeter', "<till\@$domainname>" ], ['', '', '']) { + foreach my $row ([ '', '', '' ], [ N("Authors: "), 'Till Kamppeter', "<till\@$domainname>" ], [ '', '', '' ]) { $tree_model->append_set(undef, [ map_index { $::i => $_ } @$row ]); } $list->get_selection->set_mode('none'); |
