[gnome-shell] status/network: Sort items, not connections
- From: Georges Basile Stavracas Neto <gbsneto src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-shell] status/network: Sort items, not connections
- Date: Wed, 10 Aug 2022 13:56:29 +0000 (UTC)
commit be950d5c4a6f165c61619774f83c0f7b3186d872
Author: Florian Müllner <fmuellner gnome org>
Date: Sat Aug 6 16:15:07 2022 +0200
status/network: Sort items, not connections
You could argue that the item name is closer to what is displayed
to the user, but it doesn't really matter: Connection items will
always use the connection ID when there is more than one, which
is the only case where sorting matters.
However sorting by items will allow us to generalize the code, and
use it for items that do not represent a connection.
Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/2407>
js/ui/status/network.js | 24 ++++++++++++------------
1 file changed, 12 insertions(+), 12 deletions(-)
---
diff --git a/js/ui/status/network.js b/js/ui/status/network.js
index 38ac690f16..2a241f7d7a 100644
--- a/js/ui/status/network.js
+++ b/js/ui/status/network.js
@@ -265,7 +265,7 @@ var NMConnectionSection = class NMConnectionSection extends Signals.EventEmitter
this._client = client;
this._connectionItems = new Map();
- this._connections = [];
+ this._itemsOrder = [];
this._section = new PopupMenu.PopupMenuSection();
@@ -306,8 +306,8 @@ var NMConnectionSection = class NMConnectionSection extends Signals.EventEmitter
return true;
}
- _connectionSortFunction(one, two) {
- return GLib.utf8_collate(one.get_id(), two.get_id());
+ _itemSortFunction(one, two) {
+ return GLib.utf8_collate(one.name, two.name);
}
_makeConnectionItem(connection) {
@@ -335,13 +335,13 @@ var NMConnectionSection = class NMConnectionSection extends Signals.EventEmitter
}
_updateForConnection(item, connection) {
- let pos = this._connections.indexOf(connection);
+ item.updateForConnection(connection);
- this._connections.splice(pos, 1);
- pos = Util.insertSorted(this._connections, connection, this._connectionSortFunction.bind(this));
- this._section.moveMenuItem(item, pos);
+ let pos = this._itemsOrder.indexOf(item);
- item.updateForConnection(connection);
+ this._itemsOrder.splice(pos, 1);
+ pos = Util.insertSorted(this._itemsOrder, item, this._itemSortFunction.bind(this));
+ this._section.moveMenuItem(item, pos);
}
_addConnection(connection) {
@@ -353,7 +353,7 @@ var NMConnectionSection = class NMConnectionSection extends Signals.EventEmitter
item.connect('activation-failed', () => this.emit('activation-failed'));
item.connect('notify::name', this._sync.bind(this));
- let pos = Util.insertSorted(this._connections, connection, this._connectionSortFunction.bind(this));
+ let pos = Util.insertSorted(this._itemsOrder, item, this._itemSortFunction.bind(this));
this._section.addMenuItem(item, pos);
this._connectionItems.set(connection.get_uuid(), item);
this._sync();
@@ -365,12 +365,12 @@ var NMConnectionSection = class NMConnectionSection extends Signals.EventEmitter
if (item == undefined)
return;
+ const pos = this._itemsOrder.indexOf(item);
+ this._itemsOrder.splice(pos, 1);
+
item.destroy();
this._connectionItems.delete(uuid);
- let pos = this._connections.indexOf(connection);
- this._connections.splice(pos, 1);
-
this._sync();
}
};
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]