summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorOlivier Blin <oblin@mandriva.com>2008-11-13 19:00:36 +0000
committerOlivier Blin <oblin@mandriva.com>2008-11-13 19:00:36 +0000
commit30e33b9b8ef6eaaaaa3708b46f477f5552078b0f (patch)
tree31b3a834211ac0cecc88e0215e126b0e9ad79338 /lib
parentc898507b862a21d36aa920af258c9246794b5f6d (diff)
downloaddrakx-net-30e33b9b8ef6eaaaaa3708b46f477f5552078b0f.tar
drakx-net-30e33b9b8ef6eaaaaa3708b46f477f5552078b0f.tar.gz
drakx-net-30e33b9b8ef6eaaaaa3708b46f477f5552078b0f.tar.bz2
drakx-net-30e33b9b8ef6eaaaaa3708b46f477f5552078b0f.tar.xz
drakx-net-30e33b9b8ef6eaaaaa3708b46f477f5552078b0f.zip
allow to sort networks list (from Pascal Terjan, #40177)
Diffstat (limited to 'lib')
-rw-r--r--lib/network/connection_manager.pm23
1 files changed, 23 insertions, 0 deletions
diff --git a/lib/network/connection_manager.pm b/lib/network/connection_manager.pm
index 43df11f..5b77c5e 100644
--- a/lib/network/connection_manager.pm
+++ b/lib/network/connection_manager.pm
@@ -275,6 +275,29 @@ sub create_networks_list {
1;
});
$cmanager->{gui}{networks_list}->set_has_tooltip(1);
+ $cmanager->{gui}{networks_list}->get_column(1)->set_sort_column_id(1);
+ $cmanager->{gui}{networks_list}->get_model->set_sort_func (1, sub {
+ my ($sortable, $iter_left, $iter_right) = @_;
+ my $s1 = lc $sortable->get($iter_left, 2);
+ my $s2 = lc $sortable->get($iter_right, 2);
+ return $s1 eq $s2?0:($s1 gt $s2?1:-1);
+ });
+ $cmanager->{gui}{networks_list}->get_column(2)->set_sort_column_id(2);
+ $cmanager->{gui}{networks_list}->get_model->set_sort_func (2, sub {
+ my ($sortable, $iter_left, $iter_right) = @_;
+ my $s1 = $cmanager->{connection}{networks}{$sortable->get($iter_left, 0)}->{signal_strength};
+ my $s2 = $cmanager->{connection}{networks}{$sortable->get($iter_right, 0)}->{signal_strength};
+ return $s2 <=> $s1;
+ });
+ $cmanager->{gui}{networks_list}->get_column(3)->set_sort_column_id(3);
+ $cmanager->{gui}{networks_list}->get_model->set_sort_func (3, sub {
+ my ($sortable, $iter_left, $iter_right) = @_;
+ my $s1 = $cmanager->{connection}{networks}{$sortable->get($iter_left, 0)}->{flags};
+ my $s2 = $cmanager->{connection}{networks}{$sortable->get($iter_right, 0)}->{flags};
+ #FIXME Should define an explicit order OPEN < WEP < WPA
+ return $s1 eq $s2?0:($s1 lt $s2?1:-1);
+ });
+
}
sub select_network {