summaryrefslogtreecommitdiffstats
path: root/perl-install/standalone/net_applet
diff options
context:
space:
mode:
authorOlivier Blin <oblin@mandriva.org>2005-07-18 10:42:56 +0000
committerOlivier Blin <oblin@mandriva.org>2005-07-18 10:42:56 +0000
commit30331c62e74af33e4e9ed140dad177dd119e6686 (patch)
treefac69941b9fb8a53a5755241b658df2df85d84bc /perl-install/standalone/net_applet
parent23daad1d73371f7e7927fb94dd970a4f7757790c (diff)
downloaddrakx-backup-do-not-use-30331c62e74af33e4e9ed140dad177dd119e6686.tar
drakx-backup-do-not-use-30331c62e74af33e4e9ed140dad177dd119e6686.tar.gz
drakx-backup-do-not-use-30331c62e74af33e4e9ed140dad177dd119e6686.tar.bz2
drakx-backup-do-not-use-30331c62e74af33e4e9ed140dad177dd119e6686.tar.xz
drakx-backup-do-not-use-30331c62e74af33e4e9ed140dad177dd119e6686.zip
factorize code to netMonitor() and use $current_interface
Diffstat (limited to 'perl-install/standalone/net_applet')
-rw-r--r--perl-install/standalone/net_applet23
1 files changed, 12 insertions, 11 deletions
diff --git a/perl-install/standalone/net_applet b/perl-install/standalone/net_applet
index 8bdf7cbe6..4640e4934 100644
--- a/perl-install/standalone/net_applet
+++ b/perl-install/standalone/net_applet
@@ -20,7 +20,7 @@ use ugtk2 qw(:create :helpers :wrappers);
my $enable_activefw;
my ($eventbox, $img);
-my ($current_state, $menu, $timeout, $update_timeout);
+my ($current_state, $current_interface, $menu, $timeout, $update_timeout);
my $onstartupfile = "$ENV{HOME}/.net_applet";
add_icon_path("/usr/share/libDrakX/pixmaps/");
# Allow multiple instances, but only one per user:
@@ -57,7 +57,7 @@ Run the \"%s\" assistant from the Mandriva Linux Control Center", N("Set up a ne
my %actions = (
'upNetwork' => { name => sub { N("Connect %s", $_[0]) }, launch => sub { network::tools::start_interface($_[0], 1) } },
'downNetwork' => { name => sub { N("Disconnect %s", $_[0]) }, launch => sub { network::tools::stop_interface($_[0], 1) } },
- 'monitorNetwork' => { name => N("Monitor Network"), launch => sub { system("/usr/sbin/net_monitor --defaultintf $_[0] &") } },
+ 'monitorNetwork' => { name => N("Monitor Network"), launch => \&netMonitor },
'wireless' => { name => N("Manage wireless networks"), launch => sub { system("/usr/sbin/drakroam &") } },
'confNetwork' => { name => N("Configure Network"), launch => sub { system("/usr/sbin/drakconnect --skip-wizard &") } },
'chooseInterface' => {
@@ -89,11 +89,9 @@ gtkadd(my $icon = Gtk2::TrayIcon->new("Net_Applet"),
)
);
$eventbox->signal_connect(button_press_event => sub {
- if ($_[1]->button == 1) {
- is_running('net_monitor') or netMonitor();
- }
- $_[1]->button == 3 && $menu and $menu->popup(undef, undef, undef, undef, $_[1]->button, $_[1]->time);
- });
+ $_[1]->button == 1 and netMonitor();
+ $_[1]->button == 3 && $menu and $menu->popup(undef, undef, undef, undef, $_[1]->button, $_[1]->time);
+});
shouldStart() or die "$onstartupfile should be set to TRUE or use net_applet --force";
@@ -140,8 +138,10 @@ sub shouldStart() {
return getAutoStart();
}
sub netMonitor() {
- system("/usr/sbin/net_monitor&");
- checkNetwork();
+ unless (is_running('net_monitor')) {
+ system("/usr/sbin/net_monitor --defaultintf $current_interface &")
+ checkNetwork();
+ }
}
sub checkWireless() {
my $networks = $monitor->list_wireless;
@@ -165,10 +165,11 @@ sub checkWireless() {
}
sub checkNetwork() {
checkWireless();
- my ($gw_intf, $_is_up, $gw_address) = $watched_interface ?
+ my ($_is_up, $gw_address);
+ ($current_interface, $_is_up, $gw_address) = $watched_interface ?
($watched_interface, network::tools::get_interface_status($watched_interface)) :
network::tools::get_internet_connection($net);
- go2State($gw_address ? 'connected' : $gw_intf ? 'disconnected' : 'notconfigured', $gw_intf);
+ go2State($gw_address ? 'connected' : $current_interface ? 'disconnected' : 'notconfigured', $current_interface);
}
sub checkNetworkForce() {
$net = {};