Refactor: Use private instance methods instead of prefixing with _

This commit is contained in:
Julian 2023-01-22 20:35:13 +01:00
parent cc118d7796
commit e07411f9fd
Signed by: julian
GPG Key ID: 094C2AC34192FA11
2 changed files with 21 additions and 21 deletions

View File

@ -25,16 +25,16 @@ class Extension {
// orders. // orders.
this._boxOrderCreator = new BoxOrderCreator.BoxOrderCreator(this._appIndicatorKStatusNotifierItemManager); this._boxOrderCreator = new BoxOrderCreator.BoxOrderCreator(this._appIndicatorKStatusNotifierItemManager);
this._addNewItemsToBoxOrders(); this.#addNewItemsToBoxOrders();
this._orderTopBarItemsOfAllBoxes(); this.#orderTopBarItemsOfAllBoxes();
this._overwritePanelAddToPanelBox(); this.#overwritePanelAddToPanelBox();
// Handle changes of configured box orders. // Handle changes of configured box orders.
this._settingsHandlerIds = [ ]; this._settingsHandlerIds = [ ];
const addConfiguredBoxOrderChangeHandler = (box) => { const addConfiguredBoxOrderChangeHandler = (box) => {
let handlerId = this.settings.connect(`changed::${box}-box-order`, () => { 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 /// For the case, where the currently saved box order is based
/// on a permutation of an outdated box order, get an updated /// on a permutation of an outdated box order, get an updated
@ -42,13 +42,13 @@ class Extension {
let updatedBoxOrder; let updatedBoxOrder;
switch (box) { switch (box) {
case "left": case "left":
updatedBoxOrder = this._createUpdatedBoxOrders().left; updatedBoxOrder = this.#createUpdatedBoxOrders().left;
break; break;
case "center": case "center":
updatedBoxOrder = this._createUpdatedBoxOrders().center; updatedBoxOrder = this.#createUpdatedBoxOrders().center;
break; break;
case "right": case "right":
updatedBoxOrder = this._createUpdatedBoxOrders().right; updatedBoxOrder = this.#createUpdatedBoxOrders().right;
break; break;
} }
// Only save the updated box order to settings, if it is // 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 * This method adds all new items currently present in the Gnome Shell top
* bar to the box orders. * bar to the box orders.
*/ */
_addNewItemsToBoxOrders() { #addNewItemsToBoxOrders() {
const boxOrders = this._createUpdatedBoxOrders(); const boxOrders = this.#createUpdatedBoxOrders();
this.settings.set_strv("left-box-order", boxOrders.left); this.settings.set_strv("left-box-order", boxOrders.left);
this.settings.set_strv("center-box-order", boxOrders.center); this.settings.set_strv("center-box-order", boxOrders.center);
this.settings.set_strv("right-box-order", boxOrders.right); 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 * 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() { #orderTopBarItemsOfAllBoxes() {
this._orderTopBarItems("left"); this.#orderTopBarItems("left");
this._orderTopBarItems("center"); this.#orderTopBarItems("center");
this._orderTopBarItems("right"); this.#orderTopBarItems("right");
} }
/** /**
@ -115,7 +115,7 @@ class Extension {
* bar item additions to make sure that they are added in the correct * bar item additions to make sure that they are added in the correct
* position and box. * position and box.
*/ */
_overwritePanelAddToPanelBox() { #overwritePanelAddToPanelBox() {
// Add the original `Panel._addToPanelBox` method as // Add the original `Panel._addToPanelBox` method as
// `Panel._originalAddToPanelBox`. // `Panel._originalAddToPanelBox`.
Panel.Panel.prototype._originalAddToPanelBox = Panel.Panel.prototype._addToPanelBox; 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. * bar to the correct box order and returns the new box orders.
* @returns {BoxOrders} - The updated box orders. * @returns {BoxOrders} - The updated box orders.
*/ */
_createUpdatedBoxOrders() { #createUpdatedBoxOrders() {
// Load the configured box orders from settings. // Load the configured box orders from settings.
const boxOrders = { const boxOrders = {
left: this.settings.get_strv("left-box-order"), left: this.settings.get_strv("left-box-order"),
@ -370,7 +370,7 @@ class Extension {
* the configured box orders. * the configured box orders.
* @param {string} box - The box to order. * @param {string} box - The box to order.
*/ */
_orderTopBarItems(box) { #orderTopBarItems(box) {
// Get the valid box order. // Get the valid box order.
const validBoxOrder = this._boxOrderCreator.createValidBoxOrder(box); const validBoxOrder = this._boxOrderCreator.createValidBoxOrder(box);

View File

@ -21,15 +21,15 @@ var PrefsBoxOrderItemRow = GObject.registerClass({
constructor(params = {}, item) { constructor(params = {}, item) {
super(params); super(params);
this._associateItem(item); this.#associateItem(item);
this._configureMenu(); this.#configureMenu();
} }
/** /**
* Associate `this` with an item. * Associate `this` with an item.
* @param {String} item * @param {String} item
*/ */
_associateItem(item) { #associateItem(item) {
this.item = item; this.item = item;
// Set `this._item_name_display_label` to something nicer, if the // Set `this._item_name_display_label` to something nicer, if the
@ -42,7 +42,7 @@ var PrefsBoxOrderItemRow = GObject.registerClass({
/** /**
* Configure the menu. * Configure the menu.
*/ */
_configureMenu() { #configureMenu() {
let menu = new Gio.Menu(); let menu = new Gio.Menu();
menu.append("Forget", `prefsBoxOrderItemRow-${this.item}.forget`); menu.append("Forget", `prefsBoxOrderItemRow-${this.item}.forget`);
this._menu_button.set_menu_model(menu); this._menu_button.set_menu_model(menu);