diff options
author | Olivier Blin <blino@mageia.org> | 2013-05-07 02:12:29 +0000 |
---|---|---|
committer | Olivier Blin <blino@mageia.org> | 2013-05-07 02:12:29 +0000 |
commit | 946a66201d82a73c13398dc5dd811389a25d735c (patch) | |
tree | 151124a250b66a7122782794c4081e2810957afe /lib/network/connection_manager/gtk.pm | |
parent | 2f8bd5a7038ca023c4106862708ecd1e2ddb17ab (diff) | |
download | drakx-net-946a66201d82a73c13398dc5dd811389a25d735c.tar drakx-net-946a66201d82a73c13398dc5dd811389a25d735c.tar.gz drakx-net-946a66201d82a73c13398dc5dd811389a25d735c.tar.bz2 drakx-net-946a66201d82a73c13398dc5dd811389a25d735c.tar.xz drakx-net-946a66201d82a73c13398dc5dd811389a25d735c.zip |
connection manager gtk: use a global pixbufs hash to simplify API
Diffstat (limited to 'lib/network/connection_manager/gtk.pm')
-rw-r--r-- | lib/network/connection_manager/gtk.pm | 29 |
1 files changed, 17 insertions, 12 deletions
diff --git a/lib/network/connection_manager/gtk.pm b/lib/network/connection_manager/gtk.pm index 5a3d8e0..3f8c21b 100644 --- a/lib/network/connection_manager/gtk.pm +++ b/lib/network/connection_manager/gtk.pm @@ -11,16 +11,21 @@ use Gtk2::SimpleList; use network::signal_strength; use locale; # for cmp -sub create_pixbufs() { - { - state => { map { $_ => gtkcreate_pixbuf($_) } qw(connected disconnected refresh) }, - link_level => { map { - $_ => gtkcreate_pixbuf('wifi-' . sprintf('%03d', $_))->scale_simple(24, 24, 'hyper'); - } qw(20 40 60 80 100) }, - encryption => { map { - $_ => gtkcreate_pixbuf("encryption-$_-24"); - } qw(open weak strong) }, - }; +our %pixbufs = ( + state => { map { $_ => gtkcreate_pixbuf($_) } qw(connected disconnected refresh) }, + link_level => { map { + $_ => gtkcreate_pixbuf('wifi-' . sprintf('%03d', $_))->scale_simple(24, 24, 'hyper'); + } qw(20 40 60 80 100) }, + encryption => { map { + $_ => gtkcreate_pixbuf("encryption-$_-24"); + } qw(open weak strong) }, +); + +sub new { + my ($class, $in, $net, $w) = @_; + bless { + in => $in, net => $net, gui => { w => $w }, + }, $class; } sub start_connection { @@ -177,7 +182,7 @@ sub update_networks_list { my @networks = filter_networks($cmanager->{connection}); foreach my $network (@networks) { my $ap = $network->{ap}; - my $connected_pixbuf = $network->{current} ? $connected ? $cmanager->{gui}{pixbufs}{state}{connected} : $cmanager->{gui}{pixbufs}{state}{refresh} : undef; + my $connected_pixbuf = $network->{current} ? $connected ? $pixbufs{state}{connected} : $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); @@ -193,7 +198,7 @@ sub update_networks_list { $connected_pixbuf, $network_name, $strength_pixbuf, - $cmanager->{gui}{pixbufs}{encryption}{$network->{flags} =~ /WPA/i ? 'strong' : $network->{flags} =~ /WEP/i ? 'weak' : 'open'}, + $pixbufs{encryption}{$network->{flags} =~ /WPA/i ? 'strong' : $network->{flags} =~ /WEP/i ? 'weak' : 'open'}, $network->{mode}, ]; } |