diff options
author | Thierry Vignaud <tvignaud@mandriva.org> | 2005-07-29 05:48:23 +0000 |
---|---|---|
committer | Thierry Vignaud <tvignaud@mandriva.org> | 2005-07-29 05:48:23 +0000 |
commit | 9177b0fd02f89be8d286b91d12ab6255942865c3 (patch) | |
tree | 0103ab8656aa97569a6c9cac74371a4930cb134b | |
parent | 1d356f126fea25c848ccbf9ccbf6dae7f84c00a1 (diff) | |
download | drakx-9177b0fd02f89be8d286b91d12ab6255942865c3.tar drakx-9177b0fd02f89be8d286b91d12ab6255942865c3.tar.gz drakx-9177b0fd02f89be8d286b91d12ab6255942865c3.tar.bz2 drakx-9177b0fd02f89be8d286b91d12ab6255942865c3.tar.xz drakx-9177b0fd02f89be8d286b91d12ab6255942865c3.zip |
- perl_checker fixes
- reuse common
- drop interactive dependancy
-rw-r--r-- | perl-install/standalone/drakhosts | 27 |
1 files 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 }, }, ); |