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:
June 2021-05-16 21:32:30 +02:00
commit a73ed96bda
No known key found for this signature in database
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);
}
} }
/** /**