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>
This commit is contained in:
parent
cb4d96072e
commit
1a0dbd00e4
@ -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();
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user