From 765bccebb7ac1efc08549b6a191f1ac66529cd18 Mon Sep 17 00:00:00 2001 From: Olivier Blin Date: Mon, 17 Nov 2008 11:30:54 +0000 Subject: extract get_connections --- lib/network/netcenter.pm | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-) (limited to 'lib') diff --git a/lib/network/netcenter.pm b/lib/network/netcenter.pm index 20c4a9f..285d3e0 100755 --- a/lib/network/netcenter.pm +++ b/lib/network/netcenter.pm @@ -115,6 +115,18 @@ sub build_cmanager_box { $box; } +sub get_connections() { + my @all_connections = map { $_->get_connections(automatic_only => 1, fast_only => 1) } network::connection::get_types; + @all_connections = grep { !network::tools::is_zeroconf_interface($_->get_interface) } @all_connections; + my ($sysfs, $no_sysfs) = partition { exists $_->{device}{sysfs_device} } @all_connections; + my ($real, $other) = partition { network::tools::is_real_interface($_->get_interface) } @$sysfs; + ( + (uniq_ { $_->{device}{sysfs_device} } @$real), + (uniq_ { $_->{device}{sysfs_device} } @$other), + (uniq_ { $_->{device}{interface} } @$no_sysfs), + ); +} + sub main { my ($in, $net, $dbus) = @_; @@ -128,15 +140,7 @@ sub main { #- so that transient_for is defined, for wait messages and popups to be centered $::main_window = $w->{real_window}; - my @all_connections = map { $_->get_connections(automatic_only => 1, fast_only => 1) } network::connection::get_types; - @all_connections = grep { !network::tools::is_zeroconf_interface($_->get_interface) } @all_connections; - my ($sysfs, $no_sysfs) = partition { exists $_->{device}{sysfs_device} } @all_connections; - my ($real, $other) = partition { network::tools::is_real_interface($_->get_interface) } @$sysfs; - my @connections = ( - (uniq_ { $_->{device}{sysfs_device} } @$real), - (uniq_ { $_->{device}{sysfs_device} } @$other), - (uniq_ { $_->{device}{interface} } @$no_sysfs), - ); + my @connections = get_connections(); my $pixbufs = network::connection_manager::create_pixbufs(); my @cmanagers = map { build_cmanager($in, $net, $w, $pixbufs, $_) } @connections; -- cgit v1.2.1