From 9177b0fd02f89be8d286b91d12ab6255942865c3 Mon Sep 17 00:00:00 2001 From: Thierry Vignaud Date: Fri, 29 Jul 2005 05:48:23 +0000 Subject: - perl_checker fixes - reuse common - drop interactive dependancy --- perl-install/standalone/drakhosts | 27 ++++++++++++--------------- 1 file changed, 12 insertions(+), 15 deletions(-) diff --git a/perl-install/standalone/drakhosts b/perl-install/standalone/drakhosts index 709a824ae..ef005b0ce 100644 --- a/perl-install/standalone/drakhosts +++ b/perl-install/standalone/drakhosts @@ -28,7 +28,6 @@ use strict; use common; use network::network; -use interactive; use ugtk2 qw(:ask :wrappers :create :dialogs); use constant FALSE => 0; @@ -42,7 +41,7 @@ use constant COLUMN_HOSTNAME => 1; use constant COLUMN_ALIAS => 2; use constant NUM_COLUMNS => 3; -my $in = 'interactive'->vnew('su'); +require_root_capability(); my %size_groups = map { $_ => Gtk2::SizeGroup->new('horizontal') } qw(label widget); my $label_and_widgets = sub { @@ -54,7 +53,7 @@ my $label_and_widgets = sub { }; -sub get_host_data { +sub get_host_data() { # 127.0.0.1 localhost.localdomain localhost # 10.0.1.253 guibpiv.guibland.com foreach (cat_($HOSTS)) { @@ -67,7 +66,7 @@ sub get_host_data { } } -sub write_conf_hosts { +sub write_conf_hosts() { output($HOSTS, "# generated by drakhosts\n"); foreach my $a (@listhosts) { append_to_file($HOSTS, "$a->{ip} $a->{hostname} $a->{alias}\n"); @@ -75,7 +74,7 @@ sub write_conf_hosts { } sub add_modify_entry { - my ($widget, $treeview, $wanted) = @_; + my ($_widget, $treeview, $wanted) = @_; my $model = $treeview->get_model; my $selection = $treeview->get_selection; my $iter; @@ -83,7 +82,7 @@ sub add_modify_entry { undef $i; undef $iter; - map { $_ = Gtk2::Entry->new } $ip, $hostname, $alias; + $_ = Gtk2::Entry->new foreach $ip, $hostname, $alias; # test if modify or add a host @@ -104,9 +103,10 @@ sub add_modify_entry { $oldip = $listhosts[$i]{ip}; } - if ($wanted =~ /modify/) { $text = N("Please modify information"); } - if ($wanted =~ /delete/) { $text = N("Please delete information"); } - if ($wanted =~ /add/) { $text = N("Please add information"); } + my $text; + $text = N("Please modify information") if $wanted =~ /modify/; + $text = N("Please delete information") if $wanted =~ /delete/; + $text = N("Please add information") if $wanted =~ /add/; gtkpack_($dialog->vbox, 0, gtkadd(Gtk2::Frame->new($text), @@ -121,9 +121,8 @@ sub add_modify_entry { ok_clicked => sub { is_ip($ip->get_text) or err_dialog(N("Error!"), N("Please enter a valid IP address.")) and return; my $testip = chomp_($ip->get_text); - my $testname = chomp_($hostname->get_text); my $toldip = chomp_($oldip); - if ($testip !~ /$toldip/ or $wanted =~ /add/) { + if ($testip !~ /$toldip/ || $wanted =~ /add/) { foreach my $a (@listhosts) { if ($a->{ip} =~ /$testip/) { err_dialog(N("Error!"), N("Same IP is already in %s file.", $HOSTS)) and return; @@ -157,7 +156,7 @@ sub add_modify_entry { } sub remove_entry { - my ($widget, $treeview) = @_; + my ($_widget, $treeview) = @_; my $model = $treeview->get_model; my $selection = $treeview->get_selection; my $iter = $selection->get_selected; @@ -222,15 +221,13 @@ $treeview->signal_connect(button_press_event => sub { my $selection = $treeview->get_selection; my $iter = $selection->get_selected; if ($iter) { - my $path = $model->get_path($iter); - my $i = ($path->get_indices)[0]; add_modify_entry($model, $treeview, "modify") if $event->type eq '2button-press'; } }); my $okcancel = create_okcancel({ cancel_clicked => sub { ugtk2->exit }, - ok_clicked => sub { write_conf_hosts; ugtk2->exit; }, + ok_clicked => sub { write_conf_hosts(); ugtk2->exit }, }, ); -- cgit v1.2.1