environment: Port environment.js to be an ES module
Removes the init() function in favor of executing all environment changes when the file is imported. Additionally ports all unit tests using imports.gi.environment.init() to use the updated module. Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/2822>
This commit is contained in:
parent
26fa1046a3
commit
9a2c3da868
@ -4,6 +4,7 @@ extends:
|
||||
overrides:
|
||||
- files:
|
||||
- js/ui/init.js
|
||||
- js/ui/environment.js
|
||||
- js/dbusServices/**
|
||||
- js/portalHelper/**
|
||||
- subprojects/extensions-app/**
|
||||
|
@ -1,22 +1,24 @@
|
||||
/* exported init */
|
||||
|
||||
// Load all required dependencies with the correct versions
|
||||
imports.misc.dependencies; // eslint-disable-line no-unused-expressions
|
||||
import '../misc/dependencies.js';
|
||||
|
||||
import {setConsoleLogDomain} from 'console';
|
||||
import * as Gettext from 'gettext';
|
||||
|
||||
import Clutter from 'gi://Clutter';
|
||||
import Gdk from 'gi://Gdk';
|
||||
import Gio from 'gi://Gio';
|
||||
import GLib from 'gi://GLib';
|
||||
import GObject from 'gi://GObject';
|
||||
import Meta from 'gi://Meta';
|
||||
import Polkit from 'gi://Polkit';
|
||||
import Shell from 'gi://Shell';
|
||||
import St from 'gi://St';
|
||||
|
||||
const Clutter = imports.gi.Clutter;
|
||||
const Gdk = imports.gi.Gdk;
|
||||
const Gio = imports.gi.Gio;
|
||||
const GLib = imports.gi.GLib;
|
||||
const GObject = imports.gi.GObject;
|
||||
const Meta = imports.gi.Meta;
|
||||
const Polkit = imports.gi.Polkit;
|
||||
const Shell = imports.gi.Shell;
|
||||
const St = imports.gi.St;
|
||||
const Gettext = imports.gettext;
|
||||
const SignalTracker = imports.misc.signalTracker;
|
||||
const {adjustAnimationTime} = imports.misc.animationUtils;
|
||||
|
||||
setConsoleLogDomain('GNOME Shell');
|
||||
|
||||
Gio._promisify(Gio.DataInputStream.prototype, 'fill_async');
|
||||
Gio._promisify(Gio.DataInputStream.prototype, 'read_line_async');
|
||||
Gio._promisify(Gio.DBus, 'get');
|
||||
@ -28,9 +30,8 @@ Gio._promisify(Gio.File.prototype, 'query_info_async');
|
||||
Gio._promisify(Polkit.Permission, 'new');
|
||||
|
||||
// We can't import shell JS modules yet, because they may have
|
||||
// variable initializations, etc, that depend on init() already having
|
||||
// been run.
|
||||
|
||||
// variable initializations, etc, that depend on this file's
|
||||
// changes
|
||||
|
||||
// "monkey patch" in some varargs ClutterContainer methods; we need
|
||||
// to do this per-container class since there is no representation
|
||||
@ -248,7 +249,6 @@ function _easeActorProperty(actor, propName, target, params) {
|
||||
transition.connect('stopped', (t, finished) => callback(finished));
|
||||
}
|
||||
|
||||
function init() {
|
||||
// Add some bindings to the global JS namespace
|
||||
globalThis.global = Shell.Global.get();
|
||||
|
||||
@ -283,11 +283,11 @@ function init() {
|
||||
});
|
||||
_patchLayoutClass(Clutter.BoxLayout, {spacing: 'spacing'});
|
||||
|
||||
let origSetEasingDuration = Clutter.Actor.prototype.set_easing_duration;
|
||||
const origSetEasingDuration = Clutter.Actor.prototype.set_easing_duration;
|
||||
Clutter.Actor.prototype.set_easing_duration = function (msecs) {
|
||||
origSetEasingDuration.call(this, adjustAnimationTime(msecs));
|
||||
};
|
||||
let origSetEasingDelay = Clutter.Actor.prototype.set_easing_delay;
|
||||
const origSetEasingDelay = Clutter.Actor.prototype.set_easing_delay;
|
||||
Clutter.Actor.prototype.set_easing_delay = function (msecs) {
|
||||
origSetEasingDelay.call(this, adjustAnimationTime(msecs));
|
||||
};
|
||||
@ -329,7 +329,7 @@ function init() {
|
||||
return Shell.util_touch_file_finish(this, result);
|
||||
};
|
||||
|
||||
let origToString = Object.prototype.toString;
|
||||
const origToString = Object.prototype.toString;
|
||||
Object.prototype.toString = function () {
|
||||
let base = origToString.call(this);
|
||||
try {
|
||||
@ -342,7 +342,7 @@ function init() {
|
||||
}
|
||||
};
|
||||
|
||||
let slowdownEnv = GLib.getenv('GNOME_SHELL_SLOWDOWN_FACTOR');
|
||||
const slowdownEnv = GLib.getenv('GNOME_SHELL_SLOWDOWN_FACTOR');
|
||||
if (slowdownEnv) {
|
||||
let factor = parseFloat(slowdownEnv);
|
||||
if (!isNaN(factor) && factor > 0.0)
|
||||
@ -360,4 +360,3 @@ function init() {
|
||||
|
||||
// Prevent extensions from opening a display connection to ourselves
|
||||
Gdk.set_allowed_backends('');
|
||||
}
|
||||
|
@ -1,10 +1,7 @@
|
||||
import {setConsoleLogDomain} from 'console';
|
||||
import GLib from 'gi://GLib';
|
||||
import Gio from 'gi://Gio';
|
||||
|
||||
setConsoleLogDomain('GNOME Shell');
|
||||
|
||||
imports.ui.environment.init();
|
||||
import './environment.js';
|
||||
|
||||
// Run the Mutter main loop after
|
||||
// GJS finishes resolving this module.
|
||||
|
@ -5,9 +5,7 @@
|
||||
const JsUnit = imports.jsUnit;
|
||||
import Pango from 'gi://Pango';
|
||||
|
||||
const Environment = imports.ui.environment;
|
||||
Environment.init();
|
||||
|
||||
import '../../js/ui/environment.js';
|
||||
const Util = imports.misc.util;
|
||||
|
||||
const tests = [
|
||||
|
@ -1,12 +1,13 @@
|
||||
/* -*- mode: js2; js2-basic-offset: 4; indent-tabs-mode: nil -*- */
|
||||
|
||||
// Test cases for Util.insertSorted
|
||||
import * as Assertions from '../common/assertions.js';
|
||||
|
||||
// Needed so that Util can bring some UI stuff
|
||||
// we don't actually use
|
||||
const Environment = imports.ui.environment;
|
||||
Environment.init();
|
||||
import '../../js/ui/environment.js';
|
||||
|
||||
import * as Assertions from '../common/assertions.js';
|
||||
|
||||
const Util = imports.misc.util;
|
||||
|
||||
let arrayInt = [1, 2, 3, 5, 6];
|
||||
|
@ -4,9 +4,9 @@
|
||||
|
||||
const JsUnit = imports.jsUnit;
|
||||
|
||||
import '../../js/ui/environment.js';
|
||||
|
||||
import * as Assertions from '../common/assertions.js';
|
||||
const Environment = imports.ui.environment;
|
||||
Environment.init();
|
||||
|
||||
const JsParse = imports.misc.jsParse;
|
||||
|
||||
|
@ -5,8 +5,7 @@
|
||||
const JsUnit = imports.jsUnit;
|
||||
import Pango from 'gi://Pango';
|
||||
|
||||
const Environment = imports.ui.environment;
|
||||
Environment.init();
|
||||
import '../../js/ui/environment.js';
|
||||
|
||||
imports.ui.main; // eslint-disable-line no-unused-expressions
|
||||
const MessageList = imports.ui.messageList;
|
||||
|
@ -2,16 +2,14 @@
|
||||
|
||||
// Test cases for version comparison
|
||||
|
||||
import '../../js/ui/environment.js';
|
||||
import GObject from 'gi://GObject';
|
||||
|
||||
const JsUnit = imports.jsUnit;
|
||||
const Signals = imports.misc.signals;
|
||||
|
||||
const Environment = imports.ui.environment;
|
||||
const {TransientSignalHolder, registerDestroyableType} = imports.misc.signalTracker;
|
||||
|
||||
Environment.init();
|
||||
|
||||
const Destroyable = GObject.registerClass({
|
||||
Signals: {'destroy': {}},
|
||||
}, class Destroyable extends GObject.Object {});
|
||||
|
@ -4,8 +4,7 @@
|
||||
|
||||
const JsUnit = imports.jsUnit;
|
||||
|
||||
const Environment = imports.ui.environment;
|
||||
Environment.init();
|
||||
import '../../js/ui/environment.js';
|
||||
|
||||
const Util = imports.misc.util;
|
||||
|
||||
|
@ -4,8 +4,7 @@
|
||||
|
||||
const JsUnit = imports.jsUnit;
|
||||
|
||||
const Environment = imports.ui.environment;
|
||||
Environment.init();
|
||||
import '../../js/ui/environment.js';
|
||||
|
||||
const Util = imports.misc.util;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user