From e07411f9fd596cd3bfcadb142fae2d5bdce3e302 Mon Sep 17 00:00:00 2001 From: Julian Schacher Date: Sun, 22 Jan 2023 20:35:13 +0100 Subject: [PATCH] Refactor: Use private instance methods instead of prefixing with `_` --- src/extension.js | 34 ++++++++++++------------ src/prefsModules/PrefsBoxOrderItemRow.js | 8 +++--- 2 files changed, 21 insertions(+), 21 deletions(-) diff --git a/src/extension.js b/src/extension.js index ff9f521..475e8b6 100644 --- a/src/extension.js +++ b/src/extension.js @@ -25,16 +25,16 @@ class Extension { // orders. this._boxOrderCreator = new BoxOrderCreator.BoxOrderCreator(this._appIndicatorKStatusNotifierItemManager); - this._addNewItemsToBoxOrders(); - this._orderTopBarItemsOfAllBoxes(); - this._overwritePanelAddToPanelBox(); + 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.#orderTopBarItems(box); /// For the case, where the currently saved box order is based /// on a permutation of an outdated box order, get an updated @@ -42,13 +42,13 @@ class Extension { let updatedBoxOrder; switch (box) { case "left": - updatedBoxOrder = this._createUpdatedBoxOrders().left; + updatedBoxOrder = this.#createUpdatedBoxOrders().left; break; case "center": - updatedBoxOrder = this._createUpdatedBoxOrders().center; + updatedBoxOrder = this.#createUpdatedBoxOrders().center; break; case "right": - updatedBoxOrder = this._createUpdatedBoxOrders().right; + updatedBoxOrder = this.#createUpdatedBoxOrders().right; break; } // Only save the updated box order to settings, if it is @@ -86,8 +86,8 @@ class Extension { * This method adds all new items currently present in the Gnome Shell top * bar to the box orders. */ - _addNewItemsToBoxOrders() { - const boxOrders = this._createUpdatedBoxOrders(); + #addNewItemsToBoxOrders() { + const boxOrders = this.#createUpdatedBoxOrders(); this.settings.set_strv("left-box-order", boxOrders.left); this.settings.set_strv("center-box-order", boxOrders.center); this.settings.set_strv("right-box-order", boxOrders.right); @@ -95,12 +95,12 @@ class Extension { /** * This methods orders the top bar items of all boxes according to the - * configured box orders using `this._orderTopBarItems`. + * configred box orders using `this.#orderTopBarItems`. */ - _orderTopBarItemsOfAllBoxes() { - this._orderTopBarItems("left"); - this._orderTopBarItems("center"); - this._orderTopBarItems("right"); + #orderTopBarItemsOfAllBoxes() { + this.#orderTopBarItems("left"); + this.#orderTopBarItems("center"); + this.#orderTopBarItems("right"); } /** @@ -115,7 +115,7 @@ class Extension { * bar item additions to make sure that they are added in the correct * position and box. */ - _overwritePanelAddToPanelBox() { + #overwritePanelAddToPanelBox() { // Add the original `Panel._addToPanelBox` method as // `Panel._originalAddToPanelBox`. Panel.Panel.prototype._originalAddToPanelBox = Panel.Panel.prototype._addToPanelBox; @@ -301,7 +301,7 @@ class Extension { * bar to the correct box order and returns the new box orders. * @returns {BoxOrders} - The updated box orders. */ - _createUpdatedBoxOrders() { + #createUpdatedBoxOrders() { // Load the configured box orders from settings. const boxOrders = { left: this.settings.get_strv("left-box-order"), @@ -370,7 +370,7 @@ class Extension { * the configured box orders. * @param {string} box - The box to order. */ - _orderTopBarItems(box) { + #orderTopBarItems(box) { // Get the valid box order. const validBoxOrder = this._boxOrderCreator.createValidBoxOrder(box); diff --git a/src/prefsModules/PrefsBoxOrderItemRow.js b/src/prefsModules/PrefsBoxOrderItemRow.js index 037d64a..420c1ff 100644 --- a/src/prefsModules/PrefsBoxOrderItemRow.js +++ b/src/prefsModules/PrefsBoxOrderItemRow.js @@ -21,15 +21,15 @@ var PrefsBoxOrderItemRow = GObject.registerClass({ constructor(params = {}, item) { super(params); - this._associateItem(item); - this._configureMenu(); + this.#associateItem(item); + this.#configureMenu(); } /** * Associate `this` with an item. * @param {String} item */ - _associateItem(item) { + #associateItem(item) { this.item = item; // Set `this._item_name_display_label` to something nicer, if the @@ -42,7 +42,7 @@ var PrefsBoxOrderItemRow = GObject.registerClass({ /** * Configure the menu. */ - _configureMenu() { + #configureMenu() { let menu = new Gio.Menu(); menu.append("Forget", `prefsBoxOrderItemRow-${this.item}.forget`); this._menu_button.set_menu_model(menu);