[polari] connections: Explicitly sort connections list alphabetically



commit c73741c0c460e7efa89badb5d37c3bc3b9ac15cb
Author: raresv <rares visalom gmail com>
Date:   Sun Apr 17 14:04:39 2016 +0300

    connections: Explicitly sort connections list alphabetically
    
    At the moment, Polari displays the networks in the exact order
    that they appear in the networks.json file. As a result, any
    future change to the list may break the order if not done
    carefully. Avoid that risk by setting an appropriate
    sort function.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=762733

 src/connections.js |    8 ++++++++
 1 files changed, 8 insertions(+), 0 deletions(-)
---
diff --git a/src/connections.js b/src/connections.js
index daa3120..f0d5144 100644
--- a/src/connections.js
+++ b/src/connections.js
@@ -77,6 +77,7 @@ const ConnectionsList = new Lang.Class({
         this._filterTerms = [];
         this._list.set_filter_func(Lang.bind(this, this._filterRows));
         this._list.set_header_func(Lang.bind(this, this._updateHeader));
+        this._list.set_sort_func(Lang.bind(this, this._sort));
 
         this._accountsMonitor = AccountsMonitor.getDefault();
         this._accountsMonitor.connect('account-added', Lang.bind(this,
@@ -167,6 +168,13 @@ const ConnectionsList = new Lang.Class({
             return;
 
         this._rows.get(account.service).sensitive = sensitive;
+    },
+
+    _sort: function(row1, row2) {
+        let name1 = this._networksManager.getNetworkName(row1.id);
+        let name2 = this._networksManager.getNetworkName(row2.id);
+
+        return name1.localeCompare(name2);
     }
 });
 


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]