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.
This commit is contained in:
Julian 2021-05-16 21:32:30 +02:00
parent fd21ecb189
commit a73ed96bda
Signed by: julian
GPG Key ID: 094C2AC34192FA11

View File

@ -14,11 +14,30 @@ class Extension {
this._addNewItemsToBoxOrders(); this._addNewItemsToBoxOrders();
this._orderTopBarItemsOfAllBoxes(); this._orderTopBarItemsOfAllBoxes();
this._overwritePanelAddToPanelBox(); 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() { disable() {
// Revert the overwrite of `Panel._addToPanelBox`. // Revert the overwrite of `Panel._addToPanelBox`.
Panel.Panel.prototype._addToPanelBox = Panel.Panel.prototype._originalAddToPanelBox; Panel.Panel.prototype._addToPanelBox = Panel.Panel.prototype._originalAddToPanelBox;
// Disconnect signals.
for (const handlerId of this._settingsHandlerIds) {
this.settings.disconnect(handlerId);
}
} }
/** /**