From a73ed96bdabe6cd6dd545de9d5834f071d51b0e4 Mon Sep 17 00:00:00 2001 From: Julian Schacher Date: Sun, 16 May 2021 21:32:30 +0200 Subject: [PATCH] Feature: Handle changes of configured box orders Handle changes of configured box orders, by ordering the relevant top bar items according to the configured box order, which changed. --- src/extension.js | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/src/extension.js b/src/extension.js index 5615d14..242a32e 100644 --- a/src/extension.js +++ b/src/extension.js @@ -14,11 +14,30 @@ class Extension { this._addNewItemsToBoxOrders(); this._orderTopBarItemsOfAllBoxes(); this._overwritePanelAddToPanelBox(); + + // Handle changes of configured box orders. + this._settingsHandlerIds = [ ]; + + const addConfiguredBoxOrderChangeHandler = (box) => { + let handlerId = this.settings.connect(`changed::${box}-box-order`, () => { + this._orderTopBarItems(box); + }); + this._settingsHandlerIds.push(handlerId); + } + + addConfiguredBoxOrderChangeHandler("left"); + addConfiguredBoxOrderChangeHandler("center"); + addConfiguredBoxOrderChangeHandler("right"); } disable() { // Revert the overwrite of `Panel._addToPanelBox`. Panel.Panel.prototype._addToPanelBox = Panel.Panel.prototype._originalAddToPanelBox; + + // Disconnect signals. + for (const handlerId of this._settingsHandlerIds) { + this.settings.disconnect(handlerId); + } } /**