From c8ce404ab436e913e5ed78ff54706b6c90cbffb8 Mon Sep 17 00:00:00 2001 From: Olivier Blin Date: Wed, 28 May 2008 12:58:43 +0000 Subject: do not use a networks list when there is only one network (cellular cards) --- lib/network/connection_manager.pm | 33 ++++++++++++++++++++++++--------- lib/network/netcenter.pm | 9 +++++++-- 2 files changed, 31 insertions(+), 11 deletions(-) diff --git a/lib/network/connection_manager.pm b/lib/network/connection_manager.pm index 124a423..f8e6c6b 100644 --- a/lib/network/connection_manager.pm +++ b/lib/network/connection_manager.pm @@ -249,6 +249,11 @@ sub toggle_connection { sub create_networks_list { my ($cmanager) = @_; + if ($cmanager->{gui}{show_unique_network}) { + $cmanager->{gui}{networks_list} = gtknew('HBox', spacing => 20); + return; + } + $cmanager->{gui}{networks_list} = Gtk2::SimpleList->new( "AP" => "hidden", '' => "pixbuf", @@ -312,17 +317,27 @@ sub update_networks { my $connected_pixbuf = $network->{current} ? $connected ? $cmanager->{gui}{pixbufs}{state}{connected} : $cmanager->{gui}{pixbufs}{state}{refresh} : undef; my $network_name = !$network->{essid} && exists $cmanager->{net}{wireless}{$ap} && $cmanager->{net}{wireless}{$ap}{WIRELESS_ESSID} || $network->{name}; my $strength_pixbuf = network::signal_strength::get_strength_icon($network); - push @{$cmanager->{gui}{networks_list}{data}}, [ - $ap || $network->{name}, - $connected_pixbuf, - $network_name, - $strength_pixbuf, - $cmanager->{gui}{pixbufs}{encryption}{$network->{flags} =~ /WPA/i ? 'strong' : $network->{flags} =~ /WEP/i ? 'weak' : 'open'}, - $network->{mode}, - ]; + + if ($cmanager->{gui}{show_unique_network}) { + gtkset($cmanager->{gui}{networks_list}, children => [ + 0, Gtk2::Image->new_from_pixbuf($connected_pixbuf), + 1, $network_name, + 0, Gtk2::Image->new_from_pixbuf($strength_pixbuf), + ]); + $cmanager->{connection}{network} = $network_name; + } else { + push @{$cmanager->{gui}{networks_list}{data}}, [ + $ap || $network->{name}, + $connected_pixbuf, + $network_name, + $strength_pixbuf, + $cmanager->{gui}{pixbufs}{encryption}{$network->{flags} =~ /WPA/i ? 'strong' : $network->{flags} =~ /WEP/i ? 'weak' : 'open'}, + $network->{mode}, + ]; + } } - if ($cmanager->{connection}{network}) { + if ($cmanager->{connection}{network} && !$cmanager->{gui}{show_unique_network}) { my $index = eval { find_index { $_->[0] eq $cmanager->{connection}{network} } @{$cmanager->{gui}{networks_list}{data}} }; $cmanager->{gui}{networks_list}->select($index) if defined $index; } diff --git a/lib/network/netcenter.pm b/lib/network/netcenter.pm index ca04085..d8e0cea 100755 --- a/lib/network/netcenter.pm +++ b/lib/network/netcenter.pm @@ -17,6 +17,7 @@ sub build_cmanager { my $cmanager = network::connection_manager->new($in, $net, $w, $pixbufs); $cmanager->set_connection($connection); + $cmanager->{gui}{show_unique_network} = $cmanager->{connection}->has_unique_network; if ($connection->can('get_networks')) { $cmanager->create_networks_list; @@ -73,8 +74,12 @@ sub main { 0, gtknew('Label', padding => [ 5, 0 ]), 1, gtknew('VBox', spacing => 5, children_tight => [ ($cmanager->{connection}->can('get_networks') ? ( - gtknew('Label', text => N("Please select your network:"), alignment => [ 0, 0 ]), - gtknew('ScrolledWindow', height => 160, child => $cmanager->{gui}{networks_list}), + $cmanager->{gui}{show_unique_network} ? ( + $cmanager->{gui}{networks_list}, + ): ( + gtknew('Label', text => N("Please select your network:"), alignment => [ 0, 0 ]), + gtknew('ScrolledWindow', height => 160, child => $cmanager->{gui}{networks_list}) + ), ) : ()), gtknew('HBox', children => [ 1, gtknew('HButtonBox', spacing => 6, layout => 'start', children_loose => [ -- cgit v1.2.1