Update: Make the preferences window content scrollable

Previously it could happen that the preferences window got larger than
the height of the screen (e.g. when having a bunch of items and a low
vertical screen resolution).
Fix this, by making the preferences window content scrollable.

Also introduce a nice default window size.
This commit is contained in:
June 2021-07-04 02:20:56 +02:00
commit a4ea0c630a
No known key found for this signature in database
GPG key ID: 094C2AC34192FA11
2 changed files with 86 additions and 61 deletions

View file

@ -36,12 +36,33 @@ var PrefsWidget = GObject.registerClass({
"center-box-order",
"right-box-order"
]
}, class PrefsWidget extends Gtk.Box {
}, class PrefsWidget extends Gtk.ScrolledWindow {
_init(params = {}) {
super._init(params);
this._settings = ExtensionUtils.getSettings();
// Never show a horizontal scrollbar.
// Achieved by setting the hscrollbar_policy to 2, while setting the
// vscrollbar_policy to 1 (the default value).
this.set_policy(2, 1);
// Set the default size of the preferences window to a sensible value on
// realize.
this.connect("realize", () => {
// Get the window.
const window = this.get_root();
// Use 500 and 750 for the default size.
// Those are the same values the Just Perfection Gnome Shell
// extension uses.
// It seems like those values only get used the first time the
// preferences window gets opened in a session. On all consecutive
// opens, the window is a bit larger than those values.
window.default_width = 500;
window.default_height = 750;
});
// Initialize the given `gtkListBox`.
const initializeGtkListBox = (boxOrder, gtkListBox) => {
// Add the items of the given configured box order as