From 30a36c970b52f03c92b3977abd087bb6eec53df9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Florian=20M=C3=BCllner?= Date: Tue, 15 Aug 2023 00:13:34 +0200 Subject: [PATCH] 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: --- js/ui/quickSettings.js | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/js/ui/quickSettings.js b/js/ui/quickSettings.js index 83597c6d4..c684141f7 100644 --- a/js/ui/quickSettings.js +++ b/js/ui/quickSettings.js @@ -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);