summaryrefslogtreecommitdiffstats
path: root/perl-install/standalone/printerdrake
diff options
context:
space:
mode:
authorMystery Man <unknown@mandriva.org>2005-10-20 14:05:54 +0000
committerMystery Man <unknown@mandriva.org>2005-10-20 14:05:54 +0000
commit9b6a0d83d135fad376b4eadcb2bd7bd8c8a07aa5 (patch)
treef3ef7ada2ce82dafb6d41cc087b0cc7fdfc40a46 /perl-install/standalone/printerdrake
parent3e4ad5e1b687f262a1d7cc39a0b905a595ac7f95 (diff)
downloaddrakx-backup-do-not-use-10_34_11_100mdk.tar
drakx-backup-do-not-use-10_34_11_100mdk.tar.gz
drakx-backup-do-not-use-10_34_11_100mdk.tar.bz2
drakx-backup-do-not-use-10_34_11_100mdk.tar.xz
drakx-backup-do-not-use-10_34_11_100mdk.zip
This commit was manufactured by cvs2svn to create tagV10_34_11_100mdk
'V10_34_11_100mdk'.
Diffstat (limited to 'perl-install/standalone/printerdrake')
-rwxr-xr-xperl-install/standalone/printerdrake288
1 files changed, 184 insertions, 104 deletions
diff --git a/perl-install/standalone/printerdrake b/perl-install/standalone/printerdrake
index 42694f065..bb01d456f 100755
--- a/perl-install/standalone/printerdrake
+++ b/perl-install/standalone/printerdrake
@@ -1,9 +1,9 @@
#!/usr/bin/perl
#
-# Copyright (C) 2003-2004 MandrakeSoft
+# Copyright (C) 2003-2005 Mandriva
#
-# Till Kamppeter <till@mandrakesoft.com>
-# Daouda Lo <daouda@mandrakesoft.com>
+# Till Kamppeter <till at mandriva.com>
+# Daouda Lo <daouda at mandriva.com>
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License Version 2 as
@@ -20,6 +20,11 @@
#
use strict;
+
+# i18n: IMPORTANT: to get correct namespace (printerdrake instead of
+# libDrakX)
+BEGIN { unshift @::textdomains, 'drakconf' }
+
use lib qw(/usr/lib/libDrakX);
use standalone;
@@ -37,64 +42,55 @@ use Gtk2::Gdk::Keysyms;
use modules;
use c;
-my $companyname = "Mandrakesoft";
-my $distroname = "Mandrakelinux";
-my $domainname = "mandrakesoft.com";
+my %sysh = distrib();
+my $distroname = $sysh{system};
+
+my $domainname = "mandriva.com";
my $pixdir = '/usr/share/libDrakX/pixmaps/';
+my $refreshinterval = 5;
+
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);
+# Suppress some wait messages to avoid windows popping up if no new print
+# queue has to be set up
+$commandline =~ /-onlyautoqueue/ and $::autoqueue = 1;
# Data structure for GTK2 main window
my $us = {};
-$us->{VERSION} = '0.1';
-
-# GTK2 splash screen
-my $window_splash;
-if (0 && !$::isInstall && !$::isEmbedded) {
- $window_splash = Gtk2::Window->new('popup');
-#BUG $window_splash->signal_connect(delete_event => \&quit_global);
- $window_splash->set_title(N("Printerdrake") . $us->{VERSION});
- $window_splash->set_position('center_always');
- $window_splash->add(gtkadd(gtkset_shadow_type(Gtk2::Frame->new, 'etched_out'),
- gtkpack(Gtk2::VBox->new(0, 0),
- gtkcreate_img("$pixdir/about.png"),
- Gtk2::Label->new(N("Loading printer configuration... Please wait"))
- )
- )
- );
- $window_splash->show_all;
- gtkflush();
-}
-
-#my $wait = $in->wait_message(N("Please wait"),
-# N("Loading printer configuration... "));
-#gtkflush();
+$us->{VERSION} = '2006';
# Check whether Foomatic is installed and install it if necessary
#printer::printerdrake::install_foomatic($in);
-my $w = $in->wait_message(N("Printerdrake"),
- N("Reading data of installed printers..."));
+my $w = $::autoqueue ||
+ $in->wait_message(N("Printerdrake"),
+ N("Reading data of installed printers..."));
# 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,29 +99,32 @@ $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);
--r '/etc/modules.conf' and modules::mergein_conf('/etc/modules.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);
+
+# Stop here when we are supposed to only automatically set up print queues
+$commandline =~ /-onlyautoqueue/ and exit 0;
# GTK2 main window
-my $error = 0;
my $stringsearch = '';
-sub HelpSystem() { exec("drakhelp --id printerdrake") unless fork() };
+sub HelpSystem() { exec("drakhelp --id printerdrake") unless fork() }
+$::noborderWhenEmbedded = 1;
$us->{wnd} = ugtk2->new(N("%s Printer Management Tool", $distroname) . " " . $us->{VERSION});
gtkset_size_request($us->{wnd}{rwindow}, 660, 460);
@@ -133,13 +132,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") ],
@@ -168,15 +168,18 @@ my ($menu, $factory) = create_factory_menu($::isEmbedded ? $::Plug : $us->{wnd}{
%printer::main::thedb =
();
}, undef, '<CheckItem>' ],
+ [ N("/_Options") . N("/Configure _Auto Administration"), undef, \&ConfigAutoAdmin, undef, '<StockItem>', 'gtk-autoadmin' ],
[ 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' ]
+ if_(-x "/usr/sbin/drakhelp_inst",
+ [ N("/_Help") . N("/_Help"), undef, sub { HelpSystem() }, undef, '<StockItem>', 'gtk-help' ],
+ ),
+ if_(!-e "/etc/sysconfig/oem",
+ [ 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');
+%buttorcheck = map { $_ => $factory->get_widget("<main>" . join '', map { s/_//; $_ } @{$options{$_}}) } ('add', 'default', 'edit', 'delete', 'expert');
if (defined $buttorcheck{expert}) {
$buttorcheck{expert}->set_active($printer->{expert});
@@ -190,80 +193,100 @@ my $searchBox = gtkpack_(Gtk2::HBox->new(0,5),
1, Gtk2::Label->new(""),
0, Gtk2::Label->new(N("Search:")),
0, gtksignal_connect($filter = Gtk2::Entry->new,
- key_press_event => sub { $_[1]->keyval == $Gtk2::Gdk::Keysyms{Return} and Refresh($filter->get_text) }),
+ key_press_event => sub { $_[1]->keyval == $Gtk2::Gdk::Keysyms{Return} and do { $stringsearch = $filter->get_text; Refresh($stringsearch) };}),
0, my $fbut = Gtk2::Button->new(N("Apply filter")),
);
gtkappend_page(my $nb = Gtk2::Notebook->new, gtkpack(create_scrolled_window($localtree)), gtkshow(Gtk2::Label->new(N("Configured on this machine"))));
gtkappend_page($nb, gtkpack(create_scrolled_window($remotetree)), gtkshow(Gtk2::Label->new(N("Configured on other machines"))));
$nb->set_show_border(0);
+
+my @extra_widgets;
+if ($::isEmbedded) {
+ push @extra_widgets, 0, Gtk2::Banner->new("/usr/share/mcc/themes/default/printer-mcc-mdk.png",
+ #-PO: do not translate, this is already translated in mcc
+ translate("Printers"));
+}
+
$us->{wnd}{window}->add(gtkpack_(Gtk2::VBox->new(0, 0),
0, $menu,
+ @extra_widgets,
0, $toolb,
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;
-#-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 ],
-#-PO "Set as default" is a button text and the translation has to be AS SHORT AS POSSIBLE
- [ N("Set as default"), N("Set selected printer as the default printer"), 'printer_default', \&SetAsDefault ],
-#-PO "Edit" is a button text and the translation has to be AS SHORT AS POSSIBLE
- [ N("Edit"), N("Edit selected printer"), 'printer_conf', \&Edit ],
-#-PO "Delete" is a button text and the translation has to be AS SHORT AS POSSIBLE
- [ N("Delete"), N("Delete selected printer"), 'printer_del', \&Delete ],
-#-PO "Refresh" is a button text and the translation has to be AS SHORT AS POSSIBLE
- [ N("Refresh"), N("Refresh the list"), 'refresh', sub { Refresh($stringsearch) } ],
-#-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 ]
+} ([
+ # 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 ],
+ [
+ #-PO: "Set as default" is a button text and the translation has to be AS SHORT AS POSSIBLE
+ N("Set as default"), N("Set selected printer as the default printer"), 'printer_default', \&SetAsDefault ],
+ [
+ #-PO: "Edit" is a button text and the translation has to be AS SHORT AS POSSIBLE
+ N("Edit"), N("Edit selected printer"), 'printer_conf', \&Edit ],
+ [
+ #-PO: "Delete" is a button text and the translation has to be AS SHORT AS POSSIBLE
+ N("Delete"), N("Delete selected printer"), 'printer_del', \&Delete ],
+ [
+ #-PO: "Refresh" is a button text and the translation has to be AS SHORT AS POSSIBLE
+ N("Refresh"), N("Refresh the list"), 'refresh', sub { Refresh($stringsearch) } ],
+ [
+ #-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);
$nb->signal_connect('switch-page' => sub { NotebookSwitch() });
$us->{wnd}{rwindow}->show_all;
set_selection($printer->{DEFAULT});
-#undef $wait;
-if (0 && !$::isInstall && !$::isEmbedded) {
- $window_splash->destroy;
- undef $window_splash;
-}
gtkset_mousecursor_normal();
# Prevent subwindows to embed themselves in the mcc which has already the
# main window embedded
+my $isEmbedded = $::isEmbedded;
local $::isEmbedded = 0;
-Gtk2->main;
+# Auto refresh
+my $refreshing = 0;
+Glib::Timeout->add($refreshinterval * 1000,
+ sub { Refresh($stringsearch); 1 });
+
+$us->{wnd}->main;
ugtk2->exit;
sub GrayDelEdit() {
- foreach ($tbdefault, $tbedit, $tbdel, $buttorcheck{default}, $buttorcheck{edit}, $buttorcheck{delete}) { defined $_ and $_->set_sensitive(0) };
+ foreach ($tbdefault, $tbedit, $tbdel, $buttorcheck{default}, $buttorcheck{edit}, $buttorcheck{delete}) { defined $_ and $_->set_sensitive(0) }
}
sub TreeUnselect {
my $treev = shift;
$treev->get_selection->unselect_all;
- GrayDelEdit()
+ GrayDelEdit();
}
sub NotebookSwitch() {
TreeUnselect($localtree);
@@ -272,38 +295,48 @@ sub NotebookSwitch() {
}
sub RefreshLocalPrintersFull {
- my ($strfilt) = @_;
+ my ($strfilt, @allprinters) = @_;
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) {
+ foreach my $p (@printers) {
# Apply string search to all fields, not only the printer name
+ my $state = ($printer->{SPOOLER} !~ /cups/ ? N("Unknown") :
+ ((any {
+ ($_->{queuename} eq $p) &&
+ ($_->{state} eq "enabled");
+ } @allprinters) ? N("Enabled") : N("Disabled")));
my $connect = printer::main::connectionstr($printer->{configured}{$p}{queuedata}{connect});
my $model = $printer->{configured}{$p}{queuedata}{make} . ' ' .
$printer->{configured}{$p}{queuedata}{model};
my $description = $printer->{configured}{$p}{queuedata}{desc};
my $location = $printer->{configured}{$p}{queuedata}{loc};
- my $searchstr = "$p|$model|$connect|$description|$location";
- push(@LocalReal, $p) if $searchstr =~ /\Q$strfilt/i;
- };
+ my $searchstr = "$p|$state|$model|$connect|$description|$location";
+ push(@LocalReal, $p) if !$strfilt || ($searchstr =~ /\Q$strfilt/i);
+ }
foreach my $p (sort { lc($a) cmp lc($b) } @LocalReal) {
+ my $state = ($printer->{SPOOLER} !~ /cups/ ? N("Unknown") :
+ ((any {
+ ($_->{queuename} eq $p) &&
+ ($_->{state} eq "enabled");
+ } @allprinters) ? 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 ]);
}
}
sub RefreshRemotePrintersFull {
- my ($strfilt) = @_;
- my @printers;
- defined $printer and @printers = printer::cups::lpstat_lpv();
+ my ($strfilt, @printers) = @_;
$rtree_model->clear;
my @RemoteReal;
LOOP: foreach my $p (@printers) {
@@ -311,38 +344,50 @@ 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 $state = ($p->{state} eq "enabled" ?
+ N("Enabled") : N("Disabled"));
+ my $server = $p->{ipp} || $printer->{remote_cups_server};
my $description = $p->{description};
my $location = $p->{location};
- my $searchstr = "$queue|$server|$description|$location";
+ my $searchstr = "$queue|$state|$server|$description|$location";
# All remaining to which the search term applies
- push(@RemoteReal, $p) if $searchstr =~ /\Q$strfilt/i;
- };
+ push(@RemoteReal, $p) if !$strfilt || ($searchstr =~ /\Q$strfilt/i);
+ }
foreach my $p (sort { lc($a->{queuename}) cmp lc($b->{queuename}) }
@RemoteReal) {
my $queue = $p->{queuename};
- my $server = $p->{ipp};
+ my $state = ($p->{state} eq "enabled" ?
+ N("Enabled") : N("Disabled"));
+ my $server = $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 ]);
}
}
sub Refresh {
+ # Do not have ourselves recalled if we are already running
+ return if $refreshing;
+ $refreshing = 1;
my ($strfilt) = @_;
my $selection = get_selection();
- RefreshLocalPrintersFull($strfilt);
- RefreshRemotePrintersFull($strfilt);
+ printer::services::wait_for_cups() if ($printer->{SPOOLER} eq "cups");
+ my @printers;
+ defined $printer and @printers = printer::cups::lpstat_lpv();
+ RefreshLocalPrintersFull($strfilt, @printers);
+ RefreshRemotePrintersFull($strfilt, @printers);
GrayDelEdit();
set_selection($selection);
+ $refreshing = 0;
}
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 {
@@ -386,7 +431,17 @@ 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();
+}
+
+sub ConfigAutoAdmin() {
+ deactivate_mainwindow();
+ printer::printerdrake::config_auto_admin($printer, $in);
Refresh($stringsearch);
activate_mainwindow();
}
@@ -394,7 +449,6 @@ sub ConfigCUPS() {
sub deactivate_mainwindow() {
$us->{wnd}{rwindow}->set_sensitive(0);
gtkset_mousecursor_wait();
- $error = 0;
}
sub activate_mainwindow() {
@@ -466,7 +520,7 @@ sub GetNameEntFromIter {
my (undef, $iter) = $tree->get_selection->get_selected;
return undef if !defined($iter);
my $name = $model->get($iter, $rank);
- $name
+ $name;
}
sub CreateTree {
@@ -475,18 +529,39 @@ 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;
return unless $iter;
- foreach ($tbdefault, $tbedit, $tbdel, $buttorcheck{default}, $buttorcheck{edit}, $buttorcheck{delete}) { $_->set_sensitive(1) };
+ 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);
+ }
+ }
Edit() if $event->type eq '2button-press';
});
$tree->signal_connect(key_press_event => sub {
@@ -495,13 +570,13 @@ sub CreateTree {
return unless $iter;
Edit() if $event->keyval == $Gtk2::Gdk::Keysyms{Return};
});
- $tree
+ $tree;
}
sub NewDialog {
my ($title, $o_no_button) = @_;
my $dialog = gtkset_border_width(Gtk2::Dialog->new, 10);
- $dialog->set_transient_for($us->{wnd}{rwindow});
+ $dialog->set_transient_for($us->{wnd}{real_window});
$dialog->set_position('center-on-parent');
$dialog->set_title($title);
$dialog->action_area->pack_start(gtkadd(Gtk2::HButtonBox->new,
@@ -518,13 +593,18 @@ 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');
gtkpack_($window_about->vbox,
-r "$pixdir/about-printerdrake.png" ?
- (0, Gtk2::Image->new_from_file("$pixdir/about-printerdrake.png")) : (1, gtkmodify_font(Gtk2::Label->new(N("Printer Management \n") . $us->{VERSION}), 'Bold 18'),),
+ (0, Gtk2::Image->new_from_file("$pixdir/about-printerdrake.png")) :
+ (1, gtkset_markup(Gtk2::Label->new,
+ qq(<span weight="bold" size="x-large">) .
+ #-PO: here %s is the version number
+ N("Printer Management %s", $us->{VERSION}) . "</span>"),
+ ),
1, $list,
);
$window_about->show_all;