quickSettings: Add insertItemBefore() method

The QuickSettings menu currently only support appending items
at the end. Extensions can get around that limitation by accessing
the private grid property to move the item afterwards, but we don't
allow this in our own code.

Expose a new insertItemBefore() method that allows adding an item
before an existing one.

Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/2894>
This commit is contained in:
Florian Müllner 2023-08-15 00:13:34 +02:00
parent ca503774b2
commit 30a36c970b

View File

@ -780,6 +780,15 @@ export const QuickSettingsMenu = class extends PopupMenu.PopupMenu {
addItem(item, colSpan = 1) {
this._grid.add_child(item);
this._completeAddItem(item, colSpan);
}
insertItemBefore(item, sibling, colSpan = 1) {
this._grid.insert_child_below(item, sibling);
this._completeAddItem(item, colSpan);
}
_completeAddItem(item, colSpan) {
this._grid.layout_manager.child_set_property(
this._grid, item, 'column-span', colSpan);