diff options
author | Frédéric Buclin <LpSolit@gmail.com> | 2017-03-10 18:41:40 +0100 |
---|---|---|
committer | Frédéric Buclin <LpSolit@gmail.com> | 2017-03-10 18:41:40 +0100 |
commit | 8220942b9142ed45d8af31635954726433d1e3d2 (patch) | |
tree | 41887c6083d4301fe2670e04cc7a25a935d353db | |
parent | 7a02bcb2b5e9a44fade5d6a702cc14960142b6c8 (diff) | |
download | drakx-net-8220942b9142ed45d8af31635954726433d1e3d2.tar drakx-net-8220942b9142ed45d8af31635954726433d1e3d2.tar.gz drakx-net-8220942b9142ed45d8af31635954726433d1e3d2.tar.bz2 drakx-net-8220942b9142ed45d8af31635954726433d1e3d2.tar.xz drakx-net-8220942b9142ed45d8af31635954726433d1e3d2.zip |
Make sure the status icon exists before trying to display it (mga#20425)
This patch also does some cleanup (left during the StatusNotifier
implementation)
-rw-r--r-- | NEWS | 3 | ||||
-rwxr-xr-x | bin/net_applet | 21 |
2 files changed, 12 insertions, 12 deletions
@@ -1,3 +1,6 @@ +- net_applet: + o make sure the status icon exists before trying to display it (mga#20425) + 2.28 - draksambashare: o fix bogus hint about drakwizard (mga#8112) diff --git a/bin/net_applet b/bin/net_applet index 76e46f3..1a0d369 100755 --- a/bin/net_applet +++ b/bin/net_applet @@ -52,10 +52,8 @@ our %wireless_networks; our %pixbufs = ( - state => { map { $_ => gtknew('Pixbuf', file => $_) } map { $_, $_ . "_big" } qw(connected disconnected unconfigured connecting) }, - encryption => { map { - $_ => gtknew('Pixbuf', file => "encryption-$_-24"); - } qw(open weak strong) }, + state => { map { $_ => gtknew('Pixbuf', file => $_ . '_big') } qw(connected disconnected unconfigured connecting) }, + encryption => { map { $_ => gtknew('Pixbuf', file => "encryption-$_-24") } qw(open weak strong) }, ); sub get_current_network() { @@ -63,22 +61,21 @@ sub get_current_network() { } sub get_state_pixbuf { - my $img; - my $wnet = $current_state eq 'connected' && get_current_network(); - if ($wnet) { + if (my $wnet = $current_state eq 'connected' && get_current_network()) { return network::signal_strength::get_strength_icon($wnet); } else { - # By default, use the big image, and fall back to the small one if it does not exist. - return $pixbufs{state}{"${current_state}_big"} || $pixbufs{state}{$current_state}; + return $pixbufs{state}{$current_state}; } } sub update_tray_icon() { if (!$ifw_alert) { - my @args = $is_plasma ? qw(STATUS_NOTIFIER_ICON) : (); - push @args, get_state_pixbuf(); - $icon->set_from_pixbuf(@args); + if (my $pixbuf = get_state_pixbuf()) { + my @args = $is_plasma ? qw(STATUS_NOTIFIER_ICON) : (); + push @args, $pixbuf; + $icon->set_from_pixbuf(@args); + } } elsif ($is_plasma) { $icon->set_from_icon_name('STATUS_NOTIFIER_ICON', 'dialog-warning'); |