Refactor: Add settings to globalThis

Do this so that we don't have to get them in each class individually.
This commit is contained in:
Julian 2023-01-22 15:48:35 +01:00
parent 2f9f4d1a3f
commit 34ba8a58cd
Signed by: julian
GPG Key ID: 094C2AC34192FA11
4 changed files with 6 additions and 10 deletions

View File

@ -11,4 +11,6 @@ function buildPrefsWidget() {
} }
function init() { function init() {
// Load the settings.
globalThis.settings = ExtensionUtils.getSettings();
} }

View File

@ -19,8 +19,6 @@ var PrefsBoxOrderListBox = GObject.registerClass({
constructor(params = {}, boxOrder) { constructor(params = {}, boxOrder) {
super(params); super(params);
this._settings = ExtensionUtils.getSettings();
this.boxOrder = boxOrder; this.boxOrder = boxOrder;
} }
@ -37,6 +35,6 @@ var PrefsBoxOrderListBox = GObject.registerClass({
const item = potentialPrefsBoxOrderItemRow.item; const item = potentialPrefsBoxOrderItemRow.item;
currentBoxOrder.push(item); currentBoxOrder.push(item);
} }
this._settings.set_strv(this.boxOrder, currentBoxOrder); settings.set_strv(this.boxOrder, currentBoxOrder);
} }
}); });

View File

@ -34,8 +34,6 @@ var PrefsBoxOrderListEmptyPlaceholder = GObject.registerClass({
ownListBox.insert(value, 0); ownListBox.insert(value, 0);
/// Finally save the box orders to settings. /// Finally save the box orders to settings.
const settings = ExtensionUtils.getSettings();
settings.set_strv(ownListBox.boxOrder, [value.item]); settings.set_strv(ownListBox.boxOrder, [value.item]);
let updatedBoxOrder = [ ]; let updatedBoxOrder = [ ];

View File

@ -25,8 +25,6 @@ var PrefsPage = GObject.registerClass({
constructor(params = {}) { constructor(params = {}) {
super(params); super(params);
this._settings = ExtensionUtils.getSettings();
// Scroll up or down, when a Drag-and-Drop operation is in progress and // Scroll up or down, when a Drag-and-Drop operation is in progress and
// the user has their cursor either in the upper or lower 10% of this // the user has their cursor either in the upper or lower 10% of this
// widget respectively. // widget respectively.
@ -73,8 +71,8 @@ var PrefsPage = GObject.registerClass({
gtkListBox.set_placeholder(new PrefsBoxOrderListEmptyPlaceholder.PrefsBoxOrderListEmptyPlaceholder()); gtkListBox.set_placeholder(new PrefsBoxOrderListEmptyPlaceholder.PrefsBoxOrderListEmptyPlaceholder());
}; };
initializeGtkListBox(this._settings.get_strv("left-box-order"), this._left_box_order); initializeGtkListBox(settings.get_strv("left-box-order"), this._left_box_order);
initializeGtkListBox(this._settings.get_strv("center-box-order"), this._center_box_order); initializeGtkListBox(settings.get_strv("center-box-order"), this._center_box_order);
initializeGtkListBox(this._settings.get_strv("right-box-order"), this._right_box_order); initializeGtkListBox(settings.get_strv("right-box-order"), this._right_box_order);
} }
}); });