mirror of
https://gitlab.gnome.org/julianschacher/top-bar-organizer.git
synced 2025-10-27 15:19:09 +00:00
Fix: Don't use globalThis, since it won't get g.c. on window close
Don't use `globalThis`, since it won't get garbage collected on window close. See here for the relevant review: https://extensions.gnome.org/review/38364 And for the relevant documentation: https://gjs.guide/extensions/review-guidelines/review-guidelines.html#only-use-init-for-initialization
This commit is contained in:
parent
2ef16f310c
commit
7b1c030325
@ -11,6 +11,4 @@ function buildPrefsWidget() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function init() {
|
function init() {
|
||||||
// Load the settings.
|
|
||||||
globalThis.settings = ExtensionUtils.getSettings();
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,6 +1,5 @@
|
|||||||
"use strict";
|
"use strict";
|
||||||
/* exported PrefsBoxOrderListBox */
|
/* exported PrefsBoxOrderListBox */
|
||||||
/* global settings */
|
|
||||||
|
|
||||||
const Gtk = imports.gi.Gtk;
|
const Gtk = imports.gi.Gtk;
|
||||||
const GObject = imports.gi.GObject;
|
const GObject = imports.gi.GObject;
|
||||||
@ -30,6 +29,9 @@ var PrefsBoxOrderListBox = GObject.registerClass({
|
|||||||
constructor(params = {}) {
|
constructor(params = {}) {
|
||||||
super(params);
|
super(params);
|
||||||
|
|
||||||
|
// Load the settings.
|
||||||
|
this._settings = ExtensionUtils.getSettings();
|
||||||
|
|
||||||
// Add a placeholder widget for the case, where no GtkListBoxRows are
|
// Add a placeholder widget for the case, where no GtkListBoxRows are
|
||||||
// present.
|
// present.
|
||||||
this.set_placeholder(new PrefsBoxOrderListEmptyPlaceholder.PrefsBoxOrderListEmptyPlaceholder());
|
this.set_placeholder(new PrefsBoxOrderListEmptyPlaceholder.PrefsBoxOrderListEmptyPlaceholder());
|
||||||
@ -42,6 +44,9 @@ var PrefsBoxOrderListBox = GObject.registerClass({
|
|||||||
set boxOrder(value) {
|
set boxOrder(value) {
|
||||||
this._boxOrder = value;
|
this._boxOrder = value;
|
||||||
|
|
||||||
|
// Load the settings here as well, since a `CONSTRUCT_ONLY` property
|
||||||
|
// apparently can't access `this._settings`.
|
||||||
|
const settings = ExtensionUtils.getSettings();
|
||||||
// Get the actual box order for the given box order name from settings.
|
// Get the actual box order for the given box order name from settings.
|
||||||
const boxOrder = settings.get_strv(this._boxOrder);
|
const boxOrder = settings.get_strv(this._boxOrder);
|
||||||
// Populate this GtkListBox with GtkListBoxRows for the items of the
|
// Populate this GtkListBox with GtkListBoxRows for the items of the
|
||||||
@ -67,6 +72,6 @@ var PrefsBoxOrderListBox = GObject.registerClass({
|
|||||||
const item = potentialPrefsBoxOrderItemRow.item;
|
const item = potentialPrefsBoxOrderItemRow.item;
|
||||||
currentBoxOrder.push(item);
|
currentBoxOrder.push(item);
|
||||||
}
|
}
|
||||||
settings.set_strv(this.boxOrder, currentBoxOrder);
|
this._settings.set_strv(this.boxOrder, currentBoxOrder);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user