From a751e213f6b6358ca9c50ea65bbd9f86bf988aae Mon Sep 17 00:00:00 2001 From: Evan Welsh Date: Mon, 10 Jul 2023 02:53:00 -0700 Subject: [PATCH] js: Port to modules Part-of: --- .eslintrc.yml | 16 +- .../extensions/extensionsService.js | 2 +- .../screencast/screencastService.js | 6 +- js/extensions/extension.js | 2 +- js/gdm/authList.js | 11 +- js/gdm/authPrompt.js | 45 ++-- js/gdm/batch.js | 25 +- js/gdm/credentialManager.js | 7 +- js/gdm/loginDialog.js | 53 ++--- js/gdm/oVirt.js | 13 +- js/gdm/realmd.js | 11 +- js/gdm/util.js | 63 +++-- js/gdm/vmware.js | 13 +- js/misc/.eslintrc.yml | 5 + js/misc/animationUtils.js | 16 +- js/misc/dateUtils.js | 21 +- js/misc/dbusUtils.js | 1 - js/misc/extensionUtils.js | 15 +- js/misc/fileUtils.js | 14 +- js/misc/gnomeSession.js | 21 +- js/misc/history.js | 13 +- js/misc/ibusManager.js | 24 +- js/misc/inputMethod.js | 20 +- js/misc/introspect.js | 19 +- js/misc/jsParse.js | 25 +- js/misc/keyboardManager.js | 25 +- js/misc/loginManager.js | 24 +- js/misc/modemManager.js | 19 +- js/misc/objectManager.js | 13 +- js/misc/params.js | 3 +- js/misc/parentalControlsManager.js | 16 +- js/misc/permissionStore.js | 7 +- js/misc/signalTracker.js | 11 +- js/misc/signals.js | 9 +- js/misc/smartcardManager.js | 13 +- js/misc/systemActions.js | 23 +- js/misc/util.js | 43 ++-- js/misc/weather.js | 23 +- js/portalHelper/main.js | 8 +- js/ui/accessDialog.js | 31 ++- js/ui/altTab.js | 71 +++--- js/ui/animation.js | 25 +- js/ui/appDisplay.js | 92 ++++---- js/ui/appFavorites.js | 11 +- js/ui/appMenu.js | 26 +- js/ui/audioDeviceSelection.js | 31 ++- js/ui/background.js | 51 ++-- js/ui/backgroundMenu.js | 18 +- js/ui/barLevel.js | 11 +- js/ui/boxpointer.js | 19 +- js/ui/calendar.js | 57 +++-- js/ui/checkBox.js | 13 +- js/ui/closeDialog.js | 25 +- js/ui/components.js | 10 +- js/ui/components/automountManager.js | 24 +- js/ui/components/autorunManager.js | 37 ++- js/ui/components/keyring.js | 35 ++- js/ui/components/networkAgent.js | 42 ++-- js/ui/components/polkitAgent.js | 37 ++- js/ui/components/telepathyClient.js | 63 +++-- js/ui/ctrlAltTab.js | 29 ++- js/ui/dash.js | 47 ++-- js/ui/dateMenu.js | 50 ++-- js/ui/dialog.js | 21 +- js/ui/dnd.js | 49 ++-- js/ui/edgeDragAction.js | 17 +- js/ui/endSessionDialog.js | 41 ++-- js/ui/environment.js | 4 +- js/ui/extensionDownloader.js | 39 ++- js/ui/extensionSystem.js | 29 +-- js/ui/focusCaretTracker.js | 9 +- js/ui/grabHelper.js | 13 +- js/ui/ibusCandidatePopup.js | 21 +- js/ui/iconGrid.js | 39 ++- js/ui/inhibitShortcutsDialog.js | 23 +- js/ui/init.js | 2 +- js/ui/kbdA11yDialog.js | 15 +- js/ui/keyboard.js | 80 +++---- js/ui/layout.js | 53 ++--- js/ui/lightbox.js | 21 +- js/ui/locatePointer.js | 15 +- js/ui/lookingGlass.js | 87 ++++--- js/ui/magnifier.js | 47 ++-- js/ui/main.js | 222 +++++++++--------- js/ui/messageList.js | 42 ++-- js/ui/messageTray.js | 78 +++--- js/ui/modalDialog.js | 29 ++- js/ui/mpris.js | 25 +- js/ui/notificationDaemon.js | 43 ++-- js/ui/osdMonitorLabeler.js | 20 +- js/ui/osdWindow.js | 29 ++- js/ui/overview.js | 51 ++-- js/ui/overviewControls.js | 45 ++-- js/ui/padOsd.js | 47 ++-- js/ui/pageIndicators.js | 11 +- js/ui/panel.js | 99 ++++---- js/ui/panelMenu.js | 21 +- js/ui/pointerA11yTimeout.js | 19 +- js/ui/pointerWatcher.js | 15 +- js/ui/popupMenu.js | 68 +++--- js/ui/quickSettings.js | 40 ++-- js/ui/remoteSearch.js | 27 +-- js/ui/ripples.js | 9 +- js/ui/runDialog.js | 29 ++- js/ui/screenShield.js | 49 ++-- js/ui/screenshot.js | 67 +++--- js/ui/scripting.js | 8 +- js/ui/search.js | 51 ++-- js/ui/searchController.js | 17 +- js/ui/sessionMode.js | 22 +- js/ui/shellDBus.js | 35 ++- js/ui/shellEntry.js | 27 +-- js/ui/shellMountOperation.js | 57 +++-- js/ui/slider.js | 13 +- js/ui/status/accessibility.js | 17 +- js/ui/status/autoRotate.js | 12 +- js/ui/status/backgroundApps.js | 27 +-- js/ui/status/backlight.js | 15 +- js/ui/status/bluetooth.js | 24 +- js/ui/status/brightness.js | 12 +- js/ui/status/camera.js | 11 +- js/ui/status/darkMode.js | 11 +- js/ui/status/dwellClick.js | 15 +- js/ui/status/keyboard.js | 71 +++--- js/ui/status/location.js | 47 ++-- js/ui/status/network.js | 40 ++-- js/ui/status/nightLight.js | 13 +- js/ui/status/powerProfiles.js | 13 +- js/ui/status/remoteAccess.js | 25 +- js/ui/status/rfkill.js | 15 +- js/ui/status/system.js | 33 ++- js/ui/status/thunderbolt.js | 39 ++- js/ui/status/volume.js | 24 +- js/ui/swipeTracker.js | 15 +- js/ui/switchMonitor.js | 17 +- js/ui/switcherPopup.js | 31 ++- js/ui/unlockDialog.js | 43 ++-- js/ui/userWidget.js | 19 +- js/ui/welcomeDialog.js | 19 +- js/ui/windowAttentionHandler.js | 15 +- js/ui/windowManager.js | 96 ++++---- js/ui/windowMenu.js | 23 +- js/ui/windowPreview.js | 37 ++- js/ui/workspace.js | 52 ++-- js/ui/workspaceAnimation.js | 26 +- js/ui/workspaceSwitcherPopup.js | 19 +- js/ui/workspaceThumbnail.js | 49 ++-- js/ui/workspacesView.js | 42 ++-- js/ui/xdndHandler.js | 13 +- tests/shell/basic.js | 6 +- tests/shell/closeWithActiveWindows.js | 4 +- tests/shell/core.js | 6 +- tests/shell/headlessStart.js | 5 +- tests/shell/hwtest.js | 5 +- tests/unit/highlighter.js | 2 +- tests/unit/insertSorted.js | 2 +- tests/unit/jsParse.js | 2 +- tests/unit/markup.js | 4 +- tests/unit/params.js | 2 +- tests/unit/signalTracker.js | 4 +- tests/unit/url.js | 2 +- tests/unit/versionCompare.js | 2 +- 162 files changed, 2183 insertions(+), 2336 deletions(-) create mode 100644 js/misc/.eslintrc.yml diff --git a/.eslintrc.yml b/.eslintrc.yml index 8a7d9f51b..bd06d4f2f 100644 --- a/.eslintrc.yml +++ b/.eslintrc.yml @@ -1,17 +1,5 @@ extends: - ./lint/eslintrc-gjs.yml - ./lint/eslintrc-shell.yml -overrides: - - files: - - js/ui/init.js - - js/ui/environment.js - - js/ui/scripting.js - - js/misc/dependencies.js - - js/dbusServices/** - - js/extensions/** - - js/portalHelper/** - - subprojects/extensions-app/** - - subprojects/extensions-tool/** - - tests/** - parserOptions: - sourceType: module +parserOptions: + sourceType: module diff --git a/js/dbusServices/extensions/extensionsService.js b/js/dbusServices/extensions/extensionsService.js index b8e571bf9..180696458 100644 --- a/js/dbusServices/extensions/extensionsService.js +++ b/js/dbusServices/extensions/extensionsService.js @@ -6,7 +6,7 @@ import Shew from 'gi://Shew'; import {ExtensionPrefsDialog} from './extensionPrefsDialog.js'; import {ServiceImplementation} from './dbusService.js'; -const {deserializeExtension} = imports.misc.extensionUtils; +import {deserializeExtension} from './misc/extensionUtils.js'; const {loadInterfaceXML} = imports.misc.dbusUtils; const ExtensionsIface = loadInterfaceXML('org.gnome.Shell.Extensions'); diff --git a/js/dbusServices/screencast/screencastService.js b/js/dbusServices/screencast/screencastService.js index 745102376..60b0afd08 100644 --- a/js/dbusServices/screencast/screencastService.js +++ b/js/dbusServices/screencast/screencastService.js @@ -7,7 +7,7 @@ import Gtk from 'gi://Gtk?version=4.0'; import {ServiceImplementation} from './dbusService.js'; const {loadInterfaceXML, loadSubInterfaceXML} = imports.misc.dbusUtils; -const Signals = imports.misc.signals; +import * as Signals from './misc/signals.js'; const ScreencastIface = loadInterfaceXML('org.gnome.Shell.Screencast'); @@ -63,7 +63,7 @@ const SessionState = { STOPPED: 'STOPPED', }; -var Recorder = class extends Signals.EventEmitter { +class Recorder extends Signals.EventEmitter { constructor(sessionPath, x, y, width, height, filePath, options, invocation) { super(); @@ -397,7 +397,7 @@ var Recorder = class extends Signals.EventEmitter { return Gst.parse_launch_full(fullPipeline, null, Gst.ParseFlags.FATAL_ERRORS); } -}; +} export const ScreencastService = class extends ServiceImplementation { static canScreencast() { diff --git a/js/extensions/extension.js b/js/extensions/extension.js index c6a05f08b..1973fb78e 100644 --- a/js/extensions/extension.js +++ b/js/extensions/extension.js @@ -2,7 +2,7 @@ const Gi = imports._gi; import {ExtensionBase, GettextWrapper} from './sharedInternals.js'; -const {extensionManager} = imports.ui.main; +import {extensionManager} from '../ui/main.js'; export class Extension extends ExtensionBase { static lookupByUUID(uuid) { diff --git a/js/gdm/authList.js b/js/gdm/authList.js index a119f232a..03e66e074 100644 --- a/js/gdm/authList.js +++ b/js/gdm/authList.js @@ -15,12 +15,11 @@ * You should have received a copy of the GNU General Public License * along with this program; if not, see . */ -/* exported AuthList */ -const Clutter = imports.gi.Clutter; -const GObject = imports.gi.GObject; -const Meta = imports.gi.Meta; -const St = imports.gi.St; +import Clutter from 'gi://Clutter'; +import GObject from 'gi://GObject'; +import Meta from 'gi://Meta'; +import St from 'gi://St'; const SCROLL_ANIMATION_TIME = 500; @@ -68,7 +67,7 @@ const AuthListItem = GObject.registerClass({ } }); -var AuthList = GObject.registerClass({ +export const AuthList = GObject.registerClass({ Signals: { 'activate': { param_types: [GObject.TYPE_STRING] }, 'item-added': { param_types: [AuthListItem.$gtype] }, diff --git a/js/gdm/authPrompt.js b/js/gdm/authPrompt.js index 419a03606..71917346d 100644 --- a/js/gdm/authPrompt.js +++ b/js/gdm/authPrompt.js @@ -1,36 +1,35 @@ // -*- mode: js; js-indent-level: 4; indent-tabs-mode: nil -*- -/* exported AuthPrompt */ -const Clutter = imports.gi.Clutter; -const GLib = imports.gi.GLib; -const GObject = imports.gi.GObject; -const Pango = imports.gi.Pango; -const Shell = imports.gi.Shell; -const St = imports.gi.St; +import Clutter from 'gi://Clutter'; +import GLib from 'gi://GLib'; +import GObject from 'gi://GObject'; +import Pango from 'gi://Pango'; +import Shell from 'gi://Shell'; +import St from 'gi://St'; -const Animation = imports.ui.animation; -const AuthList = imports.gdm.authList; -const Batch = imports.gdm.batch; -const GdmUtil = imports.gdm.util; -const Params = imports.misc.params; -const ShellEntry = imports.ui.shellEntry; -const UserWidget = imports.ui.userWidget; -const {wiggle} = imports.misc.animationUtils; +import * as Animation from '../ui/animation.js'; +import * as AuthList from './authList.js'; +import * as Batch from './batch.js'; +import * as GdmUtil from './util.js'; +import * as Params from '../misc/params.js'; +import * as ShellEntry from '../ui/shellEntry.js'; +import * as UserWidget from '../ui/userWidget.js'; +import {wiggle} from '../misc/animationUtils.js'; -var DEFAULT_BUTTON_WELL_ICON_SIZE = 16; -var DEFAULT_BUTTON_WELL_ANIMATION_DELAY = 1000; -var DEFAULT_BUTTON_WELL_ANIMATION_TIME = 300; +const DEFAULT_BUTTON_WELL_ICON_SIZE = 16; +const DEFAULT_BUTTON_WELL_ANIMATION_DELAY = 1000; +const DEFAULT_BUTTON_WELL_ANIMATION_TIME = 300; -var MESSAGE_FADE_OUT_ANIMATION_TIME = 500; +const MESSAGE_FADE_OUT_ANIMATION_TIME = 500; /** @enum {number} */ -var AuthPromptMode = { +export const AuthPromptMode = { UNLOCK_ONLY: 0, UNLOCK_OR_LOG_IN: 1, }; /** @enum {number} */ -var AuthPromptStatus = { +export const AuthPromptStatus = { NOT_VERIFYING: 0, VERIFYING: 1, VERIFICATION_FAILED: 2, @@ -40,13 +39,13 @@ var AuthPromptStatus = { }; /** @enum {number} */ -var BeginRequestType = { +export const BeginRequestType = { PROVIDE_USERNAME: 0, DONT_PROVIDE_USERNAME: 1, REUSE_USERNAME: 2, }; -var AuthPrompt = GObject.registerClass({ +export const AuthPrompt = GObject.registerClass({ Signals: { 'cancelled': {}, 'failed': {}, diff --git a/js/gdm/batch.js b/js/gdm/batch.js index 771afe7e4..6984e4bbe 100644 --- a/js/gdm/batch.js +++ b/js/gdm/batch.js @@ -43,12 +43,11 @@ * are not used elsewhere. These APIs may ultimately get dropped entirely and * replaced by something else. */ -/* exported ConcurrentBatch, ConsecutiveBatch */ -const GObject = imports.gi.GObject; -const Signals = imports.misc.signals; +import GObject from 'gi://GObject'; +import * as Signals from '../misc/signals.js'; -var Task = class extends Signals.EventEmitter { +export class Task extends Signals.EventEmitter { constructor(scope, handler) { super(); @@ -66,9 +65,9 @@ var Task = class extends Signals.EventEmitter { return null; } -}; +} -var Hold = class extends Task { +export class Hold extends Task { constructor() { super(null, () => this); @@ -102,9 +101,9 @@ var Hold = class extends Task { isAcquired() { return this._acquisitions > 0; } -}; +} -var Batch = class extends Task { +export class Batch extends Task { constructor(scope, tasks) { super(); @@ -171,9 +170,9 @@ var Batch = class extends Task { cancel() { this.tasks = this.tasks.splice(0, this._currentTaskIndex + 1); } -}; +} -var ConcurrentBatch = class extends Batch { +export class ConcurrentBatch extends Batch { process() { let hold = this.runTask(); @@ -185,9 +184,9 @@ var ConcurrentBatch = class extends Batch { // concurrently. this.nextTask(); } -}; +} -var ConsecutiveBatch = class extends Batch { +export class ConsecutiveBatch extends Batch { process() { let hold = this.runTask(); @@ -203,4 +202,4 @@ var ConsecutiveBatch = class extends Batch { this.nextTask(); } } -}; +} diff --git a/js/gdm/credentialManager.js b/js/gdm/credentialManager.js index 2ea9f72ba..33b56cb9a 100644 --- a/js/gdm/credentialManager.js +++ b/js/gdm/credentialManager.js @@ -1,9 +1,8 @@ // -*- mode: js; js-indent-level: 4; indent-tabs-mode: nil -*- -/* exported CredentialManager */ -const Signals = imports.misc.signals; +import * as Signals from '../misc/signals.js'; -var CredentialManager = class CredentialManager extends Signals.EventEmitter { +export class CredentialManager extends Signals.EventEmitter { constructor(service) { super(); @@ -24,4 +23,4 @@ var CredentialManager = class CredentialManager extends Signals.EventEmitter { get service() { return this._service; } -}; +} diff --git a/js/gdm/loginDialog.js b/js/gdm/loginDialog.js index 5f8a32c36..2d354ff43 100644 --- a/js/gdm/loginDialog.js +++ b/js/gdm/loginDialog.js @@ -1,5 +1,4 @@ // -*- mode: js; js-indent-level: 4; indent-tabs-mode: nil -*- -/* exported LoginDialog */ /* * Copyright 2011 Red Hat, Inc * @@ -17,35 +16,35 @@ * along with this program; if not, see . */ -const AccountsService = imports.gi.AccountsService; -const Atk = imports.gi.Atk; -const Clutter = imports.gi.Clutter; -const Gdm = imports.gi.Gdm; -const Gio = imports.gi.Gio; -const GLib = imports.gi.GLib; -const GObject = imports.gi.GObject; -const Meta = imports.gi.Meta; -const Pango = imports.gi.Pango; -const Shell = imports.gi.Shell; -const St = imports.gi.St; +import AccountsService from 'gi://AccountsService'; +import Atk from 'gi://Atk'; +import Clutter from 'gi://Clutter'; +import Gdm from 'gi://Gdm'; +import Gio from 'gi://Gio'; +import GLib from 'gi://GLib'; +import GObject from 'gi://GObject'; +import Meta from 'gi://Meta'; +import Pango from 'gi://Pango'; +import Shell from 'gi://Shell'; +import St from 'gi://St'; -const AuthPrompt = imports.gdm.authPrompt; -const Batch = imports.gdm.batch; -const BoxPointer = imports.ui.boxpointer; -const CtrlAltTab = imports.ui.ctrlAltTab; -const GdmUtil = imports.gdm.util; -const Layout = imports.ui.layout; -const LoginManager = imports.misc.loginManager; -const Main = imports.ui.main; -const PopupMenu = imports.ui.popupMenu; -const Realmd = imports.gdm.realmd; -const UserWidget = imports.ui.userWidget; +import * as AuthPrompt from './authPrompt.js'; +import * as Batch from './batch.js'; +import * as BoxPointer from '../ui/boxpointer.js'; +import * as CtrlAltTab from '../ui/ctrlAltTab.js'; +import * as GdmUtil from './util.js'; +import * as Layout from '../ui/layout.js'; +import * as LoginManager from '../misc/loginManager.js'; +import * as Main from '../ui/main.js'; +import * as PopupMenu from '../ui/popupMenu.js'; +import * as Realmd from './realmd.js'; +import * as UserWidget from '../ui/userWidget.js'; const _FADE_ANIMATION_TIME = 250; const _SCROLL_ANIMATION_TIME = 500; const _TIMED_LOGIN_IDLE_THRESHOLD = 5.0; -var UserListItem = GObject.registerClass({ +export const UserListItem = GObject.registerClass({ Signals: { 'activate': {} }, }, class UserListItem extends St.Button { _init(user) { @@ -157,7 +156,7 @@ var UserListItem = GObject.registerClass({ } }); -var UserList = GObject.registerClass({ +const UserList = GObject.registerClass({ Signals: { 'activate': { param_types: [UserListItem.$gtype] }, 'item-added': { param_types: [UserListItem.$gtype] }, @@ -312,7 +311,7 @@ var UserList = GObject.registerClass({ } }); -var SessionMenuButton = GObject.registerClass({ +const SessionMenuButton = GObject.registerClass({ Signals: { 'session-activated': { param_types: [GObject.TYPE_STRING] } }, }, class SessionMenuButton extends St.Bin { _init() { @@ -407,7 +406,7 @@ var SessionMenuButton = GObject.registerClass({ } }); -var LoginDialog = GObject.registerClass({ +export const LoginDialog = GObject.registerClass({ Signals: { 'failed': {}, 'wake-up-screen': {}, diff --git a/js/gdm/oVirt.js b/js/gdm/oVirt.js index 7e829fbba..41f113335 100644 --- a/js/gdm/oVirt.js +++ b/js/gdm/oVirt.js @@ -1,10 +1,9 @@ // -*- mode: js; js-indent-level: 4; indent-tabs-mode: nil -*- -/* exported getOVirtCredentialsManager */ -const Gio = imports.gi.Gio; -const Credential = imports.gdm.credentialManager; +import Gio from 'gi://Gio'; +import * as Credential from './credentialManager.js'; -var SERVICE_NAME = 'gdm-ovirtcred'; +export const SERVICE_NAME = 'gdm-ovirtcred'; const OVirtCredentialsIface = ` @@ -32,7 +31,7 @@ function OVirtCredentials() { return self; } -var OVirtCredentialsManager = class OVirtCredentialsManager extends Credential.CredentialManager { +class OVirtCredentialsManager extends Credential.CredentialManager { constructor() { super(SERVICE_NAME); this._credentials = new OVirtCredentials(); @@ -41,12 +40,12 @@ var OVirtCredentialsManager = class OVirtCredentialsManager extends Credential.C this.token = token; }); } -}; +} /** * @returns {OVirtCredentialsManager} */ -function getOVirtCredentialsManager() { +export function getOVirtCredentialsManager() { if (!_oVirtCredentialsManager) _oVirtCredentialsManager = new OVirtCredentialsManager(); diff --git a/js/gdm/realmd.js b/js/gdm/realmd.js index 52661c1e5..7b386d916 100644 --- a/js/gdm/realmd.js +++ b/js/gdm/realmd.js @@ -1,10 +1,9 @@ // -*- mode: js; js-indent-level: 4; indent-tabs-mode: nil -*- -/* exported Manager */ -const Gio = imports.gi.Gio; -const Signals = imports.misc.signals; +import Gio from 'gi://Gio'; +import * as Signals from '../misc/signals.js'; -const { loadInterfaceXML } = imports.misc.fileUtils; +import {loadInterfaceXML} from '../misc/fileUtils.js'; const ProviderIface = loadInterfaceXML("org.freedesktop.realmd.Provider"); const Provider = Gio.DBusProxy.makeProxyWrapper(ProviderIface); @@ -15,7 +14,7 @@ const Service = Gio.DBusProxy.makeProxyWrapper(ServiceIface); const RealmIface = loadInterfaceXML("org.freedesktop.realmd.Realm"); const Realm = Gio.DBusProxy.makeProxyWrapper(RealmIface); -var Manager = class extends Signals.EventEmitter { +export class Manager extends Signals.EventEmitter { constructor() { super(); @@ -109,4 +108,4 @@ var Manager = class extends Signals.EventEmitter { this._realms = { }; this._updateLoginFormat(); } -}; +} diff --git a/js/gdm/util.js b/js/gdm/util.js index 94e05eaf0..837f12eec 100644 --- a/js/gdm/util.js +++ b/js/gdm/util.js @@ -1,21 +1,18 @@ // -*- mode: js; js-indent-level: 4; indent-tabs-mode: nil -*- -/* exported BANNER_MESSAGE_KEY, BANNER_MESSAGE_TEXT_KEY, LOGO_KEY, - DISABLE_USER_LIST_KEY, fadeInActor, fadeOutActor, cloneAndFadeOutActor, - ShellUserVerifier */ -const Clutter = imports.gi.Clutter; -const Gdm = imports.gi.Gdm; -const Gio = imports.gi.Gio; -const GLib = imports.gi.GLib; -const Signals = imports.misc.signals; +import Clutter from 'gi://Clutter'; +import Gdm from 'gi://Gdm'; +import Gio from 'gi://Gio'; +import GLib from 'gi://GLib'; +import * as Signals from '../misc/signals.js'; -const Batch = imports.gdm.batch; -const OVirt = imports.gdm.oVirt; -const Vmware = imports.gdm.vmware; -const Main = imports.ui.main; -const { loadInterfaceXML } = imports.misc.fileUtils; -const Params = imports.misc.params; -const SmartcardManager = imports.misc.smartcardManager; +import * as Batch from './batch.js'; +import * as OVirt from './oVirt.js'; +import * as Vmware from './vmware.js'; +import * as Main from '../ui/main.js'; +import {loadInterfaceXML} from '../misc/fileUtils.js'; +import * as Params from '../misc/params.js'; +import * as SmartcardManager from '../misc/smartcardManager.js'; const FprintManagerIface = loadInterfaceXML('net.reactivated.Fprint.Manager'); const FprintManagerProxy = Gio.DBusProxy.makeProxyWrapper(FprintManagerIface); @@ -28,24 +25,24 @@ Gio._promisify(Gdm.UserVerifierProxy.prototype, 'call_begin_verification_for_user'); Gio._promisify(Gdm.UserVerifierProxy.prototype, 'call_begin_verification'); -var PASSWORD_SERVICE_NAME = 'gdm-password'; -var FINGERPRINT_SERVICE_NAME = 'gdm-fingerprint'; -var SMARTCARD_SERVICE_NAME = 'gdm-smartcard'; -var CLONE_FADE_ANIMATION_TIME = 250; +export const PASSWORD_SERVICE_NAME = 'gdm-password'; +export const FINGERPRINT_SERVICE_NAME = 'gdm-fingerprint'; +export const SMARTCARD_SERVICE_NAME = 'gdm-smartcard'; +const CLONE_FADE_ANIMATION_TIME = 250; -var LOGIN_SCREEN_SCHEMA = 'org.gnome.login-screen'; -var PASSWORD_AUTHENTICATION_KEY = 'enable-password-authentication'; -var FINGERPRINT_AUTHENTICATION_KEY = 'enable-fingerprint-authentication'; -var SMARTCARD_AUTHENTICATION_KEY = 'enable-smartcard-authentication'; -var BANNER_MESSAGE_KEY = 'banner-message-enable'; -var BANNER_MESSAGE_TEXT_KEY = 'banner-message-text'; -var ALLOWED_FAILURES_KEY = 'allowed-failures'; +export const LOGIN_SCREEN_SCHEMA = 'org.gnome.login-screen'; +export const PASSWORD_AUTHENTICATION_KEY = 'enable-password-authentication'; +export const FINGERPRINT_AUTHENTICATION_KEY = 'enable-fingerprint-authentication'; +export const SMARTCARD_AUTHENTICATION_KEY = 'enable-smartcard-authentication'; +export const BANNER_MESSAGE_KEY = 'banner-message-enable'; +export const BANNER_MESSAGE_TEXT_KEY = 'banner-message-text'; +export const ALLOWED_FAILURES_KEY = 'allowed-failures'; -var LOGO_KEY = 'logo'; -var DISABLE_USER_LIST_KEY = 'disable-user-list'; +export const LOGO_KEY = 'logo'; +export const DISABLE_USER_LIST_KEY = 'disable-user-list'; // Give user 48ms to read each character of a PAM message -var USER_READ_TIME = 48; +const USER_READ_TIME = 48; const FINGERPRINT_ERROR_TIMEOUT_WAIT = 15; /** @@ -53,7 +50,7 @@ const FINGERPRINT_ERROR_TIMEOUT_WAIT = 15; * * @enum {number} */ -var MessageType = { +export const MessageType = { NONE: 0, HINT: 1, INFO: 2, @@ -69,7 +66,7 @@ const FingerprintReaderType = { /** * @param {Clutter.Actor} actor */ -function cloneAndFadeOutActor(actor) { +export function cloneAndFadeOutActor(actor) { // Immediately hide actor so its sibling can have its space // and position, but leave a non-reactive clone on-screen, // so from the user's point of view it smoothly fades away @@ -99,7 +96,7 @@ function cloneAndFadeOutActor(actor) { return hold; } -var ShellUserVerifier = class extends Signals.EventEmitter { +export class ShellUserVerifier extends Signals.EventEmitter { constructor(client, params) { super(); params = Params.parse(params, { reauthenticationOnly: false }); @@ -765,4 +762,4 @@ var ShellUserVerifier = class extends Signals.EventEmitter { this._verificationFailed(serviceName, true); } -}; +} diff --git a/js/gdm/vmware.js b/js/gdm/vmware.js index 367ec4fc2..c569f0101 100644 --- a/js/gdm/vmware.js +++ b/js/gdm/vmware.js @@ -1,13 +1,12 @@ // -*- mode: js; js-indent-level: 4; indent-tabs-mode: nil -*- -/* exported getVmwareCredentialsManager */ -const Gio = imports.gi.Gio; -const Credential = imports.gdm.credentialManager; +import Gio from 'gi://Gio'; +import * as Credential from './credentialManager.js'; const dbusPath = '/org/vmware/viewagent/Credentials'; const dbusInterface = 'org.vmware.viewagent.Credentials'; -var SERVICE_NAME = 'gdm-vmwcred'; +export const SERVICE_NAME = 'gdm-vmwcred'; const VmwareCredentialsIface = ` @@ -35,7 +34,7 @@ function VmwareCredentials() { return self; } -var VmwareCredentialsManager = class VmwareCredentialsManager extends Credential.CredentialManager { +class VmwareCredentialsManager extends Credential.CredentialManager { constructor() { super(SERVICE_NAME); this._credentials = new VmwareCredentials(); @@ -44,12 +43,12 @@ var VmwareCredentialsManager = class VmwareCredentialsManager extends Credential this.token = token; }); } -}; +} /** * @returns {VmwareCredentialsManager} */ -function getVmwareCredentialsManager() { +export function getVmwareCredentialsManager() { if (!_vmwareCredentialsManager) _vmwareCredentialsManager = new VmwareCredentialsManager(); diff --git a/js/misc/.eslintrc.yml b/js/misc/.eslintrc.yml new file mode 100644 index 000000000..4526a5cf4 --- /dev/null +++ b/js/misc/.eslintrc.yml @@ -0,0 +1,5 @@ +overrides: + - files: + - dbusUtils.js + parserOptions: + sourceType: script \ No newline at end of file diff --git a/js/misc/animationUtils.js b/js/misc/animationUtils.js index 619d719bd..1562f1018 100644 --- a/js/misc/animationUtils.js +++ b/js/misc/animationUtils.js @@ -1,11 +1,9 @@ -/* exported adjustAnimationTime, ensureActorVisibleInScrollView, wiggle */ +import St from 'gi://St'; +import Clutter from 'gi://Clutter'; -const St = imports.gi.St; -const Clutter = imports.gi.Clutter; +import * as Params from './params.js'; -const Params = imports.misc.params; - -var SCROLL_TIME = 100; +const SCROLL_TIME = 100; const WIGGLE_OFFSET = 6; const WIGGLE_DURATION = 65; @@ -19,7 +17,7 @@ const N_WIGGLES = 3; * Adjust `msecs` to account for St's enable-animations * and slow-down-factor settings */ -function adjustAnimationTime(msecs) { +export function adjustAnimationTime(msecs) { const settings = St.Settings.get(); if (!settings.enable_animations) @@ -33,7 +31,7 @@ function adjustAnimationTime(msecs) { * @param {St.ScrollView} scrollView - the scroll view the actor is in * @param {Clutter.Actor} actor - the actor */ -function ensureActorVisibleInScrollView(scrollView, actor) { +export function ensureActorVisibleInScrollView(scrollView, actor) { const {adjustment} = scrollView.vscroll; let [value, lower_, upper, stepIncrement_, pageIncrement_, pageSize] = adjustment.get_values(); @@ -79,7 +77,7 @@ function ensureActorVisibleInScrollView(scrollView, actor) { * @param {number} params.duration - the amount of time to move the actor per-wiggle * @param {number} params.wiggleCount - the number of times to wiggle the actor */ -function wiggle(actor, params) { +export function wiggle(actor, params) { if (!St.Settings.get().enable_animations) return; diff --git a/js/misc/dateUtils.js b/js/misc/dateUtils.js index d90d1ceeb..4e7e68056 100644 --- a/js/misc/dateUtils.js +++ b/js/misc/dateUtils.js @@ -1,11 +1,10 @@ -/* exported formatDateWithCFormatString, formatTime, formatTimeSpan, clearCachedLocalTimeZone */ +import * as System from 'system'; +import * as Gettext from 'gettext'; +import GLib from 'gi://GLib'; +import Gio from 'gi://Gio'; +import Shell from 'gi://Shell'; -const System = imports.system; -const Gettext = imports.gettext; -const GLib = imports.gi.GLib; -const Gio = imports.gi.Gio; -const Shell = imports.gi.Shell; -const Params = imports.misc.params; +import * as Params from './params.js'; let _desktopSettings = null; let _localTimeZone = null; @@ -39,7 +38,7 @@ function _convertJSDateToGLibDateTime(date) { * @param {string} format a format String for the date * @returns {string} */ -function formatDateWithCFormatString(date, format) { +export function formatDateWithCFormatString(date, format) { const dt = _convertJSDateToGLibDateTime(date); return dt?.format(format) ?? ''; @@ -52,7 +51,7 @@ function formatDateWithCFormatString(date, format) { * @param {Date} date the start of the time span * @returns {string} */ -function formatTimeSpan(date) { +export function formatTimeSpan(date) { if (_localTimeZone === null) _localTimeZone = GLib.TimeZone.new_local(); @@ -121,7 +120,7 @@ function formatTimeSpan(date) { * @param {boolean=} params.ampm whether to include the "am" or "pm" in the string * @returns {string} */ -function formatTime(time, params) { +export function formatTime(time, params) { let date; // HACK: The built-in Date type sucks at timezones, which we need for the // world clock; it's often more convenient though, so allow either @@ -223,7 +222,7 @@ function formatTime(time, params) { * Update the timezone used by JavaScript Date objects and other * date utilities */ -function clearCachedLocalTimeZone() { +export function clearCachedLocalTimeZone() { // SpiderMonkey caches the time zone so we must explicitly clear it // before we can update the calendar, see // https://bugzilla.gnome.org/show_bug.cgi?id=678507 diff --git a/js/misc/dbusUtils.js b/js/misc/dbusUtils.js index da358c7ee..686c63f20 100644 --- a/js/misc/dbusUtils.js +++ b/js/misc/dbusUtils.js @@ -1,4 +1,3 @@ -// -*- mode: js; js-indent-level: 4; indent-tabs-mode: nil -*- /* exported loadInterfaceXML, loadSubInterfaceXML */ const Config = imports.misc.config; diff --git a/js/misc/extensionUtils.js b/js/misc/extensionUtils.js index 06b0f8659..682099e60 100644 --- a/js/misc/extensionUtils.js +++ b/js/misc/extensionUtils.js @@ -1,13 +1,10 @@ -/* exported ExtensionState, ExtensionType, - * serializeExtension, deserializeExtension */ - // Common utils for the extension system, the extensions D-Bus service // and the Extensions app -const Gio = imports.gi.Gio; -const GLib = imports.gi.GLib; +import Gio from 'gi://Gio'; +import GLib from 'gi://GLib'; -var ExtensionType = { +export const ExtensionType = { SYSTEM: 1, PER_USER: 2, }; @@ -15,7 +12,7 @@ var ExtensionType = { /** * @enum {number} */ -var ExtensionState = { +export const ExtensionState = { ENABLED: 1, DISABLED: 2, ERROR: 3, @@ -47,7 +44,7 @@ const SERIALIZED_PROPERTIES = [ * @param {object} extension - an extension object * @returns {object} */ -function serializeExtension(extension) { +export function serializeExtension(extension) { let obj = {...extension.metadata}; SERIALIZED_PROPERTIES.forEach(prop => { @@ -83,7 +80,7 @@ function serializeExtension(extension) { * @param {object} variant - an unpacked {GLib.Variant} * @returns {object} */ -function deserializeExtension(variant) { +export function deserializeExtension(variant) { let res = {metadata: {}}; for (let prop in variant) { let val = variant[prop].unpack(); diff --git a/js/misc/fileUtils.js b/js/misc/fileUtils.js index 31256294b..b5e355bbe 100644 --- a/js/misc/fileUtils.js +++ b/js/misc/fileUtils.js @@ -1,11 +1,9 @@ // -*- mode: js; js-indent-level: 4; indent-tabs-mode: nil -*- -/* exported collectFromDatadirs, recursivelyDeleteDir, - recursivelyMoveDir, loadInterfaceXML, loadSubInterfaceXML */ -const Gio = imports.gi.Gio; -const GLib = imports.gi.GLib; +import GLib from 'gi://GLib'; +import Gio from 'gi://Gio'; -var { loadInterfaceXML } = imports.misc.dbusUtils; +export const {loadInterfaceXML} = imports.misc.dbusUtils; /** * @typedef {object} SubdirInfo @@ -20,7 +18,7 @@ var { loadInterfaceXML } = imports.misc.dbusUtils; * @returns {Generator} a generator which yields file info for subdirectories named * `subdir` within data directories */ -function* collectFromDatadirs(subdir, includeUserDir) { +export function* collectFromDatadirs(subdir, includeUserDir) { let dataDirs = GLib.get_system_data_dirs(); if (includeUserDir) dataDirs.unshift(GLib.get_user_data_dir()); @@ -48,7 +46,7 @@ function* collectFromDatadirs(subdir, includeUserDir) { * @param {Gio.File} dir * @param {boolean} deleteParent */ -function recursivelyDeleteDir(dir, deleteParent) { +export function recursivelyDeleteDir(dir, deleteParent) { let children = dir.enumerate_children('standard::name,standard::type', Gio.FileQueryInfoFlags.NOFOLLOW_SYMLINKS, null); @@ -70,7 +68,7 @@ function recursivelyDeleteDir(dir, deleteParent) { * @param {Gio.File} srcDir * @param {Gio.File} destDir */ -function recursivelyMoveDir(srcDir, destDir) { +export function recursivelyMoveDir(srcDir, destDir) { let children = srcDir.enumerate_children('standard::name,standard::type', Gio.FileQueryInfoFlags.NOFOLLOW_SYMLINKS, null); diff --git a/js/misc/gnomeSession.js b/js/misc/gnomeSession.js index 2b430342a..0ff179c19 100644 --- a/js/misc/gnomeSession.js +++ b/js/misc/gnomeSession.js @@ -1,28 +1,27 @@ // -*- mode: js; js-indent-level: 4; indent-tabs-mode: nil -*- -/* exported PresenceStatus, Presence, Inhibitor, SessionManager, InhibitFlags */ -const Gio = imports.gi.Gio; +import Gio from 'gi://Gio'; -const { loadInterfaceXML } = imports.misc.fileUtils; +import {loadInterfaceXML} from './fileUtils.js'; const PresenceIface = loadInterfaceXML('org.gnome.SessionManager.Presence'); /** @enum {number} */ -var PresenceStatus = { +export const PresenceStatus = { AVAILABLE: 0, INVISIBLE: 1, BUSY: 2, IDLE: 3, }; -var PresenceProxy = Gio.DBusProxy.makeProxyWrapper(PresenceIface); +const PresenceProxy = Gio.DBusProxy.makeProxyWrapper(PresenceIface); /** * @param {Function} initCallback * @param {Gio.Cancellable} cancellable * @returns {Gio.DBusProxy} */ -function Presence(initCallback, cancellable) { +export function Presence(initCallback, cancellable) { return new PresenceProxy(Gio.DBus.session, 'org.gnome.SessionManager', '/org/gnome/SessionManager/Presence', initCallback, cancellable); } @@ -31,7 +30,7 @@ function Presence(initCallback, cancellable) { // change at runtime (changes always come in the form // of new inhibitors) const InhibitorIface = loadInterfaceXML('org.gnome.SessionManager.Inhibitor'); -var InhibitorProxy = Gio.DBusProxy.makeProxyWrapper(InhibitorIface); +const InhibitorProxy = Gio.DBusProxy.makeProxyWrapper(InhibitorIface); /** * @param {string} objectPath @@ -39,24 +38,24 @@ var InhibitorProxy = Gio.DBusProxy.makeProxyWrapper(InhibitorIface); * @param {Gio.Cancellable} cancellable * @returns {Gio.DBusProxy} */ -function Inhibitor(objectPath, initCallback, cancellable) { +export function Inhibitor(objectPath, initCallback, cancellable) { return new InhibitorProxy(Gio.DBus.session, 'org.gnome.SessionManager', objectPath, initCallback, cancellable); } // Not the full interface, only the methods we use const SessionManagerIface = loadInterfaceXML('org.gnome.SessionManager'); -var SessionManagerProxy = Gio.DBusProxy.makeProxyWrapper(SessionManagerIface); +const SessionManagerProxy = Gio.DBusProxy.makeProxyWrapper(SessionManagerIface); /** * @param {Function} initCallback * @param {Gio.Cancellable} cancellable * @returns {Gio.DBusProxy} */ -function SessionManager(initCallback, cancellable) { +export function SessionManager(initCallback, cancellable) { return new SessionManagerProxy(Gio.DBus.session, 'org.gnome.SessionManager', '/org/gnome/SessionManager', initCallback, cancellable); } -var InhibitFlags = { +export const InhibitFlags = { LOGOUT: 1 << 0, SWITCH: 1 << 1, SUSPEND: 1 << 2, diff --git a/js/misc/history.js b/js/misc/history.js index 268f13bb8..613ce612d 100644 --- a/js/misc/history.js +++ b/js/misc/history.js @@ -1,13 +1,12 @@ // -*- mode: js; js-indent-level: 4; indent-tabs-mode: nil -*- -/* exported HistoryManager */ -const Signals = imports.misc.signals; -const Clutter = imports.gi.Clutter; -const Params = imports.misc.params; +import * as Signals from './signals.js'; +import Clutter from 'gi://Clutter'; +import * as Params from './params.js'; -var DEFAULT_LIMIT = 512; +const DEFAULT_LIMIT = 512; -var HistoryManager = class extends Signals.EventEmitter { +export class HistoryManager extends Signals.EventEmitter { constructor(params) { super(); @@ -111,4 +110,4 @@ var HistoryManager = class extends Signals.EventEmitter { if (this._key) global.settings.set_strv(this._key, this._history); } -}; +} diff --git a/js/misc/ibusManager.js b/js/misc/ibusManager.js index ffba04d8c..168d175e5 100644 --- a/js/misc/ibusManager.js +++ b/js/misc/ibusManager.js @@ -1,15 +1,15 @@ // -*- mode: js; js-indent-level: 4; indent-tabs-mode: nil -*- -/* exported getIBusManager */ -const Gio = imports.gi.Gio; -const GLib = imports.gi.GLib; -const IBus = imports.gi.IBus; -const Meta = imports.gi.Meta; -const Shell = imports.gi.Shell; -const Signals = imports.misc.signals; -const BoxPointer = imports.ui.boxpointer; +import Gio from 'gi://Gio'; +import GLib from 'gi://GLib'; +import IBus from 'gi://IBus'; +import Meta from 'gi://Meta'; +import Shell from 'gi://Shell'; -const IBusCandidatePopup = imports.ui.ibusCandidatePopup; +import * as Signals from './signals.js'; +import * as BoxPointer from '../ui/boxpointer.js'; + +import * as IBusCandidatePopup from '../ui/ibusCandidatePopup.js'; Gio._promisify(IBus.Bus.prototype, 'list_engines_async', 'list_engines_async_finish'); @@ -49,13 +49,13 @@ function _checkIBusVersion(requiredMajor, requiredMinor, requiredMicro) { /** * @returns {IBusManager} */ -function getIBusManager() { +export function getIBusManager() { if (_ibusManager == null) _ibusManager = new IBusManager(); return _ibusManager; } -var IBusManager = class extends Signals.EventEmitter { +class IBusManager extends Signals.EventEmitter { constructor() { super(); @@ -410,4 +410,4 @@ var IBusManager = class extends Signals.EventEmitter { } return true; } -}; +} diff --git a/js/misc/inputMethod.js b/js/misc/inputMethod.js index c3749114e..1ac1dff57 100644 --- a/js/misc/inputMethod.js +++ b/js/misc/inputMethod.js @@ -1,22 +1,22 @@ // -*- mode: js; js-indent-level: 4; indent-tabs-mode: nil -*- -/* exported InputMethod */ -const Clutter = imports.gi.Clutter; -const GLib = imports.gi.GLib; -const Gio = imports.gi.Gio; -const GObject = imports.gi.GObject; -const IBus = imports.gi.IBus; -const Keyboard = imports.ui.status.keyboard; -const Main = imports.ui.main; +import Clutter from 'gi://Clutter'; +import GLib from 'gi://GLib'; +import Gio from 'gi://Gio'; +import GObject from 'gi://GObject'; +import IBus from 'gi://IBus'; + +import * as Keyboard from '../ui/status/keyboard.js'; +import * as Main from '../ui/main.js'; Gio._promisify(IBus.Bus.prototype, 'create_input_context_async', 'create_input_context_async_finish'); Gio._promisify(IBus.InputContext.prototype, 'process_key_event_async', 'process_key_event_async_finish'); -var HIDE_PANEL_TIME = 50; +const HIDE_PANEL_TIME = 50; -var InputMethod = GObject.registerClass({ +export const InputMethod = GObject.registerClass({ Signals: { 'surrounding-text-set': {}, 'terminal-mode-changed': {}, diff --git a/js/misc/introspect.js b/js/misc/introspect.js index d55a2fe9d..aa50dc78c 100644 --- a/js/misc/introspect.js +++ b/js/misc/introspect.js @@ -1,9 +1,8 @@ -/* exported IntrospectService */ -const Gio = imports.gi.Gio; -const GLib = imports.gi.GLib; -const Meta = imports.gi.Meta; -const Shell = imports.gi.Shell; -const St = imports.gi.St; +import Gio from 'gi://Gio'; +import GLib from 'gi://GLib'; +import Meta from 'gi://Meta'; +import Shell from 'gi://Shell'; +import St from 'gi://St'; const APP_ALLOWLIST = [ 'org.freedesktop.impl.portal.desktop.gtk', @@ -12,12 +11,12 @@ const APP_ALLOWLIST = [ const INTROSPECT_DBUS_API_VERSION = 3; -const { loadInterfaceXML } = imports.misc.fileUtils; -const { DBusSenderChecker } = imports.misc.util; +import {loadInterfaceXML} from './fileUtils.js'; +import {DBusSenderChecker} from './util.js'; const IntrospectDBusIface = loadInterfaceXML('org.gnome.Shell.Introspect'); -var IntrospectService = class { +export class IntrospectService { constructor() { this._dbusImpl = Gio.DBusExportedObject.wrapJSObject(IntrospectDBusIface, this); @@ -218,4 +217,4 @@ var IntrospectService = class { get version() { return INTROSPECT_DBUS_API_VERSION; } -}; +} diff --git a/js/misc/jsParse.js b/js/misc/jsParse.js index e55d69a30..42c61051e 100644 --- a/js/misc/jsParse.js +++ b/js/misc/jsParse.js @@ -1,5 +1,4 @@ /* -*- mode: js2; js2-basic-offset: 4; indent-tabs-mode: nil -*- */ -/* exported getCompletions, getCommonPrefix, getDeclaredConstants */ const AsyncFunction = async function () {}.constructor; @@ -15,7 +14,7 @@ const AsyncFunction = async function () {}.constructor; * @param {string} commandHeader * @param {readonly string[]} [globalCompletionList] */ -async function getCompletions(text, commandHeader, globalCompletionList) { +export async function getCompletions(text, commandHeader, globalCompletionList) { let methods = []; let expr_, base; let attrHead = ''; @@ -70,7 +69,7 @@ function isStopChar(c) { * @param {string} expr * @param {number} offset */ -function findMatchingQuote(expr, offset) { +export function findMatchingQuote(expr, offset) { let quoteChar = expr.charAt(offset); for (let i = offset - 1; i >= 0; --i) { if (expr.charAt(i) == quoteChar && expr.charAt(i - 1) != '\\') @@ -85,7 +84,7 @@ function findMatchingQuote(expr, offset) { * @param {string} expr * @param {number} offset */ -function findMatchingSlash(expr, offset) { +export function findMatchingSlash(expr, offset) { for (let i = offset - 1; i >= 0; --i) { if (expr.charAt(i) == '/' && expr.charAt(i - 1) != '\\') return i; @@ -102,7 +101,7 @@ function findMatchingSlash(expr, offset) { * @param {string} expr * @param {number} offset */ -function findMatchingBrace(expr, offset) { +export function findMatchingBrace(expr, offset) { let closeBrace = expr.charAt(offset); let openBrace = { ')': '(', ']': '[' }[closeBrace]; @@ -115,7 +114,7 @@ function findMatchingBrace(expr, offset) { * @param {...any} braces * @returns {number} */ -function findTheBrace(expr, offset, ...braces) { +export function findTheBrace(expr, offset, ...braces) { let [openBrace, closeBrace] = braces; if (offset < 0) @@ -146,7 +145,7 @@ function findTheBrace(expr, offset, ...braces) { * @param {string} expr * @param {number} offset */ -function getExpressionOffset(expr, offset) { +export function getExpressionOffset(expr, offset) { while (offset >= 0) { let currChar = expr.charAt(offset); @@ -178,7 +177,7 @@ function isValidPropertyName(w) { * * @param {object} obj */ -function getAllProps(obj) { +export function getAllProps(obj) { if (obj === null || obj === undefined) return []; @@ -195,7 +194,7 @@ function getAllProps(obj) { * @param {string} expr * @param {string=} commandHeader */ -async function getPropertyNamesFromExpression(expr, commandHeader = '') { +export async function getPropertyNamesFromExpression(expr, commandHeader = '') { let obj = {}; if (!isUnsafeExpression(expr)) { try { @@ -227,7 +226,7 @@ async function getPropertyNamesFromExpression(expr, commandHeader = '') { * * @param {readonly string[]} words */ -function getCommonPrefix(words) { +export function getCommonPrefix(words) { let word = words[0]; for (let i = 0; i < word.length; i++) { for (let w = 1; w < words.length; w++) { @@ -243,7 +242,7 @@ function getCommonPrefix(words) { * * @param {string} str */ -function removeLiterals(str) { +export function removeLiterals(str) { if (str.length == 0) return ''; @@ -265,7 +264,7 @@ function removeLiterals(str) { * * @param {string} str */ -function isUnsafeExpression(str) { +export function isUnsafeExpression(str) { // Check for any sort of assignment // The strategy used is dumb: remove any quotes // or regexs and comparison operators and see if there is an '=' character. @@ -290,7 +289,7 @@ function isUnsafeExpression(str) { * * @param {string} str */ -function getDeclaredConstants(str) { +export function getDeclaredConstants(str) { let ret = []; str.split(';').forEach(s => { let base_, keyword; diff --git a/js/misc/keyboardManager.js b/js/misc/keyboardManager.js index e5520dd34..2446c0068 100644 --- a/js/misc/keyboardManager.js +++ b/js/misc/keyboardManager.js @@ -1,21 +1,20 @@ // -*- mode: js; js-indent-level: 4; indent-tabs-mode: nil -*- -/* exported getKeyboardManager, holdKeyboard, releaseKeyboard */ -const GLib = imports.gi.GLib; -const GnomeDesktop = imports.gi.GnomeDesktop; +import GLib from 'gi://GLib'; +import GnomeDesktop from 'gi://GnomeDesktop'; -const Main = imports.ui.main; +import * as Main from '../ui/main.js'; -var DEFAULT_LOCALE = 'en_US'; -var DEFAULT_LAYOUT = 'us'; -var DEFAULT_VARIANT = ''; +export const DEFAULT_LOCALE = 'en_US'; +export const DEFAULT_LAYOUT = 'us'; +export const DEFAULT_VARIANT = ''; let _xkbInfo = null; /** * @returns {GnomeDesktop.XkbInfo} */ -function getXkbInfo() { +export function getXkbInfo() { if (_xkbInfo == null) _xkbInfo = new GnomeDesktop.XkbInfo(); return _xkbInfo; @@ -26,24 +25,24 @@ let _keyboardManager = null; /** * @returns {KeyboardManager} */ -function getKeyboardManager() { +export function getKeyboardManager() { if (_keyboardManager == null) _keyboardManager = new KeyboardManager(); return _keyboardManager; } -function releaseKeyboard() { +export function releaseKeyboard() { if (Main.modalCount > 0) global.display.unfreeze_keyboard(global.get_current_time()); else global.display.ungrab_keyboard(global.get_current_time()); } -function holdKeyboard() { +export function holdKeyboard() { global.display.freeze_keyboard(global.get_current_time()); } -var KeyboardManager = class { +class KeyboardManager { constructor() { // The XKB protocol doesn't allow for more that 4 layouts in a // keymap. Wayland doesn't impose this limit and libxkbcommon can @@ -167,4 +166,4 @@ var KeyboardManager = class { get currentLayout() { return this._current; } -}; +} diff --git a/js/misc/loginManager.js b/js/misc/loginManager.js index 720a81137..02b561bee 100644 --- a/js/misc/loginManager.js +++ b/js/misc/loginManager.js @@ -1,11 +1,10 @@ // -*- mode: js; js-indent-level: 4; indent-tabs-mode: nil -*- -/* exported canLock, getLoginManager, registerSessionWithGDM */ -const GLib = imports.gi.GLib; -const Gio = imports.gi.Gio; -const Signals = imports.misc.signals; +import GLib from 'gi://GLib'; +import Gio from 'gi://Gio'; +import * as Signals from './signals.js'; -const { loadInterfaceXML } = imports.misc.fileUtils; +import {loadInterfaceXML} from './fileUtils.js'; const SystemdLoginManagerIface = loadInterfaceXML('org.freedesktop.login1.Manager'); const SystemdLoginSessionIface = loadInterfaceXML('org.freedesktop.login1.Session'); @@ -36,7 +35,7 @@ function versionCompare(required, reference) { /** * @returns {boolean} */ -function canLock() { +export function canLock() { try { let params = GLib.Variant.new('(ss)', ['org.gnome.DisplayManager.Manager', 'Version']); let result = Gio.DBus.system.call_sync('org.gnome.DisplayManager', @@ -53,8 +52,7 @@ function canLock() { } } - -async function registerSessionWithGDM() { +export async function registerSessionWithGDM() { log("Registering session with GDM"); try { await Gio.DBus.system.call( @@ -79,7 +77,7 @@ let _loginManager = null; * An abstraction over systemd/logind and ConsoleKit. * @returns {LoginManagerSystemd | LoginManagerDummy} - the LoginManager singleton */ -function getLoginManager() { +export function getLoginManager() { if (_loginManager == null) { if (haveSystemd()) _loginManager = new LoginManagerSystemd(); @@ -90,7 +88,7 @@ function getLoginManager() { return _loginManager; } -var LoginManagerSystemd = class extends Signals.EventEmitter { +class LoginManagerSystemd extends Signals.EventEmitter { constructor() { super(); @@ -207,9 +205,9 @@ var LoginManagerSystemd = class extends Signals.EventEmitter { _prepareForSleep(proxy, sender, [aboutToSuspend]) { this.emit('prepare-for-sleep', aboutToSuspend); } -}; +} -var LoginManagerDummy = class extends Signals.EventEmitter { +class LoginManagerDummy extends Signals.EventEmitter { getCurrentSessionProxy() { // we could return a DummySession object that fakes whatever callers // expect (at the time of writing: connect() and connectSignal() @@ -247,4 +245,4 @@ var LoginManagerDummy = class extends Signals.EventEmitter { async inhibit() { return null; } -}; +} diff --git a/js/misc/modemManager.js b/js/misc/modemManager.js index c95bd3c51..407106f8f 100644 --- a/js/misc/modemManager.js +++ b/js/misc/modemManager.js @@ -1,12 +1,11 @@ // -*- mode: js; js-indent-level: 4; indent-tabs-mode: nil -*- -/* exported ModemBase, ModemGsm, ModemCdma, BroadbandModem */ -const Gio = imports.gi.Gio; -const GObject = imports.gi.GObject; -const NM = imports.gi.NM; -const NMA4 = imports.gi.NMA4; +import Gio from 'gi://Gio'; +import GObject from 'gi://GObject'; +import NM from 'gi://NM'; +import NMA4 from 'gi://NMA4'; -const { loadInterfaceXML } = imports.misc.fileUtils; +import {loadInterfaceXML} from './fileUtils.js'; let _mpd; @@ -105,7 +104,7 @@ const ModemGsmNetworkProxy = Gio.DBusProxy.makeProxyWrapper(ModemGsmNetworkInter const ModemCdmaInterface = loadInterfaceXML('org.freedesktop.ModemManager.Modem.Cdma'); const ModemCdmaProxy = Gio.DBusProxy.makeProxyWrapper(ModemCdmaInterface); -var ModemBase = GObject.registerClass({ +const ModemBase = GObject.registerClass({ GTypeFlags: GObject.TypeFlags.ABSTRACT, Properties: { 'operator-name': GObject.ParamSpec.string( @@ -147,7 +146,7 @@ var ModemBase = GObject.registerClass({ } }); -var ModemGsm = GObject.registerClass( +export const ModemGsm = GObject.registerClass( class ModemGsm extends ModemBase { _init(path) { super._init(); @@ -181,7 +180,7 @@ class ModemGsm extends ModemBase { } }); -var ModemCdma = GObject.registerClass( +export const ModemCdma = GObject.registerClass( class ModemCdma extends ModemBase { _init(path) { super._init(); @@ -234,7 +233,7 @@ const BroadbandModem3gppProxy = Gio.DBusProxy.makeProxyWrapper(BroadbandModem3gp const BroadbandModemCdmaInterface = loadInterfaceXML('org.freedesktop.ModemManager1.Modem.ModemCdma'); const BroadbandModemCdmaProxy = Gio.DBusProxy.makeProxyWrapper(BroadbandModemCdmaInterface); -var BroadbandModem = GObject.registerClass({ +export const BroadbandModem = GObject.registerClass({ Properties: { 'capabilities': GObject.ParamSpec.flags( 'capabilities', 'capabilities', 'capabilities', diff --git a/js/misc/objectManager.js b/js/misc/objectManager.js index b9827c45f..22f0a1532 100644 --- a/js/misc/objectManager.js +++ b/js/misc/objectManager.js @@ -1,10 +1,9 @@ // -*- mode: js; js-indent-level: 4; indent-tabs-mode: nil -*- -/* exported ObjectManager */ -const Gio = imports.gi.Gio; -const GLib = imports.gi.GLib; -const Params = imports.misc.params; -const Signals = imports.misc.signals; +import Gio from 'gi://Gio'; +import GLib from 'gi://GLib'; +import * as Params from './params.js'; +import * as Signals from './signals.js'; // Specified in the D-Bus specification here: // http://dbus.freedesktop.org/doc/dbus-specification.html#standard-interfaces-objectmanager @@ -27,7 +26,7 @@ const ObjectManagerIface = ` const ObjectManagerInfo = Gio.DBusInterfaceInfo.new_for_xml(ObjectManagerIface); -var ObjectManager = class extends Signals.EventEmitter { +export class ObjectManager extends Signals.EventEmitter { constructor(params) { super(); @@ -259,4 +258,4 @@ var ObjectManager = class extends Signals.EventEmitter { return proxies; } -}; +} diff --git a/js/misc/params.js b/js/misc/params.js index 978cd0bd8..8eb6eeb21 100644 --- a/js/misc/params.js +++ b/js/misc/params.js @@ -1,5 +1,4 @@ // -*- mode: js; js-indent-level: 4; indent-tabs-mode: nil -*- -/* exported parse */ /** * parse: @@ -18,7 +17,7 @@ * @returns a new object, containing the merged parameters from * `params` and `defaults` */ -function parse(params = {}, defaults, allowExtras) { +export function parse(params = {}, defaults, allowExtras) { if (!allowExtras) { for (let prop in params) { if (!(prop in defaults)) diff --git a/js/misc/parentalControlsManager.js b/js/misc/parentalControlsManager.js index 9c32b7f82..bc20e4e17 100644 --- a/js/misc/parentalControlsManager.js +++ b/js/misc/parentalControlsManager.js @@ -21,19 +21,17 @@ // along with this program; if not, write to the Free Software // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. -/* exported getDefault */ - -const Gio = imports.gi.Gio; -const GObject = imports.gi.GObject; -const Shell = imports.gi.Shell; +import Gio from 'gi://Gio'; +import GObject from 'gi://GObject'; +import Shell from 'gi://Shell'; // We require libmalcontent ≥ 0.6.0 const HAVE_MALCONTENT = imports.package.checkSymbol( 'Malcontent', '0', 'ManagerGetValueFlags'); -var Malcontent = null; +let Malcontent = null; if (HAVE_MALCONTENT) { - Malcontent = imports.gi.Malcontent; + ({default: Malcontent} = await import('gi://Malcontent?version=0')); Gio._promisify(Malcontent.Manager.prototype, 'get_app_filter_async'); } @@ -42,7 +40,7 @@ let _singleton = null; /** * @returns {ParentalControlsManager} */ -function getDefault() { +export function getDefault() { if (_singleton === null) _singleton = new ParentalControlsManager(); @@ -53,7 +51,7 @@ function getDefault() { // parental controls settings. It’s possible for the user’s parental controls // to change at runtime if the Parental Controls application is used by an // administrator from within the user’s session. -var ParentalControlsManager = GObject.registerClass({ +const ParentalControlsManager = GObject.registerClass({ Signals: { 'app-filter-changed': {}, }, diff --git a/js/misc/permissionStore.js b/js/misc/permissionStore.js index ae317398c..0659bcadc 100644 --- a/js/misc/permissionStore.js +++ b/js/misc/permissionStore.js @@ -1,9 +1,8 @@ // -*- mode: js; js-indent-level: 4; indent-tabs-mode: nil -*- -/* exported PermissionStore */ -const Gio = imports.gi.Gio; +import Gio from 'gi://Gio'; -const { loadInterfaceXML } = imports.misc.fileUtils; +import {loadInterfaceXML} from './fileUtils.js'; const PermissionStoreIface = loadInterfaceXML('org.freedesktop.impl.portal.PermissionStore'); const PermissionStoreProxy = Gio.DBusProxy.makeProxyWrapper(PermissionStoreIface); @@ -13,7 +12,7 @@ const PermissionStoreProxy = Gio.DBusProxy.makeProxyWrapper(PermissionStoreIface * @param {Gio.Cancellable} cancellable * @returns {Gio.DBusProxy} */ -function PermissionStore(initCallback, cancellable) { +export function PermissionStore(initCallback, cancellable) { return new PermissionStoreProxy(Gio.DBus.session, 'org.freedesktop.impl.portal.PermissionStore', '/org/freedesktop/impl/portal/PermissionStore', diff --git a/js/misc/signalTracker.js b/js/misc/signalTracker.js index ba99411c4..52d1abbc1 100644 --- a/js/misc/signalTracker.js +++ b/js/misc/signalTracker.js @@ -1,5 +1,4 @@ -/* exported TransientSignalHolder, connectObject, disconnectObject */ -const GObject = imports.gi.GObject; +import GObject from 'gi://GObject'; const destroyableTypes = []; @@ -12,7 +11,7 @@ function _hasDestroySignal(obj) { return destroyableTypes.some(type => obj instanceof type); } -var TransientSignalHolder = GObject.registerClass( +export const TransientSignalHolder = GObject.registerClass( class TransientSignalHolder extends GObject.Object { static [GObject.signals] = { 'destroy': {}, @@ -207,7 +206,7 @@ class SignalTracker { * with an optional flags value, followed by an object to track * @returns {void} */ -function connectObject(thisObj, ...args) { +export function connectObject(thisObj, ...args) { const getParams = argArray => { const [signalName, handler, arg, ...rest] = argArray; if (typeof arg !== 'number') @@ -254,7 +253,7 @@ function connectObject(thisObj, ...args) { * @param {Object} obj - the tracked object * @returns {void} */ -function disconnectObject(thisObj, obj) { +export function disconnectObject(thisObj, obj) { SignalManager.getDefault().maybeGetSignalTracker(thisObj)?.untrack(obj); } @@ -264,7 +263,7 @@ function disconnectObject(thisObj, obj) { * * @param {GObject.Type} gtype - a GObject type */ -function registerDestroyableType(gtype) { +export function registerDestroyableType(gtype) { if (!GObject.type_is_a(gtype, GObject.Object)) throw new Error(`${gtype} is not a GObject subclass`); diff --git a/js/misc/signals.js b/js/misc/signals.js index f4acced0c..c40a9eb06 100644 --- a/js/misc/signals.js +++ b/js/misc/signals.js @@ -1,7 +1,8 @@ -const Signals = imports.signals; -const SignalTracker = imports.misc.signalTracker; +import * as SignalTracker from './signalTracker.js'; -var EventEmitter = class EventEmitter { +const Signals = imports.signals; + +export class EventEmitter { connectObject(...args) { return SignalTracker.connectObject(this, ...args); } @@ -17,6 +18,6 @@ var EventEmitter = class EventEmitter { disconnect_object(...args) { return this.disconnectObject(...args); } -}; +} Signals.addSignalMethods(EventEmitter.prototype); diff --git a/js/misc/smartcardManager.js b/js/misc/smartcardManager.js index c35a756d6..24db1cde6 100644 --- a/js/misc/smartcardManager.js +++ b/js/misc/smartcardManager.js @@ -1,10 +1,9 @@ // -*- mode: js; js-indent-level: 4; indent-tabs-mode: nil -*- -/* exported getSmartcardManager */ -const Gio = imports.gi.Gio; -const Signals = imports.misc.signals; +import Gio from 'gi://Gio'; +import * as Signals from './signals.js'; -const ObjectManager = imports.misc.objectManager; +import * as ObjectManager from './objectManager.js'; const SmartcardTokenIface = ` @@ -21,14 +20,14 @@ let _smartcardManager = null; /** * @returns {SmartcardManager} */ -function getSmartcardManager() { +export function getSmartcardManager() { if (_smartcardManager == null) _smartcardManager = new SmartcardManager(); return _smartcardManager; } -var SmartcardManager = class extends Signals.EventEmitter { +class SmartcardManager extends Signals.EventEmitter { constructor() { super(); @@ -119,4 +118,4 @@ var SmartcardManager = class extends Signals.EventEmitter { return true; } -}; +} diff --git a/js/misc/systemActions.js b/js/misc/systemActions.js index 2e984fa80..098688756 100644 --- a/js/misc/systemActions.js +++ b/js/misc/systemActions.js @@ -1,15 +1,14 @@ -/* exported getDefault */ -const AccountsService = imports.gi.AccountsService; -const Clutter = imports.gi.Clutter; -const Gdm = imports.gi.Gdm; -const Gio = imports.gi.Gio; -const GLib = imports.gi.GLib; -const GObject = imports.gi.GObject; +import AccountsService from 'gi://AccountsService'; +import Clutter from 'gi://Clutter'; +import Gdm from 'gi://Gdm'; +import Gio from 'gi://Gio'; +import GLib from 'gi://GLib'; +import GObject from 'gi://GObject'; -const GnomeSession = imports.misc.gnomeSession; -const LoginManager = imports.misc.loginManager; -const Main = imports.ui.main; -const Screenshot = imports.ui.screenshot; +import * as GnomeSession from './gnomeSession.js'; +import * as LoginManager from './loginManager.js'; +import * as Main from '../ui/main.js'; +import * as Screenshot from '../ui/screenshot.js'; const LOCKDOWN_SCHEMA = 'org.gnome.desktop.lockdown'; const LOGIN_SCREEN_SCHEMA = 'org.gnome.login-screen'; @@ -33,7 +32,7 @@ let _singleton = null; /** * @returns {SystemActions} */ -function getDefault() { +export function getDefault() { if (_singleton == null) _singleton = new SystemActions(); diff --git a/js/misc/util.js b/js/misc/util.js index 8654e4286..dbb95e9d5 100644 --- a/js/misc/util.js +++ b/js/misc/util.js @@ -1,16 +1,13 @@ // -*- mode: js; js-indent-level: 4; indent-tabs-mode: nil -*- -/* exported findUrls, spawn, spawnCommandLine, spawnApp, trySpawnCommandLine, - createTimeLabel, insertSorted, lerp, GNOMEversionCompare, - DBusSenderChecker, Highlighter */ -const Gio = imports.gi.Gio; -const GLib = imports.gi.GLib; -const Shell = imports.gi.Shell; -const St = imports.gi.St; -const GnomeDesktop = imports.gi.GnomeDesktop; +import Gio from 'gi://Gio'; +import GLib from 'gi://GLib'; +import Shell from 'gi://Shell'; +import St from 'gi://St'; +import GnomeDesktop from 'gi://GnomeDesktop'; -const Main = imports.ui.main; -const {formatTime} = imports.misc.dateUtils; +import * as Main from '../ui/main.js'; +import {formatTime} from './dateUtils.js'; // http://daringfireball.net/2010/07/improved_regex_for_matching_urls const _balancedParens = '\\([^\\s()<>]+\\)'; @@ -52,7 +49,7 @@ let _desktopSettings = null; * * @returns {{url: string, pos: number}[]} the list of match objects, as described above */ -function findUrls(str) { +export function findUrls(str) { let res = [], match; while ((match = _urlRegexp.exec(str))) res.push({ url: match[2], pos: match.index + match[1].length }); @@ -67,7 +64,7 @@ function findUrls(str) { * * @param {readonly string[]} argv an argv array */ -function spawn(argv) { +export function spawn(argv) { try { trySpawn(argv); } catch (err) { @@ -83,7 +80,7 @@ function spawn(argv) { * Runs commandLine in the background, handling any errors that * occur when trying to parse or start the program. */ -function spawnCommandLine(commandLine) { +export function spawnCommandLine(commandLine) { try { let [success_, argv] = GLib.shell_parse_argv(commandLine); trySpawn(argv); @@ -99,7 +96,7 @@ function spawnCommandLine(commandLine) { * * Runs argv as if it was an application, handling startup notification */ -function spawnApp(argv) { +export function spawnApp(argv) { try { let app = Gio.AppInfo.create_from_commandline(argv.join(' '), null, Gio.AppInfoCreateFlags.SUPPORTS_STARTUP_NOTIFICATION); @@ -169,7 +166,7 @@ function trySpawn(argv) { * Runs commandLine in the background. If launching commandLine * fails, this will throw an error. */ -function trySpawnCommandLine(commandLine) { +export function trySpawnCommandLine(commandLine) { let success_, argv; try { @@ -197,7 +194,7 @@ function _handleSpawnError(command, err) { * @param {object} params params for {@link formatTime} * @returns {St.Label} */ -function createTimeLabel(date, params) { +export function createTimeLabel(date, params) { if (_desktopSettings == null) _desktopSettings = new Gio.Settings({ schema_id: 'org.gnome.desktop.interface' }); @@ -264,7 +261,7 @@ function lowerBound(array, val, cmp) { * * Returns the position at which it was inserted */ -function insertSorted(array, val, cmp) { +export function insertSorted(array, val, cmp) { let pos = lowerBound(array, val, cmp); array.splice(pos, 0, val); @@ -277,7 +274,7 @@ function insertSorted(array, val, cmp) { * @param {number} progress * @returns {number} */ -function lerp(start, end, progress) { +export function lerp(start, end, progress) { return start + progress * (end - start); } @@ -311,7 +308,7 @@ function _GNOMEversionToNumber(version) { * Returns an integer less than, equal to, or greater than * zero, if `version1` is older, equal or newer than `version2` */ -function GNOMEversionCompare(version1, version2) { +export function GNOMEversionCompare(version1, version2) { const v1Array = version1.split('.'); const v2Array = version2.split('.'); @@ -327,7 +324,7 @@ function GNOMEversionCompare(version1, version2) { return 0; } -var DBusSenderChecker = class { +export class DBusSenderChecker { /** * @param {string[]} allowList - list of allowed well-known names */ @@ -402,10 +399,10 @@ var DBusSenderChecker = class { Gio.DBus.unwatch_name(id); this._watchList = []; } -}; +} /* @class Highlighter Highlight given terms in text using markup. */ -var Highlighter = class { +export class Highlighter { /** * @param {?string[]} terms - list of terms to highlight */ @@ -454,4 +451,4 @@ var Highlighter = class { return escaped.join(''); } -}; +} diff --git a/js/misc/weather.js b/js/misc/weather.js index 677f81c59..2bb2a3b4d 100644 --- a/js/misc/weather.js +++ b/js/misc/weather.js @@ -1,16 +1,15 @@ // -*- mode: js; js-indent-level: 4; indent-tabs-mode: nil -*- -/* exported WeatherClient */ -const Geoclue = imports.gi.Geoclue; -const Gio = imports.gi.Gio; -const GLib = imports.gi.GLib; -const GWeather = imports.gi.GWeather; -const Shell = imports.gi.Shell; -const Signals = imports.misc.signals; +import Geoclue from 'gi://Geoclue'; +import Gio from 'gi://Gio'; +import GLib from 'gi://GLib'; +import GWeather from 'gi://GWeather'; +import Shell from 'gi://Shell'; +import * as Signals from './signals.js'; -const PermissionStore = imports.misc.permissionStore; +import * as PermissionStore from './permissionStore.js'; -const { loadInterfaceXML } = imports.misc.fileUtils; +import {loadInterfaceXML} from './fileUtils.js'; Gio._promisify(Geoclue.Simple, 'new'); @@ -23,9 +22,9 @@ const WEATHER_INTEGRATION_IFACE = 'org.gnome.Shell.WeatherIntegration'; const WEATHER_APP_ID = 'org.gnome.Weather.desktop'; // Minimum time between updates to show loading indication -var UPDATE_THRESHOLD = 10 * GLib.TIME_SPAN_MINUTE; +const UPDATE_THRESHOLD = 10 * GLib.TIME_SPAN_MINUTE; -var WeatherClient = class extends Signals.EventEmitter { +export class WeatherClient extends Signals.EventEmitter { constructor() { super(); @@ -326,4 +325,4 @@ var WeatherClient = class extends Signals.EventEmitter { this._updateAutoLocation(); } -}; +} diff --git a/js/portalHelper/main.js b/js/portalHelper/main.js index 1f16537cd..d2abda9c6 100644 --- a/js/portalHelper/main.js +++ b/js/portalHelper/main.js @@ -11,7 +11,7 @@ import {programInvocationName, programArgs} from 'system'; const _ = Gettext.gettext; const Config = imports.misc.config; -const {loadInterfaceXML} = imports.misc.fileUtils; +import {loadInterfaceXML} from './fileUtils.js'; const PortalHelperResult = { CANCELLED: 0, @@ -39,7 +39,7 @@ const CONNECTIVITY_RECHECK_RATELIMIT_TIMEOUT = 30 * GLib.USEC_PER_SEC; const HelperDBusInterface = loadInterfaceXML('org.gnome.Shell.PortalHelper'); -var PortalSecurityButton = GObject.registerClass( +const PortalSecurityButton = GObject.registerClass( class PortalSecurityButton extends Gtk.MenuButton { _init() { const popover = new Gtk.Popover(); @@ -107,7 +107,7 @@ class PortalSecurityButton extends Gtk.MenuButton { } }); -var PortalWindow = GObject.registerClass( +const PortalWindow = GObject.registerClass( class PortalWindow extends Gtk.ApplicationWindow { _init(application, url, timestamp, doneCallback) { super._init({ @@ -281,7 +281,7 @@ class PortalWindow extends Gtk.ApplicationWindow { } }); -var WebPortalHelper = GObject.registerClass( +const WebPortalHelper = GObject.registerClass( class WebPortalHelper extends Adw.Application { _init() { super._init({ diff --git a/js/ui/accessDialog.js b/js/ui/accessDialog.js index 44f4f655f..723aa7f55 100644 --- a/js/ui/accessDialog.js +++ b/js/ui/accessDialog.js @@ -1,29 +1,28 @@ -/* exported AccessDialogDBus */ -const Clutter = imports.gi.Clutter; -const Gio = imports.gi.Gio; -const GLib = imports.gi.GLib; -const GObject = imports.gi.GObject; -const Pango = imports.gi.Pango; -const Shell = imports.gi.Shell; -const St = imports.gi.St; +import Clutter from 'gi://Clutter'; +import Gio from 'gi://Gio'; +import GLib from 'gi://GLib'; +import GObject from 'gi://GObject'; +import Pango from 'gi://Pango'; +import Shell from 'gi://Shell'; +import St from 'gi://St'; -const CheckBox = imports.ui.checkBox; -const Dialog = imports.ui.dialog; -const ModalDialog = imports.ui.modalDialog; +import * as CheckBox from './checkBox.js'; +import * as Dialog from './dialog.js'; +import * as ModalDialog from './modalDialog.js'; -const { loadInterfaceXML } = imports.misc.fileUtils; +import {loadInterfaceXML} from '../misc/fileUtils.js'; const RequestIface = loadInterfaceXML('org.freedesktop.impl.portal.Request'); const AccessIface = loadInterfaceXML('org.freedesktop.impl.portal.Access'); /** @enum {number} */ -var DialogResponse = { +const DialogResponse = { OK: 0, CANCEL: 1, CLOSED: 2, }; -var AccessDialog = GObject.registerClass( +const AccessDialog = GObject.registerClass( class AccessDialog extends ModalDialog.ModalDialog { _init(invocation, handle, title, description, body, options) { super._init({ styleClass: 'access-dialog' }); @@ -128,7 +127,7 @@ class AccessDialog extends ModalDialog.ModalDialog { } }); -var AccessDialogDBus = class { +export class AccessDialogDBus { constructor() { this._accessDialog = null; @@ -166,4 +165,4 @@ var AccessDialogDBus = class { this._accessDialog = dialog; } -}; +} diff --git a/js/ui/altTab.js b/js/ui/altTab.js index 644a11dc2..4b468d9df 100644 --- a/js/ui/altTab.js +++ b/js/ui/altTab.js @@ -1,33 +1,31 @@ // -*- mode: js; js-indent-level: 4; indent-tabs-mode: nil -*- -/* exported AppSwitcherPopup, GroupCyclerPopup, WindowSwitcherPopup, - WindowCyclerPopup */ -const Atk = imports.gi.Atk; -const Clutter = imports.gi.Clutter; -const Gio = imports.gi.Gio; -const GLib = imports.gi.GLib; -const GObject = imports.gi.GObject; -const Meta = imports.gi.Meta; -const Shell = imports.gi.Shell; -const St = imports.gi.St; +import Atk from 'gi://Atk'; +import Clutter from 'gi://Clutter'; +import Gio from 'gi://Gio'; +import GLib from 'gi://GLib'; +import GObject from 'gi://GObject'; +import Meta from 'gi://Meta'; +import St from 'gi://St'; +import Shell from 'gi://Shell'; -const Main = imports.ui.main; -const SwitcherPopup = imports.ui.switcherPopup; +import * as Main from './main.js'; +import * as SwitcherPopup from './switcherPopup.js'; -var APP_ICON_HOVER_TIMEOUT = 200; // milliseconds +const APP_ICON_HOVER_TIMEOUT = 200; // milliseconds -var THUMBNAIL_DEFAULT_SIZE = 256; -var THUMBNAIL_POPUP_TIME = 500; // milliseconds -var THUMBNAIL_FADE_TIME = 100; // milliseconds +const THUMBNAIL_DEFAULT_SIZE = 256; +const THUMBNAIL_POPUP_TIME = 500; // milliseconds +const THUMBNAIL_FADE_TIME = 100; // milliseconds -var WINDOW_PREVIEW_SIZE = 128; -var APP_ICON_SIZE = 96; -var APP_ICON_SIZE_SMALL = 48; +const WINDOW_PREVIEW_SIZE = 128; +const APP_ICON_SIZE = 96; +const APP_ICON_SIZE_SMALL = 48; const baseIconSizes = [96, 64, 48, 32, 22]; /** @enum {number} */ -var AppIconMode = { +const AppIconMode = { THUMBNAIL_ONLY: 1, APP_ICON_ONLY: 2, BOTH: 3, @@ -48,20 +46,23 @@ function _createWindowClone(window, size) { }); } +/** + * @param {Meta.Workspace} workspace + * @returns {Meta.Window} + */ function getWindows(workspace) { // We ignore skip-taskbar windows in switchers, but if they are attached // to their parent, their position in the MRU list may be more appropriate // than the parent; so start with the complete list ... - let windows = global.display.get_tab_list(Meta.TabList.NORMAL_ALL, - workspace); + let windows = global.display.get_tab_list(Meta.TabList.NORMAL_ALL, workspace); // ... map windows to their parent where appropriate ... return windows.map(w => { return w.is_attached_dialog() ? w.get_transient_for() : w; // ... and filter out skip-taskbar windows and duplicates - }).filter((w, i, a) => !w.skip_taskbar && a.indexOf(w) == i); + }).filter((w, i, a) => !w.skip_taskbar && a.indexOf(w) === i); } -var AppSwitcherPopup = GObject.registerClass( +export const AppSwitcherPopup = GObject.registerClass( class AppSwitcherPopup extends SwitcherPopup.SwitcherPopup { _init() { super._init(); @@ -404,7 +405,7 @@ class AppSwitcherPopup extends SwitcherPopup.SwitcherPopup { } }); -var CyclerHighlight = GObject.registerClass( +const CyclerHighlight = GObject.registerClass( class CyclerHighlight extends St.Widget { _init() { super._init({ layout_manager: new Clutter.BinLayout() }); @@ -470,7 +471,7 @@ class CyclerHighlight extends St.Widget { // We don't show an actual popup, so just provide what SwitcherPopup // expects instead of inheriting from SwitcherList -var CyclerList = GObject.registerClass({ +const CyclerList = GObject.registerClass({ Signals: { 'item-activated': { param_types: [GObject.TYPE_INT] }, 'item-entered': { param_types: [GObject.TYPE_INT] }, @@ -483,7 +484,7 @@ var CyclerList = GObject.registerClass({ } }); -var CyclerPopup = GObject.registerClass({ +const CyclerPopup = GObject.registerClass({ GTypeFlags: GObject.TypeFlags.ABSTRACT, }, class CyclerPopup extends SwitcherPopup.SwitcherPopup { _init() { @@ -539,7 +540,7 @@ var CyclerPopup = GObject.registerClass({ }); -var GroupCyclerPopup = GObject.registerClass( +export const GroupCyclerPopup = GObject.registerClass( class GroupCyclerPopup extends CyclerPopup { _init() { this._settings = new Gio.Settings({ schema_id: 'org.gnome.shell.app-switcher' }); @@ -572,7 +573,7 @@ class GroupCyclerPopup extends CyclerPopup { } }); -var WindowSwitcherPopup = GObject.registerClass( +export const WindowSwitcherPopup = GObject.registerClass( class WindowSwitcherPopup extends SwitcherPopup.SwitcherPopup { _init() { super._init(); @@ -630,7 +631,7 @@ class WindowSwitcherPopup extends SwitcherPopup.SwitcherPopup { } }); -var WindowCyclerPopup = GObject.registerClass( +export const WindowCyclerPopup = GObject.registerClass( class WindowCyclerPopup extends CyclerPopup { _init() { this._settings = new Gio.Settings({ schema_id: 'org.gnome.shell.window-switcher' }); @@ -661,7 +662,7 @@ class WindowCyclerPopup extends CyclerPopup { } }); -var AppIcon = GObject.registerClass( +export const AppIcon = GObject.registerClass( class AppIcon extends St.BoxLayout { _init(app) { super._init({ @@ -688,7 +689,7 @@ class AppIcon extends St.BoxLayout { } }); -var AppSwitcher = GObject.registerClass( +const AppSwitcher = GObject.registerClass( class AppSwitcher extends SwitcherPopup.SwitcherList { _init(apps, altTabPopup) { super._init(true); @@ -905,7 +906,7 @@ class AppSwitcher extends SwitcherPopup.SwitcherList { } }); -var ThumbnailSwitcher = GObject.registerClass( +const ThumbnailSwitcher = GObject.registerClass( class ThumbnailSwitcher extends SwitcherPopup.SwitcherList { _init(windows) { super._init(false); @@ -995,7 +996,7 @@ class ThumbnailSwitcher extends SwitcherPopup.SwitcherList { } }); -var WindowIcon = GObject.registerClass( +export const WindowIcon = GObject.registerClass( class WindowIcon extends St.BoxLayout { _init(window, mode) { super._init({ @@ -1055,7 +1056,7 @@ class WindowIcon extends St.BoxLayout { } }); -var WindowSwitcher = GObject.registerClass( +const WindowSwitcher = GObject.registerClass( class WindowSwitcher extends SwitcherPopup.SwitcherList { _init(windows, mode) { super._init(true); diff --git a/js/ui/animation.js b/js/ui/animation.js index b70f8767b..d36afbfe3 100644 --- a/js/ui/animation.js +++ b/js/ui/animation.js @@ -1,19 +1,18 @@ // -*- mode: js; js-indent-level: 4; indent-tabs-mode: nil -*- -/* exported Animation, AnimatedIcon, Spinner */ -const Clutter = imports.gi.Clutter; -const GLib = imports.gi.GLib; -const GObject = imports.gi.GObject; -const Gio = imports.gi.Gio; -const St = imports.gi.St; +import Clutter from 'gi://Clutter'; +import GLib from 'gi://GLib'; +import GObject from 'gi://GObject'; +import Gio from 'gi://Gio'; +import St from 'gi://St'; -const Params = imports.misc.params; +import * as Params from '../misc/params.js'; -var ANIMATED_ICON_UPDATE_TIMEOUT = 16; -var SPINNER_ANIMATION_TIME = 300; -var SPINNER_ANIMATION_DELAY = 1000; +const ANIMATED_ICON_UPDATE_TIMEOUT = 16; +const SPINNER_ANIMATION_TIME = 300; +const SPINNER_ANIMATION_DELAY = 1000; -var Animation = GObject.registerClass( +export const Animation = GObject.registerClass( class Animation extends St.Bin { _init(file, width, height, speed) { const themeContext = St.ThemeContext.get_for_stage(global.stage); @@ -118,14 +117,14 @@ class Animation extends St.Bin { } }); -var AnimatedIcon = GObject.registerClass( +export const AnimatedIcon = GObject.registerClass( class AnimatedIcon extends Animation { _init(file, size) { super._init(file, size, size, ANIMATED_ICON_UPDATE_TIMEOUT); } }); -var Spinner = GObject.registerClass( +export const Spinner = GObject.registerClass( class Spinner extends AnimatedIcon { _init(size, params) { params = Params.parse(params, { diff --git a/js/ui/appDisplay.js b/js/ui/appDisplay.js index 3f9334eae..88673b0a5 100644 --- a/js/ui/appDisplay.js +++ b/js/ui/appDisplay.js @@ -1,46 +1,46 @@ // -*- mode: js; js-indent-level: 4; indent-tabs-mode: nil -*- -/* exported AppDisplay, AppSearchProvider */ -const Clutter = imports.gi.Clutter; -const Gio = imports.gi.Gio; -const GLib = imports.gi.GLib; -const GObject = imports.gi.GObject; -const Graphene = imports.gi.Graphene; -const Pango = imports.gi.Pango; -const Shell = imports.gi.Shell; -const St = imports.gi.St; +import Clutter from 'gi://Clutter'; +import GLib from 'gi://GLib'; +import GObject from 'gi://GObject'; +import Gio from 'gi://Gio'; +import Graphene from 'gi://Graphene'; +import Pango from 'gi://Pango'; +import Shell from 'gi://Shell'; +import St from 'gi://St'; -const AppFavorites = imports.ui.appFavorites; -const { AppMenu } = imports.ui.appMenu; -const BoxPointer = imports.ui.boxpointer; -const DND = imports.ui.dnd; -const GrabHelper = imports.ui.grabHelper; -const IconGrid = imports.ui.iconGrid; -const Layout = imports.ui.layout; -const Main = imports.ui.main; -const PageIndicators = imports.ui.pageIndicators; -const ParentalControlsManager = imports.misc.parentalControlsManager; -const PopupMenu = imports.ui.popupMenu; -const Search = imports.ui.search; -const SwipeTracker = imports.ui.swipeTracker; -const Params = imports.misc.params; -const SystemActions = imports.misc.systemActions; +import * as AppFavorites from './appFavorites.js'; +import {AppMenu} from './appMenu.js'; +import * as BoxPointer from './boxpointer.js'; +import * as DND from './dnd.js'; +import * as GrabHelper from './grabHelper.js'; +import * as IconGrid from './iconGrid.js'; +import * as Layout from './layout.js'; +import * as PageIndicators from './pageIndicators.js'; +import * as ParentalControlsManager from '../misc/parentalControlsManager.js'; +import * as PopupMenu from './popupMenu.js'; +import * as Search from './search.js'; +import * as SwipeTracker from './swipeTracker.js'; +import * as Params from '../misc/params.js'; +import * as SystemActions from '../misc/systemActions.js'; -var MENU_POPUP_TIMEOUT = 600; -var POPDOWN_DIALOG_TIMEOUT = 500; +import * as Main from './main.js'; -var FOLDER_SUBICON_FRACTION = .4; +const MENU_POPUP_TIMEOUT = 600; +const POPDOWN_DIALOG_TIMEOUT = 500; -var VIEWS_SWITCH_TIME = 400; -var VIEWS_SWITCH_ANIMATION_DELAY = 100; +const FOLDER_SUBICON_FRACTION = .4; -var SCROLL_TIMEOUT_TIME = 150; +const VIEWS_SWITCH_TIME = 400; +const VIEWS_SWITCH_ANIMATION_DELAY = 100; -var APP_ICON_SCALE_IN_TIME = 500; -var APP_ICON_SCALE_IN_DELAY = 700; +const SCROLL_TIMEOUT_TIME = 150; -var APP_ICON_TITLE_EXPAND_TIME = 200; -var APP_ICON_TITLE_COLLAPSE_TIME = 100; +const APP_ICON_SCALE_IN_TIME = 500; +const APP_ICON_SCALE_IN_DELAY = 700; + +const APP_ICON_TITLE_EXPAND_TIME = 200; +const APP_ICON_TITLE_COLLAPSE_TIME = 100; const FOLDER_DIALOG_ANIMATION_TIME = 200; @@ -154,7 +154,7 @@ function _findBestFolderName(apps) { return null; } -const AppGrid = GObject.registerClass({ +export const AppGrid = GObject.registerClass({ Properties: { 'indicators-padding': GObject.ParamSpec.boxed('indicators-padding', 'Indicators padding', 'Indicators padding', @@ -1284,7 +1284,7 @@ var BaseAppView = GObject.registerClass({ } }); -var PageManager = GObject.registerClass({ +const PageManager = GObject.registerClass({ Signals: { 'layout-changed': {} }, }, class PageManager extends GObject.Object { _init() { @@ -1345,7 +1345,7 @@ var PageManager = GObject.registerClass({ } }); -var AppDisplay = GObject.registerClass( +export const AppDisplay = GObject.registerClass( class AppDisplay extends BaseAppView { _init() { super._init({ @@ -1788,7 +1788,7 @@ class AppDisplay extends BaseAppView { } }); -var AppSearchProvider = class AppSearchProvider { +export class AppSearchProvider { constructor() { this._appSys = Shell.AppSystem.get_default(); this.id = 'applications'; @@ -1879,9 +1879,9 @@ var AppSearchProvider = class AppSearchProvider { return new SystemActionIcon(this, resultMeta); } } -}; +} -var AppViewItem = GObject.registerClass( +export const AppViewItem = GObject.registerClass( class AppViewItem extends St.Button { _init(params = {}, isDraggable = true, expandTitleOnHover = true) { super._init({ @@ -2098,7 +2098,7 @@ class AppViewItem extends St.Button { } }); -var FolderGrid = GObject.registerClass( +const FolderGrid = GObject.registerClass( class FolderGrid extends AppGrid { _init() { super._init({ @@ -2118,7 +2118,7 @@ class FolderGrid extends AppGrid { } }); -var FolderView = GObject.registerClass( +export const FolderView = GObject.registerClass( class FolderView extends BaseAppView { _init(folder, id, parentView) { super._init({ @@ -2313,7 +2313,7 @@ class FolderView extends BaseAppView { } }); -var FolderIcon = GObject.registerClass({ +export const FolderIcon = GObject.registerClass({ Signals: { 'apps-changed': {}, }, @@ -2489,7 +2489,7 @@ var FolderIcon = GObject.registerClass({ } }); -var AppFolderDialog = GObject.registerClass({ +export const AppFolderDialog = GObject.registerClass({ Signals: { 'open-state-changed': { param_types: [GObject.TYPE_BOOLEAN] }, }, @@ -2974,7 +2974,7 @@ var AppFolderDialog = GObject.registerClass({ } }); -var AppIcon = GObject.registerClass({ +export const AppIcon = GObject.registerClass({ Signals: { 'menu-state-changed': { param_types: [GObject.TYPE_BOOLEAN] }, 'sync-tooltip': {}, @@ -3279,7 +3279,7 @@ var AppIcon = GObject.registerClass({ } }); -var SystemActionIcon = GObject.registerClass( +const SystemActionIcon = GObject.registerClass( class SystemActionIcon extends Search.GridSearchResult { activate() { SystemActions.getDefault().activateAction(this.metaInfo['id']); diff --git a/js/ui/appFavorites.js b/js/ui/appFavorites.js index a544672ce..234297a14 100644 --- a/js/ui/appFavorites.js +++ b/js/ui/appFavorites.js @@ -1,11 +1,10 @@ // -*- mode: js; js-indent-level: 4; indent-tabs-mode: nil -*- -/* exported getAppFavorites */ -const Shell = imports.gi.Shell; -const ParentalControlsManager = imports.misc.parentalControlsManager; -const Signals = imports.misc.signals; +import Shell from 'gi://Shell'; +import * as ParentalControlsManager from '../misc/parentalControlsManager.js'; +import * as Signals from '../misc/signals.js'; -const Main = imports.ui.main; +import * as Main from './main.js'; // In alphabetical order const RENAMED_DESKTOP_IDS = { @@ -210,7 +209,7 @@ var appFavoritesInstance = null; /** * @returns {AppFavorites} */ -function getAppFavorites() { +export function getAppFavorites() { if (appFavoritesInstance == null) appFavoritesInstance = new AppFavorites(); return appFavoritesInstance; diff --git a/js/ui/appMenu.js b/js/ui/appMenu.js index 81704759c..8eb307830 100644 --- a/js/ui/appMenu.js +++ b/js/ui/appMenu.js @@ -1,18 +1,18 @@ // -*- mode: js; js-indent-level: 4; indent-tabs-mode: nil -*- -/* exported AppMenu */ -const Clutter = imports.gi.Clutter; -const Gio = imports.gi.Gio; -const GLib = imports.gi.GLib; -const Meta = imports.gi.Meta; -const Shell = imports.gi.Shell; -const St = imports.gi.St; -const AppFavorites = imports.ui.appFavorites; -const Main = imports.ui.main; -const ParentalControlsManager = imports.misc.parentalControlsManager; -const PopupMenu = imports.ui.popupMenu; +import Clutter from 'gi://Clutter'; +import Gio from 'gi://Gio'; +import GLib from 'gi://GLib'; +import Meta from 'gi://Meta'; +import Shell from 'gi://Shell'; +import St from 'gi://St'; -var AppMenu = class AppMenu extends PopupMenu.PopupMenu { +import * as AppFavorites from './appFavorites.js'; +import * as Main from './main.js'; +import * as ParentalControlsManager from '../misc/parentalControlsManager.js'; +import * as PopupMenu from './popupMenu.js'; + +export class AppMenu extends PopupMenu.PopupMenu { /** * @param {Clutter.Actor} sourceActor - actor the menu is attached to * @param {St.Side} side - arrow side @@ -292,4 +292,4 @@ var AppMenu = class AppMenu extends PopupMenu.PopupMenu { }, item); }); } -}; +} diff --git a/js/ui/audioDeviceSelection.js b/js/ui/audioDeviceSelection.js index 67a3eb920..9034535b5 100644 --- a/js/ui/audioDeviceSelection.js +++ b/js/ui/audioDeviceSelection.js @@ -1,19 +1,18 @@ -/* exported AudioDeviceSelectionDBus */ -const Clutter = imports.gi.Clutter; -const Gio = imports.gi.Gio; -const GLib = imports.gi.GLib; -const GObject = imports.gi.GObject; -const Meta = imports.gi.Meta; -const Shell = imports.gi.Shell; -const St = imports.gi.St; +import Clutter from 'gi://Clutter'; +import Gio from 'gi://Gio'; +import GLib from 'gi://GLib'; +import GObject from 'gi://GObject'; +import Meta from 'gi://Meta'; +import Shell from 'gi://Shell'; +import St from 'gi://St'; -const Dialog = imports.ui.dialog; -const Main = imports.ui.main; -const ModalDialog = imports.ui.modalDialog; +import * as Dialog from './dialog.js'; +import * as ModalDialog from './modalDialog.js'; -const { loadInterfaceXML } = imports.misc.fileUtils; +import * as Main from './main.js'; +import {loadInterfaceXML} from '../misc/fileUtils.js'; -var AudioDevice = { +const AudioDevice = { HEADPHONES: 1 << 0, HEADSET: 1 << 1, MICROPHONE: 1 << 2, @@ -21,7 +20,7 @@ var AudioDevice = { const AudioDeviceSelectionIface = loadInterfaceXML('org.gnome.Shell.AudioDeviceSelection'); -var AudioDeviceSelectionDialog = GObject.registerClass({ +const AudioDeviceSelectionDialog = GObject.registerClass({ Signals: { 'device-selected': { param_types: [GObject.TYPE_UINT] } }, }, class AudioDeviceSelectionDialog extends ModalDialog.ModalDialog { _init(devices) { @@ -150,7 +149,7 @@ var AudioDeviceSelectionDialog = GObject.registerClass({ } }); -var AudioDeviceSelectionDBus = class AudioDeviceSelectionDBus { +export class AudioDeviceSelectionDBus { constructor() { this._audioSelectionDialog = null; @@ -211,4 +210,4 @@ var AudioDeviceSelectionDBus = class AudioDeviceSelectionDBus { invocation.return_value(null); } -}; +} diff --git a/js/ui/background.js b/js/ui/background.js index b7978ada6..e85adf534 100644 --- a/js/ui/background.js +++ b/js/ui/background.js @@ -1,5 +1,4 @@ // -*- mode: js; js-indent-level: 4; indent-tabs-mode: nil -*- -/* exported SystemBackground, BackgroundManager */ // READ THIS FIRST // Background handling is a maze of objects, both objects in this file, and @@ -94,21 +93,21 @@ // MetaBackgroundImage MetaBackgroundImage // MetaBackgroundImage MetaBackgroundImage -const Clutter = imports.gi.Clutter; -const GDesktopEnums = imports.gi.GDesktopEnums; -const Gio = imports.gi.Gio; -const GLib = imports.gi.GLib; -const GObject = imports.gi.GObject; -const GnomeBG = imports.gi.GnomeBG; -const GnomeDesktop = imports.gi.GnomeDesktop; -const Meta = imports.gi.Meta; -const Signals = imports.misc.signals; +import Clutter from 'gi://Clutter'; +import GDesktopEnums from 'gi://GDesktopEnums'; +import Gio from 'gi://Gio'; +import GLib from 'gi://GLib'; +import GObject from 'gi://GObject'; +import GnomeBG from 'gi://GnomeBG'; +import GnomeDesktop from 'gi://GnomeDesktop'; +import Meta from 'gi://Meta'; +import * as Signals from '../misc/signals.js'; -const LoginManager = imports.misc.loginManager; -const Main = imports.ui.main; -const Params = imports.misc.params; +import * as LoginManager from '../misc/loginManager.js'; +import * as Main from './main.js'; +import * as Params from '../misc/params.js'; -var DEFAULT_BACKGROUND_COLOR = Clutter.Color.from_pixel(0x2e3436ff); +const DEFAULT_BACKGROUND_COLOR = Clutter.Color.from_pixel(0x2e3436ff); const BACKGROUND_SCHEMA = 'org.gnome.desktop.background'; const PRIMARY_COLOR_KEY = 'primary-color'; @@ -121,14 +120,14 @@ const PICTURE_URI_DARK_KEY = 'picture-uri-dark'; const INTERFACE_SCHEMA = 'org.gnome.desktop.interface'; const COLOR_SCHEME_KEY = 'color-scheme'; -var FADE_ANIMATION_TIME = 1000; +const FADE_ANIMATION_TIME = 1000; // These parameters affect how often we redraw. // The first is how different (percent crossfaded) the slide show // has to look before redrawing and the second is the minimum // frequency (in seconds) we're willing to wake up -var ANIMATION_OPACITY_STEP_INCREMENT = 4.0; -var ANIMATION_MIN_WAKEUP_INTERVAL = 1.0; +const ANIMATION_OPACITY_STEP_INCREMENT = 4.0; +const ANIMATION_MIN_WAKEUP_INTERVAL = 1.0; let _backgroundCache = null; @@ -142,7 +141,7 @@ function _fileEqual0(file1, file2) { return file1.equal(file2); } -var BackgroundCache = class BackgroundCache extends Signals.EventEmitter { +class BackgroundCache extends Signals.EventEmitter { constructor() { super(); @@ -227,7 +226,7 @@ var BackgroundCache = class BackgroundCache extends Signals.EventEmitter { } } } -}; +} /** * @returns {BackgroundCache} @@ -238,7 +237,7 @@ function getBackgroundCache() { return _backgroundCache; } -var Background = GObject.registerClass({ +const Background = GObject.registerClass({ Signals: { 'loaded': {}, 'bg-changed': {} }, }, class Background extends Meta.Background { _init(params) { @@ -532,7 +531,7 @@ var Background = GObject.registerClass({ let _systemBackground; -var SystemBackground = GObject.registerClass({ +export const SystemBackground = GObject.registerClass({ Signals: { 'loaded': {} }, }, class SystemBackground extends Meta.BackgroundActor { _init() { @@ -555,7 +554,7 @@ var SystemBackground = GObject.registerClass({ } }); -var BackgroundSource = class BackgroundSource { +class BackgroundSource { constructor(layoutManager, settingsSchema) { // Allow override the background image setting for performance testing this._layoutManager = layoutManager; @@ -649,9 +648,9 @@ var BackgroundSource = class BackgroundSource { this._backgrounds = null; } -}; +} -var Animation = GObject.registerClass( +const Animation = GObject.registerClass( class Animation extends GnomeBG.BGSlideShow { _init(params) { super._init(params); @@ -691,7 +690,7 @@ class Animation extends GnomeBG.BGSlideShow { } }); -var BackgroundManager = class BackgroundManager extends Signals.EventEmitter { +export class BackgroundManager extends Signals.EventEmitter { constructor(params) { super(); params = Params.parse(params, { @@ -847,4 +846,4 @@ var BackgroundManager = class BackgroundManager extends Signals.EventEmitter { return backgroundActor; } -}; +} diff --git a/js/ui/backgroundMenu.js b/js/ui/backgroundMenu.js index 68fe6a67b..2b22f1e45 100644 --- a/js/ui/backgroundMenu.js +++ b/js/ui/backgroundMenu.js @@ -1,14 +1,14 @@ // -*- mode: js; js-indent-level: 4; indent-tabs-mode: nil -*- -/* exported addBackgroundMenu */ -const Clutter = imports.gi.Clutter; -const St = imports.gi.St; +import Clutter from 'gi://Clutter'; +import St from 'gi://St'; -const BoxPointer = imports.ui.boxpointer; -const Main = imports.ui.main; -const PopupMenu = imports.ui.popupMenu; +import * as BoxPointer from './boxpointer.js'; +import * as PopupMenu from './popupMenu.js'; -var BackgroundMenu = class BackgroundMenu extends PopupMenu.PopupMenu { +import * as Main from './main.js'; + +export class BackgroundMenu extends PopupMenu.PopupMenu { constructor(layoutManager) { super(layoutManager.dummyCursor, 0, St.Side.TOP); @@ -22,13 +22,13 @@ var BackgroundMenu = class BackgroundMenu extends PopupMenu.PopupMenu { layoutManager.uiGroup.add_actor(this.actor); this.actor.hide(); } -}; +} /** * @param {Meta.BackgroundActor} actor * @param {import('./layout.js').LayoutManager} layoutManager */ -function addBackgroundMenu(actor, layoutManager) { +export function addBackgroundMenu(actor, layoutManager) { actor.reactive = true; actor._backgroundMenu = new BackgroundMenu(layoutManager); actor._backgroundManager = new PopupMenu.PopupMenuManager(actor); diff --git a/js/ui/barLevel.js b/js/ui/barLevel.js index 50dfe8bdd..d0fb3169b 100644 --- a/js/ui/barLevel.js +++ b/js/ui/barLevel.js @@ -1,12 +1,11 @@ /* -*- mode: js2; js2-basic-offset: 4; indent-tabs-mode: nil -*- */ -/* exported BarLevel */ -const Atk = imports.gi.Atk; -const Clutter = imports.gi.Clutter; -const GObject = imports.gi.GObject; -const St = imports.gi.St; +import Atk from 'gi://Atk'; +import Clutter from 'gi://Clutter'; +import GObject from 'gi://GObject'; +import St from 'gi://St'; -var BarLevel = GObject.registerClass({ +export const BarLevel = GObject.registerClass({ Properties: { 'value': GObject.ParamSpec.double( 'value', 'value', 'value', diff --git a/js/ui/boxpointer.js b/js/ui/boxpointer.js index dbfde1953..990f8e3a4 100644 --- a/js/ui/boxpointer.js +++ b/js/ui/boxpointer.js @@ -1,26 +1,23 @@ // -*- mode: js; js-indent-level: 4; indent-tabs-mode: nil -*- -/* exported BoxPointer */ -const Clutter = imports.gi.Clutter; -const GObject = imports.gi.GObject; -const Meta = imports.gi.Meta; -const St = imports.gi.St; +import Clutter from 'gi://Clutter'; +import GObject from 'gi://GObject'; +import Meta from 'gi://Meta'; +import St from 'gi://St'; -const Main = imports.ui.main; +import * as Main from './main.js'; -var PopupAnimation = { +export const PopupAnimation = { NONE: 0, SLIDE: 1 << 0, FADE: 1 << 1, FULL: ~0, }; -var POPUP_ANIMATION_TIME = 150; +const POPUP_ANIMATION_TIME = 150; /** * BoxPointer: - * @side: side to draw the arrow on - * @binProperties: Properties to set on contained bin * * An actor which displays a triangle "arrow" pointing to a given * side. The .bin property is a container in which content can be @@ -30,7 +27,7 @@ var POPUP_ANIMATION_TIME = 150; * totally inside the monitor workarea if possible. * */ -var BoxPointer = GObject.registerClass({ +export const BoxPointer = GObject.registerClass({ Signals: { 'arrow-side-changed': {} }, }, class BoxPointer extends St.Widget { /** diff --git a/js/ui/calendar.js b/js/ui/calendar.js index 6e7af8fea..5b2358df5 100644 --- a/js/ui/calendar.js +++ b/js/ui/calendar.js @@ -1,28 +1,27 @@ // -*- mode: js; js-indent-level: 4; indent-tabs-mode: nil -*- -/* exported Calendar, CalendarMessageList, DBusEventSource */ -const Clutter = imports.gi.Clutter; -const Gio = imports.gi.Gio; -const GLib = imports.gi.GLib; -const GObject = imports.gi.GObject; -const Shell = imports.gi.Shell; -const St = imports.gi.St; +import Clutter from 'gi://Clutter'; +import Gio from 'gi://Gio'; +import GLib from 'gi://GLib'; +import GObject from 'gi://GObject'; +import Shell from 'gi://Shell'; +import St from 'gi://St'; -const Main = imports.ui.main; -const MessageList = imports.ui.messageList; -const MessageTray = imports.ui.messageTray; -const Mpris = imports.ui.mpris; -const PopupMenu = imports.ui.popupMenu; -const {ensureActorVisibleInScrollView} = imports.misc.animationUtils; +import * as Main from './main.js'; +import * as MessageList from './messageList.js'; +import * as MessageTray from './messageTray.js'; +import * as Mpris from './mpris.js'; +import * as PopupMenu from './popupMenu.js'; +import {ensureActorVisibleInScrollView} from '../misc/animationUtils.js'; -const {formatDateWithCFormatString, formatTimeSpan} = imports.misc.dateUtils; -const {loadInterfaceXML} = imports.misc.fileUtils; +import {formatDateWithCFormatString, formatTimeSpan} from '../misc/dateUtils.js'; +import {loadInterfaceXML} from '../misc/fileUtils.js'; -var SHOW_WEEKDATE_KEY = 'show-weekdate'; +const SHOW_WEEKDATE_KEY = 'show-weekdate'; -var MESSAGE_ICON_SIZE = -1; // pick up from CSS +const MESSAGE_ICON_SIZE = -1; // pick up from CSS -var NC_ = (context, str) => `${context}\u0004${str}`; +const NC_ = (context, str) => `${context}\u0004${str}`; function sameYear(dateA, dateB) { return dateA.getYear() == dateB.getYear(); @@ -83,19 +82,19 @@ function _getCalendarDayAbbreviation(dayNumber) { // Abstraction for an appointment/event in a calendar -var CalendarEvent = class CalendarEvent { +class CalendarEvent { constructor(id, date, end, summary) { this.id = id; this.date = date; this.end = end; this.summary = summary; } -}; +} // Interface for appointments/events - e.g. the contents of a calendar // -var EventSourceBase = GObject.registerClass({ +export const EventSourceBase = GObject.registerClass({ GTypeFlags: GObject.TypeFlags.ABSTRACT, Properties: { 'has-calendars': GObject.ParamSpec.boolean( @@ -143,7 +142,7 @@ var EventSourceBase = GObject.registerClass({ } }); -var EmptyEventSource = GObject.registerClass( +export const EmptyEventSource = GObject.registerClass( class EmptyEventSource extends EventSourceBase { get isLoading() { return false; @@ -211,7 +210,7 @@ function _eventOverlapsInterval(e0, e1, i0, i1) { } // an implementation that reads data from a session bus service -var DBusEventSource = GObject.registerClass( +export const DBusEventSource = GObject.registerClass( class DBusEventSource extends EventSourceBase { _init() { super._init(); @@ -411,7 +410,7 @@ class DBusEventSource extends EventSourceBase { } }); -var Calendar = GObject.registerClass({ +export const Calendar = GObject.registerClass({ Signals: { 'selected-date-changed': { param_types: [GLib.DateTime.$gtype] } }, }, class Calendar extends St.Widget { _init() { @@ -766,7 +765,7 @@ var Calendar = GObject.registerClass({ } }); -var NotificationMessage = GObject.registerClass( +export const NotificationMessage = GObject.registerClass( class NotificationMessage extends MessageList.Message { _init(notification) { super._init(notification.title, notification.bannerBodyText); @@ -817,7 +816,7 @@ class NotificationMessage extends MessageList.Message { } }); -var TimeLabel = GObject.registerClass( +const TimeLabel = GObject.registerClass( class NotificationTimeLabel extends St.Label { _init(datetime) { super._init({ @@ -834,7 +833,7 @@ class NotificationTimeLabel extends St.Label { } }); -var NotificationSection = GObject.registerClass( +const NotificationSection = GObject.registerClass( class NotificationSection extends MessageList.MessageListSection { _init() { super._init(); @@ -896,7 +895,7 @@ class NotificationSection extends MessageList.MessageListSection { } }); -var Placeholder = GObject.registerClass( +const Placeholder = GObject.registerClass( class Placeholder extends St.BoxLayout { _init() { super._init({ style_class: 'message-list-placeholder', vertical: true }); @@ -930,7 +929,7 @@ class DoNotDisturbSwitch extends PopupMenu.Switch { } }); -var CalendarMessageList = GObject.registerClass( +export const CalendarMessageList = GObject.registerClass( class CalendarMessageList extends St.Widget { _init() { super._init({ diff --git a/js/ui/checkBox.js b/js/ui/checkBox.js index 882f12711..cce474bfd 100644 --- a/js/ui/checkBox.js +++ b/js/ui/checkBox.js @@ -1,11 +1,10 @@ -/* exported CheckBox */ -const Atk = imports.gi.Atk; -const Clutter = imports.gi.Clutter; -const GObject = imports.gi.GObject; -const Pango = imports.gi.Pango; -const St = imports.gi.St; +import Atk from 'gi://Atk'; +import Clutter from 'gi://Clutter'; +import GObject from 'gi://GObject'; +import Pango from 'gi://Pango'; +import St from 'gi://St'; -var CheckBox = GObject.registerClass( +export const CheckBox = GObject.registerClass( class CheckBox extends St.Button { _init(label) { let container = new St.BoxLayout({ diff --git a/js/ui/closeDialog.js b/js/ui/closeDialog.js index 314ac7c72..eaf816dfc 100644 --- a/js/ui/closeDialog.js +++ b/js/ui/closeDialog.js @@ -1,21 +1,20 @@ // -*- mode: js; js-indent-level: 4; indent-tabs-mode: nil -*- -/* exported CloseDialog */ -const Clutter = imports.gi.Clutter; -const GLib = imports.gi.GLib; -const GObject = imports.gi.GObject; -const Meta = imports.gi.Meta; -const Shell = imports.gi.Shell; -const St = imports.gi.St; +import Clutter from 'gi://Clutter'; +import GLib from 'gi://GLib'; +import GObject from 'gi://GObject'; +import Meta from 'gi://Meta'; +import Shell from 'gi://Shell'; +import St from 'gi://St'; -const Dialog = imports.ui.dialog; -const Main = imports.ui.main; +import * as Dialog from './dialog.js'; +import * as Main from './main.js'; -var FROZEN_WINDOW_BRIGHTNESS = -0.3; -var DIALOG_TRANSITION_TIME = 150; -var ALIVE_TIMEOUT = 5000; +const FROZEN_WINDOW_BRIGHTNESS = -0.3; +const DIALOG_TRANSITION_TIME = 150; +const ALIVE_TIMEOUT = 5000; -var CloseDialog = GObject.registerClass({ +export const CloseDialog = GObject.registerClass({ Implements: [Meta.CloseDialog], Properties: { 'window': GObject.ParamSpec.override('window', Meta.CloseDialog), diff --git a/js/ui/components.js b/js/ui/components.js index 06751a964..79e65a12b 100644 --- a/js/ui/components.js +++ b/js/ui/components.js @@ -1,7 +1,6 @@ -/* exported ComponentManager */ -const Main = imports.ui.main; +import * as Main from './main.js'; -var ComponentManager = class { +export class ComponentManager { constructor() { this._allComponents = {}; this._enabledComponents = []; @@ -28,8 +27,7 @@ var ComponentManager = class { } async _importComponent(name) { - // TODO: Import as module - let module = await imports.ui.components[name]; + let module = await import(`./components/${name}.js`); return module.Component; } @@ -59,4 +57,4 @@ var ComponentManager = class { return; component.disable(); } -}; +} diff --git a/js/ui/components/automountManager.js b/js/ui/components/automountManager.js index c81d7e441..59e7357b5 100644 --- a/js/ui/components/automountManager.js +++ b/js/ui/components/automountManager.js @@ -1,23 +1,22 @@ // -*- mode: js; js-indent-level: 4; indent-tabs-mode: nil -*- -/* exported Component */ -const Gio = imports.gi.Gio; -const GLib = imports.gi.GLib; -const Params = imports.misc.params; +import Gio from 'gi://Gio'; +import GLib from 'gi://GLib'; +import * as Params from '../../misc/params.js'; -const GnomeSession = imports.misc.gnomeSession; -const Main = imports.ui.main; -const ShellMountOperation = imports.ui.shellMountOperation; +import * as GnomeSession from '../../misc/gnomeSession.js'; +import * as Main from '../main.js'; +import * as ShellMountOperation from '../shellMountOperation.js'; -var GNOME_SESSION_AUTOMOUNT_INHIBIT = 16; +const GNOME_SESSION_AUTOMOUNT_INHIBIT = 16; // GSettings keys const SETTINGS_SCHEMA = 'org.gnome.desktop.media-handling'; const SETTING_ENABLE_AUTOMOUNT = 'automount'; -var AUTORUN_EXPIRE_TIMEOUT_SECS = 10; +const AUTORUN_EXPIRE_TIMEOUT_SECS = 10; -var AutomountManager = class { +class AutomountManager { constructor() { this._settings = new Gio.Settings({ schema_id: SETTINGS_SCHEMA }); this._activeOperations = new Map(); @@ -253,5 +252,6 @@ var AutomountManager = class { volume._allowAutorunExpireId = id; GLib.Source.set_name_by_id(id, '[gnome-shell] volume.allowAutorun'); } -}; -var Component = AutomountManager; +} + +export {AutomountManager as Component}; diff --git a/js/ui/components/autorunManager.js b/js/ui/components/autorunManager.js index 5313cc473..90b9c45f8 100644 --- a/js/ui/components/autorunManager.js +++ b/js/ui/components/autorunManager.js @@ -1,18 +1,17 @@ // -*- mode: js; js-indent-level: 4; indent-tabs-mode: nil -*- -/* exported Component */ -const Clutter = imports.gi.Clutter; -const Gio = imports.gi.Gio; -const GObject = imports.gi.GObject; -const St = imports.gi.St; +import Clutter from 'gi://Clutter'; +import Gio from 'gi://Gio'; +import GObject from 'gi://GObject'; +import St from 'gi://St'; -const GnomeSession = imports.misc.gnomeSession; -const Main = imports.ui.main; -const MessageTray = imports.ui.messageTray; +import * as GnomeSession from '../../misc/gnomeSession.js'; +import * as Main from '../main.js'; +import * as MessageTray from '../messageTray.js'; Gio._promisify(Gio.Mount.prototype, 'guess_content_type'); -const { loadInterfaceXML } = imports.misc.fileUtils; +import {loadInterfaceXML} from '../../misc/fileUtils.js'; // GSettings keys const SETTINGS_SCHEMA = 'org.gnome.desktop.media-handling'; @@ -22,7 +21,7 @@ const SETTING_IGNORE = 'autorun-x-content-ignore'; const SETTING_OPEN_FOLDER = 'autorun-x-content-open-folder'; /** @enum {number} */ -var AutorunSetting = { +const AutorunSetting = { RUN: 0, IGNORE: 1, FILES: 2, @@ -86,7 +85,7 @@ function HotplugSniffer() { '/org/gnome/Shell/HotplugSniffer'); } -var ContentTypeDiscoverer = class { +class ContentTypeDiscoverer { constructor() { this._settings = new Gio.Settings({ schema_id: SETTINGS_SCHEMA }); } @@ -127,9 +126,9 @@ var ContentTypeDiscoverer = class { return [apps, contentTypes]; } -}; +} -var AutorunManager = class { +class AutorunManager { constructor() { this._session = new GnomeSession.SessionManager(); this._volumeMonitor = Gio.VolumeMonitor.get(); @@ -161,9 +160,9 @@ var AutorunManager = class { _onMountRemoved(monitor, mount) { this._dispatcher.removeMount(mount); } -}; +} -var AutorunDispatcher = class { +class AutorunDispatcher { constructor(manager) { this._manager = manager; this._sources = []; @@ -255,9 +254,9 @@ var AutorunDispatcher = class { // destroy the notification source source.destroy(); } -}; +} -var AutorunSource = GObject.registerClass( +const AutorunSource = GObject.registerClass( class AutorunSource extends MessageTray.Source { _init(manager, mount, apps) { super._init(mount.get_name()); @@ -282,7 +281,7 @@ class AutorunSource extends MessageTray.Source { } }); -var AutorunNotification = GObject.registerClass( +const AutorunNotification = GObject.registerClass( class AutorunNotification extends MessageTray.Notification { _init(manager, source) { super._init(source, source.title); @@ -346,4 +345,4 @@ class AutorunNotification extends MessageTray.Notification { } }); -var Component = AutorunManager; +export {AutorunManager as Component}; diff --git a/js/ui/components/keyring.js b/js/ui/components/keyring.js index fa96553bb..f836db565 100644 --- a/js/ui/components/keyring.js +++ b/js/ui/components/keyring.js @@ -1,21 +1,20 @@ // -*- mode: js; js-indent-level: 4; indent-tabs-mode: nil -*- -/* exported Component */ -const Clutter = imports.gi.Clutter; -const Gcr = imports.gi.Gcr; -const Gio = imports.gi.Gio; -const GObject = imports.gi.GObject; -const Pango = imports.gi.Pango; -const Shell = imports.gi.Shell; -const St = imports.gi.St; +import Clutter from 'gi://Clutter'; +import Gcr from 'gi://Gcr'; +import Gio from 'gi://Gio'; +import GObject from 'gi://GObject'; +import Pango from 'gi://Pango'; +import Shell from 'gi://Shell'; +import St from 'gi://St'; -const Dialog = imports.ui.dialog; -const ModalDialog = imports.ui.modalDialog; -const ShellEntry = imports.ui.shellEntry; -const CheckBox = imports.ui.checkBox; -const {wiggle} = imports.misc.animationUtils; +import * as Dialog from '../dialog.js'; +import * as ModalDialog from '../modalDialog.js'; +import * as ShellEntry from '../shellEntry.js'; +import * as CheckBox from '../checkBox.js'; +import {wiggle} from '../misc/animationUtils.js'; -var KeyringDialog = GObject.registerClass( +const KeyringDialog = GObject.registerClass( class KeyringDialog extends ModalDialog.ModalDialog { _init() { super._init({ styleClass: 'prompt-dialog' }); @@ -184,7 +183,7 @@ class KeyringDialog extends ModalDialog.ModalDialog { } }); -var KeyringDummyDialog = class { +class KeyringDummyDialog { constructor() { this.prompt = new Shell.KeyringPrompt(); this.prompt.connect('show-password', this._cancelPrompt.bind(this)); @@ -194,9 +193,9 @@ var KeyringDummyDialog = class { _cancelPrompt() { this.prompt.cancel(); } -}; +} -var KeyringPrompter = GObject.registerClass( +const KeyringPrompter = GObject.registerClass( class KeyringPrompter extends Gcr.SystemPrompter { _init() { super._init(); @@ -232,4 +231,4 @@ class KeyringPrompter extends Gcr.SystemPrompter { } }); -var Component = KeyringPrompter; +export {KeyringPrompter as Component}; diff --git a/js/ui/components/networkAgent.js b/js/ui/components/networkAgent.js index 9f8b23824..1db90ccca 100644 --- a/js/ui/components/networkAgent.js +++ b/js/ui/components/networkAgent.js @@ -1,28 +1,27 @@ // -*- mode: js; js-indent-level: 4; indent-tabs-mode: nil -*- -/* exported Component */ -const Clutter = imports.gi.Clutter; -const Gio = imports.gi.Gio; -const GLib = imports.gi.GLib; -const GObject = imports.gi.GObject; -const NM = imports.gi.NM; -const Pango = imports.gi.Pango; -const Shell = imports.gi.Shell; -const St = imports.gi.St; -const Signals = imports.misc.signals; +import Clutter from 'gi://Clutter'; +import Gio from 'gi://Gio'; +import GLib from 'gi://GLib'; +import GObject from 'gi://GObject'; +import NM from 'gi://NM'; +import Pango from 'gi://Pango'; +import Shell from 'gi://Shell'; +import St from 'gi://St'; +import * as Signals from '../../misc/signals.js'; -const Dialog = imports.ui.dialog; -const Main = imports.ui.main; -const MessageTray = imports.ui.messageTray; -const ModalDialog = imports.ui.modalDialog; -const ShellEntry = imports.ui.shellEntry; +import * as Dialog from '../dialog.js'; +import * as Main from '../main.js'; +import * as MessageTray from '../messageTray.js'; +import * as ModalDialog from '../modalDialog.js'; +import * as ShellEntry from '../shellEntry.js'; Gio._promisify(Shell.NetworkAgent.prototype, 'init_async'); Gio._promisify(Shell.NetworkAgent.prototype, 'search_vpn_plugin'); const VPN_UI_GROUP = 'VPN Plugin UI'; -var NetworkSecretDialog = GObject.registerClass( +const NetworkSecretDialog = GObject.registerClass( class NetworkSecretDialog extends ModalDialog.ModalDialog { _init(agent, requestId, connection, settingName, hints, flags, contentOverride) { super._init({ styleClass: 'prompt-dialog' }); @@ -418,7 +417,7 @@ class NetworkSecretDialog extends ModalDialog.ModalDialog { } }); -var VPNRequestHandler = class extends Signals.EventEmitter { +class VPNRequestHandler extends Signals.EventEmitter { constructor(agent, requestId, authHelper, serviceType, connection, hints, flags) { super(); @@ -676,9 +675,9 @@ var VPNRequestHandler = class extends Signals.EventEmitter { this.destroy(); } } -}; +} -var NetworkAgent = class { +class NetworkAgent { constructor() { this._native = new Shell.NetworkAgent({ identifier: 'org.gnome.Shell.NetworkAgent', @@ -880,5 +879,6 @@ var NetworkAgent = class { externalUIMode: ['true', 'yes', 'on', '1'].includes(trimmedProp), }; } -}; -var Component = NetworkAgent; +} + +export {NetworkAgent as Component}; diff --git a/js/ui/components/polkitAgent.js b/js/ui/components/polkitAgent.js index 010dce8fd..9879ad1e6 100644 --- a/js/ui/components/polkitAgent.js +++ b/js/ui/components/polkitAgent.js @@ -1,22 +1,21 @@ // -*- mode: js; js-indent-level: 4; indent-tabs-mode: nil -*- -/* exported Component */ -const AccountsService = imports.gi.AccountsService; -const Clutter = imports.gi.Clutter; -const GLib = imports.gi.GLib; -const GObject = imports.gi.GObject; -const Pango = imports.gi.Pango; -const PolkitAgent = imports.gi.PolkitAgent; -const Polkit = imports.gi.Polkit; -const Shell = imports.gi.Shell; -const St = imports.gi.St; +import AccountsService from 'gi://AccountsService'; +import Clutter from 'gi://Clutter'; +import GLib from 'gi://GLib'; +import GObject from 'gi://GObject'; +import Pango from 'gi://Pango'; +import PolkitAgent from 'gi://PolkitAgent'; +import Polkit from 'gi://Polkit'; +import Shell from 'gi://Shell'; +import St from 'gi://St'; -const Dialog = imports.ui.dialog; -const Main = imports.ui.main; -const ModalDialog = imports.ui.modalDialog; -const ShellEntry = imports.ui.shellEntry; -const UserWidget = imports.ui.userWidget; -const {wiggle} = imports.misc.animationUtils; +import * as Dialog from '../dialog.js'; +import * as Main from '../main.js'; +import * as ModalDialog from '../modalDialog.js'; +import * as ShellEntry from '../shellEntry.js'; +import * as UserWidget from '../userWidget.js'; +import {wiggle} from '../misc/animationUtils.js'; /** @enum {number} */ const DialogMode = { @@ -28,7 +27,7 @@ const DIALOG_ICON_SIZE = 64; const DELAYED_RESET_TIMEOUT = 200; -var AuthenticationDialog = GObject.registerClass({ +const AuthenticationDialog = GObject.registerClass({ Signals: { 'done': { param_types: [GObject.TYPE_BOOLEAN] } }, }, class AuthenticationDialog extends ModalDialog.ModalDialog { _init(actionId, description, cookie, userNames) { @@ -414,7 +413,7 @@ var AuthenticationDialog = GObject.registerClass({ } }); -var AuthenticationAgent = GObject.registerClass( +const AuthenticationAgent = GObject.registerClass( class AuthenticationAgent extends Shell.PolkitAuthenticationAgent { _init() { super._init(); @@ -474,4 +473,4 @@ class AuthenticationAgent extends Shell.PolkitAuthenticationAgent { } }); -var Component = AuthenticationAgent; +export {AuthenticationAgent as Component}; diff --git a/js/ui/components/telepathyClient.js b/js/ui/components/telepathyClient.js index 7020a64d7..a5f88ad9c 100644 --- a/js/ui/components/telepathyClient.js +++ b/js/ui/components/telepathyClient.js @@ -1,16 +1,15 @@ // -*- mode: js; js-indent-level: 4; indent-tabs-mode: nil -*- -/* exported Component */ +import Clutter from 'gi://Clutter'; +import Gio from 'gi://Gio'; +import GLib from 'gi://GLib'; +import GObject from 'gi://GObject'; +import St from 'gi://St'; -const Clutter = imports.gi.Clutter; -const Gio = imports.gi.Gio; -const GLib = imports.gi.GLib; -const GObject = imports.gi.GObject; -const St = imports.gi.St; - -var Tpl = null; -var Tp = null; +let Tpl = null; +let Tp = null; try { - ({ TelepathyGLib: Tp, TelepathyLogger: Tpl } = imports.gi); + ({default: Tp} = await import('gi://TelepathyGlib')); + ({default: Tpl} = await import('gi://TelepathyLogger')); Gio._promisify(Tp.Channel.prototype, 'close_async'); Gio._promisify(Tp.TextChannel.prototype, 'send_message_async'); @@ -20,30 +19,30 @@ try { console.debug('Skipping chat support, telepathy not found'); } -const History = imports.misc.history; -const Main = imports.ui.main; -const MessageList = imports.ui.messageList; -const MessageTray = imports.ui.messageTray; -const Params = imports.misc.params; -const Util = imports.misc.util; +import * as History from '../../misc/history.js'; +import * as Main from '../main.js'; +import * as MessageList from '../messageList.js'; +import * as MessageTray from '../messageTray.js'; +import * as Params from '../../misc/params.js'; +import * as Util from '../../misc/util.js'; const HAVE_TP = Tp != null && Tpl != null; // See Notification.appendMessage -var SCROLLBACK_IMMEDIATE_TIME = 3 * 60; // 3 minutes -var SCROLLBACK_RECENT_TIME = 15 * 60; // 15 minutes -var SCROLLBACK_RECENT_LENGTH = 20; -var SCROLLBACK_IDLE_LENGTH = 5; +const SCROLLBACK_IMMEDIATE_TIME = 3 * 60; // 3 minutes +const SCROLLBACK_RECENT_TIME = 15 * 60; // 15 minutes +const SCROLLBACK_RECENT_LENGTH = 20; +const SCROLLBACK_IDLE_LENGTH = 5; // See Source._displayPendingMessages -var SCROLLBACK_HISTORY_LINES = 10; +const SCROLLBACK_HISTORY_LINES = 10; // See Notification._onEntryChanged -var COMPOSING_STOP_TIMEOUT = 5; +const COMPOSING_STOP_TIMEOUT = 5; -var CHAT_EXPAND_LINES = 12; +const CHAT_EXPAND_LINES = 12; -var NotificationDirection = { +const NotificationDirection = { SENT: 'chat-sent', RECEIVED: 'chat-received', }; @@ -101,7 +100,7 @@ const ChatMessage = HAVE_TP ? GObject.registerClass({ }) : null; -var TelepathyComponent = class { +class TelepathyComponent { constructor() { this._client = null; @@ -131,9 +130,9 @@ var TelepathyComponent = class { this._client.unregister(); } -}; +} -var TelepathyClient = HAVE_TP ? GObject.registerClass( +const TelepathyClient = HAVE_TP ? GObject.registerClass( class TelepathyClient extends Tp.BaseClient { _init() { // channel path -> ChatSource @@ -306,7 +305,7 @@ class TelepathyClient extends Tp.BaseClient { } }) : null; -var ChatSource = HAVE_TP ? GObject.registerClass( +const ChatSource = HAVE_TP ? GObject.registerClass( class ChatSource extends MessageTray.Source { _init(account, conn, channel, contact, client) { this._account = account; @@ -666,7 +665,7 @@ class ChatNotificationMessage extends GObject.Object { } }) : null; -var ChatNotification = HAVE_TP ? GObject.registerClass({ +const ChatNotification = HAVE_TP ? GObject.registerClass({ Signals: { 'message-removed': { param_types: [ChatNotificationMessage.$gtype] }, 'message-added': { param_types: [ChatNotificationMessage.$gtype] }, @@ -841,7 +840,7 @@ var ChatNotification = HAVE_TP ? GObject.registerClass({ } }) : null; -var ChatLineBox = GObject.registerClass( +const ChatLineBox = GObject.registerClass( class ChatLineBox extends St.BoxLayout { vfunc_get_preferred_height(forWidth) { let [, natHeight] = super.vfunc_get_preferred_height(forWidth); @@ -849,7 +848,7 @@ class ChatLineBox extends St.BoxLayout { } }); -var ChatNotificationBanner = GObject.registerClass( +const ChatNotificationBanner = GObject.registerClass( class ChatNotificationBanner extends MessageTray.NotificationBanner { _init(notification) { super._init(notification); @@ -1020,4 +1019,4 @@ class ChatNotificationBanner extends MessageTray.NotificationBanner { } }); -var Component = TelepathyComponent; +export const Component = TelepathyComponent; diff --git a/js/ui/ctrlAltTab.js b/js/ui/ctrlAltTab.js index 97d72c2e5..0cac42537 100644 --- a/js/ui/ctrlAltTab.js +++ b/js/ui/ctrlAltTab.js @@ -1,25 +1,24 @@ // -*- mode: js; js-indent-level: 4; indent-tabs-mode: nil -*- -/* exported CtrlAltTabManager */ -const Clutter = imports.gi.Clutter; -const GObject = imports.gi.GObject; -const Meta = imports.gi.Meta; -const Shell = imports.gi.Shell; -const St = imports.gi.St; +import Clutter from 'gi://Clutter'; +import GObject from 'gi://GObject'; +import Meta from 'gi://Meta'; +import Shell from 'gi://Shell'; +import St from 'gi://St'; -const Main = imports.ui.main; -const SwitcherPopup = imports.ui.switcherPopup; -const Params = imports.misc.params; +import * as Main from './main.js'; +import * as SwitcherPopup from './switcherPopup.js'; +import * as Params from '../misc/params.js'; -var POPUP_APPICON_SIZE = 96; +const POPUP_APPICON_SIZE = 96; -var SortGroup = { +export const SortGroup = { TOP: 0, MIDDLE: 1, BOTTOM: 2, }; -var CtrlAltTabManager = class CtrlAltTabManager { +export class CtrlAltTabManager { constructor() { this._items = []; this.addGroup(global.window_group, @@ -141,9 +140,9 @@ var CtrlAltTabManager = class CtrlAltTabManager { _focusWindows(timestamp) { global.display.focus_default_window(timestamp); } -}; +} -var CtrlAltTabPopup = GObject.registerClass( +const CtrlAltTabPopup = GObject.registerClass( class CtrlAltTabPopup extends SwitcherPopup.SwitcherPopup { _init(items) { super._init(items); @@ -172,7 +171,7 @@ class CtrlAltTabPopup extends SwitcherPopup.SwitcherPopup { } }); -var CtrlAltTabSwitcher = GObject.registerClass( +const CtrlAltTabSwitcher = GObject.registerClass( class CtrlAltTabSwitcher extends SwitcherPopup.SwitcherList { _init(items) { super._init(true); diff --git a/js/ui/dash.js b/js/ui/dash.js index be4b93eac..1731dd81e 100644 --- a/js/ui/dash.js +++ b/js/ui/dash.js @@ -1,25 +1,24 @@ // -*- mode: js; js-indent-level: 4; indent-tabs-mode: nil -*- -/* exported Dash */ -const Clutter = imports.gi.Clutter; -const GLib = imports.gi.GLib; -const GObject = imports.gi.GObject; -const Graphene = imports.gi.Graphene; -const Meta = imports.gi.Meta; -const Shell = imports.gi.Shell; -const St = imports.gi.St; +import Clutter from 'gi://Clutter'; +import GLib from 'gi://GLib'; +import GObject from 'gi://GObject'; +import Graphene from 'gi://Graphene'; +import Meta from 'gi://Meta'; +import Shell from 'gi://Shell'; +import St from 'gi://St'; -const AppDisplay = imports.ui.appDisplay; -const AppFavorites = imports.ui.appFavorites; -const DND = imports.ui.dnd; -const IconGrid = imports.ui.iconGrid; -const Main = imports.ui.main; -const Overview = imports.ui.overview; +import * as AppDisplay from './appDisplay.js'; +import * as AppFavorites from './appFavorites.js'; +import * as DND from './dnd.js'; +import * as IconGrid from './iconGrid.js'; +import * as Main from './main.js'; +import * as Overview from './overview.js'; -var DASH_ANIMATION_TIME = 200; -var DASH_ITEM_LABEL_SHOW_TIME = 150; -var DASH_ITEM_LABEL_HIDE_TIME = 100; -var DASH_ITEM_HOVER_TIMEOUT = 300; +const DASH_ANIMATION_TIME = 200; +const DASH_ITEM_LABEL_SHOW_TIME = 150; +const DASH_ITEM_LABEL_HIDE_TIME = 100; +const DASH_ITEM_HOVER_TIMEOUT = 300; /** * @param {AppDisplay.AppIcon} source @@ -31,7 +30,7 @@ function getAppFromSource(source) { return null; } -var DashIcon = GObject.registerClass( +export const DashIcon = GObject.registerClass( class DashIcon extends AppDisplay.AppIcon { _init(app) { super._init(app, { @@ -62,7 +61,7 @@ class DashIcon extends AppDisplay.AppIcon { // A container like StBin, but taking the child's scale into account // when requesting a size -var DashItemContainer = GObject.registerClass( +export const DashItemContainer = GObject.registerClass( class DashItemContainer extends St.Widget { _init() { super._init({ @@ -200,7 +199,7 @@ class DashItemContainer extends St.Widget { } }); -var ShowAppsIcon = GObject.registerClass( +export const ShowAppsIcon = GObject.registerClass( class ShowAppsIcon extends DashItemContainer { _init() { super._init(); @@ -285,7 +284,7 @@ class ShowAppsIcon extends DashItemContainer { } }); -var DragPlaceholderItem = GObject.registerClass( +const DragPlaceholderItem = GObject.registerClass( class DragPlaceholderItem extends DashItemContainer { _init() { super._init(); @@ -293,7 +292,7 @@ class DragPlaceholderItem extends DashItemContainer { } }); -var EmptyDropTargetItem = GObject.registerClass( +const EmptyDropTargetItem = GObject.registerClass( class EmptyDropTargetItem extends DashItemContainer { _init() { super._init(); @@ -317,7 +316,7 @@ class DashIconsLayout extends Clutter.BoxLayout { const baseIconSizes = [16, 22, 24, 32, 48, 64]; -var Dash = GObject.registerClass({ +export const Dash = GObject.registerClass({ Signals: { 'icon-size-changed': {} }, }, class Dash extends St.Widget { _init() { diff --git a/js/ui/dateMenu.js b/js/ui/dateMenu.js index af97299fd..ae8073e41 100644 --- a/js/ui/dateMenu.js +++ b/js/ui/dateMenu.js @@ -1,24 +1,22 @@ // -*- mode: js; js-indent-level: 4; indent-tabs-mode: nil -*- -/* exported DateMenuButton */ -const Clutter = imports.gi.Clutter; -const Gio = imports.gi.Gio; -const GLib = imports.gi.GLib; -const GnomeDesktop = imports.gi.GnomeDesktop; -const GObject = imports.gi.GObject; -const GWeather = imports.gi.GWeather; -const Pango = imports.gi.Pango; -const Shell = imports.gi.Shell; -const St = imports.gi.St; +import Clutter from 'gi://Clutter'; +import Gio from 'gi://Gio'; +import GLib from 'gi://GLib'; +import GnomeDesktop from 'gi://GnomeDesktop'; +import GObject from 'gi://GObject'; +import GWeather from 'gi://GWeather'; +import Pango from 'gi://Pango'; +import Shell from 'gi://Shell'; +import St from 'gi://St'; -const Main = imports.ui.main; -const PanelMenu = imports.ui.panelMenu; -const Calendar = imports.ui.calendar; -const Weather = imports.misc.weather; -const DateUtils = imports.misc.dateUtils; +import * as Main from './main.js'; +import * as PanelMenu from './panelMenu.js'; +import * as Calendar from './calendar.js'; +import * as Weather from '../misc/weather.js'; -const {formatDateWithCFormatString, formatTime} = imports.misc.dateUtils; -const {loadInterfaceXML} = imports.misc.fileUtils; +import {formatDateWithCFormatString, formatTime, clearCachedLocalTimeZone} from '../misc/dateUtils.js'; +import {loadInterfaceXML} from '../misc/fileUtils.js'; const NC_ = (context, str) => `${context}\u0004${str}`; const T_ = Shell.util_translate_time_string; @@ -52,7 +50,7 @@ function _gDateTimeToDate(datetime) { return new Date(datetime.to_unix() * 1000 + datetime.get_microsecond() / 1000); } -var TodayButton = GObject.registerClass( +const TodayButton = GObject.registerClass( class TodayButton extends St.Button { _init(calendar) { // Having the ability to go to the current date if the user is already @@ -109,7 +107,7 @@ class TodayButton extends St.Button { } }); -var EventsSection = GObject.registerClass( +const EventsSection = GObject.registerClass( class EventsSection extends St.Button { _init() { super._init({ @@ -328,7 +326,7 @@ class EventsSection extends St.Button { } }); -var WorldClocksSection = GObject.registerClass( +const WorldClocksSection = GObject.registerClass( class WorldClocksSection extends St.Button { _init() { super._init({ @@ -534,7 +532,7 @@ class WorldClocksSection extends St.Button { } }); -var WeatherSection = GObject.registerClass( +const WeatherSection = GObject.registerClass( class WeatherSection extends St.Button { _init() { super._init({ @@ -727,7 +725,7 @@ class WeatherSection extends St.Button { } }); -var MessagesIndicator = GObject.registerClass( +const MessagesIndicator = GObject.registerClass( class MessagesIndicator extends St.Icon { _init() { super._init({ @@ -788,7 +786,7 @@ class MessagesIndicator extends St.Icon { } }); -var FreezableBinLayout = GObject.registerClass( +const FreezableBinLayout = GObject.registerClass( class FreezableBinLayout extends Clutter.BinLayout { _init() { super._init(); @@ -828,7 +826,7 @@ class FreezableBinLayout extends Clutter.BinLayout { } }); -var CalendarColumnLayout = GObject.registerClass( +const CalendarColumnLayout = GObject.registerClass( class CalendarColumnLayout extends Clutter.BoxLayout { _init(actors) { super._init({orientation: Clutter.Orientation.VERTICAL}); @@ -847,7 +845,7 @@ class CalendarColumnLayout extends Clutter.BoxLayout { } }); -var DateMenuButton = GObject.registerClass( +export const DateMenuButton = GObject.registerClass( class DateMenuButton extends PanelMenu.Button { _init() { let hbox; @@ -970,7 +968,7 @@ class DateMenuButton extends PanelMenu.Button { } _updateTimeZone() { - DateUtils.clearCachedLocalTimeZone(); + clearCachedLocalTimeZone(); this._calendar.updateTimeZone(); } diff --git a/js/ui/dialog.js b/js/ui/dialog.js index d15782c08..7392e4cbe 100644 --- a/js/ui/dialog.js +++ b/js/ui/dialog.js @@ -1,12 +1,11 @@ // -*- mode: js; js-indent-level: 4; indent-tabs-mode: nil -*- -/* exported Dialog, MessageDialogContent, ListSection, ListSectionItem */ -const Clutter = imports.gi.Clutter; -const GLib = imports.gi.GLib; -const GObject = imports.gi.GObject; -const Meta = imports.gi.Meta; -const Pango = imports.gi.Pango; -const St = imports.gi.St; +import Clutter from 'gi://Clutter'; +import GLib from 'gi://GLib'; +import GObject from 'gi://GObject'; +import Meta from 'gi://Meta'; +import Pango from 'gi://Pango'; +import St from 'gi://St'; function _setLabel(label, value) { label.set({ @@ -15,7 +14,7 @@ function _setLabel(label, value) { }); } -var Dialog = GObject.registerClass( +export const Dialog = GObject.registerClass( class Dialog extends St.Widget { _init(parentActor, styleClass) { super._init({ @@ -156,7 +155,7 @@ class Dialog extends St.Widget { } }); -var MessageDialogContent = GObject.registerClass({ +export const MessageDialogContent = GObject.registerClass({ Properties: { 'title': GObject.ParamSpec.string( 'title', 'title', 'title', @@ -248,7 +247,7 @@ var MessageDialogContent = GObject.registerClass({ } }); -var ListSection = GObject.registerClass({ +export const ListSection = GObject.registerClass({ Properties: { 'title': GObject.ParamSpec.string( 'title', 'title', 'title', @@ -293,7 +292,7 @@ var ListSection = GObject.registerClass({ } }); -var ListSectionItem = GObject.registerClass({ +export const ListSectionItem = GObject.registerClass({ Properties: { 'icon-actor': GObject.ParamSpec.object( 'icon-actor', 'icon-actor', 'Icon actor', diff --git a/js/ui/dnd.js b/js/ui/dnd.js index 2fee362c9..229303954 100644 --- a/js/ui/dnd.js +++ b/js/ui/dnd.js @@ -1,25 +1,24 @@ // -*- mode: js; js-indent-level: 4; indent-tabs-mode: nil -*- -/* exported addDragMonitor, removeDragMonitor, makeDraggable */ -const Clutter = imports.gi.Clutter; -const GLib = imports.gi.GLib; -const Meta = imports.gi.Meta; -const Shell = imports.gi.Shell; -const St = imports.gi.St; -const Signals = imports.misc.signals; +import Clutter from 'gi://Clutter'; +import GLib from 'gi://GLib'; +import Meta from 'gi://Meta'; +import Shell from 'gi://Shell'; +import St from 'gi://St'; +import * as Signals from '../misc/signals.js'; -const Main = imports.ui.main; -const Params = imports.misc.params; +import * as Main from './main.js'; +import * as Params from '../misc/params.js'; // Time to scale down to maxDragActorSize -var SCALE_ANIMATION_TIME = 250; +const SCALE_ANIMATION_TIME = 250; // Time to animate to original position on cancel -var SNAP_BACK_ANIMATION_TIME = 250; +const SNAP_BACK_ANIMATION_TIME = 250; // Time to animate to original position on success -var REVERT_ANIMATION_TIME = 750; +const REVERT_ANIMATION_TIME = 750; /** @enum {number} */ -varragMotionResult = { +export const DragMotionResult = { NO_DROP: 0, COPY_DROP: 1, MOVE_DROP: 2, @@ -27,24 +26,24 @@ varragMotionResult = { }; /** @enum {number} */ -varragState = { +const DragState = { INIT: 0, DRAGGING: 1, CANCELLED: 2, }; -var DRAG_CURSOR_MAP = { +const DRAG_CURSOR_MAP = { 0: Meta.Cursor.DND_UNSUPPORTED_TARGET, 1: Meta.Cursor.DND_COPY, 2: Meta.Cursor.DND_MOVE, }; -var DragDropResult = { +export const DragDropResult = { FAILURE: 0, SUCCESS: 1, CONTINUE: 2, }; -var dragMonitors = []; +export const dragMonitors = []; let eventHandlerActor = null; let currentDraggable = null; @@ -79,23 +78,23 @@ function _getRealActorScale(actor) { /** * @param {DragMonitor} monitor */ -function addDragMonitor(monitor) { +export function addDragMonitor(monitor) { dragMonitors.push(monitor); } /** * @param {DragMonitor} monitor */ -function removeDragMonitor(monitor) { +export function removeDragMonitor(monitor) { for (let i = 0; i < dragMonitors.length; i++) { - if (dragMonitors[i] == monitor) { + if (dragMonitors[i] === monitor) { dragMonitors.splice(i, 1); return; } } } -var _Draggable = class _Draggable extends Signals.EventEmitter { +class _Draggable extends Signals.EventEmitter { constructor(actor, params) { super(); @@ -112,9 +111,9 @@ var _Draggable = class _Draggable extends Signals.EventEmitter { if (!params.manualMode) { this.actor.connect('button-press-event', - this._onButtonPress.bind(this)); + this._onButtonPress.bind(this)); this.actor.connect('touch-event', - this._onTouchEvent.bind(this)); + this._onTouchEvent.bind(this)); } this.actor.connect('destroy', () => { @@ -866,7 +865,7 @@ var _Draggable = class _Draggable extends Signals.EventEmitter { this._dragState = DragState.INIT; currentDraggable = null; } -}; +} /** * makeDraggable: @@ -890,6 +889,6 @@ var _Draggable = class _Draggable extends Signals.EventEmitter { * target wants to reuse the actor, it's up to the drop target to * reset these values. */ -function makeDraggable(actor, params) { +export function makeDraggable(actor, params) { return new _Draggable(actor, params); } diff --git a/js/ui/edgeDragAction.js b/js/ui/edgeDragAction.js index e35b5e2fc..820abc0a0 100644 --- a/js/ui/edgeDragAction.js +++ b/js/ui/edgeDragAction.js @@ -1,17 +1,16 @@ // -*- mode: js; js-indent-level: 4; indent-tabs-mode: nil -*- -/* exported EdgeDragAction */ -const Clutter = imports.gi.Clutter; -const GObject = imports.gi.GObject; -const Meta = imports.gi.Meta; -const St = imports.gi.St; +import Clutter from 'gi://Clutter'; +import GObject from 'gi://GObject'; +import Meta from 'gi://Meta'; +import St from 'gi://St'; -const Main = imports.ui.main; +import * as Main from './main.js'; -var EDGE_THRESHOLD = 20; -var DRAG_DISTANCE = 80; +const EDGE_THRESHOLD = 20; +const DRAG_DISTANCE = 80; -var EdgeDragAction = GObject.registerClass({ +export const EdgeDragAction = GObject.registerClass({ Signals: { 'activated': {}, 'progress': { param_types: [GObject.TYPE_DOUBLE] }, diff --git a/js/ui/endSessionDialog.js b/js/ui/endSessionDialog.js index 93d8d5c2f..b4022918e 100644 --- a/js/ui/endSessionDialog.js +++ b/js/ui/endSessionDialog.js @@ -1,5 +1,4 @@ // -*- mode: js; js-indent-level: 4; indent-tabs-mode: nil -*- -/* exported init, EndSessionDialog */ /* * Copyright 2010-2016 Red Hat, Inc * @@ -17,25 +16,25 @@ * along with this program; if not, see . */ -const AccountsService = imports.gi.AccountsService; -const Clutter = imports.gi.Clutter; -const Gio = imports.gi.Gio; -const GLib = imports.gi.GLib; -const GObject = imports.gi.GObject; -const Pango = imports.gi.Pango; -const Polkit = imports.gi.Polkit; -const Shell = imports.gi.Shell; -const St = imports.gi.St; -const UPower = imports.gi.UPowerGlib; +import AccountsService from 'gi://AccountsService'; +import Clutter from 'gi://Clutter'; +import Gio from 'gi://Gio'; +import GLib from 'gi://GLib'; +import GObject from 'gi://GObject'; +import Pango from 'gi://Pango'; +import Polkit from 'gi://Polkit'; +import Shell from 'gi://Shell'; +import St from 'gi://St'; +import UPower from 'gi://UPowerGlib'; -const CheckBox = imports.ui.checkBox; -const Dialog = imports.ui.dialog; -const GnomeSession = imports.misc.gnomeSession; -const LoginManager = imports.misc.loginManager; -const ModalDialog = imports.ui.modalDialog; -const UserWidget = imports.ui.userWidget; +import * as CheckBox from './checkBox.js'; +import * as Dialog from './dialog.js'; +import * as GnomeSession from '../misc/gnomeSession.js'; +import * as LoginManager from '../misc/loginManager.js'; +import * as ModalDialog from './modalDialog.js'; +import * as UserWidget from './userWidget.js'; -const { loadInterfaceXML } = imports.misc.fileUtils; +import {loadInterfaceXML} from '../misc/fileUtils.js'; const _ITEM_ICON_SIZE = 64; @@ -159,7 +158,7 @@ const DialogContent = { 4 /* DialogType.UPGRADE_RESTART */: restartUpgradeDialogContent, }; -var MAX_USERS_IN_SESSION_DIALOG = 5; +const MAX_USERS_IN_SESSION_DIALOG = 5; const LogindSessionIface = loadInterfaceXML('org.freedesktop.login1.Session'); const LogindSession = Gio.DBusProxy.makeProxyWrapper(LogindSessionIface); @@ -224,14 +223,14 @@ function _setCheckBoxLabel(checkBox, text) { } } -function init() { +export function init() { // This always returns the same singleton object // By instantiating it initially, we register the // bus object, etc. new EndSessionDialog(); } -var EndSessionDialog = GObject.registerClass( +const EndSessionDialog = GObject.registerClass( class EndSessionDialog extends ModalDialog.ModalDialog { _init() { super._init({ diff --git a/js/ui/environment.js b/js/ui/environment.js index 0a67b4327..0b1a81731 100644 --- a/js/ui/environment.js +++ b/js/ui/environment.js @@ -14,8 +14,8 @@ import Polkit from 'gi://Polkit'; import Shell from 'gi://Shell'; import St from 'gi://St'; -const SignalTracker = imports.misc.signalTracker; -const {adjustAnimationTime} = imports.misc.animationUtils; +import * as SignalTracker from '../misc/signalTracker.js'; +import {adjustAnimationTime} from '../misc/animationUtils.js'; setConsoleLogDomain('GNOME Shell'); diff --git a/js/ui/extensionDownloader.js b/js/ui/extensionDownloader.js index 64aba5a70..c0fc3b840 100644 --- a/js/ui/extensionDownloader.js +++ b/js/ui/extensionDownloader.js @@ -1,27 +1,26 @@ // -*- mode: js; js-indent-level: 4; indent-tabs-mode: nil -*- -/* exported init, installExtension, uninstallExtension, checkForUpdates */ -const Clutter = imports.gi.Clutter; -const Gio = imports.gi.Gio; -const GLib = imports.gi.GLib; -const GObject = imports.gi.GObject; -const Soup = imports.gi.Soup; +import Clutter from 'gi://Clutter'; +import Gio from 'gi://Gio'; +import GLib from 'gi://GLib'; +import GObject from 'gi://GObject'; +import Soup from 'gi://Soup'; const Config = imports.misc.config; -const Dialog = imports.ui.dialog; -const ExtensionUtils = imports.misc.extensionUtils; -const FileUtils = imports.misc.fileUtils; -const Main = imports.ui.main; -const ModalDialog = imports.ui.modalDialog; +import * as Dialog from './dialog.js'; +import * as ExtensionUtils from '../misc/extensionUtils.js'; +import * as FileUtils from '../misc/fileUtils.js'; +import * as Main from './main.js'; +import * as ModalDialog from './modalDialog.js'; Gio._promisify(Soup.Session.prototype, 'send_and_read_async'); Gio._promisify(Gio.OutputStream.prototype, 'write_bytes_async'); Gio._promisify(Gio.IOStream.prototype, 'close_async'); Gio._promisify(Gio.Subprocess.prototype, 'wait_check_async'); -var REPOSITORY_URL_DOWNLOAD = 'https://extensions.gnome.org/download-extension/%s.shell-extension.zip'; -var REPOSITORY_URL_INFO = 'https://extensions.gnome.org/extension-info/'; -var REPOSITORY_URL_UPDATE = 'https://extensions.gnome.org/update-info/'; +const REPOSITORY_URL_DOWNLOAD = 'https://extensions.gnome.org/download-extension/%s.shell-extension.zip'; +const REPOSITORY_URL_INFO = 'https://extensions.gnome.org/extension-info/'; +const REPOSITORY_URL_UPDATE = 'https://extensions.gnome.org/update-info/'; let _httpSession; @@ -30,7 +29,7 @@ let _httpSession; * @param {Gio.DBusMethodInvocation} invocation - the caller * @returns {void} */ -async function installExtension(uuid, invocation) { +export async function installExtension(uuid, invocation) { const params = { uuid, shell_version: Config.PACKAGE_VERSION, @@ -63,7 +62,7 @@ async function installExtension(uuid, invocation) { /** * @param {string} uuid */ -function uninstallExtension(uuid) { +export function uninstallExtension(uuid) { let extension = Main.extensionManager.lookup(uuid); if (!extension) return false; @@ -153,7 +152,7 @@ async function extractExtensionArchive(bytes, dir) { * @param {string} uuid - extension uuid * @returns {void} */ -async function downloadExtensionUpdate(uuid) { +export async function downloadExtensionUpdate(uuid) { if (!Main.extensionManager.updatesSupported) return; @@ -184,7 +183,7 @@ async function downloadExtensionUpdate(uuid) { * * @returns {void} */ -async function checkForUpdates() { +export async function checkForUpdates() { if (!Main.extensionManager.updatesSupported) return; @@ -244,7 +243,7 @@ async function checkForUpdates() { } } -var InstallExtensionDialog = GObject.registerClass( +const InstallExtensionDialog = GObject.registerClass( class InstallExtensionDialog extends ModalDialog.ModalDialog { _init(uuid, info, invocation) { super._init({ styleClass: 'extension-dialog' }); @@ -311,6 +310,6 @@ class InstallExtensionDialog extends ModalDialog.ModalDialog { } }); -function init() { +export function init() { _httpSession = new Soup.Session(); } diff --git a/js/ui/extensionSystem.js b/js/ui/extensionSystem.js index d2f608f4c..3dbb6b3f8 100644 --- a/js/ui/extensionSystem.js +++ b/js/ui/extensionSystem.js @@ -1,23 +1,20 @@ // -*- mode: js; js-indent-level: 4; indent-tabs-mode: nil -*- -/* exported init connect disconnect ExtensionManager */ -const GLib = imports.gi.GLib; -const Gio = imports.gi.Gio; -const GObject = imports.gi.GObject; -const Shell = imports.gi.Shell; -const St = imports.gi.St; -const Signals = imports.misc.signals; +import GLib from 'gi://GLib'; +import Gio from 'gi://Gio'; +import GObject from 'gi://GObject'; +import St from 'gi://St'; +import Shell from 'gi://Shell'; +import * as Signals from '../misc/signals.js'; -const ExtensionDownloader = imports.ui.extensionDownloader; -const ExtensionUtils = imports.misc.extensionUtils; -const FileUtils = imports.misc.fileUtils; -const Main = imports.ui.main; -const MessageTray = imports.ui.messageTray; +import * as ExtensionDownloader from './extensionDownloader.js'; +import {ExtensionState, ExtensionType} from '../misc/extensionUtils.js'; +import * as FileUtils from '../misc/fileUtils.js'; +import * as Main from './main.js'; +import * as MessageTray from './messageTray.js'; const Config = imports.misc.config; -const { ExtensionState, ExtensionType } = ExtensionUtils; - const ENABLED_EXTENSIONS_KEY = 'enabled-extensions'; const DISABLED_EXTENSIONS_KEY = 'disabled-extensions'; const DISABLE_USER_EXTENSIONS_KEY = 'disable-user-extensions'; @@ -25,7 +22,7 @@ const EXTENSION_DISABLE_VERSION_CHECK_KEY = 'disable-extension-version-validatio const UPDATE_CHECK_TIMEOUT = 24 * 60 * 60; // 1 day in seconds -var ExtensionManager = class extends Signals.EventEmitter { +export class ExtensionManager extends Signals.EventEmitter { constructor() { super(); @@ -768,7 +765,7 @@ var ExtensionManager = class extends Signals.EventEmitter { await this._onEnabledExtensionsChanged(); await this._enableAllExtensions(); } -}; +} const ExtensionUpdateSource = GObject.registerClass( class ExtensionUpdateSource extends MessageTray.Source { diff --git a/js/ui/focusCaretTracker.js b/js/ui/focusCaretTracker.js index 5cfe7a849..e37538252 100644 --- a/js/ui/focusCaretTracker.js +++ b/js/ui/focusCaretTracker.js @@ -20,15 +20,14 @@ * Contributor: * Magdalen Berns */ -/* exported FocusCaretTracker */ -const Atspi = imports.gi.Atspi; -const Signals = imports.misc.signals; +import Atspi from 'gi://Atspi'; +import * as Signals from '../misc/signals.js'; const CARETMOVED = 'object:text-caret-moved'; const STATECHANGED = 'object:state-changed'; -var FocusCaretTracker = class FocusCaretTracker extends Signals.EventEmitter { +export class FocusCaretTracker extends Signals.EventEmitter { constructor() { super(); @@ -88,4 +87,4 @@ var FocusCaretTracker = class FocusCaretTracker extends Signals.EventEmitter { this._atspiListener.deregister(CARETMOVED); this._caretListenerRegistered = false; } -}; +} diff --git a/js/ui/grabHelper.js b/js/ui/grabHelper.js index 6b8c2e1b5..9758ad26f 100644 --- a/js/ui/grabHelper.js +++ b/js/ui/grabHelper.js @@ -1,11 +1,10 @@ // -*- mode: js; js-indent-level: 4; indent-tabs-mode: nil -*- -/* exported GrabHelper */ -const Clutter = imports.gi.Clutter; -const St = imports.gi.St; +import Clutter from 'gi://Clutter'; +import St from 'gi://St'; -const Main = imports.ui.main; -const Params = imports.misc.params; +import * as Main from './main.js'; +import * as Params from '../misc/params.js'; /** * GrabHelper: @@ -18,7 +17,7 @@ const Params = imports.misc.params; * after you call ungrab(), but instead pass an 'onUngrab' callback when you * call grab(). */ -class GrabHelper { +export class GrabHelper { /** * @param {Clutter.Actor} owner the actor that owns the GrabHelper * @param {*} params optional parameters to pass to Main.pushModal() @@ -293,4 +292,4 @@ class GrabHelper { return Clutter.EVENT_STOP; } -}; +} diff --git a/js/ui/ibusCandidatePopup.js b/js/ui/ibusCandidatePopup.js index 8d9b31805..785e1d152 100644 --- a/js/ui/ibusCandidatePopup.js +++ b/js/ui/ibusCandidatePopup.js @@ -1,22 +1,21 @@ // -*- mode: js; js-indent-level: 4; indent-tabs-mode: nil -*- -/* exported CandidatePopup */ -const Clutter = imports.gi.Clutter; -const GObject = imports.gi.GObject; -const IBus = imports.gi.IBus; -const St = imports.gi.St; +import Clutter from 'gi://Clutter'; +import GObject from 'gi://GObject'; +import IBus from 'gi://IBus'; +import St from 'gi://St'; -const BoxPointer = imports.ui.boxpointer; -const Main = imports.ui.main; +import * as BoxPointer from './boxpointer.js'; +import * as Main from './main.js'; -var MAX_CANDIDATES_PER_PAGE = 16; +const MAX_CANDIDATES_PER_PAGE = 16; -var DEFAULT_INDEX_LABELS = [ +const DEFAULT_INDEX_LABELS = [ '1', '2', '3', '4', '5', '6', '7', '8', '9', '0', 'a', 'b', 'c', 'd', 'e', 'f', ]; -var CandidateArea = GObject.registerClass({ +const CandidateArea = GObject.registerClass({ Signals: { 'candidate-clicked': { param_types: [ @@ -146,7 +145,7 @@ var CandidateArea = GObject.registerClass({ } }); -var CandidatePopup = GObject.registerClass( +export const CandidatePopup = GObject.registerClass( class IbusCandidatePopup extends BoxPointer.BoxPointer { _init() { super._init(St.Side.TOP); diff --git a/js/ui/iconGrid.js b/js/ui/iconGrid.js index 289ab5398..dffeff082 100644 --- a/js/ui/iconGrid.js +++ b/js/ui/iconGrid.js @@ -1,22 +1,21 @@ // -*- mode: js; js-indent-level: 4; indent-tabs-mode: nil -*- -/* exported BaseIcon, IconGrid, IconGridLayout */ -const Clutter = imports.gi.Clutter; -const GLib = imports.gi.GLib; -const GObject = imports.gi.GObject; -const Meta = imports.gi.Meta; -const Shell = imports.gi.Shell; -const St = imports.gi.St; +import Clutter from 'gi://Clutter'; +import GLib from 'gi://GLib'; +import GObject from 'gi://GObject'; +import Meta from 'gi://Meta'; +import Shell from 'gi://Shell'; +import St from 'gi://St'; -const Params = imports.misc.params; -const Main = imports.ui.main; +import * as Params from '../misc/params.js'; +import * as Main from './main.js'; -var ICON_SIZE = 96; +const ICON_SIZE = 96; -var PAGE_SWITCH_TIME = 300; +const PAGE_SWITCH_TIME = 300; /** @enum {number} */ -var IconSize = { +const IconSize = { LARGE: 96, MEDIUM: 64, MEDIUM_SMALL: 48, @@ -25,8 +24,8 @@ var IconSize = { TINY: 16, }; -var APPICON_ANIMATION_OUT_SCALE = 3; -var APPICON_ANIMATION_OUT_TIME = 250; +const APPICON_ANIMATION_OUT_SCALE = 3; +const APPICON_ANIMATION_OUT_TIME = 250; const ICON_POSITION_DELAY = 10; @@ -49,11 +48,11 @@ const defaultGridModes = [ }, ]; -var LEFT_DIVIDER_LEEWAY = 20; -var RIGHT_DIVIDER_LEEWAY = 20; +const LEFT_DIVIDER_LEEWAY = 20; +const RIGHT_DIVIDER_LEEWAY = 20; /** @enum {number} */ -var DragLocation = { +export const DragLocation = { INVALID: 0, START_EDGE: 1, ON_ICON: 2, @@ -61,7 +60,7 @@ var DragLocation = { EMPTY_SPACE: 4, }; -var BaseIcon = GObject.registerClass( +export const BaseIcon = GObject.registerClass( class BaseIcon extends Shell.SquareBin { _init(label, params) { params = Params.parse(params, { @@ -243,7 +242,7 @@ function swap(value, length) { return length - value - 1; } -var IconGridLayout = GObject.registerClass({ +export const IconGridLayout = GObject.registerClass({ Properties: { 'allow-incomplete-pages': GObject.ParamSpec.boolean('allow-incomplete-pages', 'Allow incomplete pages', 'Allow incomplete pages', @@ -1160,7 +1159,7 @@ var IconGridLayout = GObject.registerClass({ } }); -var IconGrid = GObject.registerClass({ +export const IconGrid = GObject.registerClass({ Signals: { 'pages-changed': {}, }, diff --git a/js/ui/inhibitShortcutsDialog.js b/js/ui/inhibitShortcutsDialog.js index 95205efef..39b4b283f 100644 --- a/js/ui/inhibitShortcutsDialog.js +++ b/js/ui/inhibitShortcutsDialog.js @@ -1,14 +1,13 @@ -/* exported InhibitShortcutsDialog */ -const Clutter = imports.gi.Clutter; -const GObject = imports.gi.GObject; -const Meta = imports.gi.Meta; -const Pango = imports.gi.Pango; -const Shell = imports.gi.Shell; -const St = imports.gi.St; +import Clutter from 'gi://Clutter'; +import GObject from 'gi://GObject'; +import Meta from 'gi://Meta'; +import Pango from 'gi://Pango'; +import Shell from 'gi://Shell'; +import St from 'gi://St'; -const Dialog = imports.ui.dialog; -const ModalDialog = imports.ui.modalDialog; -const PermissionStore = imports.misc.permissionStore; +import * as Dialog from './dialog.js'; +import * as ModalDialog from './modalDialog.js'; +import * as PermissionStore from '../misc/permissionStore.js'; const APP_ALLOWLIST = ['org.gnome.Settings.desktop']; const APP_PERMISSIONS_TABLE = 'gnome'; @@ -16,9 +15,9 @@ const APP_PERMISSIONS_ID = 'shortcuts-inhibitor'; const GRANTED = 'GRANTED'; const DENIED = 'DENIED'; -var DialogResponse = Meta.InhibitShortcutsDialogResponse; +const DialogResponse = Meta.InhibitShortcutsDialogResponse; -var InhibitShortcutsDialog = GObject.registerClass({ +export const InhibitShortcutsDialog = GObject.registerClass({ Implements: [Meta.InhibitShortcutsDialog], Properties: { 'window': GObject.ParamSpec.override('window', Meta.InhibitShortcutsDialog), diff --git a/js/ui/init.js b/js/ui/init.js index c605baa6c..2dea981b7 100644 --- a/js/ui/init.js +++ b/js/ui/init.js @@ -8,7 +8,7 @@ import './environment.js'; imports._promiseNative.setMainLoopHook(() => { // Queue starting the shell GLib.idle_add(GLib.PRIORITY_DEFAULT, () => { - imports.ui.main.start().catch(e => { + import('./main.js').then(main => main.start()).catch(e => { const error = new GLib.Error( Gio.IOErrorEnum, Gio.IOErrorEnum.FAILED, e.message); diff --git a/js/ui/kbdA11yDialog.js b/js/ui/kbdA11yDialog.js index 06831f688..5d0a955f6 100644 --- a/js/ui/kbdA11yDialog.js +++ b/js/ui/kbdA11yDialog.js @@ -1,17 +1,16 @@ -/* exported KbdA11yDialog */ -const Clutter = imports.gi.Clutter; -const Gio = imports.gi.Gio; -const GObject = imports.gi.GObject; -const Meta = imports.gi.Meta; +import Clutter from 'gi://Clutter'; +import Gio from 'gi://Gio'; +import GObject from 'gi://GObject'; +import Meta from 'gi://Meta'; -const Dialog = imports.ui.dialog; -const ModalDialog = imports.ui.modalDialog; +import * as Dialog from './dialog.js'; +import * as ModalDialog from './modalDialog.js'; const KEYBOARD_A11Y_SCHEMA = 'org.gnome.desktop.a11y.keyboard'; const KEY_STICKY_KEYS_ENABLED = 'stickykeys-enable'; const KEY_SLOW_KEYS_ENABLED = 'slowkeys-enable'; -var KbdA11yDialog = GObject.registerClass( +export const KbdA11yDialog = GObject.registerClass( class KbdA11yDialog extends GObject.Object { _init() { super._init(); diff --git a/js/ui/keyboard.js b/js/ui/keyboard.js index f3eb96a79..4c8f7aefa 100644 --- a/js/ui/keyboard.js +++ b/js/ui/keyboard.js @@ -1,29 +1,27 @@ // -*- mode: js; js-indent-level: 4; indent-tabs-mode: nil -*- -/* exported KeyboardManager */ +import Clutter from 'gi://Clutter'; +import Gio from 'gi://Gio'; +import GLib from 'gi://GLib'; +import GObject from 'gi://GObject'; +import Meta from 'gi://Meta'; +import Graphene from 'gi://Graphene'; +import IBus from 'gi://IBus'; +import Shell from 'gi://Shell'; +import St from 'gi://St'; +import * as Signals from '../misc/signals.js'; -const Clutter = imports.gi.Clutter; -const Gio = imports.gi.Gio; -const GLib = imports.gi.GLib; -const GObject = imports.gi.GObject; -const Graphene = imports.gi.Graphene; -const IBus = imports.gi.IBus; -const Meta = imports.gi.Meta; -const Shell = imports.gi.Shell; -const St = imports.gi.St; -const Signals = imports.misc.signals; +import * as EdgeDragAction from './edgeDragAction.js'; +import * as InputSourceManager from './status/keyboard.js'; +import * as IBusManager from '../misc/ibusManager.js'; +import * as BoxPointer from './boxpointer.js'; +import * as Main from './main.js'; +import * as PageIndicators from './pageIndicators.js'; +import * as PopupMenu from './popupMenu.js'; +import * as SwipeTracker from './swipeTracker.js'; -const EdgeDragAction = imports.ui.edgeDragAction; -const InputSourceManager = imports.ui.status.keyboard; -const IBusManager = imports.misc.ibusManager; -const BoxPointer = imports.ui.boxpointer; -const Main = imports.ui.main; -const PageIndicators = imports.ui.pageIndicators; -const PopupMenu = imports.ui.popupMenu; -const SwipeTracker = imports.ui.swipeTracker; - -var KEYBOARD_ANIMATION_TIME = 150; -var KEYBOARD_REST_TIME = KEYBOARD_ANIMATION_TIME * 2; -var KEY_LONG_PRESS_TIME = 250; +const KEYBOARD_ANIMATION_TIME = 150; +const KEYBOARD_REST_TIME = KEYBOARD_ANIMATION_TIME * 2; +const KEY_LONG_PRESS_TIME = 250; const A11Y_APPLICATIONS_SCHEMA = 'org.gnome.desktop.a11y.applications'; const SHOW_KEYBOARD = 'screen-keyboard-enabled'; @@ -35,7 +33,7 @@ const KEY_SIZE = 2; const KEY_RELEASE_TIMEOUT = 50; const BACKSPACE_WORD_DELETE_THRESHOLD = 50; -var AspectContainer = GObject.registerClass( +const AspectContainer = GObject.registerClass( class AspectContainer extends St.Widget { _init(params) { super._init(params); @@ -82,7 +80,7 @@ class AspectContainer extends St.Widget { } }); -var KeyContainer = GObject.registerClass( +const KeyContainer = GObject.registerClass( class KeyContainer extends St.Widget { _init() { const gridLayout = new Clutter.GridLayout({ @@ -166,7 +164,7 @@ class KeyContainer extends St.Widget { } }); -var Suggestions = GObject.registerClass( +const Suggestions = GObject.registerClass( class Suggestions extends St.BoxLayout { _init() { super._init({ @@ -203,7 +201,7 @@ class Suggestions extends St.BoxLayout { } }); -var LanguageSelectionPopup = class extends PopupMenu.PopupMenu { +class LanguageSelectionPopup extends PopupMenu.PopupMenu { constructor(actor) { super(actor, 0.5, St.Side.BOTTOM); @@ -262,9 +260,9 @@ var LanguageSelectionPopup = class extends PopupMenu.PopupMenu { this.sourceActor.disconnectObject(this); super.destroy(); } -}; +} -var Key = GObject.registerClass({ +const Key = GObject.registerClass({ Signals: { 'long-press': {}, 'pressed': {}, @@ -520,7 +518,7 @@ var Key = GObject.registerClass({ } }); -var KeyboardModel = class { +class KeyboardModel { constructor(groupName) { let names = [groupName]; if (groupName.includes('+')) @@ -552,9 +550,9 @@ var KeyboardModel = class { getKeysForLevel(levelName) { return this._model.levels.find(level => level == levelName); } -}; +} -var FocusTracker = class extends Signals.EventEmitter { +class FocusTracker extends Signals.EventEmitter { constructor() { super(); @@ -651,9 +649,9 @@ var FocusTracker = class extends Signals.EventEmitter { return rect; } -}; +} -var EmojiPager = GObject.registerClass({ +const EmojiPager = GObject.registerClass({ Properties: { 'delta': GObject.ParamSpec.int( 'delta', 'delta', 'delta', @@ -936,7 +934,7 @@ var EmojiPager = GObject.registerClass({ } }); -var EmojiSelection = GObject.registerClass({ +const EmojiSelection = GObject.registerClass({ Signals: { 'emoji-selected': { param_types: [GObject.TYPE_STRING] }, 'close-request': {}, @@ -1121,7 +1119,7 @@ var EmojiSelection = GObject.registerClass({ } }); -var Keypad = GObject.registerClass({ +const Keypad = GObject.registerClass({ Signals: { 'keyval': { param_types: [GObject.TYPE_UINT] }, }, @@ -1178,7 +1176,7 @@ var Keypad = GObject.registerClass({ } }); -var KeyboardManager = class extends Signals.EventEmitter { +export class KeyboardManager extends Signals.EventEmitter { constructor() { super(); @@ -1297,9 +1295,9 @@ var KeyboardManager = class extends Signals.EventEmitter { return false; } -}; +} -var Keyboard = GObject.registerClass({ +export const Keyboard = GObject.registerClass({ Signals: { 'visibility-changed': {}, }, @@ -2170,7 +2168,7 @@ var Keyboard = GObject.registerClass({ } }); -var KeyboardController = class extends Signals.EventEmitter { +class KeyboardController extends Signals.EventEmitter { constructor() { super(); @@ -2279,4 +2277,4 @@ var KeyboardController = class extends Signals.EventEmitter { this._virtualDevice.notify_keyval(Clutter.get_current_event_time() * 1000, keyval, Clutter.KeyState.RELEASED); } -}; +} diff --git a/js/ui/layout.js b/js/ui/layout.js index baf5a807b..f7aa47d7c 100644 --- a/js/ui/layout.js +++ b/js/ui/layout.js @@ -1,28 +1,27 @@ // -*- mode: js; js-indent-level: 4; indent-tabs-mode: nil -*- -/* exported MonitorConstraint, LayoutManager */ -const Clutter = imports.gi.Clutter; -const Gio = imports.gi.Gio; -const GLib = imports.gi.GLib; -const GObject = imports.gi.GObject; -const Meta = imports.gi.Meta; -const Shell = imports.gi.Shell; -const St = imports.gi.St; -const Signals = imports.misc.signals; +import Clutter from 'gi://Clutter'; +import Gio from 'gi://Gio'; +import GLib from 'gi://GLib'; +import GObject from 'gi://GObject'; +import Meta from 'gi://Meta'; +import Shell from 'gi://Shell'; +import St from 'gi://St'; +import * as Signals from '../misc/signals.js'; -const Background = imports.ui.background; -const BackgroundMenu = imports.ui.backgroundMenu; +import * as Background from './background.js'; +import * as BackgroundMenu from './backgroundMenu.js'; -const DND = imports.ui.dnd; -const Main = imports.ui.main; -const Params = imports.misc.params; -const Ripples = imports.ui.ripples; +import * as DND from './dnd.js'; +import * as Main from './main.js'; +import * as Params from '../misc/params.js'; +import * as Ripples from './ripples.js'; -var STARTUP_ANIMATION_TIME = 500; -var BACKGROUND_FADE_ANIMATION_TIME = 1000; +const STARTUP_ANIMATION_TIME = 500; +const BACKGROUND_FADE_ANIMATION_TIME = 1000; -var HOT_CORNER_PRESSURE_THRESHOLD = 100; // pixels -var HOT_CORNER_PRESSURE_TIMEOUT = 1000; // ms +const HOT_CORNER_PRESSURE_THRESHOLD = 100; // pixels +const HOT_CORNER_PRESSURE_TIMEOUT = 1000; // ms const SCREEN_TRANSITION_DELAY = 250; // ms const SCREEN_TRANSITION_DURATION = 500; // ms @@ -38,7 +37,7 @@ function isPopupMetaWindow(actor) { } } -var MonitorConstraint = GObject.registerClass({ +export const MonitorConstraint = GObject.registerClass({ Properties: { 'primary': GObject.ParamSpec.boolean('primary', 'Primary', 'Track primary monitor', @@ -155,7 +154,7 @@ var MonitorConstraint = GObject.registerClass({ } }); -var Monitor = class Monitor { +class Monitor { constructor(index, geometry, geometryScale) { this.index = index; this.x = geometry.x; @@ -168,7 +167,7 @@ var Monitor = class Monitor { get inFullscreen() { return global.display.get_monitor_in_fullscreen(this.index); } -}; +} const UiActor = GObject.registerClass( class UiActor extends St.Widget { @@ -189,7 +188,7 @@ const defaultParams = { affectsInputRegion: true, }; -var LayoutManager = GObject.registerClass({ +export const LayoutManager = GObject.registerClass({ Signals: { 'hot-corners-changed': {}, 'startup-complete': {}, @@ -1131,7 +1130,7 @@ var LayoutManager = GObject.registerClass({ // // This class manages a "hot corner" that can toggle switching to // overview. -var HotCorner = GObject.registerClass( +export const HotCorner = GObject.registerClass( class HotCorner extends Clutter.Actor { _init(layoutManager, monitor, x, y) { super._init(); @@ -1299,7 +1298,7 @@ class HotCorner extends Clutter.Actor { } }); -var PressureBarrier = class PressureBarrier extends Signals.EventEmitter { +class PressureBarrier extends Signals.EventEmitter { constructor(threshold, timeout, actionMode) { super(); @@ -1441,9 +1440,9 @@ var PressureBarrier = class PressureBarrier extends Signals.EventEmitter { if (this._currentPressure >= this._threshold) this._trigger(); } -}; +} -var ScreenTransition = GObject.registerClass( +const ScreenTransition = GObject.registerClass( class ScreenTransition extends Clutter.Actor { _init() { super._init({ visible: false }); diff --git a/js/ui/lightbox.js b/js/ui/lightbox.js index 5f1ec8a7b..9c1e21569 100644 --- a/js/ui/lightbox.js +++ b/js/ui/lightbox.js @@ -1,16 +1,15 @@ // -*- mode: js; js-indent-level: 4; indent-tabs-mode: nil -*- -/* exported Lightbox */ -const Clutter = imports.gi.Clutter; -const GObject = imports.gi.GObject; -const Shell = imports.gi.Shell; -const St = imports.gi.St; +import Clutter from 'gi://Clutter'; +import GObject from 'gi://GObject'; +import Shell from 'gi://Shell'; +import St from 'gi://St'; -const Params = imports.misc.params; +import * as Params from '../misc/params.js'; -var DEFAULT_FADE_FACTOR = 0.4; -var VIGNETTE_BRIGHTNESS = 0.5; -var VIGNETTE_SHARPNESS = 0.7; +export const DEFAULT_FADE_FACTOR = 0.4; +export const VIGNETTE_BRIGHTNESS = 0.5; +export const VIGNETTE_SHARPNESS = 0.7; const VIGNETTE_DECLARATIONS = ' \ uniform float brightness; \n\ @@ -29,7 +28,7 @@ cogl_color_out.a *= 1.0 - pixel_brightness * brightness; \n\ cogl_color_out.a += (rand(position) - 0.5) / 100.0; \n'; -var RadialShaderEffect = GObject.registerClass({ +const RadialShaderEffect = GObject.registerClass({ Properties: { 'brightness': GObject.ParamSpec.float( 'brightness', 'brightness', 'brightness', @@ -89,7 +88,7 @@ var RadialShaderEffect = GObject.registerClass({ /** * Lightbox: */ -var Lightbox = GObject.registerClass({ +export const Lightbox = GObject.registerClass({ Properties: { 'active': GObject.ParamSpec.boolean( 'active', 'active', 'active', GObject.ParamFlags.READABLE, false), diff --git a/js/ui/locatePointer.js b/js/ui/locatePointer.js index 524aae668..925592c69 100644 --- a/js/ui/locatePointer.js +++ b/js/ui/locatePointer.js @@ -1,14 +1,13 @@ // -*- mode: js; js-indent-level: 4; indent-tabs-mode: nil -*- -/* exported LocatePointer */ -const Gio = imports.gi.Gio; -const Ripples = imports.ui.ripples; -const Main = imports.ui.main; +import Gio from 'gi://Gio'; +import * as Ripples from './ripples.js'; +import * as Main from './main.js'; -const LOCATE_POINTER_KEY = "locate-pointer"; -const LOCATE_POINTER_SCHEMA = "org.gnome.desktop.interface"; +const LOCATE_POINTER_KEY = 'locate-pointer'; +const LOCATE_POINTER_SCHEMA = 'org.gnome.desktop.interface'; -var LocatePointer = class { +export class LocatePointer { constructor() { this._settings = new Gio.Settings({ schema_id: LOCATE_POINTER_SCHEMA }); this._settings.connect(`changed::${LOCATE_POINTER_KEY}`, () => this._syncEnabled()); @@ -36,4 +35,4 @@ var LocatePointer = class { let [x, y] = global.get_pointer(); this._ripples.playAnimation(x, y); } -}; +} diff --git a/js/ui/lookingGlass.js b/js/ui/lookingGlass.js index 7feb10391..8c1696c79 100644 --- a/js/ui/lookingGlass.js +++ b/js/ui/lookingGlass.js @@ -1,34 +1,31 @@ // -*- mode: js; js-indent-level: 4; indent-tabs-mode: nil -*- -/* exported LookingGlass */ -const Clutter = imports.gi.Clutter; -const Cogl = imports.gi.Cogl; -const Gio = imports.gi.Gio; -const GLib = imports.gi.GLib; -const GObject = imports.gi.GObject; -const Graphene = imports.gi.Graphene; -const Meta = imports.gi.Meta; -const Pango = imports.gi.Pango; -const Shell = imports.gi.Shell; -const St = imports.gi.St; -const Signals = imports.misc.signals; -const System = imports.system; +import Clutter from 'gi://Clutter'; +import Cogl from 'gi://Cogl'; +import Gio from 'gi://Gio'; +import GLib from 'gi://GLib'; +import GObject from 'gi://GObject'; +import Graphene from 'gi://Graphene'; +import Meta from 'gi://Meta'; +import Pango from 'gi://Pango'; +import Shell from 'gi://Shell'; +import St from 'gi://St'; +import * as Signals from '../misc/signals.js'; +import System from 'system'; -const History = imports.misc.history; -const ExtensionUtils = imports.misc.extensionUtils; -const PopupMenu = imports.ui.popupMenu; -const ShellEntry = imports.ui.shellEntry; -const Main = imports.ui.main; -const JsParse = imports.misc.jsParse; - -const { ExtensionState } = ExtensionUtils; +import * as History from '../misc/history.js'; +import {ExtensionState} from '../misc/extensionUtils.js'; +import * as PopupMenu from './popupMenu.js'; +import * as ShellEntry from './shellEntry.js'; +import * as Main from './main.js'; +import * as JsParse from '../misc/jsParse.js'; const CHEVRON = '>>> '; /* Imports...feel free to add here as needed */ const commandHeader = ` const {Clutter, Gio, GLib, GObject, Meta, Shell, St} = imports.gi; - const Main = await imports.ui.main; + const Main = await import('resource:///org/gnome/shell/ui/main.js'); /* Utility functions...we should probably be able to use these * in the shell core code too. */ @@ -43,9 +40,10 @@ const AsyncFunction = async function () {}.constructor; const HISTORY_KEY = 'looking-glass-history'; // Time between tabs for them to count as a double-tab event -var AUTO_COMPLETE_DOUBLE_TAB_DELAY = 500; -var AUTO_COMPLETE_SHOW_COMPLETION_ANIMATION_DURATION = 200; -var AUTO_COMPLETE_GLOBAL_KEYWORDS = _getAutoCompleteGlobalKeywords(); + +const AUTO_COMPLETE_DOUBLE_TAB_DELAY = 500; +const AUTO_COMPLETE_SHOW_COMPLETION_ANIMATION_DURATION = 200; +const AUTO_COMPLETE_GLOBAL_KEYWORDS = _getAutoCompleteGlobalKeywords(); const LG_ANIMATION_TIME = 500; @@ -68,7 +66,7 @@ function _getAutoCompleteGlobalKeywords() { return keywords.concat(windowProperties).concat(headerProperties); } -var AutoComplete = class AutoComplete extends Signals.EventEmitter { +class AutoComplete extends Signals.EventEmitter { constructor(entry) { super(); @@ -133,10 +131,9 @@ var AutoComplete = class AutoComplete extends Signals.EventEmitter { this._entry.clutter_text.insert_text(additionalCompletionText, cursorPos); } -}; +} - -var Notebook = GObject.registerClass({ +const Notebook = GObject.registerClass({ Signals: { 'selection': { param_types: [Clutter.Actor.$gtype] } }, }, class Notebook extends St.BoxLayout { _init() { @@ -282,7 +279,7 @@ function objectToString(o) { } } -var ObjLink = GObject.registerClass( +const ObjLink = GObject.registerClass( class ObjLink extends St.Button { _init(lookingGlass, o, title) { let text; @@ -310,7 +307,7 @@ class ObjLink extends St.Button { } }); -var Result = GObject.registerClass( +const Result = GObject.registerClass( class Result extends St.BoxLayout { _init(lookingGlass, command, o, index) { super._init({ vertical: true }); @@ -333,7 +330,7 @@ class Result extends St.BoxLayout { } }); -var WindowList = GObject.registerClass({ +const WindowList = GObject.registerClass({ }, class WindowList extends St.BoxLayout { _init(lookingGlass) { super._init({ name: 'Windows', vertical: true, style: 'spacing: 8px' }); @@ -386,7 +383,7 @@ var WindowList = GObject.registerClass({ } }); -var ObjInspector = GObject.registerClass( +const ObjInspector = GObject.registerClass( class ObjInspector extends St.ScrollView { _init(lookingGlass) { super._init({ @@ -525,7 +522,7 @@ class ObjInspector extends St.ScrollView { } }); -var RedBorderEffect = GObject.registerClass( +const RedBorderEffect = GObject.registerClass( class RedBorderEffect extends Clutter.Effect { _init() { super._init(); @@ -577,7 +574,7 @@ class RedBorderEffect extends Clutter.Effect { } }); -var Inspector = GObject.registerClass({ +const Inspector = GObject.registerClass({ Signals: { 'closed': {}, 'target': { param_types: [Clutter.Actor.$gtype, GObject.TYPE_DOUBLE, GObject.TYPE_DOUBLE] }, @@ -718,7 +715,7 @@ var Inspector = GObject.registerClass({ } }); -var Extensions = GObject.registerClass({ +const Extensions = GObject.registerClass({ }, class Extensions extends St.BoxLayout { _init(lookingGlass) { super._init({ vertical: true, name: 'lookingGlassExtensions' }); @@ -887,7 +884,7 @@ var Extensions = GObject.registerClass({ }); -var ActorLink = GObject.registerClass({ +const ActorLink = GObject.registerClass({ Signals: { 'inspect-actor': {}, }, @@ -940,7 +937,7 @@ var ActorLink = GObject.registerClass({ } }); -var ActorTreeViewer = GObject.registerClass( +const ActorTreeViewer = GObject.registerClass( class ActorTreeViewer extends St.BoxLayout { _init(lookingGlass) { super._init(); @@ -1067,7 +1064,7 @@ class ActorTreeViewer extends St.BoxLayout { } }); -var DebugFlag = GObject.registerClass({ +const DebugFlag = GObject.registerClass({ GTypeFlags: GObject.TypeFlags.ABSTRACT, }, class DebugFlag extends St.Button { _init(label) { @@ -1132,7 +1129,7 @@ var DebugFlag = GObject.registerClass({ }); -var ClutterDebugFlag = GObject.registerClass( +const ClutterDebugFlag = GObject.registerClass( class ClutterDebugFlag extends DebugFlag { _init(categoryName, flagName) { super._init(flagName); @@ -1161,7 +1158,7 @@ class ClutterDebugFlag extends DebugFlag { } }); -var MutterPaintDebugFlag = GObject.registerClass( +const MutterPaintDebugFlag = GObject.registerClass( class MutterPaintDebugFlag extends DebugFlag { _init(flagName) { super._init(flagName); @@ -1182,7 +1179,7 @@ class MutterPaintDebugFlag extends DebugFlag { } }); -var MutterTopicDebugFlag = GObject.registerClass( +const MutterTopicDebugFlag = GObject.registerClass( class MutterTopicDebugFlag extends DebugFlag { _init(flagName) { super._init(flagName); @@ -1203,7 +1200,7 @@ class MutterTopicDebugFlag extends DebugFlag { } }); -var UnsafeModeDebugFlag = GObject.registerClass( +const UnsafeModeDebugFlag = GObject.registerClass( class UnsafeModeDebugFlag extends DebugFlag { _init() { super._init('unsafe-mode'); @@ -1222,7 +1219,7 @@ class UnsafeModeDebugFlag extends DebugFlag { } }); -var DebugFlags = GObject.registerClass( +const DebugFlags = GObject.registerClass( class DebugFlags extends St.BoxLayout { _init() { super._init({ @@ -1279,7 +1276,7 @@ class DebugFlags extends St.BoxLayout { }); -var LookingGlass = GObject.registerClass( +export const LookingGlass = GObject.registerClass( class LookingGlass extends St.BoxLayout { _init() { super._init({ diff --git a/js/ui/magnifier.js b/js/ui/magnifier.js index 9a5a7cdce..985c703fd 100644 --- a/js/ui/magnifier.js +++ b/js/ui/magnifier.js @@ -1,27 +1,26 @@ // -*- mode: js; js-indent-level: 4; indent-tabs-mode: nil -*- -/* exported Magnifier */ -const Atspi = imports.gi.Atspi; -const Clutter = imports.gi.Clutter; -const GDesktopEnums = imports.gi.GDesktopEnums; -const Gio = imports.gi.Gio; -const GLib = imports.gi.GLib; -const GObject = imports.gi.GObject; -const Meta = imports.gi.Meta; -const Shell = imports.gi.Shell; -const St = imports.gi.St; -const Signals = imports.misc.signals; +import Atspi from 'gi://Atspi'; +import Clutter from 'gi://Clutter'; +import GDesktopEnums from 'gi://GDesktopEnums'; +import Gio from 'gi://Gio'; +import GLib from 'gi://GLib'; +import GObject from 'gi://GObject'; +import Meta from 'gi://Meta'; +import Shell from 'gi://Shell'; +import St from 'gi://St'; +import * as Signals from '../misc/signals.js'; -const Background = imports.ui.background; -const FocusCaretTracker = imports.ui.focusCaretTracker; -const Main = imports.ui.main; -const Params = imports.misc.params; -const PointerWatcher = imports.ui.pointerWatcher; +import * as Background from './background.js'; +import * as FocusCaretTracker from './focusCaretTracker.js'; +import * as Main from './main.js'; +import * as Params from '../misc/params.js'; +import * as PointerWatcher from './pointerWatcher.js'; -var CROSSHAIRS_CLIP_SIZE = [100, 100]; -var NO_CHANGE = 0.0; +const CROSSHAIRS_CLIP_SIZE = [100, 100]; +const NO_CHANGE = 0.0; -var POINTER_REST_TIME = 1000; // milliseconds +const POINTER_REST_TIME = 1000; // milliseconds // Settings const MAGNIFIER_SCHEMA = 'org.gnome.desktop.a11y.magnifier'; @@ -47,7 +46,7 @@ const CROSS_HAIRS_OPACITY_KEY = 'cross-hairs-opacity'; const CROSS_HAIRS_LENGTH_KEY = 'cross-hairs-length'; const CROSS_HAIRS_CLIP_KEY = 'cross-hairs-clip'; -var MouseSpriteContent = GObject.registerClass({ +const MouseSpriteContent = GObject.registerClass({ Implements: [Clutter.Content], }, class MouseSpriteContent extends GObject.Object { _init() { @@ -95,7 +94,7 @@ var MouseSpriteContent = GObject.registerClass({ } }); -var Magnifier = class Magnifier extends Signals.EventEmitter { +export class Magnifier extends Signals.EventEmitter { constructor() { super(); @@ -758,9 +757,9 @@ var Magnifier = class Magnifier extends Signals.EventEmitter { this._zoomRegions[0].setContrast(contrast); } } -}; +} -var ZoomRegion = class ZoomRegion { +class ZoomRegion { constructor(magnifier, mouseSourceActor) { this._magnifier = magnifier; this._focusCaretTracker = new FocusCaretTracker.FocusCaretTracker(); @@ -1822,7 +1821,7 @@ var ZoomRegion = class ZoomRegion { } } -var Crosshairs = GObject.registerClass( +const Crosshairs = GObject.registerClass( class Crosshairs extends Clutter.Actor { _init() { // Set the group containing the crosshairs to three times the desktop diff --git a/js/ui/main.js b/js/ui/main.js index 866811b18..011b77bb5 100644 --- a/js/ui/main.js +++ b/js/ui/main.js @@ -1,61 +1,52 @@ // -*- mode: js; js-indent-level: 4; indent-tabs-mode: nil -*- -/* exported componentManager, notificationDaemon, windowAttentionHandler, - ctrlAltTabManager, padOsdService, osdWindowManager, - osdMonitorLabeler, shellMountOpDBusService, shellDBusService, - shellAccessDialogDBusService, shellAudioSelectionDBusService, - screenSaverDBus, uiGroup, magnifier, xdndHandler, keyboard, - kbdA11yDialog, introspectService, start, pushModal, popModal, - activateWindow, moveWindowToMonitorAndWorkspace, - createLookingGlass, initializeDeferredWork, - getStyleVariant, getThemeStylesheet, setThemeStylesheet, screenshotUI */ -const Clutter = imports.gi.Clutter; -const Gio = imports.gi.Gio; -const GLib = imports.gi.GLib; -const GObject = imports.gi.GObject; -const Meta = imports.gi.Meta; -const Shell = imports.gi.Shell; -const St = imports.gi.St; +import Clutter from 'gi://Clutter'; +import Gio from 'gi://Gio'; +import GLib from 'gi://GLib'; +import GObject from 'gi://GObject'; +import Meta from 'gi://Meta'; +import Shell from 'gi://Shell'; +import St from 'gi://St'; -const AccessDialog = imports.ui.accessDialog; -const AudioDeviceSelection = imports.ui.audioDeviceSelection; -const Components = imports.ui.components; -const CtrlAltTab = imports.ui.ctrlAltTab; -const EndSessionDialog = imports.ui.endSessionDialog; -const ExtensionSystem = imports.ui.extensionSystem; -const ExtensionDownloader = imports.ui.extensionDownloader; -const InputMethod = imports.misc.inputMethod; -const Introspect = imports.misc.introspect; -const Keyboard = imports.ui.keyboard; -const MessageTray = imports.ui.messageTray; -const ModalDialog = imports.ui.modalDialog; -const OsdWindow = imports.ui.osdWindow; -const OsdMonitorLabeler = imports.ui.osdMonitorLabeler; -const Overview = imports.ui.overview; -const PadOsd = imports.ui.padOsd; -const Panel = imports.ui.panel; -const Params = imports.misc.params; -const RunDialog = imports.ui.runDialog; -const WelcomeDialog = imports.ui.welcomeDialog; -const Layout = imports.ui.layout; -const LoginManager = imports.misc.loginManager; -const LookingGlass = imports.ui.lookingGlass; -const NotificationDaemon = imports.ui.notificationDaemon; -const WindowAttentionHandler = imports.ui.windowAttentionHandler; -const Screenshot = imports.ui.screenshot; -const ScreenShield = imports.ui.screenShield; -const SessionMode = imports.ui.sessionMode; -const ShellDBus = imports.ui.shellDBus; -const ShellMountOperation = imports.ui.shellMountOperation; -const WindowManager = imports.ui.windowManager; -const Magnifier = imports.ui.magnifier; -const XdndHandler = imports.ui.xdndHandler; -const KbdA11yDialog = imports.ui.kbdA11yDialog; -const LocatePointer = imports.ui.locatePointer; -const PointerA11yTimeout = imports.ui.pointerA11yTimeout; -const ParentalControlsManager = imports.misc.parentalControlsManager; +import * as AccessDialog from './accessDialog.js'; +import * as AudioDeviceSelection from './audioDeviceSelection.js'; +import * as Components from './components.js'; +import * as CtrlAltTab from './ctrlAltTab.js'; +import * as EndSessionDialog from './endSessionDialog.js'; +import * as ExtensionSystem from './extensionSystem.js'; +import * as ExtensionDownloader from './extensionDownloader.js'; +import * as InputMethod from '../misc/inputMethod.js'; +import * as Introspect from '../misc/introspect.js'; +import * as Keyboard from './keyboard.js'; +import * as MessageTray from './messageTray.js'; +import * as ModalDialog from './modalDialog.js'; +import * as OsdWindow from './osdWindow.js'; +import * as OsdMonitorLabeler from './osdMonitorLabeler.js'; +import * as Overview from './overview.js'; +import * as PadOsd from './padOsd.js'; +import * as Panel from './panel.js'; +import * as Params from '../misc/params.js'; +import * as RunDialog from './runDialog.js'; +import * as WelcomeDialog from './welcomeDialog.js'; +import * as Layout from './layout.js'; +import * as LoginManager from '../misc/loginManager.js'; +import * as LookingGlass from './lookingGlass.js'; +import * as NotificationDaemon from './notificationDaemon.js'; +import * as WindowAttentionHandler from './windowAttentionHandler.js'; +import * as Screenshot from './screenshot.js'; +import * as ScreenShield from './screenShield.js'; +import * as SessionMode from './sessionMode.js'; +import * as ShellDBus from './shellDBus.js'; +import * as ShellMountOperation from './shellMountOperation.js'; +import * as WindowManager from './windowManager.js'; +import * as Magnifier from './magnifier.js'; +import * as XdndHandler from './xdndHandler.js'; +import * as KbdA11yDialog from './kbdA11yDialog.js'; +import * as LocatePointer from './locatePointer.js'; +import * as PointerA11yTimeout from './pointerA11yTimeout.js'; +import * as ParentalControlsManager from '../misc/parentalControlsManager.js'; const Config = imports.misc.config; -const Util = imports.misc.util; +import * as Util from '../misc/util.js'; const WELCOME_DIALOG_LAST_SHOWN_VERSION = 'welcome-dialog-last-shown-version'; // Make sure to mention the point release, otherwise it will show every time @@ -64,41 +55,42 @@ const WELCOME_DIALOG_LAST_TOUR_CHANGE = '40.beta'; const LOG_DOMAIN = 'GNOME Shell'; const GNOMESHELL_STARTED_MESSAGE_ID = 'f3ea493c22934e26811cd62abe8e203a'; -var componentManager = null; -var extensionManager = null; -var panel = null; -var overview = null; -var runDialog = null; -var lookingGlass = null; -var welcomeDialog = null; -var wm = null; -var messageTray = null; -var screenShield = null; -var notificationDaemon = null; -var windowAttentionHandler = null; -var ctrlAltTabManager = null; -var padOsdService = null; -var osdWindowManager = null; -var osdMonitorLabeler = null; -var sessionMode = null; -var screenshotUI = null; -var shellAccessDialogDBusService = null; -var shellAudioSelectionDBusService = null; -var shellDBusService = null; -var shellMountOpDBusService = null; -var screenSaverDBus = null; -var modalCount = 0; -var actionMode = Shell.ActionMode.NONE; -var modalActorFocusStack = []; -var uiGroup = null; -var magnifier = null; -var xdndHandler = null; -var keyboard = null; -var layoutManager = null; -var kbdA11yDialog = null; -var inputMethod = null; -var introspectService = null; -var locatePointer = null; +export let componentManager = null; +export let extensionManager = null; +export let panel = null; +export let overview = null; +export let runDialog = null; +export let lookingGlass = null; +export let welcomeDialog = null; +export let wm = null; +export let messageTray = null; +export let screenShield = null; +export let notificationDaemon = null; +export let windowAttentionHandler = null; +export let ctrlAltTabManager = null; +export let padOsdService = null; +export let osdWindowManager = null; +export let osdMonitorLabeler = null; +export let sessionMode = null; +export let screenshotUI = null; +export let shellAccessDialogDBusService = null; +export let shellAudioSelectionDBusService = null; +export let shellDBusService = null; +export let shellMountOpDBusService = null; +export let screenSaverDBus = null; +export let modalCount = 0; +export let actionMode = Shell.ActionMode.NONE; +export let modalActorFocusStack = []; +export let uiGroup = null; +export let magnifier = null; +export let xdndHandler = null; +export let keyboard = null; +export let layoutManager = null; +export let kbdA11yDialog = null; +export let inputMethod = null; +export let introspectService = null; +export let locatePointer = null; + let _startDate; let _defaultCssStylesheet = null; let _cssStylesheet = null; @@ -147,7 +139,7 @@ function _sessionUpdated() { } /** @returns {void} */ -async function start() { +export async function start() { globalThis.log = console.log; // Chain up async errors reported from C @@ -408,7 +400,7 @@ function _getStylesheet(name) { } /** @returns {string} */ -function getStyleVariant() { +export function getStyleVariant() { const {colorScheme} = St.Settings.get(); switch (sessionMode.colorScheme) { case 'force-dark': @@ -460,7 +452,7 @@ function _loadDefaultStylesheet() { * @returns {?Gio.File}: A #GFile that contains the theme CSS, * null if using the default */ -function getThemeStylesheet() { +export function getThemeStylesheet() { return _cssStylesheet; } @@ -471,11 +463,11 @@ function getThemeStylesheet() { * * Set the theme CSS file that the shell will load */ -function setThemeStylesheet(cssStylesheet) { +export function setThemeStylesheet(cssStylesheet) { _cssStylesheet = cssStylesheet ? Gio.File.new_for_path(cssStylesheet) : null; } -function reloadThemeResource() { +export function reloadThemeResource() { if (_themeResource) _themeResource._unregister(); @@ -500,7 +492,7 @@ function _loadOskLayouts() { * * Reloads the theme CSS file */ -function loadTheme() { +export function loadTheme() { let themeContext = St.ThemeContext.get_for_stage(global.stage); let previousTheme = themeContext.get_theme(); @@ -528,7 +520,7 @@ function loadTheme() { * @param {string} msg A message * @param {string} details Additional information */ -function notify(msg, details) { +export function notify(msg, details) { let source = new MessageTray.SystemNotificationSource(); messageTray.add(source); let notification = new MessageTray.Notification(source, msg, details); @@ -543,7 +535,7 @@ function notify(msg, details) { * * See shell_global_notify_problem(). */ -function notifyError(msg, details) { +export function notifyError(msg, details) { // Also print to stderr so it's logged somewhere if (details) console.warn(`error: ${msg}: ${details}`); @@ -597,7 +589,7 @@ function _findModal(grab) { * * @returns {Clutter.Grab}: the grab handle created */ -function pushModal(actor, params) { +export function pushModal(actor, params) { params = Params.parse(params, { timestamp: global.get_current_time(), options: 0, @@ -654,7 +646,7 @@ function pushModal(actor, params) { * initiated event. If not provided then the value of * global.get_current_time() is assumed. */ -function popModal(grab, timestamp) { +export function popModal(grab, timestamp) { if (timestamp == undefined) timestamp = global.get_current_time(); @@ -719,7 +711,7 @@ function popModal(grab, timestamp) { * * @returns {LookingGlass.LookingGlass} */ -function createLookingGlass() { +export function createLookingGlass() { if (lookingGlass == null) lookingGlass = new LookingGlass.LookingGlass(); @@ -729,14 +721,14 @@ function createLookingGlass() { /** * Opens the run dialog */ -function openRunDialog() { +export function openRunDialog() { if (runDialog == null) runDialog = new RunDialog.RunDialog(); runDialog.open(); } -function openWelcomeDialog() { +export function openWelcomeDialog() { if (welcomeDialog === null) welcomeDialog = new WelcomeDialog.WelcomeDialog(); @@ -753,7 +745,7 @@ function openWelcomeDialog() { * Activates @window, switching to its workspace first if necessary, * and switching out of the overview if it's currently active */ -function activateWindow(window, time, workspaceNum) { +export function activateWindow(window, time, workspaceNum) { let workspaceManager = global.workspace_manager; let activeWorkspaceNum = workspaceManager.get_active_workspace_index(); let windowWorkspaceNum = workspaceNum !== undefined ? workspaceNum : window.get_workspace().index(); @@ -780,7 +772,7 @@ function activateWindow(window, time, workspaceNum) { * @param {number} workspaceIndex - the requested workspace * @param {bool} append - create workspace if it doesn't exist */ -function moveWindowToMonitorAndWorkspace(window, monitorIndex, workspaceIndex, append = false) { +export function moveWindowToMonitorAndWorkspace(window, monitorIndex, workspaceIndex, append = false) { // We need to move the window before changing the workspace, because // the move itself could cause a workspace change if the window enters // the primary monitor @@ -801,15 +793,15 @@ function moveWindowToMonitorAndWorkspace(window, monitorIndex, workspaceIndex, a // TODO - replace this timeout with some system to guess when the user might // be e.g. just reading the screen and not likely to interact. -var DEFERRED_TIMEOUT_SECONDS = 20; -var _deferredWorkData = {}; +const DEFERRED_TIMEOUT_SECONDS = 20; +let _deferredWorkData = {}; // Work scheduled for some point in the future -var _deferredWorkQueue = []; +let _deferredWorkQueue = []; // Work we need to process before the next redraw -var _beforeRedrawQueue = []; +let _beforeRedrawQueue = []; // Counter to assign work ids -var _deferredWorkSequence = 0; -var _deferredTimeoutId = 0; +let _deferredWorkSequence = 0; +let _deferredTimeoutId = 0; function _runDeferredWork(workId) { if (!_deferredWorkData[workId]) @@ -868,7 +860,7 @@ function _queueBeforeRedraw(workId) { * * @returns {string}: A string work identifier */ -function initializeDeferredWork(actor, callback) { +export function initializeDeferredWork(actor, callback) { // Turn into a string so we can use as an object property let workId = `${++_deferredWorkSequence}`; _deferredWorkData[workId] = { @@ -900,7 +892,7 @@ function initializeDeferredWork(actor, callback) { * for example when data being displayed by the actor has * changed. */ -function queueDeferredWork(workId) { +export function queueDeferredWork(workId) { let data = _deferredWorkData[workId]; if (!data) { let message = `Invalid work id ${workId}`; @@ -921,7 +913,7 @@ function queueDeferredWork(workId) { } } -var RestartMessage = GObject.registerClass( +const RestartMessage = GObject.registerClass( class RestartMessage extends ModalDialog.ModalDialog { _init(message) { super._init({ @@ -947,7 +939,7 @@ function showRestartMessage(message) { restartMessage.open(); } -var AnimationsSettings = class { +class AnimationsSettings { constructor() { this._animationsEnabled = true; this._handles = new Set(); @@ -1008,4 +1000,4 @@ var AnimationsSettings = class { this._syncAnimationsEnabled(); handle.connect('stopped', this._onRemoteAccessHandleStopped.bind(this)); } -}; +} diff --git a/js/ui/messageList.js b/js/ui/messageList.js index a09cdc10d..157067616 100644 --- a/js/ui/messageList.js +++ b/js/ui/messageList.js @@ -1,28 +1,28 @@ -/* exported MessageListSection */ -const Atk = imports.gi.Atk; -const Clutter = imports.gi.Clutter; -const Gio = imports.gi.Gio; -const GLib = imports.gi.GLib; -const GObject = imports.gi.GObject; -const Graphene = imports.gi.Graphene; -const Meta = imports.gi.Meta; -const Pango = imports.gi.Pango; -const St = imports.gi.St; -const Main = imports.ui.main; -const MessageTray = imports.ui.messageTray; +import Atk from 'gi://Atk'; +import Clutter from 'gi://Clutter'; +import Gio from 'gi://Gio'; +import GLib from 'gi://GLib'; +import GObject from 'gi://GObject'; +import Graphene from 'gi://Graphene'; +import Meta from 'gi://Meta'; +import Pango from 'gi://Pango'; +import St from 'gi://St'; -const Util = imports.misc.util; +import * as Main from './main.js'; +import * as MessageTray from './messageTray.js'; -var MESSAGE_ANIMATION_TIME = 100; +import * as Util from '../misc/util.js'; -var DEFAULT_EXPAND_LINES = 6; +const MESSAGE_ANIMATION_TIME = 100; + +const DEFAULT_EXPAND_LINES = 6; /** * @param {string} text * @param {boolean} allowMarkup * @returns {string} */ -function _fixMarkup(text, allowMarkup) { +export function _fixMarkup(text, allowMarkup) { if (allowMarkup) { // Support &, ", ', < and >, escape all other // occurrences of '&'. @@ -43,7 +43,7 @@ function _fixMarkup(text, allowMarkup) { return GLib.markup_escape_text(text, -1); } -var URLHighlighter = GObject.registerClass( +export const URLHighlighter = GObject.registerClass( class URLHighlighter extends St.Label { _init(text = '', lineWrap, allowMarkup) { super._init({ @@ -171,7 +171,7 @@ class URLHighlighter extends St.Label { } }); -var ScaleLayout = GObject.registerClass( +const ScaleLayout = GObject.registerClass( class ScaleLayout extends Clutter.BinLayout { _init(params) { this._container = null; @@ -214,7 +214,7 @@ class ScaleLayout extends Clutter.BinLayout { } }); -var LabelExpanderLayout = GObject.registerClass({ +const LabelExpanderLayout = GObject.registerClass({ Properties: { 'expansion': GObject.ParamSpec.double('expansion', 'Expansion', @@ -308,7 +308,7 @@ var LabelExpanderLayout = GObject.registerClass({ }); -var Message = GObject.registerClass({ +export const Message = GObject.registerClass({ Signals: { 'close': {}, 'expanded': {}, @@ -555,7 +555,7 @@ var Message = GObject.registerClass({ } }); -var MessageListSection = GObject.registerClass({ +export const MessageListSection = GObject.registerClass({ Properties: { 'can-clear': GObject.ParamSpec.boolean( 'can-clear', 'can-clear', 'can-clear', diff --git a/js/ui/messageTray.js b/js/ui/messageTray.js index a18ca2234..f333dcb13 100644 --- a/js/ui/messageTray.js +++ b/js/ui/messageTray.js @@ -1,42 +1,40 @@ // -*- mode: js; js-indent-level: 4; indent-tabs-mode: nil -*- -/* exported NotificationPolicy, NotificationGenericPolicy, - NotificationApplicationPolicy, Source, SourceActor, - SystemNotificationSource, MessageTray */ -const Clutter = imports.gi.Clutter; -const Gio = imports.gi.Gio; -const GLib = imports.gi.GLib; -const GObject = imports.gi.GObject; -const Meta = imports.gi.Meta; -const Shell = imports.gi.Shell; -const St = imports.gi.St; +import Clutter from 'gi://Clutter'; +import Gio from 'gi://Gio'; +import GLib from 'gi://GLib'; +import GObject from 'gi://GObject'; +import Meta from 'gi://Meta'; +import Shell from 'gi://Shell'; +import St from 'gi://St'; -const Calendar = imports.ui.calendar; -const GnomeSession = imports.misc.gnomeSession; -const Layout = imports.ui.layout; -const Main = imports.ui.main; -const Params = imports.misc.params; -const SignalTracker = imports.misc.signalTracker; +import * as Calendar from './calendar.js'; +import * as GnomeSession from '../misc/gnomeSession.js'; +import * as Layout from './layout.js'; +import * as Main from './main.js'; +import * as Params from '../misc/params.js'; +import * as SignalTracker from '../misc/signalTracker.js'; const SHELL_KEYBINDINGS_SCHEMA = 'org.gnome.shell.keybindings'; -var ANIMATION_TIME = 200; -var NOTIFICATION_TIMEOUT = 4000; +export const ANIMATION_TIME = 200; -var HIDE_TIMEOUT = 200; -var LONGER_HIDE_TIMEOUT = 600; +const NOTIFICATION_TIMEOUT = 4000; -var MAX_NOTIFICATIONS_IN_QUEUE = 3; -var MAX_NOTIFICATIONS_PER_SOURCE = 3; -var MAX_NOTIFICATION_BUTTONS = 3; +const HIDE_TIMEOUT = 200; +const LONGER_HIDE_TIMEOUT = 600; + +const MAX_NOTIFICATIONS_IN_QUEUE = 3; +const MAX_NOTIFICATIONS_PER_SOURCE = 3; +const MAX_NOTIFICATION_BUTTONS = 3; // We delay hiding of the tray if the mouse is within MOUSE_LEFT_ACTOR_THRESHOLD // range from the point where it left the tray. -var MOUSE_LEFT_ACTOR_THRESHOLD = 20; +const MOUSE_LEFT_ACTOR_THRESHOLD = 20; -var IDLE_TIME = 1000; +const IDLE_TIME = 1000; -var State = { +export const State = { HIDDEN: 0, SHOWING: 1, SHOWN: 2, @@ -51,7 +49,7 @@ var State = { // and REPLACED for notifications that were destroyed as a consequence of a // newer version having replaced them. /** @enum {number} */ -var NotificationDestroyedReason = { +export const NotificationDestroyedReason = { EXPIRED: 1, DISMISSED: 2, SOURCE_CLOSED: 3, @@ -63,7 +61,7 @@ var NotificationDestroyedReason = { // through the notification daemon. HIGH urgency value is used for chats received // through the Telepathy client. /** @enum {number} */ -var Urgency = { +export const Urgency = { LOW: 0, NORMAL: 1, HIGH: 2, @@ -77,12 +75,12 @@ var Urgency = { // status) and hence the same for every user. This affects whether the content // of a notification is shown on the lock screen. /** @enum {number} */ -var PrivacyScope = { +export const PrivacyScope = { USER: 0, SYSTEM: 1, }; -var FocusGrabber = class FocusGrabber { +class FocusGrabber { constructor(actor) { this._actor = actor; this._prevKeyFocusActor = null; @@ -133,14 +131,14 @@ var FocusGrabber = class FocusGrabber { global.stage.set_key_focus(null); } } -}; +} // NotificationPolicy: // An object that holds all bits of configurable policy related to a notification // source, such as whether to play sound or honour the critical bit. // // A notification without a policy object will inherit the default one. -var NotificationPolicy = GObject.registerClass({ +export const NotificationPolicy = GObject.registerClass({ GTypeFlags: GObject.TypeFlags.ABSTRACT, Properties: { 'enable': GObject.ParamSpec.boolean( @@ -195,7 +193,7 @@ var NotificationPolicy = GObject.registerClass({ } }); -var NotificationGenericPolicy = GObject.registerClass({ +export const NotificationGenericPolicy = GObject.registerClass({ }, class NotificationGenericPolicy extends NotificationPolicy { _init() { super._init(); @@ -225,7 +223,7 @@ var NotificationGenericPolicy = GObject.registerClass({ } }); -var NotificationApplicationPolicy = GObject.registerClass({ +export const NotificationApplicationPolicy = GObject.registerClass({ }, class NotificationApplicationPolicy extends NotificationPolicy { _init(id) { super._init(); @@ -353,7 +351,7 @@ var NotificationApplicationPolicy = GObject.registerClass({ // @source allows playing sounds). // // [1] https://developer.gnome.org/notification-spec/#markup -var Notification = GObject.registerClass({ +export const Notification = GObject.registerClass({ Properties: { 'acknowledged': GObject.ParamSpec.boolean( 'acknowledged', 'acknowledged', 'acknowledged', @@ -505,7 +503,7 @@ var Notification = GObject.registerClass({ }); SignalTracker.registerDestroyableType(Notification); -var NotificationBanner = GObject.registerClass({ +export const NotificationBanner = GObject.registerClass({ Signals: { 'done-displaying': {}, 'unfocused': {}, @@ -602,7 +600,7 @@ var NotificationBanner = GObject.registerClass({ } }); -var SourceActor = GObject.registerClass( +export const SourceActor = GObject.registerClass( class SourceActor extends St.Widget { _init(source, size) { super._init(); @@ -642,7 +640,7 @@ class SourceActor extends St.Widget { } }); -var Source = GObject.registerClass({ +export const Source = GObject.registerClass({ Properties: { 'count': GObject.ParamSpec.int( 'count', 'count', 'count', @@ -808,7 +806,7 @@ var Source = GObject.registerClass({ }); SignalTracker.registerDestroyableType(Source); -var MessageTray = GObject.registerClass({ +export const MessageTray = GObject.registerClass({ Signals: { 'queue-changed': {}, 'source-added': { param_types: [Source.$gtype] }, @@ -1420,7 +1418,7 @@ var MessageTray = GObject.registerClass({ } }); -var SystemNotificationSource = GObject.registerClass( +export const SystemNotificationSource = GObject.registerClass( class SystemNotificationSource extends Source { _init() { super._init(_("System Information"), 'dialog-information-symbolic'); diff --git a/js/ui/modalDialog.js b/js/ui/modalDialog.js index 17d189175..18e1f34e7 100644 --- a/js/ui/modalDialog.js +++ b/js/ui/modalDialog.js @@ -1,23 +1,22 @@ // -*- mode: js; js-indent-level: 4; indent-tabs-mode: nil -*- -/* exported ModalDialog */ -const Atk = imports.gi.Atk; -const Clutter = imports.gi.Clutter; -const GObject = imports.gi.GObject; -const Shell = imports.gi.Shell; -const St = imports.gi.St; +import Atk from 'gi://Atk'; +import Clutter from 'gi://Clutter'; +import GObject from 'gi://GObject'; +import Shell from 'gi://Shell'; +import St from 'gi://St'; -const Dialog = imports.ui.dialog; -const Layout = imports.ui.layout; -const Lightbox = imports.ui.lightbox; -const Main = imports.ui.main; -const Params = imports.misc.params; +import * as Dialog from './dialog.js'; +import * as Layout from './layout.js'; +import * as Lightbox from './lightbox.js'; +import * as Main from './main.js'; +import * as Params from '../misc/params.js'; -var OPEN_AND_CLOSE_TIME = 100; -var FADE_OUT_DIALOG_TIME = 1000; +const OPEN_AND_CLOSE_TIME = 100; +const FADE_OUT_DIALOG_TIME = 1000; /** @enum {number} */ -var State = { +export const State = { OPENED: 0, CLOSED: 1, OPENING: 2, @@ -25,7 +24,7 @@ var State = { FADED_OUT: 4, }; -var ModalDialog = GObject.registerClass({ +export const ModalDialog = GObject.registerClass({ Properties: { 'state': GObject.ParamSpec.int('state', 'Dialog state', 'state', GObject.ParamFlags.READABLE, diff --git a/js/ui/mpris.js b/js/ui/mpris.js index 5d1a4f275..d6faab33b 100644 --- a/js/ui/mpris.js +++ b/js/ui/mpris.js @@ -1,14 +1,13 @@ -/* exported MediaSection */ -const Gio = imports.gi.Gio; -const GObject = imports.gi.GObject; -const Shell = imports.gi.Shell; -const St = imports.gi.St; -const Signals = imports.misc.signals; +import Gio from 'gi://Gio'; +import GObject from 'gi://GObject'; +import Shell from 'gi://Shell'; +import St from 'gi://St'; +import * as Signals from '../misc/signals.js'; -const Main = imports.ui.main; -const MessageList = imports.ui.messageList; +import * as Main from './main.js'; +import * as MessageList from './messageList.js'; -const { loadInterfaceXML } = imports.misc.fileUtils; +import {loadInterfaceXML} from '../misc/fileUtils.js'; const DBusIface = loadInterfaceXML('org.freedesktop.DBus'); const DBusProxy = Gio.DBusProxy.makeProxyWrapper(DBusIface); @@ -21,7 +20,7 @@ const MprisPlayerProxy = Gio.DBusProxy.makeProxyWrapper(MprisPlayerIface); const MPRIS_PLAYER_PREFIX = 'org.mpris.MediaPlayer2.'; -var MediaMessage = GObject.registerClass( +export const MediaMessage = GObject.registerClass( class MediaMessage extends MessageList.Message { _init(player) { super._init('', ''); @@ -92,7 +91,7 @@ class MediaMessage extends MessageList.Message { } }); -var MprisPlayer = class MprisPlayer extends Signals.EventEmitter { +export class MprisPlayer extends Signals.EventEmitter { constructor(busName) { super(); @@ -245,9 +244,9 @@ var MprisPlayer = class MprisPlayer extends Signals.EventEmitter { this.emit('hide'); } } -}; +} -var MediaSection = GObject.registerClass( +export const MediaSection = GObject.registerClass( class MediaSection extends MessageList.MessageListSection { _init() { super._init(); diff --git a/js/ui/notificationDaemon.js b/js/ui/notificationDaemon.js index 253ef2c79..68ac455b9 100644 --- a/js/ui/notificationDaemon.js +++ b/js/ui/notificationDaemon.js @@ -1,24 +1,23 @@ // -*- mode: js; js-indent-level: 4; indent-tabs-mode: nil -*- -/* exported NotificationDaemon */ -const GdkPixbuf = imports.gi.GdkPixbuf; -const Gio = imports.gi.Gio; -const GLib = imports.gi.GLib; -const GObject = imports.gi.GObject; -const Shell = imports.gi.Shell; -const St = imports.gi.St; +import GdkPixbuf from 'gi://GdkPixbuf'; +import Gio from 'gi://Gio'; +import GLib from 'gi://GLib'; +import GObject from 'gi://GObject'; +import Shell from 'gi://Shell'; +import St from 'gi://St'; const Config = imports.misc.config; -const Main = imports.ui.main; -const MessageTray = imports.ui.messageTray; -const Params = imports.misc.params; +import * as Main from './main.js'; +import * as MessageTray from './messageTray.js'; +import * as Params from '../misc/params.js'; -const { loadInterfaceXML } = imports.misc.fileUtils; +import {loadInterfaceXML} from '../misc/fileUtils.js'; const FdoNotificationsIface = loadInterfaceXML('org.freedesktop.Notifications'); /** @enum {number} */ -var NotificationClosedReason = { +const NotificationClosedReason = { EXPIRED: 1, DISMISSED: 2, APP_CLOSED: 3, @@ -26,13 +25,13 @@ var NotificationClosedReason = { }; /** @enum {number} */ -var Urgency = { +const Urgency = { LOW: 0, NORMAL: 1, CRITICAL: 2, }; -var FdoNotificationDaemon = class FdoNotificationDaemon { +class FdoNotificationDaemon { constructor() { this._dbusImpl = Gio.DBusExportedObject.wrapJSObject(FdoNotificationsIface, this); this._dbusImpl.export(Gio.DBus.session, '/org/freedesktop/Notifications'); @@ -337,9 +336,9 @@ var FdoNotificationDaemon = class FdoNotificationDaemon { this._dbusImpl.emit_signal('ActionInvoked', GLib.Variant.new('(us)', [id, action])); } -}; +} -var FdoNotificationDaemonSource = GObject.registerClass( +const FdoNotificationDaemonSource = GObject.registerClass( class FdoNotificationDaemonSource extends MessageTray.Source { _init(title, pid, sender, appId) { this.pid = pid; @@ -465,7 +464,7 @@ const PRIORITY_URGENCY_MAP = { urgent: MessageTray.Urgency.CRITICAL, }; -var GtkNotificationDaemonNotification = GObject.registerClass( +const GtkNotificationDaemonNotification = GObject.registerClass( class GtkNotificationDaemonNotification extends MessageTray.Notification { _init(source, notification) { super._init(source); @@ -556,7 +555,7 @@ function getPlatformData() { function InvalidAppError() {} -var GtkNotificationDaemonAppSource = GObject.registerClass( +const GtkNotificationDaemonAppSource = GObject.registerClass( class GtkNotificationDaemonAppSource extends MessageTray.Source { _init(appId) { let objectPath = objectPathFromAppId(appId); @@ -667,7 +666,7 @@ class GtkNotificationDaemonAppSource extends MessageTray.Source { const GtkNotificationsIface = loadInterfaceXML('org.gtk.Notifications'); -var GtkNotificationDaemon = class GtkNotificationDaemon { +class GtkNotificationDaemon { constructor() { this._sources = {}; @@ -771,11 +770,11 @@ var GtkNotificationDaemon = class GtkNotificationDaemon { invocation.return_value(null); } -}; +} -var NotificationDaemon = class NotificationDaemon { +export class NotificationDaemon { constructor() { this._fdoNotificationDaemon = new FdoNotificationDaemon(); this._gtkNotificationDaemon = new GtkNotificationDaemon(); } -}; +} diff --git a/js/ui/osdMonitorLabeler.js b/js/ui/osdMonitorLabeler.js index 8f4e53b46..9f2a9b27c 100644 --- a/js/ui/osdMonitorLabeler.js +++ b/js/ui/osdMonitorLabeler.js @@ -1,15 +1,15 @@ // -*- mode: js; js-indent-level: 4; indent-tabs-mode: nil -*- -/* exported OsdMonitorLabeler */ -const Clutter = imports.gi.Clutter; -const Gio = imports.gi.Gio; -const GObject = imports.gi.GObject; -const Meta = imports.gi.Meta; -const St = imports.gi.St; +import Clutter from 'gi://Clutter'; +import Gio from 'gi://Gio'; +import GObject from 'gi://GObject'; +import Meta from 'gi://Meta'; +import St from 'gi://St'; -const Main = imports.ui.main; -var OsdMonitorLabel = GObject.registerClass( +import * as Main from './main.js'; + +const OsdMonitorLabel = GObject.registerClass( class OsdMonitorLabel extends St.Widget { _init(monitor, label) { super._init({ x_expand: true, y_expand: true }); @@ -49,7 +49,7 @@ class OsdMonitorLabel extends St.Widget { } }); -var OsdMonitorLabeler = class { +export class OsdMonitorLabeler { constructor() { this._monitorManager = global.backend.get_monitor_manager(); this._client = null; @@ -118,4 +118,4 @@ var OsdMonitorLabeler = class { this._reset(); } -}; +} diff --git a/js/ui/osdWindow.js b/js/ui/osdWindow.js index 3891325ca..bfd8022a4 100644 --- a/js/ui/osdWindow.js +++ b/js/ui/osdWindow.js @@ -1,21 +1,20 @@ // -*- mode: js; js-indent-level: 4; indent-tabs-mode: nil -*- -/* exported OsdWindowManager */ -const Clutter = imports.gi.Clutter; -const GLib = imports.gi.GLib; -const GObject = imports.gi.GObject; -const Meta = imports.gi.Meta; -const St = imports.gi.St; +import Clutter from 'gi://Clutter'; +import GLib from 'gi://GLib'; +import GObject from 'gi://GObject'; +import Meta from 'gi://Meta'; +import St from 'gi://St'; -const BarLevel = imports.ui.barLevel; -const Layout = imports.ui.layout; -const Main = imports.ui.main; +import * as BarLevel from './barLevel.js'; +import * as Layout from './layout.js'; +import * as Main from './main.js'; -var HIDE_TIMEOUT = 1500; -var FADE_TIME = 100; -var LEVEL_ANIMATION_TIME = 100; +const HIDE_TIMEOUT = 1500; +const FADE_TIME = 100; +const LEVEL_ANIMATION_TIME = 100; -var OsdWindow = GObject.registerClass( +export const OsdWindow = GObject.registerClass( class OsdWindow extends Clutter.Actor { _init(monitorIndex) { super._init({ @@ -145,7 +144,7 @@ class OsdWindow extends Clutter.Actor { } }); -var OsdWindowManager = class { +export class OsdWindowManager { constructor() { this._osdWindows = []; Main.layoutManager.connect('monitors-changed', @@ -193,4 +192,4 @@ var OsdWindowManager = class { for (let i = 0; i < this._osdWindows.length; i++) this._osdWindows[i].cancel(); } -}; +} diff --git a/js/ui/overview.js b/js/ui/overview.js index f0fd2b9d6..444629ba2 100644 --- a/js/ui/overview.js +++ b/js/ui/overview.js @@ -1,34 +1,33 @@ // -*- mode: js; js-indent-level: 4; indent-tabs-mode: nil -*- -/* exported Overview, ANIMATION_TIME */ -const Clutter = imports.gi.Clutter; -const Gio = imports.gi.Gio; -const GLib = imports.gi.GLib; -const GObject = imports.gi.GObject; -const Meta = imports.gi.Meta; -const Shell = imports.gi.Shell; -const St = imports.gi.St; -const Signals = imports.misc.signals; +import Clutter from 'gi://Clutter'; +import Gio from 'gi://Gio'; +import GLib from 'gi://GLib'; +import GObject from 'gi://GObject'; +import Meta from 'gi://Meta'; +import Shell from 'gi://Shell'; +import St from 'gi://St'; +import * as Signals from '../misc/signals.js'; // Time for initial animation going into Overview mode; // this is defined here to make it available in imports. -var ANIMATION_TIME = 250; +export const ANIMATION_TIME = 250; -const DND = imports.ui.dnd; -const LayoutManager = imports.ui.layout; -const Main = imports.ui.main; -const MessageTray = imports.ui.messageTray; -const OverviewControls = imports.ui.overviewControls; -const Params = imports.misc.params; -const SwipeTracker = imports.ui.swipeTracker; -const WindowManager = imports.ui.windowManager; -const WorkspaceThumbnail = imports.ui.workspaceThumbnail; +import * as DND from './dnd.js'; +import * as LayoutManager from './layout.js'; +import * as Main from './main.js'; +import * as MessageTray from './messageTray.js'; +import * as OverviewControls from './overviewControls.js'; +import * as Params from '../misc/params.js'; +import * as SwipeTracker from './swipeTracker.js'; +import * as WindowManager from './windowManager.js'; +import * as WorkspaceThumbnail from './workspaceThumbnail.js'; -var DND_WINDOW_SWITCH_TIMEOUT = 750; +const DND_WINDOW_SWITCH_TIMEOUT = 750; -var OVERVIEW_ACTIVATION_TIMEOUT = 0.5; +const OVERVIEW_ACTIVATION_TIMEOUT = 0.5; -var ShellInfo = class { +class ShellInfo { constructor() { this._source = null; } @@ -65,9 +64,9 @@ var ShellInfo = class { this._source.showNotification(notification); } -}; +} -var OverviewActor = GObject.registerClass( +const OverviewActor = GObject.registerClass( class OverviewActor extends St.BoxLayout { _init() { super._init({ @@ -149,7 +148,7 @@ const OVERVIEW_SHOWN_TRANSITIONS = { }, }; -var Overview = class extends Signals.EventEmitter { +export class Overview extends Signals.EventEmitter { constructor() { super(); @@ -725,4 +724,4 @@ var Overview = class extends Signals.EventEmitter { get searchEntry() { return this._overview.searchEntry; } -}; +} diff --git a/js/ui/overviewControls.js b/js/ui/overviewControls.js index 68e59b794..d1021eef9 100644 --- a/js/ui/overviewControls.js +++ b/js/ui/overviewControls.js @@ -1,40 +1,39 @@ // -*- mode: js; js-indent-level: 4; indent-tabs-mode: nil -*- -/* exported ControlsManager */ -const Clutter = imports.gi.Clutter; -const Gio = imports.gi.Gio; -const GLib = imports.gi.GLib; -const GObject = imports.gi.GObject; -const Meta = imports.gi.Meta; -const Shell = imports.gi.Shell; -const St = imports.gi.St; +import GLib from 'gi://GLib'; +import Clutter from 'gi://Clutter'; +import Gio from 'gi://Gio'; +import GObject from 'gi://GObject'; +import Meta from 'gi://Meta'; +import Shell from 'gi://Shell'; +import St from 'gi://St'; -const AppDisplay = imports.ui.appDisplay; -const Dash = imports.ui.dash; -const Layout = imports.ui.layout; -const Main = imports.ui.main; -const Overview = imports.ui.overview; -const SearchController = imports.ui.searchController; -const Util = imports.misc.util; -const WindowManager = imports.ui.windowManager; -const WorkspaceThumbnail = imports.ui.workspaceThumbnail; -const WorkspacesView = imports.ui.workspacesView; +import * as AppDisplay from './appDisplay.js'; +import * as Dash from './dash.js'; +import * as Layout from './layout.js'; +import * as Main from './main.js'; +import * as Overview from './overview.js'; +import * as SearchController from './searchController.js'; +import * as Util from '../misc/util.js'; +import * as WindowManager from './windowManager.js'; +import * as WorkspaceThumbnail from './workspaceThumbnail.js'; +import * as WorkspacesView from './workspacesView.js'; const SMALL_WORKSPACE_RATIO = 0.15; const DASH_MAX_HEIGHT_RATIO = 0.15; const A11Y_SCHEMA = 'org.gnome.desktop.a11y.keyboard'; -var SIDE_CONTROLS_ANIMATION_TIME = Overview.ANIMATION_TIME; +export const SIDE_CONTROLS_ANIMATION_TIME = 250; /** @enum {number} */ -var ControlsState = { +export const ControlsState = { HIDDEN: 0, WINDOW_PICKER: 1, APP_GRID: 2, }; -var ControlsManagerLayout = GObject.registerClass( +const ControlsManagerLayout = GObject.registerClass( class ControlsManagerLayout extends Clutter.BoxLayout { _init(searchEntry, appDisplay, workspacesDisplay, workspacesThumbnails, searchController, dash, stateAdjustment) { @@ -265,7 +264,7 @@ class ControlsManagerLayout extends Clutter.BoxLayout { } }); -var OverviewAdjustment = GObject.registerClass({ +export const OverviewAdjustment = GObject.registerClass({ Properties: { 'gesture-in-progress': GObject.ParamSpec.boolean( 'gesture-in-progress', 'Gesture in progress', 'Gesture in progress', @@ -316,7 +315,7 @@ var OverviewAdjustment = GObject.registerClass({ } }); -var ControlsManager = GObject.registerClass( +export const ControlsManager = GObject.registerClass( class ControlsManager extends St.Widget { _init() { super._init({ diff --git a/js/ui/padOsd.js b/js/ui/padOsd.js index fa6d3d097..3cef21490 100644 --- a/js/ui/padOsd.js +++ b/js/ui/padOsd.js @@ -1,24 +1,23 @@ // -*- mode: js; js-indent-level: 4; indent-tabs-mode: nil -*- -/* exported PadOsd, PadOsdService */ -const Atk = imports.gi.Atk; -const Clutter = imports.gi.Clutter; -const GDesktopEnums = imports.gi.GDesktopEnums; -const Gio = imports.gi.Gio; -const GLib = imports.gi.GLib; -const GObject = imports.gi.GObject; -const Meta = imports.gi.Meta; -const Pango = imports.gi.Pango; -const Rsvg = imports.gi.Rsvg; -const St = imports.gi.St; +import Atk from 'gi://Atk'; +import Clutter from 'gi://Clutter'; +import GDesktopEnums from 'gi://GDesktopEnums'; +import Gio from 'gi://Gio'; +import GLib from 'gi://GLib'; +import GObject from 'gi://GObject'; +import Meta from 'gi://Meta'; +import Pango from 'gi://Pango'; +import Rsvg from 'gi://Rsvg'; +import St from 'gi://St'; -const Signals = imports.misc.signals; +import * as Signals from '../misc/signals.js'; -const Main = imports.ui.main; -const PopupMenu = imports.ui.popupMenu; -const Layout = imports.ui.layout; +import * as Main from './main.js'; +import * as PopupMenu from './popupMenu.js'; +import * as Layout from './layout.js'; -const { loadInterfaceXML } = imports.misc.fileUtils; +import {loadInterfaceXML} from '../misc/fileUtils.js'; const ACTIVE_COLOR = "#729fcf"; @@ -31,7 +30,7 @@ const CCW = 1; const UP = 0; const DOWN = 1; -var PadChooser = GObject.registerClass({ +const PadChooser = GObject.registerClass({ Signals: { 'pad-selected': { param_types: [Clutter.InputDevice.$gtype] } }, }, class PadChooser extends St.Button { _init(device, groupDevices) { @@ -100,7 +99,7 @@ var PadChooser = GObject.registerClass({ } }); -var KeybindingEntry = GObject.registerClass({ +const KeybindingEntry = GObject.registerClass({ Signals: { 'keybinding-edited': { param_types: [GObject.TYPE_STRING] } }, }, class KeybindingEntry extends St.Entry { _init() { @@ -120,7 +119,7 @@ var KeybindingEntry = GObject.registerClass({ } }); -var ActionComboBox = GObject.registerClass({ +const ActionComboBox = GObject.registerClass({ Signals: { 'action-selected': { param_types: [GObject.TYPE_INT] } }, }, class ActionComboBox extends St.Button { _init() { @@ -209,7 +208,7 @@ var ActionComboBox = GObject.registerClass({ } }); -var ActionEditor = GObject.registerClass({ +const ActionEditor = GObject.registerClass({ Signals: { 'done': {} }, }, class ActionEditor extends St.Widget { _init() { @@ -297,7 +296,7 @@ var ActionEditor = GObject.registerClass({ } }); -var PadDiagram = GObject.registerClass({ +const PadDiagram = GObject.registerClass({ Properties: { 'left-handed': GObject.ParamSpec.boolean('left-handed', 'left-handed', 'Left handed', @@ -641,7 +640,7 @@ var PadDiagram = GObject.registerClass({ } }); -var PadOsd = GObject.registerClass({ +export const PadOsd = GObject.registerClass({ Signals: { 'pad-selected': { param_types: [Clutter.InputDevice.$gtype] }, 'closed': {}, @@ -963,7 +962,7 @@ var PadOsd = GObject.registerClass({ const PadOsdIface = loadInterfaceXML('org.gnome.Shell.Wacom.PadOsd'); -var PadOsdService = class extends Signals.EventEmitter { +export class PadOsdService extends Signals.EventEmitter { constructor() { super(); @@ -994,4 +993,4 @@ var PadOsdService = class extends Signals.EventEmitter { global.display.request_pad_osd(padDevice, editionMode); invocation.return_value(null); } -}; +} diff --git a/js/ui/pageIndicators.js b/js/ui/pageIndicators.js index 02f64470e..60fa8e195 100644 --- a/js/ui/pageIndicators.js +++ b/js/ui/pageIndicators.js @@ -1,17 +1,16 @@ // -*- mode: js; js-indent-level: 4; indent-tabs-mode: nil -*- -/* exported PageIndicators */ -const Clutter = imports.gi.Clutter; -const Graphene = imports.gi.Graphene; -const GObject = imports.gi.GObject; -const St = imports.gi.St; +import Clutter from 'gi://Clutter'; +import Graphene from 'gi://Graphene'; +import GObject from 'gi://GObject'; +import St from 'gi://St'; const INDICATOR_INACTIVE_OPACITY = 128; const INDICATOR_INACTIVE_OPACITY_HOVER = 255; const INDICATOR_INACTIVE_SCALE = 2 / 3; const INDICATOR_INACTIVE_SCALE_PRESSED = 0.5; -var PageIndicators = GObject.registerClass({ +export const PageIndicators = GObject.registerClass({ Signals: { 'page-activated': { param_types: [GObject.TYPE_INT] } }, }, class PageIndicators extends St.BoxLayout { _init(orientation = Clutter.Orientation.VERTICAL) { diff --git a/js/ui/panel.js b/js/ui/panel.js index 49b18926e..f65657e7b 100644 --- a/js/ui/panel.js +++ b/js/ui/panel.js @@ -1,50 +1,49 @@ // -*- mode: js; js-indent-level: 4; indent-tabs-mode: nil -*- -/* exported Panel */ -const Atk = imports.gi.Atk; -const Clutter = imports.gi.Clutter; -const GLib = imports.gi.GLib; -const GObject = imports.gi.GObject; -const Meta = imports.gi.Meta; -const Shell = imports.gi.Shell; -const St = imports.gi.St; +import Atk from 'gi://Atk'; +import Clutter from 'gi://Clutter'; +import GLib from 'gi://GLib'; +import GObject from 'gi://GObject'; +import Meta from 'gi://Meta'; +import Shell from 'gi://Shell'; +import St from 'gi://St'; -const Animation = imports.ui.animation; -const { AppMenu } = imports.ui.appMenu; +import * as Animation from './animation.js'; +import {AppMenu} from './appMenu.js'; const Config = imports.misc.config; -const CtrlAltTab = imports.ui.ctrlAltTab; -const DND = imports.ui.dnd; -const Overview = imports.ui.overview; -const PopupMenu = imports.ui.popupMenu; -const PanelMenu = imports.ui.panelMenu; -const {QuickSettingsMenu, SystemIndicator} = imports.ui.quickSettings; -const Main = imports.ui.main; +import * as CtrlAltTab from './ctrlAltTab.js'; +import * as DND from './dnd.js'; +import * as Overview from './overview.js'; +import * as PopupMenu from './popupMenu.js'; +import * as PanelMenu from './panelMenu.js'; +import {QuickSettingsMenu, SystemIndicator} from './quickSettings.js'; +import * as Main from './main.js'; -const RemoteAccessStatus = imports.ui.status.remoteAccess; -const PowerProfileStatus = imports.ui.status.powerProfiles; -const RFKillStatus = imports.ui.status.rfkill; -const CameraStatus = imports.ui.status.camera; -const VolumeStatus = imports.ui.status.volume; -const BrightnessStatus = imports.ui.status.brightness; -const SystemStatus = imports.ui.status.system; -const LocationStatus = imports.ui.status.location; -const NightLightStatus = imports.ui.status.nightLight; -const DarkModeStatus = imports.ui.status.darkMode; -const BacklightStatus = imports.ui.status.backlight; -const ThunderboltStatus = imports.ui.status.thunderbolt; -const AutoRotateStatus = imports.ui.status.autoRotate; -const BackgroundAppsStatus = imports.ui.status.backgroundApps; +import * as RemoteAccessStatus from './status/remoteAccess.js'; +import * as PowerProfileStatus from './status/powerProfiles.js'; +import * as RFKillStatus from './status/rfkill.js'; +import * as CameraStatus from './status/camera.js'; +import * as VolumeStatus from './status/volume.js'; +import * as BrightnessStatus from './status/brightness.js'; +import * as SystemStatus from './status/system.js'; +import * as LocationStatus from './status/location.js'; +import * as NightLightStatus from './status/nightLight.js'; +import * as DarkModeStatus from './status/darkMode.js'; +import * as BacklightStatus from './status/backlight.js'; +import * as ThunderboltStatus from './status/thunderbolt.js'; +import * as AutoRotateStatus from './status/autoRotate.js'; +import * as BackgroundAppsStatus from './status/backgroundApps.js'; -const {DateMenuButton} = imports.ui.dateMenu; -const {ATIndicator} = imports.ui.status.accessibility; -const {InputSourceIndicator} = imports.ui.status.keyboard; -const {DwellClickIndicator} = imports.ui.status.dwellClick; -const {ScreenRecordingIndicator, ScreenSharingIndicator} = imports.ui.status.remoteAccess; +import {DateMenuButton} from './dateMenu.js'; +import {ATIndicator} from './status/accessibility.js'; +import {InputSourceIndicator} from './status/keyboard.js'; +import {DwellClickIndicator} from './status/dwellClick.js'; +import {ScreenRecordingIndicator, ScreenSharingIndicator} from './status/remoteAccess.js'; -var PANEL_ICON_SIZE = 16; -var APP_MENU_ICON_MARGIN = 0; +const PANEL_ICON_SIZE = 16; +const APP_MENU_ICON_MARGIN = 0; -var BUTTON_DND_ACTIVATION_TIMEOUT = 250; +const BUTTON_DND_ACTIVATION_TIMEOUT = 250; const N_QUICK_SETTINGS_COLUMNS = 2; @@ -56,8 +55,8 @@ const N_QUICK_SETTINGS_COLUMNS = 2; * this menu also handles startup notification for it. So when we * have an active startup notification, we switch modes to display that. */ -var AppMenuButton = GObject.registerClass({ - Signals: { 'changed': {} }, +const AppMenuButton = GObject.registerClass({ + Signals: {'changed': {}}, }, class AppMenuButton extends PanelMenu.Button { _init(panel) { super._init(0.0, null, true); @@ -257,7 +256,7 @@ var AppMenuButton = GObject.registerClass({ } }); -var ActivitiesButton = GObject.registerClass( +const ActivitiesButton = GObject.registerClass( class ActivitiesButton extends PanelMenu.Button { _init() { super._init(0.0, null, true); @@ -350,7 +349,7 @@ class UnsafeModeIndicator extends SystemIndicator { } }); -var QuickSettings = GObject.registerClass( +const QuickSettings = GObject.registerClass( class QuickSettings extends PanelMenu.Button { constructor() { super(0.0, C_('System menu in the top bar', 'System'), true); @@ -368,10 +367,8 @@ class QuickSettings extends PanelMenu.Button { async _setupIndicators() { if (Config.HAVE_NETWORKMANAGER) { - // TODO: This will be an asynchronous import once this migrates - // to modules. Add a no-op await now to enforce this being an async - // function. - const NetworkStatus = await imports.ui.status.network; + /** @type {import('./status/network.js')} */ + const NetworkStatus = await import('./status/network.js'); this._network = new NetworkStatus.Indicator(); } else { @@ -379,10 +376,8 @@ class QuickSettings extends PanelMenu.Button { } if (Config.HAVE_BLUETOOTH) { - // TODO: This will be an asynchronous import once this migrates - // to modules. Add a no-op await now to enforce this being an async - // function. - const BluetoothStatus = await imports.ui.status.bluetooth; + /** @type {import('./status/bluetooth.js')} */ + const BluetoothStatus = await import('./status/bluetooth.js'); this._bluetooth = new BluetoothStatus.Indicator(); } else { @@ -467,7 +462,7 @@ const PANEL_ITEM_IMPLEMENTATIONS = { 'screenSharing': ScreenSharingIndicator, }; -var Panel = GObject.registerClass( +export const Panel = GObject.registerClass( class Panel extends St.Widget { _init() { super._init({ diff --git a/js/ui/panelMenu.js b/js/ui/panelMenu.js index 963f9f273..759479ac4 100644 --- a/js/ui/panelMenu.js +++ b/js/ui/panelMenu.js @@ -1,16 +1,15 @@ // -*- mode: js; js-indent-level: 4; indent-tabs-mode: nil -*- -/* exported Button, SystemIndicator */ -const Atk = imports.gi.Atk; -const Clutter = imports.gi.Clutter; -const GObject = imports.gi.GObject; -const St = imports.gi.St; +import Atk from 'gi://Atk'; +import Clutter from 'gi://Clutter'; +import GObject from 'gi://GObject'; +import St from 'gi://St'; -const Main = imports.ui.main; -const Params = imports.misc.params; -const PopupMenu = imports.ui.popupMenu; +import * as Main from './main.js'; +import * as Params from '../misc/params.js'; +import * as PopupMenu from './popupMenu.js'; -var ButtonBox = GObject.registerClass( +export const ButtonBox = GObject.registerClass( class ButtonBox extends St.Widget { _init(params) { params = Params.parse(params, { @@ -95,7 +94,7 @@ class ButtonBox extends St.Widget { } }); -var Button = GObject.registerClass({ +export const Button = GObject.registerClass({ Signals: { 'menu-set': {} }, }, class PanelMenuButton extends ButtonBox { _init(menuAlignment, nameText, dontCreateMenu) { @@ -204,7 +203,7 @@ var Button = GObject.registerClass({ * of an icon and a menu section, which will be composed into the * aggregate menu. */ -var SystemIndicator = GObject.registerClass( +export const SystemIndicator = GObject.registerClass( class SystemIndicator extends St.BoxLayout { _init() { super._init({ diff --git a/js/ui/pointerA11yTimeout.js b/js/ui/pointerA11yTimeout.js index 6a4eef246..729c55776 100644 --- a/js/ui/pointerA11yTimeout.js +++ b/js/ui/pointerA11yTimeout.js @@ -1,14 +1,13 @@ -/* exported PointerA11yTimeout */ -const Clutter = imports.gi.Clutter; -const GObject = imports.gi.GObject; -const Meta = imports.gi.Meta; -const St = imports.gi.St; -const Main = imports.ui.main; -const Cairo = imports.cairo; +import Clutter from 'gi://Clutter'; +import GObject from 'gi://GObject'; +import Meta from 'gi://Meta'; +import St from 'gi://St'; +import * as Main from './main.js'; +import Cairo from 'gi://cairo'; const SUCCESS_ZOOM_OUT_DURATION = 150; -var PieTimer = GObject.registerClass({ +const PieTimer = GObject.registerClass({ Properties: { 'angle': GObject.ParamSpec.double( 'angle', 'angle', 'angle', @@ -109,7 +108,7 @@ var PieTimer = GObject.registerClass({ } }); -var PointerA11yTimeout = class PointerA11yTimeout { +export class PointerA11yTimeout { constructor() { let seat = Clutter.get_default_backend().get_default_seat(); @@ -134,4 +133,4 @@ var PointerA11yTimeout = class PointerA11yTimeout { global.display.set_cursor(Meta.Cursor.DEFAULT); }); } -}; +} diff --git a/js/ui/pointerWatcher.js b/js/ui/pointerWatcher.js index 68989f29b..219b316e6 100644 --- a/js/ui/pointerWatcher.js +++ b/js/ui/pointerWatcher.js @@ -1,10 +1,9 @@ // -*- mode: js; js-indent-level: 4; indent-tabs-mode: nil -*- -/* exported getPointerWatcher */ -const GLib = imports.gi.GLib; +import GLib from 'gi://GLib'; // We stop polling if the user is idle for more than this amount of time -var IDLE_TIME = 1000; +const IDLE_TIME = 1000; // This file implements a reasonably efficient system for tracking the position // of the mouse pointer. We simply query the pointer from the X server in a loop, @@ -15,14 +14,14 @@ let _pointerWatcher = null; /** * @returns {PointerWatcher} */ -function getPointerWatcher() { +export function getPointerWatcher() { if (_pointerWatcher == null) _pointerWatcher = new PointerWatcher(); return _pointerWatcher; } -var PointerWatch = class { +class PointerWatch { constructor(watcher, interval, callback) { this.watcher = watcher; this.interval = interval; @@ -35,9 +34,9 @@ var PointerWatch = class { remove() { this.watcher._removeWatch(this); } -}; +} -var PointerWatcher = class { +class PointerWatcher { constructor() { this._idleMonitor = global.backend.get_core_idle_monitor(); this._idleMonitor.add_idle_watch(IDLE_TIME, this._onIdleMonitorBecameIdle.bind(this)); @@ -126,4 +125,4 @@ var PointerWatcher = class { i++; } } -}; +} diff --git a/js/ui/popupMenu.js b/js/ui/popupMenu.js index 7377f34e1..fe547f416 100644 --- a/js/ui/popupMenu.js +++ b/js/ui/popupMenu.js @@ -1,23 +1,20 @@ // -*- mode: js; js-indent-level: 4; indent-tabs-mode: nil -*- -/* exported PopupMenuItem, PopupSeparatorMenuItem, Switch, PopupSwitchMenuItem, - PopupImageMenuItem, PopupMenu, PopupDummyMenu, PopupSubMenu, - PopupMenuSection, PopupSubMenuMenuItem, PopupMenuManager */ -const Atk = imports.gi.Atk; -const Clutter = imports.gi.Clutter; -const Gio = imports.gi.Gio; -const GObject = imports.gi.GObject; -const Graphene = imports.gi.Graphene; -const Shell = imports.gi.Shell; -const St = imports.gi.St; -const Signals = imports.misc.signals; +import Atk from 'gi://Atk'; +import Clutter from 'gi://Clutter'; +import Gio from 'gi://Gio'; +import GObject from 'gi://GObject'; +import Graphene from 'gi://Graphene'; +import Shell from 'gi://Shell'; +import St from 'gi://St'; +import * as Signals from '../misc/signals.js'; -const BoxPointer = imports.ui.boxpointer; -const Main = imports.ui.main; -const Params = imports.misc.params; +import * as BoxPointer from './boxpointer.js'; +import * as Main from './main.js'; +import * as Params from '../misc/params.js'; /** @enum {number} */ -var Ornament = { +export const Ornament = { NONE: 0, DOT: 1, CHECK: 2, @@ -34,10 +31,11 @@ function isPopupMenuItemVisible(child) { /** * arrowIcon + * * @param {St.Side} side - Side to which the arrow points. * @returns {St.Icon} a new arrow icon */ -function arrowIcon(side) { +export function arrowIcon(side) { let iconName; switch (side) { case St.Side.TOP: @@ -65,7 +63,7 @@ function arrowIcon(side) { return arrow; } -var PopupBaseMenuItem = GObject.registerClass({ +export const PopupBaseMenuItem = GObject.registerClass({ Properties: { 'active': GObject.ParamSpec.boolean('active', 'active', 'active', GObject.ParamFlags.READWRITE, @@ -268,7 +266,7 @@ var PopupBaseMenuItem = GObject.registerClass({ } }); -var PopupMenuItem = GObject.registerClass( +export const PopupMenuItem = GObject.registerClass( class PopupMenuItem extends PopupBaseMenuItem { _init(text, params) { super._init(params); @@ -284,7 +282,7 @@ class PopupMenuItem extends PopupBaseMenuItem { }); -var PopupSeparatorMenuItem = GObject.registerClass( +export const PopupSeparatorMenuItem = GObject.registerClass( class PopupSeparatorMenuItem extends PopupBaseMenuItem { _init(text) { super._init({ @@ -315,7 +313,7 @@ class PopupSeparatorMenuItem extends PopupBaseMenuItem { } }); -var Switch = GObject.registerClass({ +export const Switch = GObject.registerClass({ Properties: { 'state': GObject.ParamSpec.boolean( 'state', 'state', 'state', @@ -355,7 +353,7 @@ var Switch = GObject.registerClass({ } }); -var PopupSwitchMenuItem = GObject.registerClass({ +export const PopupSwitchMenuItem = GObject.registerClass({ Signals: { 'toggled': { param_types: [GObject.TYPE_BOOLEAN] } }, }, class PopupSwitchMenuItem extends PopupBaseMenuItem { _init(text, active, params) { @@ -445,7 +443,7 @@ var PopupSwitchMenuItem = GObject.registerClass({ } }); -var PopupImageMenuItem = GObject.registerClass( +export const PopupImageMenuItem = GObject.registerClass( class PopupImageMenuItem extends PopupBaseMenuItem { _init(text, icon, params) { super._init(params); @@ -482,7 +480,7 @@ class PopupImageMenuItem extends PopupBaseMenuItem { } }); -var PopupMenuBase = class extends Signals.EventEmitter { +export class PopupMenuBase extends Signals.EventEmitter { constructor(sourceActor, styleClass) { super(); @@ -809,9 +807,9 @@ var PopupMenuBase = class extends Signals.EventEmitter { Main.sessionMode.disconnectObject(this); } -}; +} -var PopupMenu = class extends PopupMenuBase { +export class PopupMenu extends PopupMenuBase { constructor(sourceActor, arrowAlignment, arrowSide) { super(sourceActor, 'popup-menu-content'); @@ -953,9 +951,9 @@ var PopupMenu = class extends PopupMenuBase { super.destroy(); } -}; +} -var PopupDummyMenu = class extends Signals.EventEmitter { +export class PopupDummyMenu extends Signals.EventEmitter { constructor(sourceActor) { super(); @@ -991,9 +989,9 @@ var PopupDummyMenu = class extends Signals.EventEmitter { destroy() { this.emit('destroy'); } -}; +} -var PopupSubMenu = class extends PopupMenuBase { +export class PopupSubMenu extends PopupMenuBase { constructor(sourceActor, sourceArrow) { super(sourceActor); @@ -1130,7 +1128,7 @@ var PopupSubMenu = class extends PopupMenuBase { return Clutter.EVENT_PROPAGATE; } -}; +} /** * PopupMenuSection: @@ -1140,7 +1138,7 @@ var PopupSubMenu = class extends PopupMenuBase { * can add it to another menu), but is completely transparent * to the user */ -var PopupMenuSection = class extends PopupMenuBase { +export class PopupMenuSection extends PopupMenuBase { constructor() { super(); @@ -1160,9 +1158,9 @@ var PopupMenuSection = class extends PopupMenuBase { close() { this.emit('open-state-changed', false); } -}; +} -var PopupSubMenuMenuItem = GObject.registerClass( +export const PopupSubMenuMenuItem = GObject.registerClass( class PopupSubMenuMenuItem extends PopupBaseMenuItem { _init(text, wantIcon) { super._init(); @@ -1269,7 +1267,7 @@ class PopupSubMenuMenuItem extends PopupBaseMenuItem { /* Basic implementation of a menu manager. * Call addMenu to add menus */ -var PopupMenuManager = class { +export class PopupMenuManager { constructor(owner, grabParams) { this._grabParams = Params.parse(grabParams, { actionMode: Shell.ActionMode.POPUP }); @@ -1394,4 +1392,4 @@ var PopupMenuManager = class { if (isUser) menu.close(BoxPointer.PopupAnimation.FULL); } -}; +} diff --git a/js/ui/quickSettings.js b/js/ui/quickSettings.js index 9016fedf6..83597c6d4 100644 --- a/js/ui/quickSettings.js +++ b/js/ui/quickSettings.js @@ -1,26 +1,24 @@ -/* exported QuickToggle, QuickMenuToggle, QuickSlider, QuickSettingsMenu, SystemIndicator */ -const Atk = imports.gi.Atk; -const Clutter = imports.gi.Clutter; -const Gio = imports.gi.Gio; -const GLib = imports.gi.GLib; -const GObject = imports.gi.GObject; -const Graphene = imports.gi.Graphene; -const Meta = imports.gi.Meta; -const Pango = imports.gi.Pango; -const St = imports.gi.St; +import Atk from 'gi://Atk'; +import Clutter from 'gi://Clutter'; +import Gio from 'gi://Gio'; +import GLib from 'gi://GLib'; +import GObject from 'gi://GObject'; +import Graphene from 'gi://Graphene'; +import Meta from 'gi://Meta'; +import Pango from 'gi://Pango'; +import St from 'gi://St'; -const Main = imports.ui.main; -const PopupMenu = imports.ui.popupMenu; -const {Slider} = imports.ui.slider; +import * as Main from './main.js'; +import * as PopupMenu from './popupMenu.js'; +import {Slider} from './slider.js'; -const {PopupAnimation} = imports.ui.boxpointer; +import {PopupAnimation} from './boxpointer.js'; const DIM_BRIGHTNESS = -0.4; const POPUP_ANIMATION_TIME = 400; - const MENU_BUTTON_BRIGHTNESS = 0.1; -var QuickSettingsItem = GObject.registerClass({ +export const QuickSettingsItem = GObject.registerClass({ Properties: { 'has-menu': GObject.ParamSpec.boolean( 'has-menu', 'has-menu', 'has-menu', @@ -42,7 +40,7 @@ var QuickSettingsItem = GObject.registerClass({ } }); -var QuickToggle = GObject.registerClass({ +export const QuickToggle = GObject.registerClass({ Properties: { 'title': GObject.ParamSpec.string('title', '', '', GObject.ParamFlags.READWRITE, @@ -143,7 +141,7 @@ var QuickToggle = GObject.registerClass({ } }); -var QuickMenuToggle = GObject.registerClass({ +export const QuickMenuToggle = GObject.registerClass({ Properties: { 'title': GObject.ParamSpec.string('title', '', '', GObject.ParamFlags.READWRITE, @@ -234,7 +232,7 @@ var QuickMenuToggle = GObject.registerClass({ } }); -var QuickSlider = GObject.registerClass({ +export const QuickSlider = GObject.registerClass({ Properties: { 'icon-name': GObject.ParamSpec.override('icon-name', St.Button), 'gicon': GObject.ParamSpec.object('gicon', '', '', @@ -707,7 +705,7 @@ const QuickSettingsLayout = GObject.registerClass({ } }); -var QuickSettingsMenu = class extends PopupMenu.PopupMenu { +export const QuickSettingsMenu = class extends PopupMenu.PopupMenu { constructor(sourceActor, nColumns = 1) { super(sourceActor, 0, St.Side.TOP); @@ -818,7 +816,7 @@ var QuickSettingsMenu = class extends PopupMenu.PopupMenu { } }; -var SystemIndicator = GObject.registerClass( +export const SystemIndicator = GObject.registerClass( class SystemIndicator extends St.BoxLayout { _init() { super._init({ diff --git a/js/ui/remoteSearch.js b/js/ui/remoteSearch.js index eef475227..efbf89374 100644 --- a/js/ui/remoteSearch.js +++ b/js/ui/remoteSearch.js @@ -1,13 +1,12 @@ // -*- mode: js; js-indent-level: 4; indent-tabs-mode: nil -*- -/* exported loadRemoteSearchProviders */ -const GdkPixbuf = imports.gi.GdkPixbuf; -const Gio = imports.gi.Gio; -const GLib = imports.gi.GLib; -const Shell = imports.gi.Shell; -const St = imports.gi.St; +import GdkPixbuf from 'gi://GdkPixbuf'; +import Gio from 'gi://Gio'; +import GLib from 'gi://GLib'; +import Shell from 'gi://Shell'; +import St from 'gi://St'; -const FileUtils = imports.misc.fileUtils; +import * as FileUtils from '../misc/fileUtils.js'; const KEY_FILE_GROUP = 'Shell Search Provider'; @@ -61,8 +60,8 @@ const SearchProvider2Iface = ` `; -var SearchProviderProxyInfo = Gio.DBusInterfaceInfo.new_for_xml(SearchProviderIface); -var SearchProvider2ProxyInfo = Gio.DBusInterfaceInfo.new_for_xml(SearchProvider2Iface); +const SearchProviderProxyInfo = Gio.DBusInterfaceInfo.new_for_xml(SearchProviderIface); +const SearchProvider2ProxyInfo = Gio.DBusInterfaceInfo.new_for_xml(SearchProvider2Iface); /** * loadRemoteSearchProviders: @@ -70,7 +69,7 @@ var SearchProvider2ProxyInfo = Gio.DBusInterfaceInfo.new_for_xml(SearchProvider2 * @param {Gio.Settings} searchSettings - search settings * @returns {RemoteSearchProvider[]} - the list of remote providers */ -function loadRemoteSearchProviders(searchSettings) { +export function loadRemoteSearchProviders(searchSettings) { let objectPaths = {}; let loadedProviders = []; @@ -193,7 +192,7 @@ function loadRemoteSearchProviders(searchSettings) { return loadedProviders; } -var RemoteSearchProvider = class { +class RemoteSearchProvider { constructor(appInfo, dbusName, dbusPath, autoStart, proxyInfo) { if (!proxyInfo) proxyInfo = SearchProviderProxyInfo; @@ -313,9 +312,9 @@ var RemoteSearchProvider = class { log(`Search provider ${this.appInfo.get_id()} does not implement LaunchSearch`); this.appInfo.launch([], global.create_app_launch_context(0, -1)); } -}; +} -var RemoteSearchProvider2 = class extends RemoteSearchProvider { +class RemoteSearchProvider2 extends RemoteSearchProvider { constructor(appInfo, dbusName, dbusPath, autoStart) { super(appInfo, dbusName, dbusPath, autoStart, SearchProvider2ProxyInfo); @@ -331,4 +330,4 @@ var RemoteSearchProvider2 = class extends RemoteSearchProvider { this.proxy.LaunchSearchAsync( terms, global.get_current_time()).catch(logError); } -}; +} diff --git a/js/ui/ripples.js b/js/ui/ripples.js index f27274ae4..9eb3c7ef4 100644 --- a/js/ui/ripples.js +++ b/js/ui/ripples.js @@ -1,11 +1,10 @@ // -*- mode: js; js-indent-level: 4; indent-tabs-mode: nil -*- -/* exported Ripples */ -const Clutter = imports.gi.Clutter; -const St = imports.gi.St; +import Clutter from 'gi://Clutter'; +import St from 'gi://St'; // Shamelessly copied from the layout "hotcorner" ripples implementation -var Ripples = class Ripples { +export class Ripples { constructor(px, py, styleClass) { this._x = 0; this._y = 0; @@ -108,4 +107,4 @@ var Ripples = class Ripples { this._animRipple(this._ripple2, 50, 1000, 0.0, 0.7, 1.25); this._animRipple(this._ripple3, 350, 1000, 0.0, 0.3, 1); } -}; +} diff --git a/js/ui/runDialog.js b/js/ui/runDialog.js index 0398e303e..2b4ea3d33 100644 --- a/js/ui/runDialog.js +++ b/js/ui/runDialog.js @@ -1,20 +1,19 @@ // -*- mode: js; js-indent-level: 4; indent-tabs-mode: nil -*- -/* exported RunDialog */ -const Clutter = imports.gi.Clutter; -const Gio = imports.gi.Gio; -const GLib = imports.gi.GLib; -const GObject = imports.gi.GObject; -const Meta = imports.gi.Meta; -const Shell = imports.gi.Shell; -const St = imports.gi.St; +import Clutter from 'gi://Clutter'; +import Gio from 'gi://Gio'; +import GLib from 'gi://GLib'; +import GObject from 'gi://GObject'; +import Meta from 'gi://Meta'; +import Shell from 'gi://Shell'; +import St from 'gi://St'; -const Dialog = imports.ui.dialog; -const Main = imports.ui.main; -const ModalDialog = imports.ui.modalDialog; -const ShellEntry = imports.ui.shellEntry; -const Util = imports.misc.util; -const History = imports.misc.history; +import * as Dialog from './dialog.js'; +import * as Main from './main.js'; +import * as ModalDialog from './modalDialog.js'; +import * as ShellEntry from './shellEntry.js'; +import * as Util from '../misc/util.js'; +import * as History from '../misc/history.js'; const HISTORY_KEY = 'command-history'; @@ -25,7 +24,7 @@ const TERMINAL_SCHEMA = 'org.gnome.desktop.default-applications.terminal'; const EXEC_KEY = 'exec'; const EXEC_ARG_KEY = 'exec-arg'; -var RunDialog = GObject.registerClass( +export const RunDialog = GObject.registerClass( class RunDialog extends ModalDialog.ModalDialog { _init() { super._init({ diff --git a/js/ui/screenShield.js b/js/ui/screenShield.js index 39ae22648..c40560f8b 100644 --- a/js/ui/screenShield.js +++ b/js/ui/screenShield.js @@ -1,28 +1,27 @@ // -*- mode: js; js-indent-level: 4; indent-tabs-mode: nil -*- -/* exported ScreenShield */ -const AccountsService = imports.gi.AccountsService; -const Clutter = imports.gi.Clutter; -const Gio = imports.gi.Gio; -const GLib = imports.gi.GLib; -const Graphene = imports.gi.Graphene; -const Meta = imports.gi.Meta; -const Shell = imports.gi.Shell; -const St = imports.gi.St; +import AccountsService from 'gi://AccountsService'; +import Clutter from 'gi://Clutter'; +import Gio from 'gi://Gio'; +import GLib from 'gi://GLib'; +import Graphene from 'gi://Graphene'; +import Meta from 'gi://Meta'; +import Shell from 'gi://Shell'; +import St from 'gi://St'; -const Signals = imports.misc.signals; +import * as Signals from '../misc/signals.js'; -const GnomeSession = imports.misc.gnomeSession; -const OVirt = imports.gdm.oVirt; -const LoginManager = imports.misc.loginManager; -const Lightbox = imports.ui.lightbox; -const Main = imports.ui.main; -const Overview = imports.ui.overview; -const MessageTray = imports.ui.messageTray; -const ShellDBus = imports.ui.shellDBus; -const SmartcardManager = imports.misc.smartcardManager; +import * as GnomeSession from '../misc/gnomeSession.js'; +import * as OVirt from '../gdm/oVirt.js'; +import * as LoginManager from '../misc/loginManager.js'; +import * as Lightbox from './lightbox.js'; +import * as Main from './main.js'; +import * as Overview from './overview.js'; +import * as MessageTray from './messageTray.js'; +import * as ShellDBus from './shellDBus.js'; +import * as SmartcardManager from '../misc/smartcardManager.js'; -const {adjustAnimationTime} = imports.misc.animationUtils; +import {adjustAnimationTime} from '../misc/animationUtils.js'; const SCREENSAVER_SCHEMA = 'org.gnome.desktop.screensaver'; const LOCK_ENABLED_KEY = 'lock-enabled'; @@ -38,9 +37,9 @@ const LOCKED_STATE_STR = 'screenShield.locked'; // - MANUAL_FADE_TIME is used for lowering the shield when asked by the user, // or when cancelling the dialog // - CURTAIN_SLIDE_TIME is used when raising the shield before unlocking -var STANDARD_FADE_TIME = 10000; -var MANUAL_FADE_TIME = 300; -var CURTAIN_SLIDE_TIME = 300; +const STANDARD_FADE_TIME = 10000; +const MANUAL_FADE_TIME = 300; +const CURTAIN_SLIDE_TIME = 300; /** * If you are setting org.gnome.desktop.session.idle-delay directly in dconf, @@ -50,7 +49,7 @@ var CURTAIN_SLIDE_TIME = 300; * This will ensure that the screen blanks at the right time when it fades out. * https://bugzilla.gnome.org/show_bug.cgi?id=668703 explains the dependency. */ -var ScreenShield = class extends Signals.EventEmitter { +export class ScreenShield extends Signals.EventEmitter { constructor() { super(); @@ -707,4 +706,4 @@ var ScreenShield = class extends Signals.EventEmitter { return GLib.SOURCE_REMOVE; }); } -}; +} diff --git a/js/ui/screenshot.js b/js/ui/screenshot.js index 86b62c149..42e356846 100644 --- a/js/ui/screenshot.js +++ b/js/ui/screenshot.js @@ -1,22 +1,21 @@ // -*- mode: js; js-indent-level: 4; indent-tabs-mode: nil -*- -/* exported ScreenshotService, ScreenshotUI, showScreenshotUI, captureScreenshot */ -const Clutter = imports.gi.Clutter; -const Cogl = imports.gi.Cogl; -const Gio = imports.gi.Gio; -const GObject = imports.gi.GObject; -const GLib = imports.gi.GLib; -const Graphene = imports.gi.Graphene; -const Meta = imports.gi.Meta; -const Shell = imports.gi.Shell; -const St = imports.gi.St; +import Clutter from 'gi://Clutter'; +import Cogl from 'gi://Cogl'; +import Gio from 'gi://Gio'; +import GObject from 'gi://GObject'; +import GLib from 'gi://GLib'; +import Graphene from 'gi://Graphene'; +import Meta from 'gi://Meta'; +import Shell from 'gi://Shell'; +import St from 'gi://St'; -const GrabHelper = imports.ui.grabHelper; -const Layout = imports.ui.layout; -const Lightbox = imports.ui.lightbox; -const Main = imports.ui.main; -const MessageTray = imports.ui.messageTray; -const Workspace = imports.ui.workspace; +import * as GrabHelper from './grabHelper.js'; +import * as Layout from './layout.js'; +import * as Lightbox from './lightbox.js'; +import * as Main from './main.js'; +import * as MessageTray from './messageTray.js'; +import * as Workspace from './workspace.js'; Gio._promisify(Shell.Screenshot.prototype, 'pick_color'); Gio._promisify(Shell.Screenshot.prototype, 'screenshot'); @@ -25,15 +24,15 @@ Gio._promisify(Shell.Screenshot.prototype, 'screenshot_area'); Gio._promisify(Shell.Screenshot.prototype, 'screenshot_stage_to_content'); Gio._promisify(Shell.Screenshot, 'composite_to_stream'); -const { loadInterfaceXML } = imports.misc.fileUtils; -const { DBusSenderChecker } = imports.misc.util; +import {loadInterfaceXML} from '../misc/fileUtils.js'; +import {DBusSenderChecker} from '../misc/util.js'; const ScreenshotIface = loadInterfaceXML('org.gnome.Shell.Screenshot'); const ScreencastIface = loadInterfaceXML('org.gnome.Shell.Screencast'); const ScreencastProxy = Gio.DBusProxy.makeProxyWrapper(ScreencastIface); -var IconLabelButton = GObject.registerClass( +const IconLabelButton = GObject.registerClass( class IconLabelButton extends St.Button { _init(iconName, label, params) { super._init(params); @@ -44,7 +43,7 @@ class IconLabelButton extends St.Button { }); this.set_child(this._container); - this._container.add_child(new St.Icon({ icon_name: iconName })); + this._container.add_child(new St.Icon({icon_name: iconName})); this._container.add_child(new St.Label({ text: label, x_align: Clutter.ActorAlign.CENTER, @@ -52,7 +51,7 @@ class IconLabelButton extends St.Button { } }); -var Tooltip = GObject.registerClass( +export const Tooltip = GObject.registerClass( class Tooltip extends St.Label { _init(widget, params) { super._init(params); @@ -120,7 +119,7 @@ class Tooltip extends St.Label { } }); -var UIAreaIndicator = GObject.registerClass( +const UIAreaIndicator = GObject.registerClass( class UIAreaIndicator extends St.Widget { _init(params) { super._init(params); @@ -229,7 +228,7 @@ class UIAreaIndicator extends St.Widget { } }); -var UIAreaSelector = GObject.registerClass({ +const UIAreaSelector = GObject.registerClass({ Signals: { 'drag-started': {}, 'drag-ended': {} }, }, class UIAreaSelector extends St.Widget { _init(params) { @@ -700,7 +699,7 @@ var UIAreaSelector = GObject.registerClass({ } }); -var UIWindowSelectorLayout = GObject.registerClass( +const UIWindowSelectorLayout = GObject.registerClass( class UIWindowSelectorLayout extends Workspace.WorkspaceLayout { _init(monitorIndex) { super._init(null, monitorIndex, null); @@ -765,7 +764,7 @@ class UIWindowSelectorLayout extends Workspace.WorkspaceLayout { } }); -var UIWindowSelectorWindow = GObject.registerClass( +const UIWindowSelectorWindow = GObject.registerClass( class UIWindowSelectorWindow extends St.Button { _init(actor, params) { super._init(params); @@ -937,7 +936,7 @@ class UIWindowSelectorWindow extends St.Button { } }); -var UIWindowSelector = GObject.registerClass( +const UIWindowSelector = GObject.registerClass( class UIWindowSelector extends St.Widget { _init(monitorIndex, params) { super._init(params); @@ -1005,7 +1004,7 @@ const UIMode = { SCREENCAST: 1, }; -var ScreenshotUI = GObject.registerClass({ +export const ScreenshotUI = GObject.registerClass({ Properties: { 'screencast-in-progress': GObject.ParamSpec.boolean( 'screencast-in-progress', @@ -2279,7 +2278,7 @@ function showScreenRecordingUI() { }); } -var ScreenshotService = class { +export class ScreenshotService { constructor() { this._dbusImpl = Gio.DBusExportedObject.wrapJSObject(ScreenshotIface, this); this._dbusImpl.export(Gio.DBus.session, '/org/gnome/Shell/Screenshot'); @@ -2595,9 +2594,9 @@ var ScreenshotService = class { this._removeShooterForSender(invocation.get_sender()); } } -}; +} -var SelectArea = GObject.registerClass( +export const SelectArea = GObject.registerClass( class SelectArea extends St.Widget { _init() { this._startX = -1; @@ -2700,7 +2699,7 @@ class SelectArea extends St.Widget { } }); -var RecolorEffect = GObject.registerClass({ +const RecolorEffect = GObject.registerClass({ Properties: { color: GObject.ParamSpec.boxed( 'color', 'color', 'replacement color', @@ -2829,7 +2828,7 @@ var RecolorEffect = GObject.registerClass({ } }); -var PickPixel = GObject.registerClass( +export const PickPixel = GObject.registerClass( class PickPixel extends St.Widget { _init(screenshot) { super._init({ visible: false, reactive: true }); @@ -2921,9 +2920,9 @@ class PickPixel extends St.Widget { } }); -var FLASHSPOT_ANIMATION_OUT_TIME = 500; // milliseconds +const FLASHSPOT_ANIMATION_OUT_TIME = 500; // milliseconds -var Flashspot = GObject.registerClass( +export const Flashspot = GObject.registerClass( class Flashspot extends Lightbox.Lightbox { _init(area) { super._init(Main.uiGroup, { diff --git a/js/ui/scripting.js b/js/ui/scripting.js index 74e420899..1ef001669 100644 --- a/js/ui/scripting.js +++ b/js/ui/scripting.js @@ -6,11 +6,11 @@ import Meta from 'gi://Meta'; import Shell from 'gi://Shell'; const Config = imports.misc.config; -const Main = imports.ui.main; -const Params = imports.misc.params; -const Util = imports.misc.util; +import * as Main from './main.js'; +import * as Params from '../misc/params.js'; +import * as Util from '../misc/util.js'; -const { loadInterfaceXML } = imports.misc.fileUtils; +import {loadInterfaceXML} from '../misc/fileUtils.js'; // This module provides functionality for driving the shell user interface // in an automated fashion. The primary current use case for this is diff --git a/js/ui/search.js b/js/ui/search.js index 9e42c9bce..066d8b380 100644 --- a/js/ui/search.js +++ b/js/ui/search.js @@ -1,28 +1,27 @@ // -*- mode: js; js-indent-level: 4; indent-tabs-mode: nil -*- -/* exported SearchResultsView */ -const Clutter = imports.gi.Clutter; -const Gio = imports.gi.Gio; -const GLib = imports.gi.GLib; -const GObject = imports.gi.GObject; -const Meta = imports.gi.Meta; -const Shell = imports.gi.Shell; -const St = imports.gi.St; +import Clutter from 'gi://Clutter'; +import Gio from 'gi://Gio'; +import GLib from 'gi://GLib'; +import GObject from 'gi://GObject'; +import Meta from 'gi://Meta'; +import Shell from 'gi://Shell'; +import St from 'gi://St'; -const AppDisplay = imports.ui.appDisplay; -const IconGrid = imports.ui.iconGrid; -const Main = imports.ui.main; -const ParentalControlsManager = imports.misc.parentalControlsManager; -const RemoteSearch = imports.ui.remoteSearch; -const {ensureActorVisibleInScrollView} = imports.misc.animationUtils; +import * as AppDisplay from './appDisplay.js'; +import * as IconGrid from './iconGrid.js'; +import * as Main from './main.js'; +import * as ParentalControlsManager from '../misc/parentalControlsManager.js'; +import * as RemoteSearch from './remoteSearch.js'; +import {ensureActorVisibleInScrollView} from '../misc/animationUtils.js'; -const { Highlighter } = imports.misc.util; +import {Highlighter} from '../misc/util.js'; const SEARCH_PROVIDERS_SCHEMA = 'org.gnome.desktop.search-providers'; -var MAX_LIST_SEARCH_RESULTS_ROWS = 5; +const MAX_LIST_SEARCH_RESULTS_ROWS = 5; -var MaxWidthBox = GObject.registerClass( +const MaxWidthBox = GObject.registerClass( class MaxWidthBox extends St.BoxLayout { vfunc_allocate(box) { let themeNode = this.get_theme_node(); @@ -40,7 +39,7 @@ class MaxWidthBox extends St.BoxLayout { } }); -var SearchResult = GObject.registerClass( +export const SearchResult = GObject.registerClass( class SearchResult extends St.Button { _init(provider, metaInfo, resultsView) { this.provider = provider; @@ -69,7 +68,7 @@ class SearchResult extends St.Button { } }); -var ListSearchResult = GObject.registerClass( +export const ListSearchResult = GObject.registerClass( class ListSearchResult extends SearchResult { _init(provider, metaInfo, resultsView) { super._init(provider, metaInfo, resultsView); @@ -129,7 +128,7 @@ class ListSearchResult extends SearchResult { } }); -var GridSearchResult = GObject.registerClass( +export const GridSearchResult = GObject.registerClass( class GridSearchResult extends SearchResult { _init(provider, metaInfo, resultsView) { super._init(provider, metaInfo, resultsView); @@ -149,7 +148,7 @@ class GridSearchResult extends SearchResult { } }); -var SearchResultsBase = GObject.registerClass({ +const SearchResultsBase = GObject.registerClass({ GTypeFlags: GObject.TypeFlags.ABSTRACT, Properties: { 'focus-child': GObject.ParamSpec.object( @@ -281,7 +280,7 @@ var SearchResultsBase = GObject.registerClass({ } }); -var ListSearchResults = GObject.registerClass( +export const ListSearchResults = GObject.registerClass( class ListSearchResults extends SearchResultsBase { _init(provider, resultsView) { super._init(provider, resultsView); @@ -336,7 +335,7 @@ class ListSearchResults extends SearchResultsBase { } }); -var GridSearchResultsLayout = GObject.registerClass({ +const GridSearchResultsLayout = GObject.registerClass({ Properties: { 'spacing': GObject.ParamSpec.int('spacing', 'Spacing', 'Spacing', GObject.ParamFlags.READWRITE, 0, GLib.MAXINT32, 0), @@ -455,7 +454,7 @@ var GridSearchResultsLayout = GObject.registerClass({ } }); -var GridSearchResults = GObject.registerClass( +export const GridSearchResults = GObject.registerClass( class GridSearchResults extends SearchResultsBase { _init(provider, resultsView) { super._init(provider, resultsView); @@ -539,7 +538,7 @@ class GridSearchResults extends SearchResultsBase { } }); -var SearchResultsView = GObject.registerClass({ +export const SearchResultsView = GObject.registerClass({ Signals: {'terms-changed': {}}, }, class SearchResultsView extends St.BoxLayout { _init() { @@ -891,7 +890,7 @@ var SearchResultsView = GObject.registerClass({ } }); -var ProviderInfo = GObject.registerClass( +const ProviderInfo = GObject.registerClass( class ProviderInfo extends St.Button { _init(provider) { this.provider = provider; diff --git a/js/ui/searchController.js b/js/ui/searchController.js index d34fe54f2..a6db7e4b4 100644 --- a/js/ui/searchController.js +++ b/js/ui/searchController.js @@ -1,15 +1,14 @@ // -*- mode: js; js-indent-level: 4; indent-tabs-mode: nil -*- -/* exported SearchController */ -const Clutter = imports.gi.Clutter; -const GObject = imports.gi.GObject; -const St = imports.gi.St; +import Clutter from 'gi://Clutter'; +import GObject from 'gi://GObject'; +import St from 'gi://St'; -const Main = imports.ui.main; -const Search = imports.ui.search; -const ShellEntry = imports.ui.shellEntry; +import * as Main from './main.js'; +import * as Search from './search.js'; +import * as ShellEntry from './shellEntry.js'; -var FocusTrap = GObject.registerClass( +const FocusTrap = GObject.registerClass( class FocusTrap extends St.Widget { vfunc_navigate_focus(from, direction) { if (direction === St.DirectionType.TAB_FORWARD || @@ -26,7 +25,7 @@ function getTermsForSearchString(searchString) { return searchString.split(/\s+/); } -var SearchController = GObject.registerClass({ +export const SearchController = GObject.registerClass({ Properties: { 'search-active': GObject.ParamSpec.boolean( 'search-active', 'search-active', 'search-active', diff --git a/js/ui/sessionMode.js b/js/ui/sessionMode.js index a78e92dea..e2596df3d 100644 --- a/js/ui/sessionMode.js +++ b/js/ui/sessionMode.js @@ -1,11 +1,13 @@ // -*- mode: js; js-indent-level: 4; indent-tabs-mode: nil -*- -/* exported SessionMode, listModes */ -const GLib = imports.gi.GLib; -const Signals = imports.misc.signals; +import GLib from 'gi://GLib'; +import * as Signals from '../misc/signals.js'; -const FileUtils = imports.misc.fileUtils; -const Params = imports.misc.params; +import * as FileUtils from '../misc/fileUtils.js'; +import * as Params from '../misc/params.js'; + +import {LoginDialog} from '../gdm/loginDialog.js'; +import {UnlockDialog} from '../ui/unlockDialog.js'; const Config = imports.misc.config; @@ -53,7 +55,7 @@ const _modes = { hasNotifications: true, isGreeter: true, isPrimary: true, - unlockDialog: imports.gdm.loginDialog.LoginDialog, + unlockDialog: LoginDialog, components: Config.HAVE_NETWORKMANAGER ? ['networkAgent', 'polkitAgent'] : ['polkitAgent'], @@ -90,7 +92,7 @@ const _modes = { hasNotifications: true, isLocked: false, isPrimary: true, - unlockDialog: imports.ui.unlockDialog.UnlockDialog, + unlockDialog: UnlockDialog, components: USER_SESSION_COMPONENTS, panel: { left: ['activities'], @@ -135,7 +137,7 @@ function _loadModes() { _loadMode(dir, info); } -function listModes() { +export function listModes() { _loadModes(); let loop = new GLib.MainLoop(null, false); let id = GLib.idle_add(GLib.PRIORITY_DEFAULT, () => { @@ -150,7 +152,7 @@ function listModes() { loop.run(); } -var SessionMode = class extends Signals.EventEmitter { +export class SessionMode extends Signals.EventEmitter { constructor() { super(); @@ -208,4 +210,4 @@ var SessionMode = class extends Signals.EventEmitter { this.emit('updated'); } -}; +} diff --git a/js/ui/shellDBus.js b/js/ui/shellDBus.js index c36d3fd5b..eb37eff3b 100644 --- a/js/ui/shellDBus.js +++ b/js/ui/shellDBus.js @@ -1,25 +1,24 @@ // -*- mode: js; js-indent-level: 4; indent-tabs-mode: nil -*- -/* exported GnomeShell, ScreenSaverDBus */ -const Gio = imports.gi.Gio; -const GLib = imports.gi.GLib; -const Meta = imports.gi.Meta; -const Shell = imports.gi.Shell; +import Gio from 'gi://Gio'; +import GLib from 'gi://GLib'; +import Meta from 'gi://Meta'; +import Shell from 'gi://Shell'; const Config = imports.misc.config; -const ExtensionDownloader = imports.ui.extensionDownloader; -const ExtensionUtils = imports.misc.extensionUtils; -const Main = imports.ui.main; -const Screenshot = imports.ui.screenshot; +import * as ExtensionDownloader from './extensionDownloader.js'; +import * as ExtensionUtils from '../misc/extensionUtils.js'; +import * as Main from './main.js'; +import * as Screenshot from './screenshot.js'; -const { loadInterfaceXML } = imports.misc.fileUtils; -const { DBusSenderChecker } = imports.misc.util; -const { ControlsState } = imports.ui.overviewControls; +import {loadInterfaceXML} from '../misc/fileUtils.js'; +import {DBusSenderChecker} from '../misc/util.js'; +import {ControlsState} from './overviewControls.js'; const GnomeShellIface = loadInterfaceXML('org.gnome.Shell'); const ScreenSaverIface = loadInterfaceXML('org.gnome.ScreenSaver'); -var GnomeShell = class { +export class GnomeShell { constructor() { this._dbusImpl = Gio.DBusExportedObject.wrapJSObject(GnomeShellIface, this); this._dbusImpl.export(Gio.DBus.session, '/org/gnome/Shell'); @@ -390,11 +389,11 @@ var GnomeShell = class { get ShellVersion() { return Config.PACKAGE_VERSION; } -}; +} const GnomeShellExtensionsIface = loadInterfaceXML('org.gnome.Shell.Extensions'); -var GnomeShellExtensions = class { +class GnomeShellExtensions { constructor() { this._dbusImpl = Gio.DBusExportedObject.wrapJSObject(GnomeShellExtensionsIface, this); this._dbusImpl.export(Gio.DBus.session, '/org/gnome/Shell'); @@ -493,9 +492,9 @@ var GnomeShellExtensions = class { this._dbusImpl.emit_signal('ExtensionStatusChanged', GLib.Variant.new('(sis)', [newState.uuid, newState.state, newState.error])); } -}; +} -var ScreenSaverDBus = class { +export class ScreenSaverDBus { constructor(screenShield) { this._screenShield = screenShield; screenShield.connect('active-changed', shield => { @@ -540,4 +539,4 @@ var ScreenSaverDBus = class { else return 0; } -}; +} diff --git a/js/ui/shellEntry.js b/js/ui/shellEntry.js index e169648d7..6eba2a724 100644 --- a/js/ui/shellEntry.js +++ b/js/ui/shellEntry.js @@ -1,18 +1,17 @@ // -*- mode: js; js-indent-level: 4; indent-tabs-mode: nil -*- -/* exported addContextMenu CapsLockWarning */ -const Clutter = imports.gi.Clutter; -const GObject = imports.gi.GObject; -const Pango = imports.gi.Pango; -const Shell = imports.gi.Shell; -const St = imports.gi.St; +import Clutter from 'gi://Clutter'; +import GObject from 'gi://GObject'; +import Pango from 'gi://Pango'; +import Shell from 'gi://Shell'; +import St from 'gi://St'; -const BoxPointer = imports.ui.boxpointer; -const Main = imports.ui.main; -const Params = imports.misc.params; -const PopupMenu = imports.ui.popupMenu; +import * as BoxPointer from './boxpointer.js'; +import * as Main from './main.js'; +import * as Params from '../misc/params.js'; +import * as PopupMenu from './popupMenu.js'; -var EntryMenu = class extends PopupMenu.PopupMenu { +export class EntryMenu extends PopupMenu.PopupMenu { constructor(entry) { super(entry, 0, St.Side.TOP); @@ -102,7 +101,7 @@ var EntryMenu = class extends PopupMenu.PopupMenu { _onPasswordActivated() { this._entry.password_visible = !this._entry.password_visible; } -}; +} function _setMenuAlignment(entry, stageX) { let [success, entryX] = entry.transform_stage_point(stageX, 0); @@ -135,7 +134,7 @@ function _onPopup(actor, entry) { * @param {St.Entry} entry * @param {*} params */ -function addContextMenu(entry, params) { +export function addContextMenu(entry, params) { if (entry.menu) return; @@ -165,7 +164,7 @@ function addContextMenu(entry, params) { }); } -var CapsLockWarning = GObject.registerClass( +export const CapsLockWarning = GObject.registerClass( class CapsLockWarning extends St.Label { _init(params) { let defaultParams = { style_class: 'caps-lock-warning-label' }; diff --git a/js/ui/shellMountOperation.js b/js/ui/shellMountOperation.js index 15afa7361..035fd971d 100644 --- a/js/ui/shellMountOperation.js +++ b/js/ui/shellMountOperation.js @@ -1,28 +1,27 @@ // -*- mode: js; js-indent-level: 4; indent-tabs-mode: nil -*- -/* exported ShellMountOperation, GnomeShellMountOpHandler */ -const Clutter = imports.gi.Clutter; -const Gio = imports.gi.Gio; -const GLib = imports.gi.GLib; -const GObject = imports.gi.GObject; -const Pango = imports.gi.Pango; -const Shell = imports.gi.Shell; -const St = imports.gi.St; +import Clutter from 'gi://Clutter'; +import Gio from 'gi://Gio'; +import GLib from 'gi://GLib'; +import GObject from 'gi://GObject'; +import Pango from 'gi://Pango'; +import Shell from 'gi://Shell'; +import St from 'gi://St'; -const Animation = imports.ui.animation; -const CheckBox = imports.ui.checkBox; -const Dialog = imports.ui.dialog; -const Main = imports.ui.main; -const MessageTray = imports.ui.messageTray; -const ModalDialog = imports.ui.modalDialog; -const Params = imports.misc.params; -const ShellEntry = imports.ui.shellEntry; +import * as Animation from './animation.js'; +import * as CheckBox from './checkBox.js'; +import * as Dialog from './dialog.js'; +import * as Main from './main.js'; +import * as MessageTray from './messageTray.js'; +import * as ModalDialog from './modalDialog.js'; +import * as Params from '../misc/params.js'; +import * as ShellEntry from './shellEntry.js'; -const { loadInterfaceXML } = imports.misc.fileUtils; -const {wiggle} = imports.misc.animationUtils; +import {loadInterfaceXML} from '../misc/fileUtils.js'; +import {wiggle} from '../misc/animationUtils.js'; -var LIST_ITEM_ICON_SIZE = 48; -var WORK_SPINNER_ICON_SIZE = 16; +const LIST_ITEM_ICON_SIZE = 48; +const WORK_SPINNER_ICON_SIZE = 16; const REMEMBER_MOUNT_PASSWORD_KEY = 'remember-mount-password'; @@ -55,7 +54,7 @@ function _setLabelsForMessage(content, message) { /* -------------------------------------------------------- */ -var ShellMountOperation = class { +export class ShellMountOperation { constructor(source, params) { params = Params.parse(params, { existingDialog: null }); @@ -186,9 +185,9 @@ var ShellMountOperation = class { this._dialog?.disconnectObject(this); return this._dialog; } -}; +} -var ShellUnmountNotifier = GObject.registerClass( +const ShellUnmountNotifier = GObject.registerClass( class ShellUnmountNotifier extends MessageTray.Source { _init() { super._init('', 'media-removable'); @@ -226,7 +225,7 @@ class ShellUnmountNotifier extends MessageTray.Source { } }); -var ShellMountQuestionDialog = GObject.registerClass({ +const ShellMountQuestionDialog = GObject.registerClass({ Signals: { 'response': { param_types: [GObject.TYPE_INT] } }, }, class ShellMountQuestionDialog extends ModalDialog.ModalDialog { _init() { @@ -254,7 +253,7 @@ var ShellMountQuestionDialog = GObject.registerClass({ } }); -var ShellMountPasswordDialog = GObject.registerClass({ +const ShellMountPasswordDialog = GObject.registerClass({ Signals: { 'response': { param_types: [ @@ -475,7 +474,7 @@ var ShellMountPasswordDialog = GObject.registerClass({ } }); -var ShellProcessesDialog = GObject.registerClass({ +const ShellProcessesDialog = GObject.registerClass({ Signals: { 'response': { param_types: [GObject.TYPE_INT] } }, }, class ShellProcessesDialog extends ModalDialog.ModalDialog { _init() { @@ -533,14 +532,14 @@ var ShellProcessesDialog = GObject.registerClass({ const GnomeShellMountOpIface = loadInterfaceXML('org.Gtk.MountOperationHandler'); /** @enum {number} */ -var ShellMountOperationType = { +const ShellMountOperationType = { NONE: 0, ASK_PASSWORD: 1, ASK_QUESTION: 2, SHOW_PROCESSES: 3, }; -var GnomeShellMountOpHandler = class { +export class GnomeShellMountOpHandler { constructor() { this._dbusImpl = Gio.DBusExportedObject.wrapJSObject(GnomeShellMountOpIface, this); this._dbusImpl.export(Gio.DBus.session, '/org/gtk/MountOperationHandler'); @@ -754,4 +753,4 @@ var GnomeShellMountOpHandler = class { this._clearCurrentRequest(Gio.MountOperationResult.UNHANDLED, {}); this._closeDialog(); } -}; +} diff --git a/js/ui/slider.js b/js/ui/slider.js index 797d84c98..6653898b0 100644 --- a/js/ui/slider.js +++ b/js/ui/slider.js @@ -1,15 +1,14 @@ /* -*- mode: js2; js2-basic-offset: 4; indent-tabs-mode: nil -*- */ -/* exported Slider */ -const Atk = imports.gi.Atk; -const Clutter = imports.gi.Clutter; -const GObject = imports.gi.GObject; +import Atk from 'gi://Atk'; +import Clutter from 'gi://Clutter'; +import GObject from 'gi://GObject'; -const BarLevel = imports.ui.barLevel; +import * as BarLevel from './barLevel.js'; -var SLIDER_SCROLL_STEP = 0.02; /* Slider scrolling step in % */ +const SLIDER_SCROLL_STEP = 0.02; /* Slider scrolling step in % */ -var Slider = GObject.registerClass({ +export const Slider = GObject.registerClass({ Signals: { 'drag-begin': {}, 'drag-end': {}, diff --git a/js/ui/status/accessibility.js b/js/ui/status/accessibility.js index e088512c5..783ce20b6 100644 --- a/js/ui/status/accessibility.js +++ b/js/ui/status/accessibility.js @@ -1,13 +1,12 @@ // -*- mode: js; js-indent-level: 4; indent-tabs-mode: nil -*- -/* exported ATIndicator */ -const Gio = imports.gi.Gio; -const GLib = imports.gi.GLib; -const GObject = imports.gi.GObject; -const St = imports.gi.St; +import Gio from 'gi://Gio'; +import GLib from 'gi://GLib'; +import GObject from 'gi://GObject'; +import St from 'gi://St'; -const PanelMenu = imports.ui.panelMenu; -const PopupMenu = imports.ui.popupMenu; +import * as PanelMenu from '../panelMenu.js'; +import * as PopupMenu from '../popupMenu.js'; const A11Y_SCHEMA = 'org.gnome.desktop.a11y'; const KEY_ALWAYS_SHOW = 'always-show-universal-access-status'; @@ -20,7 +19,7 @@ const KEY_MOUSE_KEYS_ENABLED = 'mousekeys-enable'; const APPLICATIONS_SCHEMA = 'org.gnome.desktop.a11y.applications'; -var DPI_FACTOR_LARGE = 1.25; +const DPI_FACTOR_LARGE = 1.25; const WM_SCHEMA = 'org.gnome.desktop.wm.preferences'; const KEY_VISUAL_BELL = 'visual-bell'; @@ -31,7 +30,7 @@ const KEY_TEXT_SCALING_FACTOR = 'text-scaling-factor'; const A11Y_INTERFACE_SCHEMA = 'org.gnome.desktop.a11y.interface'; const KEY_HIGH_CONTRAST = 'high-contrast'; -var ATIndicator = GObject.registerClass( +export const ATIndicator = GObject.registerClass( class ATIndicator extends PanelMenu.Button { _init() { super._init(0.5, _("Accessibility")); diff --git a/js/ui/status/autoRotate.js b/js/ui/status/autoRotate.js index 28ef04a29..277e5fc86 100644 --- a/js/ui/status/autoRotate.js +++ b/js/ui/status/autoRotate.js @@ -1,11 +1,9 @@ -/* exported Indicator */ -const Gio = imports.gi.Gio; -const GObject = imports.gi.GObject; +import Gio from 'gi://Gio'; +import GObject from 'gi://GObject'; +import * as SystemActions from '../../misc/systemActions.js'; -const SystemActions = imports.misc.systemActions; - -const {QuickToggle, SystemIndicator} = imports.ui.quickSettings; +import {QuickToggle, SystemIndicator} from '../quickSettings.js'; const RotationToggle = GObject.registerClass( class RotationToggle extends QuickToggle { @@ -37,7 +35,7 @@ class RotationToggle extends QuickToggle { } }); -var Indicator = GObject.registerClass( +export const Indicator = GObject.registerClass( class Indicator extends SystemIndicator { _init() { super._init(); diff --git a/js/ui/status/backgroundApps.js b/js/ui/status/backgroundApps.js index c5a339700..c2d84424a 100644 --- a/js/ui/status/backgroundApps.js +++ b/js/ui/status/backgroundApps.js @@ -1,17 +1,16 @@ -/* exported Indicator */ -const Clutter = imports.gi.Clutter; -const Gio = imports.gi.Gio; -const GLib = imports.gi.GLib; -const GObject = imports.gi.GObject; -const Shell = imports.gi.Shell; -const St = imports.gi.St; +import Clutter from 'gi://Clutter'; +import Gio from 'gi://Gio'; +import GLib from 'gi://GLib'; +import GObject from 'gi://GObject'; +import Shell from 'gi://Shell'; +import St from 'gi://St'; -const Main = imports.ui.main; -const PopupMenu = imports.ui.popupMenu; -const Util = imports.misc.util; +import * as Main from '../main.js'; +import * as PopupMenu from '../popupMenu.js'; +import * as Util from '../../misc/util.js'; -const {Spinner} = imports.ui.animation; -const {QuickToggle, SystemIndicator} = imports.ui.quickSettings; +import {Spinner} from '../animation.js'; +import {QuickToggle, SystemIndicator} from '../quickSettings.js'; const {loadInterfaceXML} = imports.misc.dbusUtils; const DBUS_NAME = 'org.freedesktop.background.Monitor'; @@ -24,7 +23,7 @@ const BackgroundMonitorProxy = Gio.DBusProxy.makeProxyWrapper(BackgroundMonitorI Gio._promisify(Gio.DBusConnection.prototype, 'call'); -var BackgroundAppMenuItem = GObject.registerClass({ +const BackgroundAppMenuItem = GObject.registerClass({ Properties: { 'app': GObject.ParamSpec.object('app', '', '', GObject.ParamFlags.READWRITE, @@ -255,7 +254,7 @@ class BackgroundAppsToggle extends QuickToggle { } }); -var Indicator = GObject.registerClass( +export const Indicator = GObject.registerClass( class Indicator extends SystemIndicator { _init() { super._init(); diff --git a/js/ui/status/backlight.js b/js/ui/status/backlight.js index 74df6a6cc..f35791848 100644 --- a/js/ui/status/backlight.js +++ b/js/ui/status/backlight.js @@ -1,14 +1,17 @@ // -*- mode: js; js-indent-level: 4; indent-tabs-mode: nil -*- /* exported Indicator */ -const {Clutter, Gio, GObject, St} = imports.gi; +import Clutter from 'gi://Clutter'; +import Gio from 'gi://Gio'; +import GObject from 'gi://GObject'; +import St from 'gi://St'; -const {QuickMenuToggle, SystemIndicator} = imports.ui.quickSettings; +import {QuickMenuToggle, SystemIndicator} from '../quickSettings.js'; -const PopupMenu = imports.ui.popupMenu; -const {Slider} = imports.ui.slider; +import * as PopupMenu from '../popupMenu.js'; +import {Slider} from '../slider.js'; -const {loadInterfaceXML} = imports.misc.fileUtils; +import {loadInterfaceXML} from '../../misc/fileUtils.js'; const BUS_NAME = 'org.gnome.SettingsDaemon.Power'; const OBJECT_PATH = '/org/gnome/SettingsDaemon/Power'; @@ -201,7 +204,7 @@ class KeyboardBrightnessToggle extends QuickMenuToggle { } }); -var Indicator = GObject.registerClass( +export const Indicator = GObject.registerClass( class Indicator extends SystemIndicator { _init() { super._init(); diff --git a/js/ui/status/bluetooth.js b/js/ui/status/bluetooth.js index 8588dbb87..d398f717f 100644 --- a/js/ui/status/bluetooth.js +++ b/js/ui/status/bluetooth.js @@ -1,18 +1,18 @@ // -*- mode: js; js-indent-level: 4; indent-tabs-mode: nil -*- -/* exported Indicator */ +import 'gi://GnomeBluetooth?version=3.0'; -const Gio = imports.gi.Gio; -const GLib = imports.gi.GLib; -const GnomeBluetooth = imports.gi.GnomeBluetooth; -const GObject = imports.gi.GObject; -const Pango = imports.gi.Pango; -const St = imports.gi.St; +import Gio from 'gi://Gio'; +import GLib from 'gi://GLib'; +import GnomeBluetooth from 'gi://GnomeBluetooth'; +import GObject from 'gi://GObject'; +import Pango from 'gi://Pango'; +import St from 'gi://St'; -const {Spinner} = imports.ui.animation; -const PopupMenu = imports.ui.popupMenu; -const {QuickMenuToggle, SystemIndicator} = imports.ui.quickSettings; +import {Spinner} from '../animation.js'; +import * as PopupMenu from '../popupMenu.js'; +import {QuickMenuToggle, SystemIndicator} from '../quickSettings.js'; -const {loadInterfaceXML} = imports.misc.fileUtils; +import {loadInterfaceXML} from '../../misc/fileUtils.js'; const {AdapterState} = GnomeBluetooth; @@ -394,7 +394,7 @@ class BluetoothToggle extends QuickMenuToggle { } }); -var Indicator = GObject.registerClass( +export const Indicator = GObject.registerClass( class Indicator extends SystemIndicator { _init() { super._init(); diff --git a/js/ui/status/brightness.js b/js/ui/status/brightness.js index 38b3f998b..ac6883da3 100644 --- a/js/ui/status/brightness.js +++ b/js/ui/status/brightness.js @@ -1,13 +1,11 @@ // -*- mode: js; js-indent-level: 4; indent-tabs-mode: nil -*- -/* exported Indicator */ -const Gio = imports.gi.Gio; -const GObject = imports.gi.GObject; +import Gio from 'gi://Gio'; +import GObject from 'gi://GObject'; +import {QuickSlider, SystemIndicator} from '../quickSettings.js'; -const {QuickSlider, SystemIndicator} = imports.ui.quickSettings; - -const {loadInterfaceXML} = imports.misc.fileUtils; +import {loadInterfaceXML} from '../../misc/fileUtils.js'; const BUS_NAME = 'org.gnome.SettingsDaemon.Power'; const OBJECT_PATH = '/org/gnome/SettingsDaemon/Power'; @@ -56,7 +54,7 @@ class BrightnessItem extends QuickSlider { } }); -var Indicator = GObject.registerClass( +export const Indicator = GObject.registerClass( class Indicator extends SystemIndicator { _init() { super._init(); diff --git a/js/ui/status/camera.js b/js/ui/status/camera.js index b5ff2ee0a..e6ebbb661 100644 --- a/js/ui/status/camera.js +++ b/js/ui/status/camera.js @@ -1,12 +1,9 @@ -// -*- mode: js; js-indent-level: 4; indent-tabs-mode: nil -*- -/* exported Indicator */ +import GObject from 'gi://GObject'; +import Shell from 'gi://Shell'; -const GObject = imports.gi.GObject; -const Shell = imports.gi.Shell; +import {SystemIndicator} from '../quickSettings.js'; -const {SystemIndicator} = imports.ui.quickSettings; - -var Indicator = GObject.registerClass( +export const Indicator = GObject.registerClass( class Indicator extends SystemIndicator { constructor() { super(); diff --git a/js/ui/status/darkMode.js b/js/ui/status/darkMode.js index 9f4127a02..4e68a7425 100644 --- a/js/ui/status/darkMode.js +++ b/js/ui/status/darkMode.js @@ -1,10 +1,9 @@ -/* exported Indicator */ -const Gio = imports.gi.Gio; -const GObject = imports.gi.GObject; +import Gio from 'gi://Gio'; +import GObject from 'gi://GObject'; +import * as Main from '../main.js'; -const Main = imports.ui.main; -const {QuickToggle, SystemIndicator} = imports.ui.quickSettings; +import {QuickToggle, SystemIndicator} from '../quickSettings.js'; const DarkModeToggle = GObject.registerClass( class DarkModeToggle extends QuickToggle { @@ -41,7 +40,7 @@ class DarkModeToggle extends QuickToggle { } }); -var Indicator = GObject.registerClass( +export const Indicator = GObject.registerClass( class Indicator extends SystemIndicator { _init() { super._init(); diff --git a/js/ui/status/dwellClick.js b/js/ui/status/dwellClick.js index 66ca83a07..2782049c2 100644 --- a/js/ui/status/dwellClick.js +++ b/js/ui/status/dwellClick.js @@ -1,11 +1,10 @@ -/* exported DwellClickIndicator */ -const Clutter = imports.gi.Clutter; -const Gio = imports.gi.Gio; -const GLib = imports.gi.GLib; -const GObject = imports.gi.GObject; -const St = imports.gi.St; +import Clutter from 'gi://Clutter'; +import Gio from 'gi://Gio'; +import GLib from 'gi://GLib'; +import GObject from 'gi://GObject'; +import St from 'gi://St'; -const PanelMenu = imports.ui.panelMenu; +import * as PanelMenu from '../panelMenu.js'; const MOUSE_A11Y_SCHEMA = 'org.gnome.desktop.a11y.mouse'; const KEY_DWELL_CLICK_ENABLED = 'dwell-click-enabled'; @@ -34,7 +33,7 @@ const DWELL_CLICK_MODES = { }, }; -var DwellClickIndicator = GObject.registerClass( +export const DwellClickIndicator = GObject.registerClass( class DwellClickIndicator extends PanelMenu.Button { _init() { super._init(0.5, _("Dwell Click")); diff --git a/js/ui/status/keyboard.js b/js/ui/status/keyboard.js index 7ba16c828..22cd25d0b 100644 --- a/js/ui/status/keyboard.js +++ b/js/ui/status/keyboard.js @@ -1,29 +1,28 @@ // -*- mode: js; js-indent-level: 4; indent-tabs-mode: nil -*- -/* exported InputSourceIndicator */ -const Clutter = imports.gi.Clutter; -const Gio = imports.gi.Gio; -const GLib = imports.gi.GLib; -const GObject = imports.gi.GObject; -const IBus = imports.gi.IBus; -const Meta = imports.gi.Meta; -const Shell = imports.gi.Shell; -const St = imports.gi.St; -const Gettext = imports.gettext; -const Signals = imports.misc.signals; +import Clutter from 'gi://Clutter'; +import Gio from 'gi://Gio'; +import GLib from 'gi://GLib'; +import GObject from 'gi://GObject'; +import IBus from 'gi://IBus'; +import Meta from 'gi://Meta'; +import Shell from 'gi://Shell'; +import St from 'gi://St'; +import * as Gettext from 'gettext'; +import * as Signals from '../../misc/signals.js'; -const IBusManager = imports.misc.ibusManager; -const KeyboardManager = imports.misc.keyboardManager; -const Main = imports.ui.main; -const PopupMenu = imports.ui.popupMenu; -const PanelMenu = imports.ui.panelMenu; -const SwitcherPopup = imports.ui.switcherPopup; -const Util = imports.misc.util; +import * as IBusManager from '../../misc/ibusManager.js'; +import * as KeyboardManager from '../../misc/keyboardManager.js'; +import * as Main from '../main.js'; +import * as PopupMenu from '../popupMenu.js'; +import * as PanelMenu from '../panelMenu.js'; +import * as SwitcherPopup from '../switcherPopup.js'; +import * as Util from '../../misc/util.js'; -var INPUT_SOURCE_TYPE_XKB = 'xkb'; -var INPUT_SOURCE_TYPE_IBUS = 'ibus'; +export const INPUT_SOURCE_TYPE_XKB = 'xkb'; +export const INPUT_SOURCE_TYPE_IBUS = 'ibus'; -var LayoutMenuItem = GObject.registerClass( +export const LayoutMenuItem = GObject.registerClass( class LayoutMenuItem extends PopupMenu.PopupBaseMenuItem { _init(displayName, shortName) { super._init(); @@ -41,7 +40,7 @@ class LayoutMenuItem extends PopupMenu.PopupBaseMenuItem { } }); -var InputSource = class extends Signals.EventEmitter { +export class InputSource extends Signals.EventEmitter { constructor(type, id, displayName, shortName, index) { super(); @@ -79,9 +78,9 @@ var InputSource = class extends Signals.EventEmitter { else return engineDesc.layout; } -}; +} -var InputSourcePopup = GObject.registerClass( +export const InputSourcePopup = GObject.registerClass( class InputSourcePopup extends SwitcherPopup.SwitcherPopup { _init(items, action, actionBackward) { super._init(items); @@ -114,7 +113,7 @@ class InputSourcePopup extends SwitcherPopup.SwitcherPopup { } }); -var InputSourceSwitcher = GObject.registerClass( +const InputSourceSwitcher = GObject.registerClass( class InputSourceSwitcher extends SwitcherPopup.SwitcherList { _init(items) { super._init(true); @@ -145,7 +144,7 @@ class InputSourceSwitcher extends SwitcherPopup.SwitcherList { } }); -var InputSourceSettings = class extends Signals.EventEmitter { +class InputSourceSettings extends Signals.EventEmitter { constructor() { super(); @@ -184,9 +183,9 @@ var InputSourceSettings = class extends Signals.EventEmitter { get perWindow() { return false; } -}; +} -var InputSourceSystemSettings = class extends InputSourceSettings { +class InputSourceSystemSettings extends InputSourceSettings { constructor() { super(); @@ -259,9 +258,9 @@ var InputSourceSystemSettings = class extends InputSourceSettings { get keyboardOptions() { return this._options.split(','); } -}; +} -var InputSourceSessionSettings = class extends InputSourceSettings { +class InputSourceSessionSettings extends InputSourceSettings { constructor() { super(); @@ -309,9 +308,9 @@ var InputSourceSessionSettings = class extends InputSourceSettings { get perWindow() { return this._settings.get_boolean(this._KEY_PER_WINDOW); } -}; +} -var InputSourceManager = class extends Signals.EventEmitter { +export class InputSourceManager extends Signals.EventEmitter { constructor() { super(); @@ -795,20 +794,20 @@ var InputSourceManager = class extends Signals.EventEmitter { get keyboardManager() { return this._keyboardManager; } -}; +} let _inputSourceManager = null; /** * @returns {InputSourceManager} */ -function getInputSourceManager() { +export function getInputSourceManager() { if (_inputSourceManager == null) _inputSourceManager = new InputSourceManager(); return _inputSourceManager; } -var InputSourceIndicatorContainer = GObject.registerClass( +const InputSourceIndicatorContainer = GObject.registerClass( class InputSourceIndicatorContainer extends St.Widget { vfunc_get_preferred_width(forHeight) { // Here, and in vfunc_get_preferred_height, we need to query @@ -848,7 +847,7 @@ class InputSourceIndicatorContainer extends St.Widget { } }); -var InputSourceIndicator = GObject.registerClass( +export const InputSourceIndicator = GObject.registerClass( class InputSourceIndicator extends PanelMenu.Button { _init() { super._init(0.5, _("Keyboard")); diff --git a/js/ui/status/location.js b/js/ui/status/location.js index eb0312d22..5db10dc0c 100644 --- a/js/ui/status/location.js +++ b/js/ui/status/location.js @@ -1,19 +1,18 @@ // -*- mode: js; js-indent-level: 4; indent-tabs-mode: nil -*- -/* exported Indicator */ -const Clutter = imports.gi.Clutter; -const Gio = imports.gi.Gio; -const GLib = imports.gi.GLib; -const GObject = imports.gi.GObject; -const Shell = imports.gi.Shell; -const St = imports.gi.St; +import Clutter from 'gi://Clutter'; +import Gio from 'gi://Gio'; +import GLib from 'gi://GLib'; +import GObject from 'gi://GObject'; +import Shell from 'gi://Shell'; +import St from 'gi://St'; -const Dialog = imports.ui.dialog; -const ModalDialog = imports.ui.modalDialog; -const PermissionStore = imports.misc.permissionStore; -const {SystemIndicator} = imports.ui.quickSettings; +import * as Dialog from '../dialog.js'; +import * as ModalDialog from '../modalDialog.js'; +import * as PermissionStore from '../../misc/permissionStore.js'; +import {SystemIndicator} from '../quickSettings.js'; -const { loadInterfaceXML } = imports.misc.fileUtils; +import {loadInterfaceXML} from '../../misc/fileUtils.js'; const LOCATION_SCHEMA = 'org.gnome.system.location'; const MAX_ACCURACY_LEVEL = 'max-accuracy-level'; @@ -23,7 +22,7 @@ const APP_PERMISSIONS_TABLE = 'location'; const APP_PERMISSIONS_ID = 'location'; /** @enum {number} */ -var GeoclueAccuracyLevel = { +const GeoclueAccuracyLevel = { NONE: 0, COUNTRY: 1, CITY: 4, @@ -41,19 +40,23 @@ function accuracyLevelToString(accuracyLevel) { return 'NONE'; } -var GeoclueIface = loadInterfaceXML('org.freedesktop.GeoClue2.Manager'); +const GeoclueIface = loadInterfaceXML('org.freedesktop.GeoClue2.Manager'); const GeoclueManager = Gio.DBusProxy.makeProxyWrapper(GeoclueIface); -var AgentIface = loadInterfaceXML('org.freedesktop.GeoClue2.Agent'); +const AgentIface = loadInterfaceXML('org.freedesktop.GeoClue2.Agent'); let _geoclueAgent = null; -function _getGeoclueAgent() { + +/** + * @returns {GeoclueAgent} - the GeoclueAgent singleton + */ +export function getGeoclueAgent() { if (_geoclueAgent === null) _geoclueAgent = new GeoclueAgent(); return _geoclueAgent; } -var GeoclueAgent = GObject.registerClass({ +const GeoclueAgent = GObject.registerClass({ Properties: { 'enabled': GObject.ParamSpec.boolean( 'enabled', 'Enabled', 'Enabled', @@ -207,12 +210,12 @@ var GeoclueAgent = GObject.registerClass({ } }); -var Indicator = GObject.registerClass( +export const Indicator = GObject.registerClass( class Indicator extends SystemIndicator { _init() { super._init(); - this._agent = _getGeoclueAgent(); + this._agent = getGeoclueAgent(); this._indicator = this._addIndicator(); this._indicator.icon_name = 'location-services-active-symbolic'; @@ -223,7 +226,7 @@ class Indicator extends SystemIndicator { } }); -var AppAuthorizer = class { +class AppAuthorizer { constructor(desktopId, reqAccuracyLevel, permStoreProxy, maxAccuracyLevel) { this.desktopId = desktopId; this.reqAccuracyLevel = reqAccuracyLevel; @@ -323,9 +326,9 @@ var AppAuthorizer = class { log(error.message); } } -}; +} -var GeolocationDialog = GObject.registerClass({ +export const GeolocationDialog = GObject.registerClass({ Signals: { 'response': { param_types: [GObject.TYPE_UINT] } }, }, class GeolocationDialog extends ModalDialog.ModalDialog { _init(name, reason, reqAccuracyLevel) { diff --git a/js/ui/status/network.js b/js/ui/status/network.js index 1558ff57b..fec78bd1d 100644 --- a/js/ui/status/network.js +++ b/js/ui/status/network.js @@ -1,25 +1,25 @@ // -*- mode: js; js-indent-level: 4; indent-tabs-mode: nil -*- -/* exported Indicator */ -const Atk = imports.gi.Atk; -const Clutter = imports.gi.Clutter; -const Gio = imports.gi.Gio; -const GLib = imports.gi.GLib; -const GObject = imports.gi.GObject; -const NM = imports.gi.NM; -const Polkit = imports.gi.Polkit; -const St = imports.gi.St; -const Main = imports.ui.main; -const PopupMenu = imports.ui.popupMenu; -const MessageTray = imports.ui.messageTray; -const ModemManager = imports.misc.modemManager; -const Util = imports.misc.util; +import Atk from 'gi://Atk'; +import Clutter from 'gi://Clutter'; +import Gio from 'gi://Gio'; +import GLib from 'gi://GLib'; +import GObject from 'gi://GObject'; +import NM from 'gi://NM'; +import Polkit from 'gi://Polkit'; +import St from 'gi://St'; -const {Spinner} = imports.ui.animation; -const {QuickMenuToggle, SystemIndicator} = imports.ui.quickSettings; +import * as Main from '../main.js'; +import * as PopupMenu from '../popupMenu.js'; +import * as MessageTray from '../messageTray.js'; +import * as ModemManager from '../../misc/modemManager.js'; +import * as Util from '../../misc/util.js'; -const {loadInterfaceXML} = imports.misc.fileUtils; -const {registerDestroyableType} = imports.misc.signalTracker; +import {Spinner} from '../animation.js'; +import {QuickMenuToggle, SystemIndicator} from '../quickSettings.js'; + +import {loadInterfaceXML} from '../../misc/fileUtils.js'; +import {registerDestroyableType} from '../../misc/signalTracker.js'; Gio._promisify(Gio.DBusConnection.prototype, 'call'); Gio._promisify(NM.Client, 'new_async'); @@ -33,7 +33,7 @@ const MAX_VISIBLE_NETWORKS = 8; const NM80211Mode = NM['80211Mode']; /** @enum {number} */ -var PortalHelperResult = { +const PortalHelperResult = { CANCELLED: 0, COMPLETED: 1, RECHECK: 2, @@ -1935,7 +1935,7 @@ class NMModemToggle extends NMDeviceToggle { } }); -var Indicator = GObject.registerClass( +export const Indicator = GObject.registerClass( class Indicator extends SystemIndicator { _init() { super._init(); diff --git a/js/ui/status/nightLight.js b/js/ui/status/nightLight.js index 1dbd59f07..06e55aab4 100644 --- a/js/ui/status/nightLight.js +++ b/js/ui/status/nightLight.js @@ -1,13 +1,12 @@ // -*- mode: js; js-indent-level: 4; indent-tabs-mode: nil -*- -/* exported Indicator */ -const Gio = imports.gi.Gio; -const GLib = imports.gi.GLib; -const GObject = imports.gi.GObject; +import Gio from 'gi://Gio'; +import GLib from 'gi://GLib'; +import GObject from 'gi://GObject'; -const {QuickToggle, SystemIndicator} = imports.ui.quickSettings; +import {QuickToggle, SystemIndicator} from '../quickSettings.js'; -const {loadInterfaceXML} = imports.misc.fileUtils; +import {loadInterfaceXML} from '../../misc/fileUtils.js'; const BUS_NAME = 'org.gnome.SettingsDaemon.Color'; const OBJECT_PATH = '/org/gnome/SettingsDaemon/Color'; @@ -38,7 +37,7 @@ class NightLightToggle extends QuickToggle { } }); -var Indicator = GObject.registerClass( +export const Indicator = GObject.registerClass( class Indicator extends SystemIndicator { _init() { super._init(); diff --git a/js/ui/status/powerProfiles.js b/js/ui/status/powerProfiles.js index 566874ee0..a4f9b4d0e 100644 --- a/js/ui/status/powerProfiles.js +++ b/js/ui/status/powerProfiles.js @@ -1,15 +1,14 @@ // -*- mode: js; js-indent-level: 4; indent-tabs-mode: nil -*- -/* exported Indicator */ -const Gio = imports.gi.Gio; -const GObject = imports.gi.GObject; +import Gio from 'gi://Gio'; +import GObject from 'gi://GObject'; -const {QuickMenuToggle, SystemIndicator} = imports.ui.quickSettings; +import {QuickMenuToggle, SystemIndicator} from '../quickSettings.js'; -const PopupMenu = imports.ui.popupMenu; +import * as PopupMenu from '../popupMenu.js'; -const {loadInterfaceXML} = imports.misc.fileUtils; +import {loadInterfaceXML} from '../../misc/fileUtils.js'; const BUS_NAME = 'net.hadess.PowerProfiles'; const OBJECT_PATH = '/net/hadess/PowerProfiles'; @@ -123,7 +122,7 @@ class PowerProfilesToggle extends QuickMenuToggle { } }); -var Indicator = GObject.registerClass( +export const Indicator = GObject.registerClass( class Indicator extends SystemIndicator { _init() { super._init(); diff --git a/js/ui/status/remoteAccess.js b/js/ui/status/remoteAccess.js index d1d8856ec..fab80d1f1 100644 --- a/js/ui/status/remoteAccess.js +++ b/js/ui/status/remoteAccess.js @@ -1,21 +1,20 @@ // -*- mode: js; js-indent-level: 4; indent-tabs-mode: nil -*- -/* exported RemoteAccessApplet, ScreenRecordingIndicator, ScreenSharingIndicator */ -const Atk = imports.gi.Atk; -const Clutter = imports.gi.Clutter; -const GLib = imports.gi.GLib; -const GObject = imports.gi.GObject; -const Meta = imports.gi.Meta; -const St = imports.gi.St; +import Atk from 'gi://Atk'; +import Clutter from 'gi://Clutter'; +import GLib from 'gi://GLib'; +import GObject from 'gi://GObject'; +import Meta from 'gi://Meta'; +import St from 'gi://St'; -const Main = imports.ui.main; -const PanelMenu = imports.ui.panelMenu; -const {SystemIndicator} = imports.ui.quickSettings; +import * as Main from '../main.js'; +import * as PanelMenu from '../panelMenu.js'; +import {SystemIndicator} from '../quickSettings.js'; // Minimum amount of time the shared indicator is visible (in micro seconds) const MIN_SHARED_INDICATOR_VISIBLE_TIME_US = 5 * GLib.TIME_SPAN_SECOND; -var RemoteAccessApplet = GObject.registerClass( +export const RemoteAccessApplet = GObject.registerClass( class RemoteAccessApplet extends SystemIndicator { _init() { super._init(); @@ -66,7 +65,7 @@ class RemoteAccessApplet extends SystemIndicator { } }); -var ScreenRecordingIndicator = GObject.registerClass({ +export const ScreenRecordingIndicator = GObject.registerClass({ Signals: { 'menu-set': {} }, }, class ScreenRecordingIndicator extends PanelMenu.ButtonBox { _init() { @@ -136,7 +135,7 @@ var ScreenRecordingIndicator = GObject.registerClass({ } }); -var ScreenSharingIndicator = GObject.registerClass({ +export const ScreenSharingIndicator = GObject.registerClass({ Signals: {'menu-set': {}}, }, class ScreenSharingIndicator extends PanelMenu.ButtonBox { _init() { diff --git a/js/ui/status/rfkill.js b/js/ui/status/rfkill.js index 6056c9efd..d417de691 100644 --- a/js/ui/status/rfkill.js +++ b/js/ui/status/rfkill.js @@ -1,13 +1,12 @@ // -*- mode: js; js-indent-level: 4; indent-tabs-mode: nil -*- -/* exported Indicator */ -const Gio = imports.gi.Gio; -const GLib = imports.gi.GLib; -const GObject = imports.gi.GObject; +import Gio from 'gi://Gio'; +import GLib from 'gi://GLib'; +import GObject from 'gi://GObject'; -const {QuickToggle, SystemIndicator} = imports.ui.quickSettings; +import {QuickToggle, SystemIndicator} from '../quickSettings.js'; -const {loadInterfaceXML} = imports.misc.fileUtils; +import {loadInterfaceXML} from '../../misc/fileUtils.js'; const BUS_NAME = 'org.gnome.SettingsDaemon.Rfkill'; const OBJECT_PATH = '/org/gnome/SettingsDaemon/Rfkill'; @@ -87,7 +86,7 @@ let _manager; /** * @returns {RfkillManager} */ -function getRfkillManager() { +export function getRfkillManager() { if (_manager != null) return _manager; @@ -116,7 +115,7 @@ class RfkillToggle extends QuickToggle { } }); -var Indicator = GObject.registerClass( +export const Indicator = GObject.registerClass( class Indicator extends SystemIndicator { _init() { super._init(); diff --git a/js/ui/status/system.js b/js/ui/status/system.js index b4f96eb6e..8680b0bdd 100644 --- a/js/ui/status/system.js +++ b/js/ui/status/system.js @@ -1,23 +1,22 @@ // -*- mode: js; js-indent-level: 4; indent-tabs-mode: nil -*- -/* exported Indicator */ -const Atk = imports.gi.Atk; -const Clutter = imports.gi.Clutter; -const Gio = imports.gi.Gio; -const GLib = imports.gi.GLib; -const GObject = imports.gi.GObject; -const Meta = imports.gi.Meta; -const Shell = imports.gi.Shell; -const St = imports.gi.St; -const UPower = imports.gi.UPowerGlib; +import Atk from 'gi://Atk'; +import Clutter from 'gi://Clutter'; +import Gio from 'gi://Gio'; +import GLib from 'gi://GLib'; +import GObject from 'gi://GObject'; +import Meta from 'gi://Meta'; +import Shell from 'gi://Shell'; +import St from 'gi://St'; +import UPower from 'gi://UPowerGlib'; -const SystemActions = imports.misc.systemActions; -const Main = imports.ui.main; -const PopupMenu = imports.ui.popupMenu; -const {PopupAnimation} = imports.ui.boxpointer; +import * as SystemActions from '../../misc/systemActions.js'; +import * as Main from '../main.js'; +import * as PopupMenu from '../popupMenu.js'; +import {PopupAnimation} from '../boxpointer.js'; -const {QuickSettingsItem, QuickToggle, SystemIndicator} = imports.ui.quickSettings; -const {loadInterfaceXML} = imports.misc.fileUtils; +import {QuickSettingsItem, QuickToggle, SystemIndicator} from '../quickSettings.js'; +import {loadInterfaceXML} from '../../misc/fileUtils.js'; const BUS_NAME = 'org.freedesktop.UPower'; const OBJECT_PATH = '/org/freedesktop/UPower/devices/DisplayDevice'; @@ -301,7 +300,7 @@ class SystemItem extends QuickSettingsItem { } }); -var Indicator = GObject.registerClass( +export const Indicator = GObject.registerClass( class Indicator extends SystemIndicator { _init() { super._init(); diff --git a/js/ui/status/thunderbolt.js b/js/ui/status/thunderbolt.js index d3ecdcc48..fe1712496 100644 --- a/js/ui/status/thunderbolt.js +++ b/js/ui/status/thunderbolt.js @@ -1,20 +1,19 @@ // -*- mode: js; js-indent-level: 4; indent-tabs-mode: nil -*- -/* exported Indicator */ // the following is a modified version of bolt/contrib/js/client.js -const Gio = imports.gi.Gio; -const GLib = imports.gi.GLib; -const GObject = imports.gi.GObject; -const Polkit = imports.gi.Polkit; -const Shell = imports.gi.Shell; -const Signals = imports.misc.signals; +import Gio from 'gi://Gio'; +import GLib from 'gi://GLib'; +import GObject from 'gi://GObject'; +import Polkit from 'gi://Polkit'; +import Shell from 'gi://Shell'; +import * as Signals from '../../misc/signals.js'; -const Main = imports.ui.main; -const MessageTray = imports.ui.messageTray; -const {SystemIndicator} = imports.ui.quickSettings; +import * as Main from '../main.js'; +import * as MessageTray from '../messageTray.js'; +import {SystemIndicator} from '../quickSettings.js'; -const { loadInterfaceXML } = imports.misc.fileUtils; +import {loadInterfaceXML} from '../../misc/fileUtils.js'; /* Keep in sync with data/org.freedesktop.bolt.xml */ @@ -24,7 +23,7 @@ const BoltDeviceInterface = loadInterfaceXML('org.freedesktop.bolt1.Device'); const BoltDeviceProxy = Gio.DBusProxy.makeProxyWrapper(BoltDeviceInterface); /** @enum {string} */ -var Status = { +const Status = { DISCONNECTED: 'disconnected', CONNECTING: 'connecting', CONNECTED: 'connected', @@ -34,19 +33,19 @@ var Status = { }; /** @enum {string} */ -var Policy = { +const Policy = { DEFAULT: 'default', MANUAL: 'manual', AUTO: 'auto', }; /** @enum {string} */ -var AuthCtrl = { +const AuthCtrl = { NONE: 'none', }; /** @enum {string} */ -var AuthMode = { +const AuthMode = { DISABLED: 'disabled', ENABLED: 'enabled', }; @@ -55,7 +54,7 @@ const BOLT_DBUS_CLIENT_IFACE = 'org.freedesktop.bolt1.Manager'; const BOLT_DBUS_NAME = 'org.freedesktop.bolt'; const BOLT_DBUS_PATH = '/org/freedesktop/bolt'; -var Client = class extends Signals.EventEmitter { +class Client extends Signals.EventEmitter { constructor() { super(); @@ -128,10 +127,10 @@ var Client = class extends Signals.EventEmitter { get authMode() { return this._proxy.AuthMode; } -}; +} /* helper class to automatically authorize new devices */ -var AuthRobot = class extends Signals.EventEmitter { +class AuthRobot extends Signals.EventEmitter { constructor(client) { super(); @@ -216,11 +215,11 @@ var AuthRobot = class extends Signals.EventEmitter { } return GLib.SOURCE_REMOVE; } -}; +} /* eof client.js */ -var Indicator = GObject.registerClass( +export const Indicator = GObject.registerClass( class Indicator extends SystemIndicator { _init() { super._init(); diff --git a/js/ui/status/volume.js b/js/ui/status/volume.js index ecef81b00..406b533bc 100644 --- a/js/ui/status/volume.js +++ b/js/ui/status/volume.js @@ -1,16 +1,15 @@ // -*- mode: js; js-indent-level: 4; indent-tabs-mode: nil -*- -/* exported OutputIndicator InputIndicator */ -const Clutter = imports.gi.Clutter; -const Gio = imports.gi.Gio; -const GLib = imports.gi.GLib; -const GObject = imports.gi.GObject; -const Gvc = imports.gi.Gvc; +import Clutter from 'gi://Clutter'; +import Gio from 'gi://Gio'; +import GLib from 'gi://GLib'; +import GObject from 'gi://GObject'; +import Gvc from 'gi://Gvc'; -const Main = imports.ui.main; -const PopupMenu = imports.ui.popupMenu; +import * as Main from '../main.js'; +import * as PopupMenu from '../popupMenu.js'; -const {QuickSlider, SystemIndicator} = imports.ui.quickSettings; +import {QuickSlider, SystemIndicator} from '../quickSettings.js'; const ALLOW_AMPLIFIED_VOLUME_KEY = 'allow-volume-above-100-percent'; const UNMUTE_DEFAULT_VOLUME = 0.25; @@ -18,10 +17,11 @@ const UNMUTE_DEFAULT_VOLUME = 0.25; // Each Gvc.MixerControl is a connection to PulseAudio, // so it's better to make it a singleton let _mixerControl; + /** * @returns {Gvc.MixerControl} - the mixer control singleton */ -function getMixerControl() { +export function getMixerControl() { if (_mixerControl) return _mixerControl; @@ -429,7 +429,7 @@ class VolumeIndicator extends SystemIndicator { } }); -var OutputIndicator = GObject.registerClass( +export const OutputIndicator = GObject.registerClass( class OutputIndicator extends VolumeIndicator { constructor() { super(); @@ -469,7 +469,7 @@ class OutputIndicator extends VolumeIndicator { } }); -var InputIndicator = GObject.registerClass( +export const InputIndicator = GObject.registerClass( class InputIndicator extends VolumeIndicator { constructor() { super(); diff --git a/js/ui/swipeTracker.js b/js/ui/swipeTracker.js index e82f66e19..ef1487aa5 100644 --- a/js/ui/swipeTracker.js +++ b/js/ui/swipeTracker.js @@ -1,13 +1,12 @@ // -*- mode: js; js-indent-level: 4; indent-tabs-mode: nil -*- -/* exported SwipeTracker */ -const Clutter = imports.gi.Clutter; -const Gio = imports.gi.Gio; -const GObject = imports.gi.GObject; -const Meta = imports.gi.Meta; +import Clutter from 'gi://Clutter'; +import Gio from 'gi://Gio'; +import GObject from 'gi://GObject'; +import Meta from 'gi://Meta'; -const Main = imports.ui.main; -const Params = imports.misc.params; +import * as Main from './main.js'; +import * as Params from '../misc/params.js'; // FIXME: ideally these values matches physical touchpad size. We can get the // correct values for gnome-shell specifically, since mutter uses libinput @@ -430,7 +429,7 @@ const ScrollGesture = GObject.registerClass({ // instantly. /** A class for handling swipe gestures */ -var SwipeTracker = GObject.registerClass({ +export const SwipeTracker = GObject.registerClass({ Properties: { 'enabled': GObject.ParamSpec.boolean( 'enabled', 'enabled', 'enabled', diff --git a/js/ui/switchMonitor.js b/js/ui/switchMonitor.js index 767b9a1f2..803d3a655 100644 --- a/js/ui/switchMonitor.js +++ b/js/ui/switchMonitor.js @@ -1,16 +1,15 @@ // -*- mode: js; js-indent-level: 4; indent-tabs-mode: nil -*- -/* exported SwitchMonitorPopup */ -const Clutter = imports.gi.Clutter; -const GObject = imports.gi.GObject; -const Meta = imports.gi.Meta; -const St = imports.gi.St; +import Clutter from 'gi://Clutter'; +import GObject from 'gi://GObject'; +import Meta from 'gi://Meta'; +import St from 'gi://St'; -const SwitcherPopup = imports.ui.switcherPopup; +import * as SwitcherPopup from './switcherPopup.js'; -var APP_ICON_SIZE = 96; +const APP_ICON_SIZE = 96; -var SwitchMonitorPopup = GObject.registerClass( +export const SwitchMonitorPopup = GObject.registerClass( class SwitchMonitorPopup extends SwitcherPopup.SwitcherPopup { _init() { let items = []; @@ -93,7 +92,7 @@ class SwitchMonitorPopup extends SwitcherPopup.SwitcherPopup { } }); -var SwitchMonitorSwitcher = GObject.registerClass( +const SwitchMonitorSwitcher = GObject.registerClass( class SwitchMonitorSwitcher extends SwitcherPopup.SwitcherList { _init(items) { super._init(true); diff --git a/js/ui/switcherPopup.js b/js/ui/switcherPopup.js index bc5438020..a5eeee2ae 100644 --- a/js/ui/switcherPopup.js +++ b/js/ui/switcherPopup.js @@ -1,27 +1,26 @@ // -*- mode: js; js-indent-level: 4; indent-tabs-mode: nil -*- -/* exported SwitcherPopup, SwitcherList */ -const Clutter = imports.gi.Clutter; -const GLib = imports.gi.GLib; -const GObject = imports.gi.GObject; -const St = imports.gi.St; +import Clutter from 'gi://Clutter'; +import GLib from 'gi://GLib'; +import GObject from 'gi://GObject'; +import St from 'gi://St'; -const Main = imports.ui.main; +import * as Main from './main.js'; -var POPUP_DELAY_TIMEOUT = 150; // milliseconds +const POPUP_DELAY_TIMEOUT = 150; // milliseconds -var POPUP_SCROLL_TIME = 100; // milliseconds -var POPUP_FADE_OUT_TIME = 100; // milliseconds +const POPUP_SCROLL_TIME = 100; // milliseconds +const POPUP_FADE_OUT_TIME = 100; // milliseconds -var DISABLE_HOVER_TIMEOUT = 500; // milliseconds -var NO_MODS_TIMEOUT = 1500; // milliseconds +const DISABLE_HOVER_TIMEOUT = 500; // milliseconds +const NO_MODS_TIMEOUT = 1500; // milliseconds /** * @param {number} a * @param {number} b * @returns {number} */ -function mod(a, b) { +export function mod(a, b) { return (a + b) % b; } @@ -37,7 +36,7 @@ function primaryModifier(mask) { return primary; } -var SwitcherPopup = GObject.registerClass({ +export const SwitcherPopup = GObject.registerClass({ GTypeFlags: GObject.TypeFlags.ABSTRACT, }, class SwitcherPopup extends St.Widget { _init(items) { @@ -364,7 +363,7 @@ var SwitcherPopup = GObject.registerClass({ } }); -var SwitcherButton = GObject.registerClass( +const SwitcherButton = GObject.registerClass( class SwitcherButton extends St.Button { _init(square) { super._init({ @@ -383,7 +382,7 @@ class SwitcherButton extends St.Button { } }); -var SwitcherList = GObject.registerClass({ +export const SwitcherList = GObject.registerClass({ Signals: { 'item-activated': { param_types: [GObject.TYPE_INT] }, 'item-entered': { param_types: [GObject.TYPE_INT] }, @@ -654,7 +653,7 @@ var SwitcherList = GObject.registerClass({ * @param {St.DrawingArrow} area * @param {St.Side} side */ -function drawArrow(area, side) { +export function drawArrow(area, side) { let themeNode = area.get_theme_node(); let borderColor = themeNode.get_border_color(side); let bodyColor = themeNode.get_foreground_color(); diff --git a/js/ui/unlockDialog.js b/js/ui/unlockDialog.js index 00d445d9b..8859b3c3a 100644 --- a/js/ui/unlockDialog.js +++ b/js/ui/unlockDialog.js @@ -1,24 +1,23 @@ // -*- mode: js; js-indent-level: 4; indent-tabs-mode: nil -*- -/* exported UnlockDialog */ -const AccountsService = imports.gi.AccountsService; -const Atk = imports.gi.Atk; -const Clutter = imports.gi.Clutter; -const Gdm = imports.gi.Gdm; -const Gio = imports.gi.Gio; -const GnomeDesktop = imports.gi.GnomeDesktop; -const GLib = imports.gi.GLib; -const GObject = imports.gi.GObject; -const Shell = imports.gi.Shell; -const St = imports.gi.St; +import AccountsService from 'gi://AccountsService'; +import Atk from 'gi://Atk'; +import Clutter from 'gi://Clutter'; +import Gdm from 'gi://Gdm'; +import Gio from 'gi://Gio'; +import GnomeDesktop from 'gi://GnomeDesktop'; +import GLib from 'gi://GLib'; +import GObject from 'gi://GObject'; +import Shell from 'gi://Shell'; +import St from 'gi://St'; -const Background = imports.ui.background; -const Layout = imports.ui.layout; -const Main = imports.ui.main; -const MessageTray = imports.ui.messageTray; -const SwipeTracker = imports.ui.swipeTracker; -const {formatDateWithCFormatString} = imports.misc.dateUtils; -const AuthPrompt = imports.gdm.authPrompt; +import * as Background from './background.js'; +import * as Layout from './layout.js'; +import * as Main from './main.js'; +import * as MessageTray from './messageTray.js'; +import * as SwipeTracker from './swipeTracker.js'; +import {formatDateWithCFormatString} from '../misc/dateUtils.js'; +import * as AuthPrompt from '../gdm/authPrompt.js'; // The timeout before going back automatically to the lock screen (in seconds) const IDLE_TIMEOUT = 2 * 60; @@ -35,7 +34,7 @@ const BLUR_SIGMA = 45; const SUMMARY_ICON_SIZE = 32; -var NotificationsBox = GObject.registerClass({ +const NotificationsBox = GObject.registerClass({ Signals: { 'wake-up-screen': {} }, }, class NotificationsBox extends St.BoxLayout { _init() { @@ -312,7 +311,7 @@ var NotificationsBox = GObject.registerClass({ } }); -var Clock = GObject.registerClass( +const Clock = GObject.registerClass( class UnlockDialogClock extends St.BoxLayout { _init() { super._init({ style_class: 'unlock-dialog-clock', vertical: true }); @@ -383,7 +382,7 @@ class UnlockDialogClock extends St.BoxLayout { } }); -var UnlockDialogLayout = GObject.registerClass( +const UnlockDialogLayout = GObject.registerClass( class UnlockDialogLayout extends Clutter.LayoutManager { _init(stack, notifications, switchUserButton) { super._init(); @@ -462,7 +461,7 @@ class UnlockDialogLayout extends Clutter.LayoutManager { } }); -var UnlockDialog = GObject.registerClass({ +export const UnlockDialog = GObject.registerClass({ Signals: { 'failed': {}, 'wake-up-screen': {}, diff --git a/js/ui/userWidget.js b/js/ui/userWidget.js index 7de238fd3..b3cbf6f13 100644 --- a/js/ui/userWidget.js +++ b/js/ui/userWidget.js @@ -1,23 +1,22 @@ // -*- mode: js; js-indent-level: 4; indent-tabs-mode: nil -*- // // A widget showing the user avatar and name -/* exported UserWidget */ -const Clutter = imports.gi.Clutter; -const GLib = imports.gi.GLib; -const GObject = imports.gi.GObject; -const St = imports.gi.St; +import Clutter from 'gi://Clutter'; +import GLib from 'gi://GLib'; +import GObject from 'gi://GObject'; +import St from 'gi://St'; -const Params = imports.misc.params; +import * as Params from '../misc/params.js'; -var AVATAR_ICON_SIZE = 64; +const AVATAR_ICON_SIZE = 64; // Adapted from gdm/gui/user-switch-applet/applet.c // // Copyright (C) 2004-2005 James M. Cape . // Copyright (C) 2008,2009 Red Hat, Inc. -var Avatar = GObject.registerClass( +export const Avatar = GObject.registerClass( class Avatar extends St.Bin { _init(user, params) { let themeContext = St.ThemeContext.get_for_stage(global.stage); @@ -96,7 +95,7 @@ class Avatar extends St.Bin { } }); -var UserWidgetLabel = GObject.registerClass( +export const UserWidgetLabel = GObject.registerClass( class UserWidgetLabel extends St.Widget { _init(user) { super._init({ layout_manager: new Clutter.BinLayout() }); @@ -165,7 +164,7 @@ class UserWidgetLabel extends St.Widget { } }); -var UserWidget = GObject.registerClass( +export const UserWidget = GObject.registerClass( class UserWidget extends St.BoxLayout { _init(user, orientation = Clutter.Orientation.HORIZONTAL) { // If user is null, that implies a username-based login authorization. diff --git a/js/ui/welcomeDialog.js b/js/ui/welcomeDialog.js index 4bd11ee5b..37344e219 100644 --- a/js/ui/welcomeDialog.js +++ b/js/ui/welcomeDialog.js @@ -1,23 +1,22 @@ // -*- mode: js; js-indent-level: 4; indent-tabs-mode: nil -*- -/* exported WelcomeDialog */ -const Clutter = imports.gi.Clutter; -const GObject = imports.gi.GObject; -const Shell = imports.gi.Shell; -const St = imports.gi.St; +import Clutter from 'gi://Clutter'; +import GObject from 'gi://GObject'; +import Shell from 'gi://Shell'; +import St from 'gi://St'; const Config = imports.misc.config; -const Dialog = imports.ui.dialog; -const Main = imports.ui.main; -const ModalDialog = imports.ui.modalDialog; +import * as Main from './main.js'; +import * as Dialog from './dialog.js'; +import * as ModalDialog from './modalDialog.js'; /** @enum {number} */ -var DialogResponse = { +const DialogResponse = { NO_THANKS: 0, TAKE_TOUR: 1, }; -var WelcomeDialog = GObject.registerClass( +export const WelcomeDialog = GObject.registerClass( class WelcomeDialog extends ModalDialog.ModalDialog { _init() { super._init({ styleClass: 'welcome-dialog' }); diff --git a/js/ui/windowAttentionHandler.js b/js/ui/windowAttentionHandler.js index c66f6c658..2005c24ef 100644 --- a/js/ui/windowAttentionHandler.js +++ b/js/ui/windowAttentionHandler.js @@ -1,13 +1,12 @@ // -*- mode: js; js-indent-level: 4; indent-tabs-mode: nil -*- -/* exported WindowAttentionHandler */ -const GObject = imports.gi.GObject; -const Shell = imports.gi.Shell; +import GObject from 'gi://GObject'; +import Shell from 'gi://Shell'; -const Main = imports.ui.main; -const MessageTray = imports.ui.messageTray; +import * as Main from './main.js'; +import * as MessageTray from './messageTray.js'; -var WindowAttentionHandler = class { +export class WindowAttentionHandler { constructor() { this._tracker = Shell.WindowTracker.get_default(); global.display.connectObject( @@ -53,9 +52,9 @@ var WindowAttentionHandler = class { notification.update(title, banner); }, source); } -}; +} -var WindowAttentionSource = GObject.registerClass( +const WindowAttentionSource = GObject.registerClass( class WindowAttentionSource extends MessageTray.Source { _init(app, window) { this._window = window; diff --git a/js/ui/windowManager.js b/js/ui/windowManager.js index 04826f013..e401b1cca 100644 --- a/js/ui/windowManager.js +++ b/js/ui/windowManager.js @@ -1,48 +1,48 @@ // -*- mode: js; js-indent-level: 4; indent-tabs-mode: nil -*- -/* exported WindowManager */ -const Clutter = imports.gi.Clutter; -const Gio = imports.gi.Gio; -const GLib = imports.gi.GLib; -const GObject = imports.gi.GObject; -const Meta = imports.gi.Meta; -const Shell = imports.gi.Shell; -const St = imports.gi.St; +import Clutter from 'gi://Clutter'; +import Gio from 'gi://Gio'; +import GLib from 'gi://GLib'; +import GObject from 'gi://GObject'; +import Meta from 'gi://Meta'; +import Shell from 'gi://Shell'; +import St from 'gi://St'; -const AltTab = imports.ui.altTab; -const AppFavorites = imports.ui.appFavorites; -const Dialog = imports.ui.dialog; -const WorkspaceSwitcherPopup = imports.ui.workspaceSwitcherPopup; -const InhibitShortcutsDialog = imports.ui.inhibitShortcutsDialog; -const Main = imports.ui.main; -const ModalDialog = imports.ui.modalDialog; -const WindowMenu = imports.ui.windowMenu; -const PadOsd = imports.ui.padOsd; -const EdgeDragAction = imports.ui.edgeDragAction; -const CloseDialog = imports.ui.closeDialog; -const SwitchMonitor = imports.ui.switchMonitor; -const IBusManager = imports.misc.ibusManager; -const WorkspaceAnimation = imports.ui.workspaceAnimation; +import * as AltTab from './altTab.js'; +import * as AppFavorites from './appFavorites.js'; +import * as Dialog from './dialog.js'; +import * as WorkspaceSwitcherPopup from './workspaceSwitcherPopup.js'; +import * as InhibitShortcutsDialog from './inhibitShortcutsDialog.js'; +import * as ModalDialog from './modalDialog.js'; +import * as WindowMenu from './windowMenu.js'; +import * as PadOsd from './padOsd.js'; +import * as EdgeDragAction from './edgeDragAction.js'; +import * as CloseDialog from './closeDialog.js'; +import * as SwitchMonitor from './switchMonitor.js'; +import * as IBusManager from '../misc/ibusManager.js'; +import * as WorkspaceAnimation from './workspaceAnimation.js'; -const { loadInterfaceXML } = imports.misc.fileUtils; +import {loadInterfaceXML} from '../misc/fileUtils.js'; +import * as Main from './main.js'; -var SHELL_KEYBINDINGS_SCHEMA = 'org.gnome.shell.keybindings'; -var MINIMIZE_WINDOW_ANIMATION_TIME = 400; -var MINIMIZE_WINDOW_ANIMATION_MODE = Clutter.AnimationMode.EASE_OUT_EXPO; -var SHOW_WINDOW_ANIMATION_TIME = 150; -var DIALOG_SHOW_WINDOW_ANIMATION_TIME = 100; -var DESTROY_WINDOW_ANIMATION_TIME = 150; -var DIALOG_DESTROY_WINDOW_ANIMATION_TIME = 100; -var WINDOW_ANIMATION_TIME = 250; -var SCROLL_TIMEOUT_TIME = 150; -var DIM_BRIGHTNESS = -0.3; -var DIM_TIME = 500; -var UNDIM_TIME = 250; -var APP_MOTION_THRESHOLD = 30; +export const SHELL_KEYBINDINGS_SCHEMA = 'org.gnome.shell.keybindings'; -var ONE_SECOND = 1000; // in ms +const MINIMIZE_WINDOW_ANIMATION_TIME = 400; +const MINIMIZE_WINDOW_ANIMATION_MODE = Clutter.AnimationMode.EASE_OUT_EXPO; +const SHOW_WINDOW_ANIMATION_TIME = 150; +const DIALOG_SHOW_WINDOW_ANIMATION_TIME = 100; +const DESTROY_WINDOW_ANIMATION_TIME = 150; +const DIALOG_DESTROY_WINDOW_ANIMATION_TIME = 100; +const WINDOW_ANIMATION_TIME = 250; +const SCROLL_TIMEOUT_TIME = 150; +const DIM_BRIGHTNESS = -0.3; +const DIM_TIME = 500; +const UNDIM_TIME = 250; +const APP_MOTION_THRESHOLD = 30; -var MIN_NUM_WORKSPACES = 2; +const ONE_SECOND = 1000; // in ms + +const MIN_NUM_WORKSPACES = 2; const GSD_WACOM_BUS_NAME = 'org.gnome.SettingsDaemon.Wacom'; const GSD_WACOM_OBJECT_PATH = '/org/gnome/SettingsDaemon/Wacom'; @@ -55,7 +55,7 @@ const WINDOW_DIMMER_EFFECT_NAME = "gnome-shell-window-dimmer"; Gio._promisify(Shell, 'util_start_systemd_unit'); Gio._promisify(Shell, 'util_stop_systemd_unit'); -var DisplayChangeDialog = GObject.registerClass( +const DisplayChangeDialog = GObject.registerClass( class DisplayChangeDialog extends ModalDialog.ModalDialog { _init(wm) { super._init(); @@ -132,7 +132,7 @@ class DisplayChangeDialog extends ModalDialog.ModalDialog { } }); -var WindowDimmer = GObject.registerClass( +export const WindowDimmer = GObject.registerClass( class WindowDimmer extends Clutter.BrightnessContrastEffect { _init() { super._init({ @@ -180,9 +180,9 @@ function getWindowDimmer(actor) { * the main window of an application, and give the app a grace period * where it can map another window before we remove the workspace. */ -var LAST_WINDOW_GRACE_TIME = 1000; +const LAST_WINDOW_GRACE_TIME = 1000; -var WorkspaceTracker = class { +class WorkspaceTracker { constructor(wm) { this._wm = wm; @@ -385,9 +385,9 @@ var WorkspaceTracker = class { return false; } -}; +} -var TilePreview = GObject.registerClass( +export const TilePreview = GObject.registerClass( class TilePreview extends St.Widget { _init() { super._init(); @@ -475,7 +475,7 @@ class TilePreview extends St.Widget { } }); -var AppSwitchAction = GObject.registerClass({ +const AppSwitchAction = GObject.registerClass({ Signals: { 'activated': {} }, }, class AppSwitchAction extends Clutter.GestureAction { _init() { @@ -532,7 +532,7 @@ var AppSwitchAction = GObject.registerClass({ } }); -var ResizePopup = GObject.registerClass( +const ResizePopup = GObject.registerClass( class ResizePopup extends St.Widget { _init() { super._init({ layout_manager: new Clutter.BinLayout() }); @@ -558,7 +558,7 @@ class ResizePopup extends St.Widget { } }); -var WindowManager = class { +export class WindowManager { constructor() { this._shellwm = global.window_manager; @@ -1943,4 +1943,4 @@ var WindowManager = class { this._resizePopup = null; } } -}; +} diff --git a/js/ui/windowMenu.js b/js/ui/windowMenu.js index 72a65df53..1b6d0519d 100644 --- a/js/ui/windowMenu.js +++ b/js/ui/windowMenu.js @@ -1,16 +1,15 @@ // -*- mode: js; js-indent-level: 4; indent-tabs-mode: nil -* -/* exported WindowMenuManager */ -const Clutter = imports.gi.Clutter; -const Meta = imports.gi.Meta; -const St = imports.gi.St; +import Clutter from 'gi://Clutter'; +import Meta from 'gi://Meta'; +import St from 'gi://St'; -const BoxPointer = imports.ui.boxpointer; -const Main = imports.ui.main; -const PopupMenu = imports.ui.popupMenu; -const Screenshot = imports.ui.screenshot; +import * as BoxPointer from './boxpointer.js'; +import * as Main from './main.js'; +import * as PopupMenu from './popupMenu.js'; +import * as Screenshot from './screenshot.js'; -var WindowMenu = class extends PopupMenu.PopupMenu { +export class WindowMenu extends PopupMenu.PopupMenu { constructor(window, sourceActor) { super(sourceActor, 0, St.Side.TOP); @@ -212,9 +211,9 @@ var WindowMenu = class extends PopupMenu.PopupMenu { if (!window.can_close()) item.setSensitive(false); } -}; +} -var WindowMenuManager = class { +export class WindowMenuManager { constructor() { this._manager = new PopupMenu.PopupMenuManager(Main.layoutManager.dummyCursor); @@ -257,4 +256,4 @@ var WindowMenuManager = class { window.disconnect(destroyId); }); } -}; +} diff --git a/js/ui/windowPreview.js b/js/ui/windowPreview.js index 984571520..bc1d792e1 100644 --- a/js/ui/windowPreview.js +++ b/js/ui/windowPreview.js @@ -1,35 +1,34 @@ // -*- mode: js; js-indent-level: 4; indent-tabs-mode: nil -*- -/* exported WindowPreview */ -const Atk = imports.gi.Atk; -const Clutter = imports.gi.Clutter; -const GLib = imports.gi.GLib; -const GObject = imports.gi.GObject; -const Graphene = imports.gi.Graphene; -const Meta = imports.gi.Meta; -const Pango = imports.gi.Pango; -const Shell = imports.gi.Shell; -const St = imports.gi.St; +import Atk from 'gi://Atk'; +import Clutter from 'gi://Clutter'; +import GLib from 'gi://GLib'; +import GObject from 'gi://GObject'; +import Graphene from 'gi://Graphene'; +import Meta from 'gi://Meta'; +import Pango from 'gi://Pango'; +import Shell from 'gi://Shell'; +import St from 'gi://St'; -const DND = imports.ui.dnd; -const OverviewControls = imports.ui.overviewControls; +import * as DND from './dnd.js'; +import * as OverviewControls from './overviewControls.js'; -var WINDOW_DND_SIZE = 256; +const WINDOW_DND_SIZE = 256; -var WINDOW_OVERLAY_IDLE_HIDE_TIMEOUT = 750; -var WINDOW_OVERLAY_FADE_TIME = 200; +const WINDOW_OVERLAY_IDLE_HIDE_TIMEOUT = 750; +const WINDOW_OVERLAY_FADE_TIME = 200; -var WINDOW_SCALE_TIME = 200; -var WINDOW_ACTIVE_SIZE_INC = 5; // in each direction +const WINDOW_SCALE_TIME = 200; +const WINDOW_ACTIVE_SIZE_INC = 5; // in each direction -var DRAGGING_WINDOW_OPACITY = 100; +const DRAGGING_WINDOW_OPACITY = 100; const ICON_SIZE = 64; const ICON_OVERLAP = 0.7; const ICON_TITLE_SPACING = 6; -var WindowPreview = GObject.registerClass({ +export const WindowPreview = GObject.registerClass({ Properties: { 'overlay-enabled': GObject.ParamSpec.boolean( 'overlay-enabled', 'overlay-enabled', 'overlay-enabled', diff --git a/js/ui/workspace.js b/js/ui/workspace.js index b59e92f64..e9542c8d2 100644 --- a/js/ui/workspace.js +++ b/js/ui/workspace.js @@ -1,33 +1,33 @@ // -*- mode: js; js-indent-level: 4; indent-tabs-mode: nil -*- -/* exported Workspace */ -const Clutter = imports.gi.Clutter; -const GLib = imports.gi.GLib; -const GObject = imports.gi.GObject; -const Graphene = imports.gi.Graphene; -const Meta = imports.gi.Meta; -const Shell = imports.gi.Shell; -const St = imports.gi.St; +import Clutter from 'gi://Clutter'; +import GLib from 'gi://GLib'; +import GObject from 'gi://GObject'; +import Graphene from 'gi://Graphene'; +import Meta from 'gi://Meta'; +import Shell from 'gi://Shell'; +import St from 'gi://St'; -const Background = imports.ui.background; -const DND = imports.ui.dnd; -const Main = imports.ui.main; -const OverviewControls = imports.ui.overviewControls; -const Params = imports.misc.params; -const Util = imports.misc.util; -const { WindowPreview } = imports.ui.windowPreview; +import * as Background from './background.js'; +import * as DND from './dnd.js'; +import * as Main from './main.js'; +import * as OverviewControls from './overviewControls.js'; +import * as Params from '../misc/params.js'; -var WINDOW_PREVIEW_MAXIMUM_SCALE = 0.95; +import * as Util from '../misc/util.js'; +import {WindowPreview} from './windowPreview.js'; -var WINDOW_REPOSITIONING_DELAY = 750; +const WINDOW_PREVIEW_MAXIMUM_SCALE = 0.95; + +const WINDOW_REPOSITIONING_DELAY = 750; // When calculating a layout, we calculate the scale of windows and the percent // of the available area the new layout uses. If the values for the new layout, // when weighted with the values as below, are worse than the previous layout's, // we stop looking for a new layout and use the previous layout. // Otherwise, we keep looking for a new layout. -var LAYOUT_SCALE_WEIGHT = 1; -var LAYOUT_SPACE_WEIGHT = 0.1; +const LAYOUT_SCALE_WEIGHT = 1; +const LAYOUT_SPACE_WEIGHT = 0.1; const BACKGROUND_CORNER_RADIUS_PIXELS = 30; @@ -101,7 +101,7 @@ const BACKGROUND_CORNER_RADIUS_PIXELS = 30; // each window's "cell" area to be the same, but we shrink the thumbnail // and center it horizontally, and align it to the bottom vertically. -var LayoutStrategy = class { +export class LayoutStrategy { constructor(params) { params = Params.parse(params, { monitor: null, @@ -142,9 +142,9 @@ var LayoutStrategy = class { computeWindowSlots(_layout, _area) { throw new GObject.NotImplementedError(`computeWindowSlots in ${this.constructor.name}`); } -}; +} -var UnalignedLayoutStrategy = class extends LayoutStrategy { +class UnalignedLayoutStrategy extends LayoutStrategy { _newRow() { // Row properties: // @@ -386,7 +386,7 @@ var UnalignedLayoutStrategy = class extends LayoutStrategy { } return slots; } -}; +} function animateAllocation(actor, box) { actor.save_easing_state(); @@ -400,7 +400,7 @@ function animateAllocation(actor, box) { return actor.get_transition('allocation'); } -var WorkspaceLayout = GObject.registerClass({ +export const WorkspaceLayout = GObject.registerClass({ Properties: { 'spacing': GObject.ParamSpec.double( 'spacing', 'Spacing', 'Spacing', @@ -944,7 +944,7 @@ var WorkspaceLayout = GObject.registerClass({ } }); -var WorkspaceBackground = GObject.registerClass( +export const WorkspaceBackground = GObject.registerClass( class WorkspaceBackground extends Shell.WorkspaceBackground { _init(monitorIndex, stateAdjustment) { super._init({ @@ -1036,7 +1036,7 @@ class WorkspaceBackground extends Shell.WorkspaceBackground { /** * @metaWorkspace: a #Meta.Workspace, or null */ -var Workspace = GObject.registerClass( +export const Workspace = GObject.registerClass( class Workspace extends St.Widget { _init(metaWorkspace, monitorIndex, overviewAdjustment) { super._init({ diff --git a/js/ui/workspaceAnimation.js b/js/ui/workspaceAnimation.js index 5c7f41b5f..232befbb9 100644 --- a/js/ui/workspaceAnimation.js +++ b/js/ui/workspaceAnimation.js @@ -1,21 +1,21 @@ // -*- mode: js; js-indent-level: 4; indent-tabs-mode: nil -*- -/* exported WorkspaceAnimationController, WorkspaceGroup */ -const Clutter = imports.gi.Clutter; -const GObject = imports.gi.GObject; -const Meta = imports.gi.Meta; -const Shell = imports.gi.Shell; -const St = imports.gi.St; +import Clutter from 'gi://Clutter'; +import GObject from 'gi://GObject'; +import Meta from 'gi://Meta'; +import Shell from 'gi://Shell'; +import St from 'gi://St'; -const Background = imports.ui.background; -const Layout = imports.ui.layout; -const Main = imports.ui.main; -const SwipeTracker = imports.ui.swipeTracker; +import * as Background from './background.js'; +import * as Layout from './layout.js'; +import * as SwipeTracker from './swipeTracker.js'; + +import * as Main from './main.js'; const WINDOW_ANIMATION_TIME = 250; const WORKSPACE_SPACING = 100; -var WorkspaceGroup = GObject.registerClass( +const WorkspaceGroup = GObject.registerClass( class WorkspaceGroup extends Clutter.Actor { _init(workspace, monitor, movingWindow) { super._init(); @@ -270,7 +270,7 @@ const MonitorGroup = GObject.registerClass({ } }); -var WorkspaceAnimationController = class { +export class WorkspaceAnimationController { constructor() { this._movingWindow = null; this._switchData = null; @@ -497,4 +497,4 @@ var WorkspaceAnimationController = class { get movingWindow() { return this._movingWindow; } -}; +} diff --git a/js/ui/workspaceSwitcherPopup.js b/js/ui/workspaceSwitcherPopup.js index 134267925..f0e3016c1 100644 --- a/js/ui/workspaceSwitcherPopup.js +++ b/js/ui/workspaceSwitcherPopup.js @@ -1,19 +1,18 @@ // -*- mode: js; js-indent-level: 4; indent-tabs-mode: nil -*- -/* exported WorkspaceSwitcherPopup */ -const Clutter = imports.gi.Clutter; -const GLib = imports.gi.GLib; -const GObject = imports.gi.GObject; -const St = imports.gi.St; +import Clutter from 'gi://Clutter'; +import GLib from 'gi://GLib'; +import GObject from 'gi://GObject'; +import St from 'gi://St'; -const Layout = imports.ui.layout; -const Main = imports.ui.main; +import * as Layout from './layout.js'; +import * as Main from './main.js'; -var ANIMATION_TIME = 100; -var DISPLAY_TIMEOUT = 600; +const ANIMATION_TIME = 100; +const DISPLAY_TIMEOUT = 600; -var WorkspaceSwitcherPopup = GObject.registerClass( +export const WorkspaceSwitcherPopup = GObject.registerClass( class WorkspaceSwitcherPopup extends Clutter.Actor { _init() { super._init({ diff --git a/js/ui/workspaceThumbnail.js b/js/ui/workspaceThumbnail.js index 8a2abb2db..b8ca2a289 100644 --- a/js/ui/workspaceThumbnail.js +++ b/js/ui/workspaceThumbnail.js @@ -1,41 +1,40 @@ // -*- mode: js; js-indent-level: 4; indent-tabs-mode: nil -*- -/* exported WorkspaceThumbnail, ThumbnailsBox */ -const Clutter = imports.gi.Clutter; -const Gio = imports.gi.Gio; -const GLib = imports.gi.GLib; -const GObject = imports.gi.GObject; -const Graphene = imports.gi.Graphene; -const Meta = imports.gi.Meta; -const Shell = imports.gi.Shell; -const St = imports.gi.St; +import Clutter from 'gi://Clutter'; +import Gio from 'gi://Gio'; +import GLib from 'gi://GLib'; +import GObject from 'gi://GObject'; +import Meta from 'gi://Meta'; +import Shell from 'gi://Shell'; +import St from 'gi://St'; +import Graphene from 'gi://Graphene'; -const DND = imports.ui.dnd; -const Main = imports.ui.main; -const { TransientSignalHolder } = imports.misc.signalTracker; -const Util = imports.misc.util; -const Workspace = imports.ui.workspace; +import * as DND from './dnd.js'; +import * as Main from './main.js'; +import {TransientSignalHolder} from '../misc/signalTracker.js'; +import * as Util from '../misc/util.js'; +import * as Workspace from './workspace.js'; const NUM_WORKSPACES_THRESHOLD = 2; // The maximum size of a thumbnail is 5% the width and height of the screen -var MAX_THUMBNAIL_SCALE = 0.05; +export const MAX_THUMBNAIL_SCALE = 0.05; -var RESCALE_ANIMATION_TIME = 200; -var SLIDE_ANIMATION_TIME = 200; +const RESCALE_ANIMATION_TIME = 200; +const SLIDE_ANIMATION_TIME = 200; // When we create workspaces by dragging, we add a "cut" into the top and // bottom of each workspace so that the user doesn't have to hit the // placeholder exactly. -var WORKSPACE_CUT_SIZE = 10; +const WORKSPACE_CUT_SIZE = 10; -var WORKSPACE_KEEP_ALIVE_TIME = 100; +const WORKSPACE_KEEP_ALIVE_TIME = 100; -var MUTTER_SCHEMA = 'org.gnome.mutter'; +const MUTTER_SCHEMA = 'org.gnome.mutter'; /* A layout manager that requests size only for primary_actor, but then allocates all using a fixed layout */ -var PrimaryActorLayout = GObject.registerClass( +const PrimaryActorLayout = GObject.registerClass( class PrimaryActorLayout extends Clutter.FixedLayout { _init(primaryActor) { super._init(); @@ -52,7 +51,7 @@ class PrimaryActorLayout extends Clutter.FixedLayout { } }); -var WindowClone = GObject.registerClass({ +export const WindowClone = GObject.registerClass({ Signals: { 'drag-begin': {}, 'drag-cancelled': {}, @@ -211,7 +210,7 @@ var WindowClone = GObject.registerClass({ }); -var ThumbnailState = { +const ThumbnailState = { NEW: 0, EXPANDING: 1, EXPANDED: 2, @@ -227,7 +226,7 @@ var ThumbnailState = { /** * @metaWorkspace: a #Meta.Workspace */ -var WorkspaceThumbnail = GObject.registerClass({ +export const WorkspaceThumbnail = GObject.registerClass({ Properties: { 'collapse-fraction': GObject.ParamSpec.double( 'collapse-fraction', 'collapse-fraction', 'collapse-fraction', @@ -573,7 +572,7 @@ var WorkspaceThumbnail = GObject.registerClass({ }); -var ThumbnailsBox = GObject.registerClass({ +export const ThumbnailsBox = GObject.registerClass({ Properties: { 'expand-fraction': GObject.ParamSpec.double( 'expand-fraction', 'expand-fraction', 'expand-fraction', diff --git a/js/ui/workspacesView.js b/js/ui/workspacesView.js index 009d6703c..6e90f2c3c 100644 --- a/js/ui/workspacesView.js +++ b/js/ui/workspacesView.js @@ -1,22 +1,22 @@ // -*- mode: js; js-indent-level: 4; indent-tabs-mode: nil -*- -/* exported WorkspacesView, WorkspacesDisplay */ -const Clutter = imports.gi.Clutter; -const Gio = imports.gi.Gio; -const GObject = imports.gi.GObject; -const Meta = imports.gi.Meta; -const Shell = imports.gi.Shell; -const St = imports.gi.St; +import Clutter from 'gi://Clutter'; +import Gio from 'gi://Gio'; +import GObject from 'gi://GObject'; +import Meta from 'gi://Meta'; +import Shell from 'gi://Shell'; +import St from 'gi://St'; -const Layout = imports.ui.layout; -const Main = imports.ui.main; -const OverviewControls = imports.ui.overviewControls; -const SwipeTracker = imports.ui.swipeTracker; -const Util = imports.misc.util; -const Workspace = imports.ui.workspace; -const { ThumbnailsBox, MAX_THUMBNAIL_SCALE } = imports.ui.workspaceThumbnail; +import * as Layout from './layout.js'; -var WORKSPACE_SWITCH_TIME = 250; +import * as Main from './main.js'; +import * as OverviewControls from './overviewControls.js'; +import * as SwipeTracker from './swipeTracker.js'; +import * as Util from '../misc/util.js'; +import * as Workspace from './workspace.js'; +import {ThumbnailsBox, MAX_THUMBNAIL_SCALE} from './workspaceThumbnail.js'; + +const WORKSPACE_SWITCH_TIME = 250; const MUTTER_SCHEMA = 'org.gnome.mutter'; @@ -27,7 +27,7 @@ const WORKSPACE_INACTIVE_SCALE = 0.94; const SECONDARY_WORKSPACE_SCALE = 0.80; -var WorkspacesViewBase = GObject.registerClass({ +const WorkspacesViewBase = GObject.registerClass({ GTypeFlags: GObject.TypeFlags.ABSTRACT, }, class WorkspacesViewBase extends St.Widget { _init(monitorIndex, overviewAdjustment) { @@ -83,12 +83,12 @@ var WorkspacesViewBase = GObject.registerClass({ }); /** @enum {number} */ -var FitMode = { +export const FitMode = { SINGLE: 0, ALL: 1, }; -var WorkspacesView = GObject.registerClass( +export const WorkspacesView = GObject.registerClass( class WorkspacesView extends WorkspacesViewBase { _init(monitorIndex, controls, scrollAdjustment, fitModeAdjustment, overviewAdjustment) { let workspaceManager = global.workspace_manager; @@ -530,7 +530,7 @@ class WorkspacesView extends WorkspacesViewBase { } }); -var ExtraWorkspaceView = GObject.registerClass( +export const ExtraWorkspaceView = GObject.registerClass( class ExtraWorkspaceView extends WorkspacesViewBase { _init(monitorIndex, overviewAdjustment) { super._init(monitorIndex, overviewAdjustment); @@ -580,7 +580,7 @@ class ExtraWorkspaceView extends WorkspacesViewBase { } }); -const SecondaryMonitorDisplay = GObject.registerClass( +export const SecondaryMonitorDisplay = GObject.registerClass( class SecondaryMonitorDisplay extends St.Widget { _init(monitorIndex, controls, scrollAdjustment, fitModeAdjustment, overviewAdjustment) { this._monitorIndex = monitorIndex; @@ -807,7 +807,7 @@ class SecondaryMonitorDisplay extends St.Widget { } }); -var WorkspacesDisplay = GObject.registerClass( +export const WorkspacesDisplay = GObject.registerClass( class WorkspacesDisplay extends St.Widget { _init(controls, scrollAdjustment, overviewAdjustment) { super._init({ diff --git a/js/ui/xdndHandler.js b/js/ui/xdndHandler.js index d610f6396..1523a150f 100644 --- a/js/ui/xdndHandler.js +++ b/js/ui/xdndHandler.js @@ -1,13 +1,12 @@ // -*- mode: js; js-indent-level: 4; indent-tabs-mode: nil -*- -/* exported XdndHandler */ -const Clutter = imports.gi.Clutter; -const Signals = imports.misc.signals; +import Clutter from 'gi://Clutter'; +import * as Signals from '../misc/signals.js'; -const DND = imports.ui.dnd; -const Main = imports.ui.main; +import * as DND from './dnd.js'; +import * as Main from './main.js'; -var XdndHandler = class extends Signals.EventEmitter { +export class XdndHandler extends Signals.EventEmitter { constructor() { super(); @@ -113,4 +112,4 @@ var XdndHandler = class extends Signals.EventEmitter { pickedActor = pickedActor.get_parent(); } } -}; +} diff --git a/tests/shell/basic.js b/tests/shell/basic.js index 30f183aa1..831382932 100644 --- a/tests/shell/basic.js +++ b/tests/shell/basic.js @@ -3,9 +3,9 @@ import St from 'gi://St'; -const Main = imports.ui.main; -const MessageTray = imports.ui.messageTray; -import * as Scripting from 'resource://org/gnome/shell/ui/scripting.js'; +import * as Main from 'resource:///org/gnome/shell/ui/main.js'; +import * as MessageTray from 'resource:///org/gnome/shell/ui/messageTray.js'; +import * as Scripting from 'resource:///org/gnome/shell/ui/scripting.js'; // This script tests the most important (basic) functionality of the shell. diff --git a/tests/shell/closeWithActiveWindows.js b/tests/shell/closeWithActiveWindows.js index cee470095..a0d7e8f04 100644 --- a/tests/shell/closeWithActiveWindows.js +++ b/tests/shell/closeWithActiveWindows.js @@ -3,8 +3,8 @@ import Clutter from 'gi://Clutter'; -const Main = imports.ui.main; -import * as Scripting from 'resource://org/gnome/shell/ui/scripting.js'; +import * as Main from 'resource:///org/gnome/shell/ui/main.js'; +import * as Scripting from 'resource:///org/gnome/shell/ui/scripting.js'; /** Run test. */ export async function run() { diff --git a/tests/shell/core.js b/tests/shell/core.js index 593382ac4..cd2a09a16 100644 --- a/tests/shell/core.js +++ b/tests/shell/core.js @@ -1,10 +1,10 @@ // -*- mode: js; js-indent-level: 4; indent-tabs-mode: nil -*- /* eslint camelcase: ["error", { properties: "never", allow: ["^script_", "^malloc", "^glx", "^clutter"] }] */ -import System from 'system'; +import * as System from 'system'; -const Main = imports.ui.main; -import * as Scripting from 'resource://org/gnome/shell/ui/scripting.js'; +import * as Main from 'resource:///org/gnome/shell/ui/main.js'; +import * as Scripting from 'resource:///org/gnome/shell/ui/scripting.js'; // This performance script measure the most important (core) performance // metrics for the shell. By looking at the output metrics of this script diff --git a/tests/shell/headlessStart.js b/tests/shell/headlessStart.js index cf9c9436c..00db301c1 100644 --- a/tests/shell/headlessStart.js +++ b/tests/shell/headlessStart.js @@ -5,8 +5,8 @@ import GLib from 'gi://GLib'; import MetaTest from 'gi://MetaTest'; import Shell from 'gi://Shell'; -const Main = imports.ui.main; -import * as Scripting from 'resource://org/gnome/shell/ui/scripting.js'; +import * as Main from 'resource:///org/gnome/shell/ui/main.js'; +import * as Scripting from 'resource:///org/gnome/shell/ui/scripting.js'; // This script tests that the shell handles connecting monitors after startup // is properly handled. @@ -57,7 +57,6 @@ export async function run() { () => Scripting.scriptEvent('overviewShowDone')); Main.overview.connect('hidden', () => Scripting.scriptEvent('overviewHideDone')); - Main.overview.hide(); await Scripting.waitLeisure(); diff --git a/tests/shell/hwtest.js b/tests/shell/hwtest.js index e9e0ab074..8ded32388 100644 --- a/tests/shell/hwtest.js +++ b/tests/shell/hwtest.js @@ -2,8 +2,9 @@ import Clutter from 'gi://Clutter'; import Gio from 'gi://Gio'; import Shell from 'gi://Shell'; -const Main = imports.ui.main; -import * as Scripting from 'resource://org/gnome/shell/ui/scripting.js'; + +import * as Main from 'resource:///org/gnome/shell/ui/main.js'; +import * as Scripting from 'resource:///org/gnome/shell/ui/scripting.js'; export var METRICS = { timeToDesktop: { diff --git a/tests/unit/highlighter.js b/tests/unit/highlighter.js index ea2daaebf..2bd64c178 100644 --- a/tests/unit/highlighter.js +++ b/tests/unit/highlighter.js @@ -6,7 +6,7 @@ const JsUnit = imports.jsUnit; import Pango from 'gi://Pango'; import '../../js/ui/environment.js'; -const Util = imports.misc.util; +import * as Util from '../../js/misc/util.js'; const tests = [ { diff --git a/tests/unit/insertSorted.js b/tests/unit/insertSorted.js index 5ffc0871f..35131e60f 100644 --- a/tests/unit/insertSorted.js +++ b/tests/unit/insertSorted.js @@ -8,7 +8,7 @@ import '../../js/ui/environment.js'; import * as Assertions from '../common/assertions.js'; -const Util = imports.misc.util; +import * as Util from '../../js/misc/util.js'; let arrayInt = [1, 2, 3, 5, 6]; Util.insertSorted(arrayInt, 4, (one, two) => one - two); diff --git a/tests/unit/jsParse.js b/tests/unit/jsParse.js index 089cde1a9..bc5dd73b5 100644 --- a/tests/unit/jsParse.js +++ b/tests/unit/jsParse.js @@ -8,7 +8,7 @@ import '../../js/ui/environment.js'; import * as Assertions from '../common/assertions.js'; -const JsParse = imports.misc.jsParse; +import * as JsParse from '../../js/misc/jsParse.js'; const HARNESS_COMMAND_HEADER = 'let imports = obj;' + 'let global = obj;' + diff --git a/tests/unit/markup.js b/tests/unit/markup.js index 9ec737d00..846a886f2 100644 --- a/tests/unit/markup.js +++ b/tests/unit/markup.js @@ -6,9 +6,9 @@ const JsUnit = imports.jsUnit; import Pango from 'gi://Pango'; import '../../js/ui/environment.js'; +import '../../js/ui/main.js'; -imports.ui.main; // eslint-disable-line no-unused-expressions -const MessageList = imports.ui.messageList; +import * as MessageList from '../../js/ui/messageList.js'; /** * Assert that `input`, assumed to be markup, gets "fixed" to `output`, diff --git a/tests/unit/params.js b/tests/unit/params.js index a3b74df13..b297dfce6 100644 --- a/tests/unit/params.js +++ b/tests/unit/params.js @@ -1,5 +1,5 @@ const JsUnit = imports.jsUnit; -const Params = imports.misc.params; +import * as Params from '../../js/misc/params.js'; /** * Asserts that two "param" objects have the same properties diff --git a/tests/unit/signalTracker.js b/tests/unit/signalTracker.js index 4fa157c96..99c16a084 100644 --- a/tests/unit/signalTracker.js +++ b/tests/unit/signalTracker.js @@ -6,9 +6,9 @@ import '../../js/ui/environment.js'; import GObject from 'gi://GObject'; const JsUnit = imports.jsUnit; -const Signals = imports.misc.signals; +import * as Signals from '../../js/misc/signals.js'; -const {TransientSignalHolder, registerDestroyableType} = imports.misc.signalTracker; +import {TransientSignalHolder, registerDestroyableType} from '../../js/misc/signalTracker.js'; const Destroyable = GObject.registerClass({ Signals: {'destroy': {}}, diff --git a/tests/unit/url.js b/tests/unit/url.js index ac5e1ba32..7a72f8f2b 100644 --- a/tests/unit/url.js +++ b/tests/unit/url.js @@ -6,7 +6,7 @@ const JsUnit = imports.jsUnit; import '../../js/ui/environment.js'; -const Util = imports.misc.util; +import * as Util from '../../js/misc/util.js'; const tests = [ { diff --git a/tests/unit/versionCompare.js b/tests/unit/versionCompare.js index f0b31d117..0ce43d0e7 100644 --- a/tests/unit/versionCompare.js +++ b/tests/unit/versionCompare.js @@ -6,7 +6,7 @@ const JsUnit = imports.jsUnit; import '../../js/ui/environment.js'; -const Util = imports.misc.util; +import * as Util from '../../js/misc/util.js'; const tests = [ {