[gnome-shell] status/network: Limit the number of items that are shown per section
- From: Georges Basile Stavracas Neto <gbsneto src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-shell] status/network: Limit the number of items that are shown per section
- Date: Wed, 10 Aug 2022 13:56:31 +0000 (UTC)
commit 1a0dbd00e4f42f10f88169a18f616203a939d8c3
Author: Florian Müllner <fmuellner gnome org>
Date: Wed Aug 3 18:28:46 2022 +0200
status/network: Limit the number of items that are shown per section
Space will be less of a concern when each sections becomes its own
menu, but it's still not infinite. To address this, enable MRU
tracking and limit the list to the eight most recently used items.
Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/2407>
js/ui/status/network.js | 8 +++++++-
1 file changed, 7 insertions(+), 1 deletion(-)
---
diff --git a/js/ui/status/network.js b/js/ui/status/network.js
index d1b4baba31..822bbafb08 100644
--- a/js/ui/status/network.js
+++ b/js/ui/status/network.js
@@ -1280,7 +1280,7 @@ class NMSection extends PopupMenu.PopupMenuSection {
super();
this._items = new Map();
- this._itemSorter = new ItemSorter();
+ this._itemSorter = new ItemSorter({trackMru: true});
this._itemsSection = new PopupMenu.PopupMenuSection();
this.addMenuItem(this._itemsSection);
@@ -1311,6 +1311,11 @@ class NMSection extends PopupMenu.PopupMenuSection {
throw new GObject.NotImplementedError();
}
+ _updateItemsVisibility() {
+ [...this._itemSorter.itemsByMru()].forEach(
+ (item, i) => (item.visible = i < MAX_VISIBLE_NETWORKS));
+ }
+
_resortItem(item) {
const pos = this._itemSorter.upsert(item);
this._itemsSection.moveMenuItem(item, pos);
@@ -1345,6 +1350,7 @@ class NMSection extends PopupMenu.PopupMenuSection {
_sync() {
this.visible = this._items.size > 0;
+ this._updateItemsVisibility();
}
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]