diff options
author | Olivier Blin <oblin@mandriva.org> | 2005-07-22 04:25:50 +0000 |
---|---|---|
committer | Olivier Blin <oblin@mandriva.org> | 2005-07-22 04:25:50 +0000 |
commit | a9c5d55379ae22f696b82d2c6f8ca7a15eb1a46c (patch) | |
tree | 044bc1bdc5794cd059537490d80a40c15f8675b5 /perl-install/standalone | |
parent | c53ad98c834d6695504772425e4bc04e6c88f779 (diff) | |
download | drakx-backup-do-not-use-a9c5d55379ae22f696b82d2c6f8ca7a15eb1a46c.tar drakx-backup-do-not-use-a9c5d55379ae22f696b82d2c6f8ca7a15eb1a46c.tar.gz drakx-backup-do-not-use-a9c5d55379ae22f696b82d2c6f8ca7a15eb1a46c.tar.bz2 drakx-backup-do-not-use-a9c5d55379ae22f696b82d2c6f8ca7a15eb1a46c.tar.xz drakx-backup-do-not-use-a9c5d55379ae22f696b82d2c6f8ca7a15eb1a46c.zip |
split
Diffstat (limited to 'perl-install/standalone')
-rw-r--r-- | perl-install/standalone/net_applet | 64 |
1 files changed, 35 insertions, 29 deletions
diff --git a/perl-install/standalone/net_applet b/perl-install/standalone/net_applet index 35ff6df67..1166d21d2 100644 --- a/perl-install/standalone/net_applet +++ b/perl-install/standalone/net_applet @@ -144,40 +144,46 @@ sub run_net_monitor() { sub run_drakroam() { run_program::raw({ detach => 1 }, '/usr/sbin/drakroam') unless is_running('drakroam'); } +sub generate_wireless_menuitem { + my ($net) = @_; + $net->{menuitem} = Gtk2::CheckMenuItem->new; + $net->{menuitem}->set_draw_as_radio(1); + $net->{menuitem}->add(gtkpack_(gtkshow(Gtk2::HBox->new), + 1, gtkset_alignment($net->{ssid_label} = Gtk2::Label->new, 0, 0), + 0, $net->{keyring_image} = Gtk2::Image->new_from_pixbuf($pixbufs{keyring}), + 0, $net->{level_image} = Gtk2::Image->new)); + $net->{activate} = $net->{menuitem}->signal_connect('activate' => sub { + if (exists $net->{id}) { + eval { $monitor->select_network($net->{id}) }; + if ($@) { + my $error = $@; + err_dialog(N("Error"), N("Unable to select wireless network: %s", $error)); + } + } else { + run_drakroam(); + } + checkNetworkForce(); + }); + undef $current_state; #- force menu redraw +} +sub update_wireless_item { + my ($net) = @_; + $net->{ssid_label}->set_text($net->{ssid} || "[$_]"); + $net->{keyring_image}->visible(defined $net->{flags}); + my $approx_level = 20 + int(min($net->{signal_level}, 80)/20)*20; + $net->{level_image}->set_from_pixbuf($pixbufs{link_level}{$approx_level}); + + $net->{menuitem}->signal_handler_block($net->{activate}); + $net->{menuitem}->set_active($net->{current}); + $net->{menuitem}->signal_handler_unblock($net->{activate}); +} sub checkWireless() { my $networks = $monitor->list_wireless; foreach (keys %$networks) { my $net = $wireless_networks{$_} ||= {}; put_in_hash($net, $networks->{$_}); - unless (exists $net->{menuitem}) { - $net->{menuitem} = Gtk2::CheckMenuItem->new; - $net->{menuitem}->set_draw_as_radio(1); - $net->{menuitem}->add(gtkpack_(gtkshow(Gtk2::HBox->new), - 1, gtkset_alignment($net->{ssid_label} = Gtk2::Label->new, 0, 0), - 0, $net->{keyring_image} = Gtk2::Image->new_from_pixbuf($pixbufs{keyring}), - 0, $net->{level_image} = Gtk2::Image->new)); - $net->{activate} = $net->{menuitem}->signal_connect('activate' => sub { - if (exists $net->{id}) { - eval { $monitor->select_network($net->{id}) }; - if ($@) { - my $error = $@; - err_dialog(N("Error"), N("Unable to select wireless network: %s", $error)); - } - } else { - run_drakroam(); - } - checkNetworkForce(); - }); - undef $current_state; #- force menu redraw - } - $net->{ssid_label}->set_text($net->{ssid} || "[$_]"); - $net->{keyring_image}->visible(defined $net->{flags}); - my $approx_level = 20 + int(min($net->{signal_level}, 80)/20)*20; - $net->{level_image}->set_from_pixbuf($pixbufs{link_level}{$approx_level}); - - $net->{menuitem}->signal_handler_block($net->{activate}); - $net->{menuitem}->set_active($net->{current}); - $net->{menuitem}->signal_handler_unblock($net->{activate}); + exists $net->{menuitem} or generate_wireless_menuitem($net); + update_wireless_item($net); } $wireless_networks{$_}{menuitem}->visible(exists $networks->{$_}) foreach keys %wireless_networks; } |