diff --git a/src/extensionModules/BoxOrderManager.js b/src/extensionModules/BoxOrderManager.js index d0584ab..08289a1 100644 --- a/src/extensionModules/BoxOrderManager.js +++ b/src/extensionModules/BoxOrderManager.js @@ -27,13 +27,17 @@ var BoxOrderManager = GObject.registerClass({ "appIndicatorReady": {} } }, class BoxOrderManager extends GObject.Object { + #appIndicatorReadyHandlerIdMap; + #appIndicatorItemApplicationRoleMap; + #settings; + constructor(params = {}) { super(params); - this._appIndicatorReadyHandlerIdMap = new Map(); - this._appIndicatorItemApplicationRoleMap = new Map(); + this.#appIndicatorReadyHandlerIdMap = new Map(); + this.#appIndicatorItemApplicationRoleMap = new Map(); - this._settings = ExtensionUtils.getSettings(); + this.#settings = ExtensionUtils.getSettings(); } /** @@ -54,13 +58,13 @@ var BoxOrderManager = GObject.registerClass({ const appIndicator = indicatorContainer.get_child()._indicator; let application = appIndicator.id; - if (!application && this._appIndicatorReadyHandlerIdMap) { + if (!application && this.#appIndicatorReadyHandlerIdMap) { const handlerId = appIndicator.connect("ready", () => { this.emit("appIndicatorReady"); appIndicator.disconnect(handlerId); - this._appIndicatorReadyHandlerIdMap.delete(handlerId); + this.#appIndicatorReadyHandlerIdMap.delete(handlerId); }); - this._appIndicatorReadyHandlerIdMap.set(handlerId, appIndicator); + this.#appIndicatorReadyHandlerIdMap.set(handlerId, appIndicator); throw new Error("Application can't be determined."); } @@ -71,7 +75,7 @@ var BoxOrderManager = GObject.registerClass({ } // Associate the role with the application. - let roles = this._appIndicatorItemApplicationRoleMap.get(application); + let roles = this.#appIndicatorItemApplicationRoleMap.get(application); if (roles) { // If the application already has an array of associated roles, just // add the role to it, if needed. @@ -80,7 +84,7 @@ var BoxOrderManager = GObject.registerClass({ } } else { // Otherwise create a new array. - this._appIndicatorItemApplicationRoleMap.set(application, [role]); + this.#appIndicatorItemApplicationRoleMap.set(application, [role]); } // Return the placeholder. @@ -111,7 +115,7 @@ var BoxOrderManager = GObject.registerClass({ const application = role.replace("appindicator-kstatusnotifieritem-", ""); // Then get the actual roles associated with this application. - let actualRoles = this._appIndicatorItemApplicationRoleMap.get(application); + let actualRoles = this.#appIndicatorItemApplicationRoleMap.get(application); // If there are no actual roles, continue. if (!actualRoles) { @@ -131,12 +135,12 @@ var BoxOrderManager = GObject.registerClass({ * sure all signals are disconnected. */ disconnectSignals() { - for (const [handlerId, appIndicator] of this._appIndicatorReadyHandlerIdMap) { + for (const [handlerId, appIndicator] of this.#appIndicatorReadyHandlerIdMap) { if (handlerId && appIndicator) { appIndicator.disconnect(handlerId); } } - this._appIndicatorReadyHandlerIdMap = null; + this.#appIndicatorReadyHandlerIdMap = null; } /** @@ -153,7 +157,7 @@ var BoxOrderManager = GObject.registerClass({ */ createValidBoxOrder(box) { // Get a resolved box order. - let boxOrder = this.#resolveAppIndicatorPlaceholders(this._settings.get_strv(`${box}-box-order`)); + let boxOrder = this.#resolveAppIndicatorPlaceholders(this.#settings.get_strv(`${box}-box-order`)); // ToDo: simplify. // Get the indicator containers (of the items) currently present in the @@ -191,9 +195,9 @@ var BoxOrderManager = GObject.registerClass({ saveNewTopBarItems() { // Load the configured box orders from settings. const boxOrders = { - left: this._settings.get_strv("left-box-order"), - center: this._settings.get_strv("center-box-order"), - right: this._settings.get_strv("right-box-order"), + left: this.#settings.get_strv("left-box-order"), + center: this.#settings.get_strv("center-box-order"), + right: this.#settings.get_strv("right-box-order"), }; // Get roles (of items) currently present in the Gnome Shell top bar and @@ -257,11 +261,11 @@ var BoxOrderManager = GObject.registerClass({ // This function saves the given box order to settings. const saveBoxOrderToSettings = (boxOrder, box) => { - const currentBoxOrder = this._settings.get_strv(`${box}-box-order`); + const currentBoxOrder = this.#settings.get_strv(`${box}-box-order`); // Only save the updated box order to settings, if it is different, // to avoid loops, when listening on settings changes. if (JSON.stringify(currentBoxOrder) !== JSON.stringify(boxOrder)) { - this._settings.set_strv(`${box}-box-order`, boxOrder); + this.#settings.set_strv(`${box}-box-order`, boxOrder); } }; diff --git a/src/prefsModules/PrefsBoxOrderItemRow.js b/src/prefsModules/PrefsBoxOrderItemRow.js index 69e7d67..d98286f 100644 --- a/src/prefsModules/PrefsBoxOrderItemRow.js +++ b/src/prefsModules/PrefsBoxOrderItemRow.js @@ -17,6 +17,9 @@ var PrefsBoxOrderItemRow = GObject.registerClass({ "item-name-display-label" ] }, class PrefsBoxOrderItemRow extends Adw.ActionRow { + #drag_starting_point_x; + #drag_starting_point_y; + constructor(params = {}, item) { super(params); @@ -65,8 +68,8 @@ var PrefsBoxOrderItemRow = GObject.registerClass({ value.init(PrefsBoxOrderItemRow); value.set_object(this); - this._drag_starting_point_x = x; - this._drag_starting_point_y = y; + this.#drag_starting_point_x = x; + this.#drag_starting_point_y = y; return Gdk.ContentProvider.new_for_value(value); } @@ -81,7 +84,7 @@ var PrefsBoxOrderItemRow = GObject.registerClass({ let currentDragIcon = Gtk.DragIcon.get_for_drag(drag); currentDragIcon.set_child(dragWidget); - drag.set_hotspot(this._drag_starting_point_x, this._drag_starting_point_y); + drag.set_hotspot(this.#drag_starting_point_x, this.#drag_starting_point_y); } // Handle a new drop on `this` properly. diff --git a/src/prefsModules/PrefsBoxOrderListBox.js b/src/prefsModules/PrefsBoxOrderListBox.js index 395ac85..11e2202 100644 --- a/src/prefsModules/PrefsBoxOrderListBox.js +++ b/src/prefsModules/PrefsBoxOrderListBox.js @@ -23,6 +23,8 @@ var PrefsBoxOrderListBox = GObject.registerClass({ ) } }, class PrefsBoxOrderListBox extends Gtk.ListBox { + #settings; + /** * @param {Object} params */ @@ -30,7 +32,7 @@ var PrefsBoxOrderListBox = GObject.registerClass({ super(params); // Load the settings. - this._settings = ExtensionUtils.getSettings(); + this.#settings = ExtensionUtils.getSettings(); // Add a placeholder widget for the case, where no GtkListBoxRows are // present. @@ -45,7 +47,7 @@ var PrefsBoxOrderListBox = GObject.registerClass({ this._boxOrder = value; // Load the settings here as well, since a `CONSTRUCT_ONLY` property - // apparently can't access `this._settings`. + // apparently can't access `this.#settings`. const settings = ExtensionUtils.getSettings(); // Get the actual box order for the given box order name from settings. const boxOrder = settings.get_strv(this._boxOrder); @@ -74,6 +76,6 @@ var PrefsBoxOrderListBox = GObject.registerClass({ const item = potentialPrefsBoxOrderItemRow.item; currentBoxOrder.push(item); } - this._settings.set_strv(this.boxOrder, currentBoxOrder); + this.#settings.set_strv(this.boxOrder, currentBoxOrder); } }); diff --git a/src/prefsModules/ScrollManager.js b/src/prefsModules/ScrollManager.js index 60fa186..cd3bdce 100644 --- a/src/prefsModules/ScrollManager.js +++ b/src/prefsModules/ScrollManager.js @@ -3,79 +3,83 @@ const GLib = imports.gi.GLib; var ScrollManager = class ScrollManager { + #gtkScrolledWindow; + #scrollUp; + #scrollDown; + /** * @param {Gtk.ScrolledWindow} gtkScrolledWindow */ constructor(gtkScrolledWindow) { - this._gtkScrolledWindow = gtkScrolledWindow; + this.#gtkScrolledWindow = gtkScrolledWindow; - this._scrollUp = false; - this._scrollDown = false; + this.#scrollUp = false; + this.#scrollDown = false; } startScrollUp() { // If the scroll up is already started, don't do anything. - if (this._scrollUp) { + if (this.#scrollUp) { return; } // Make sure scroll down is stopped. this.stopScrollDown(); - this._scrollUp = true; + this.#scrollUp = true; GLib.timeout_add(GLib.PRIORITY_DEFAULT, 200, () => { // Set the new vadjustment value to either the current value minus a // step increment or to 0. - const newVAdjustementValue = Math.max(this._gtkScrolledWindow.vadjustment.get_value() - this._gtkScrolledWindow.vadjustment.get_step_increment(), 0); + const newVAdjustementValue = Math.max(this.#gtkScrolledWindow.vadjustment.get_value() - this.#gtkScrolledWindow.vadjustment.get_step_increment(), 0); // If the new value is the old one, return and stop this interval. - if (newVAdjustementValue === this._gtkScrolledWindow.vadjustment.get_value()) { - this._scrollUp = false; - return this._scrollUp; + if (newVAdjustementValue === this.#gtkScrolledWindow.vadjustment.get_value()) { + this.#scrollUp = false; + return this.#scrollUp; } // Otherwise, update the value. - this._gtkScrolledWindow.vadjustment.set_value(newVAdjustementValue); - return this._scrollUp; + this.#gtkScrolledWindow.vadjustment.set_value(newVAdjustementValue); + return this.#scrollUp; }); } startScrollDown() { // If the scroll down is already started, don't do anything. - if (this._scrollDown) { + if (this.#scrollDown) { return; } // Make sure scroll up is stopped. this.stopScrollUp(); - this._scrollDown = true; + this.#scrollDown = true; GLib.timeout_add(GLib.PRIORITY_DEFAULT, 200, () => { // Set the new vadjusment value either to the curent value plus a // step increment or to the upper value minus the page size. const newVAdjustementValue = Math.min( - this._gtkScrolledWindow.vadjustment.get_value() + this._gtkScrolledWindow.vadjustment.get_step_increment(), - this._gtkScrolledWindow.vadjustment.get_upper() - this._gtkScrolledWindow.vadjustment.get_page_size() + this.#gtkScrolledWindow.vadjustment.get_value() + this.#gtkScrolledWindow.vadjustment.get_step_increment(), + this.#gtkScrolledWindow.vadjustment.get_upper() - this.#gtkScrolledWindow.vadjustment.get_page_size() ); // If the new value is the old one, return and stop this interval. - if (newVAdjustementValue === this._gtkScrolledWindow.vadjustment.get_value()) { - this._scrollDown = false; - return this._scrollDown; + if (newVAdjustementValue === this.#gtkScrolledWindow.vadjustment.get_value()) { + this.#scrollDown = false; + return this.#scrollDown; } // Otherwise, update the value. - this._gtkScrolledWindow.vadjustment.set_value(newVAdjustementValue); - return this._scrollDown; + this.#gtkScrolledWindow.vadjustment.set_value(newVAdjustementValue); + return this.#scrollDown; }); } stopScrollUp() { - this._scrollUp = false; + this.#scrollUp = false; } stopScrollDown() { - this._scrollDown = false; + this.#scrollDown = false; } stopScrollAll() {