From 849eab74bb5b3e9dacca470c8e7d69a2ed12003d Mon Sep 17 00:00:00 2001 From: Bruce Leidl Date: Mon, 25 Sep 2023 12:59:10 -0400 Subject: [PATCH] Convert to use ESM modules See: https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/1499 --- js/ui/realms/realmIndicator.js | 10 +++++++--- js/ui/realms/realmManager.js | 20 ++++++++++++-------- js/ui/realms/realmSearchProvider.js | 22 +++++++++++++--------- js/ui/realms/realmSwitcher.js | 25 ++++++++++++++----------- js/ui/realms/realmWindowFrame.js | 11 ++++++++--- js/ui/realms/realmWindowMenu.js | 15 ++++++++------- js/ui/search.js | 2 +- 7 files changed, 63 insertions(+), 42 deletions(-) diff --git a/js/ui/realms/realmIndicator.js b/js/ui/realms/realmIndicator.js index d71e34689..8695b6428 100644 --- a/js/ui/realms/realmIndicator.js +++ b/js/ui/realms/realmIndicator.js @@ -1,7 +1,11 @@ -const { Clutter, GObject, Shell, St } = imports.gi; -const PanelMenu = imports.ui.panelMenu; +import Clutter from 'gi://Clutter'; +import GObject from 'gi://GObject'; +import Shell from 'gi://Shell'; +import St from 'gi://St'; -var RealmPanelIndicator = GObject.registerClass( +import * as PanelMenu from '../panelMenu.js'; + +export const RealmPanelIndicator = GObject.registerClass( class RealmPanelIndicator extends PanelMenu.Button { _init() { super._init(0.5, "Current Realm"); diff --git a/js/ui/realms/realmManager.js b/js/ui/realms/realmManager.js index b19de575c..6a2970ae0 100644 --- a/js/ui/realms/realmManager.js +++ b/js/ui/realms/realmManager.js @@ -1,13 +1,17 @@ -const { Clutter, Gio, Meta, Shell, St } = imports.gi; +import Clutter from 'gi://Clutter' +import Gio from 'gi://Gio' +import Meta from 'gi://Meta' +import Shell from 'gi://Shell' +import St from 'gi://St' -const Main = imports.ui.main; -const RealmIndicator = imports.ui.realms.realmIndicator; -const RealmSwitcher = imports.ui.realms.realmSwitcher; -const Lightbox = imports.ui.lightbox; -const RealmSearchProvider = imports.ui.realms.realmSearchProvider; -const RealmWindowFrame = imports.ui.realms.realmWindowFrame; +import * as Main from '../main.js'; +import * as RealmIndicator from './realmIndicator.js'; +import * as RealmSwitcher from './realmSwitcher.js'; +import * as Lightbox from '../lightbox.js'; +import * as RealmSearchProvider from './realmSearchProvider.js'; +import * as RealmWindowFrame from './realmWindowFrame.js'; -var RealmManager = class { +export const RealmManager = class { constructor() { this._realmIndicator = new RealmIndicator.RealmPanelIndicator(); diff --git a/js/ui/realms/realmSearchProvider.js b/js/ui/realms/realmSearchProvider.js index 56c5989c1..a50c0b6c7 100644 --- a/js/ui/realms/realmSearchProvider.js +++ b/js/ui/realms/realmSearchProvider.js @@ -1,11 +1,15 @@ -const { Clutter, GObject, Pango, Shell, St } = imports.gi; +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 Search = imports.ui.search; -const Main = imports.ui.main; -const Util = imports.misc.util; +import * as Search from '../search.js'; +import * as Main from '../main.js'; +import * as Util from '../../misc/util.js'; // Based on ProviderInfo in search.js -var RealmProviderInfo = GObject.registerClass( +const RealmProviderInfo = GObject.registerClass( class RealmProviderInfo extends St.Button { _init() { super._init({ @@ -59,10 +63,10 @@ class RealmProviderInfo extends St.Button { } }); -var MAX_LIST_SEARCH_RESULTS_ROWS = 10; +const MAX_LIST_SEARCH_RESULTS_ROWS = 10; // Based on ListSearchResult in search.js -var RealmSearchResult = GObject.registerClass( +const RealmSearchResult = GObject.registerClass( class ListSearchResult extends Search.SearchResult { _init(provider, metaInfo, resultsView) { super._init(provider, metaInfo, resultsView); @@ -152,7 +156,7 @@ class ListSearchResult extends Search.SearchResult { }); // Based on ListSearchResults in search.js -var RealmSearchResults = GObject.registerClass( +const RealmSearchResults = GObject.registerClass( class RealmSearchResults extends Search.SearchResultsBase { _init(provider, resultsView) { super._init(provider, resultsView); @@ -205,7 +209,7 @@ class RealmSearchResults extends Search.SearchResultsBase { } }); -var RealmSearchProvider = class RealmSearchProvider { +export const RealmSearchProvider = class RealmSearchProvider { constructor() { this._shellRealms = Shell.Realms.get_default(); this.id = 'realms'; diff --git a/js/ui/realms/realmSwitcher.js b/js/ui/realms/realmSwitcher.js index 507df000a..78d7b4379 100644 --- a/js/ui/realms/realmSwitcher.js +++ b/js/ui/realms/realmSwitcher.js @@ -1,15 +1,18 @@ +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 { Clutter, GObject, Meta, Shell, St } = imports.gi; - -const Background = imports.ui.background; -const SwitcherPopup = imports.ui.switcherPopup; -const Layout = imports.ui.layout; -const Main = imports.ui.main; +import * as Background from '../background.js'; +import * as SwitcherPopup from '../switcherPopup.js'; +import * as Layout from '../layout.js'; +import * as Main from '../main.js'; const WINDOW_ANIMATION_TIME = 2000; -var APP_ICON_SIZE = 96; +const APP_ICON_SIZE = 96; -var RealmItem = GObject.registerClass( +const RealmItem = GObject.registerClass( class RealmItem extends St.BoxLayout { _init(realm, workspace_group) { super._init({ vertical: true }); @@ -48,7 +51,7 @@ function getRealmItems() { return items; } -var SwitchRealmList = GObject.registerClass( +const SwitchRealmList = GObject.registerClass( class SwitchRealmList extends SwitcherPopup.SwitcherList { _init(items) { super._init(false); @@ -59,7 +62,7 @@ class SwitchRealmList extends SwitcherPopup.SwitcherList { } }); -var SwitchRealmPopup = GObject.registerClass( +export const SwitchRealmPopup = GObject.registerClass( class SwitchRealmPopup extends SwitcherPopup.SwitcherPopup { _init(action, actionBackward) { super._init(); @@ -268,7 +271,7 @@ const MonitorGroup = GObject.registerClass({ } }); -var ContextSwitchAnimationController = class { +export const ContextSwitchAnimationController = class { constructor(indicator) { this._switchData = null; this._indicator = indicator; diff --git a/js/ui/realms/realmWindowFrame.js b/js/ui/realms/realmWindowFrame.js index e200102a1..11457dffb 100644 --- a/js/ui/realms/realmWindowFrame.js +++ b/js/ui/realms/realmWindowFrame.js @@ -1,6 +1,11 @@ -const { Clutter, Cogl, GObject, Meta, Shell, St } = imports.gi; +import Clutter from 'gi://Clutter'; +import Cogl from 'gi://Cogl'; +import GObject from 'gi://GObject'; +import Meta from 'gi://Meta'; +import Shell from 'gi://Shell'; +import St from 'gi://St'; -var WindowFrameManager = class WindowFrameManager { +export const WindowFrameManager = class WindowFrameManager { constructor() { this._realms = Shell.Realms.get_default(); let frames = this._realms.window_frames(); @@ -64,7 +69,7 @@ var WindowFrameManager = class WindowFrameManager { } } -var RealmFrameEffect = GObject.registerClass( +const RealmFrameEffect = GObject.registerClass( class RealmFrameEffect extends Clutter.Effect { _init(actor, color, label_text) { super._init(); diff --git a/js/ui/realms/realmWindowMenu.js b/js/ui/realms/realmWindowMenu.js index d41fe2efe..fe6b2dca3 100644 --- a/js/ui/realms/realmWindowMenu.js +++ b/js/ui/realms/realmWindowMenu.js @@ -1,7 +1,7 @@ +import GObject from 'gi://GObject'; +import Shell from 'gi://Shell'; -const { Shell, GObject } = imports.gi; - -const PopupMenu = imports.ui.popupMenu; +import * as PopupMenu from '../popupMenu.js'; function _windowAppId(window) { const tracker = Shell.WindowTracker.get_default(); @@ -14,7 +14,7 @@ function _windowAppId(window) { } } -function windowMenuDebugString(window) { +export function windowMenuDebugString(window) { const id = _windowAppId(window); const realm_name = windowRealmName(window); const realms = Shell.Realms.get_default(); @@ -78,7 +78,8 @@ function windowContextRealmName(window) { return null; } } -function enableFrameItem(window) { + +export function enableFrameItem(window) { const realms = Shell.Realms.get_default(); const frames = realms.window_frames(); if (!frames.has_frame(window)) { @@ -99,7 +100,7 @@ function enableFrameItem(window) { return item; } -function realmWindowMenu(window) { +export function realmWindowMenu(window) { const realm_name = windowContextRealmName(window); @@ -131,4 +132,4 @@ function realmWindowMenu(window) { subMenu.menu.addMenuItem(item); }); return subMenu; -} \ No newline at end of file +} diff --git a/js/ui/search.js b/js/ui/search.js index b938b0327..e5cd5c3ed 100644 --- a/js/ui/search.js +++ b/js/ui/search.js @@ -149,7 +149,7 @@ class GridSearchResult extends SearchResult { } }); -const SearchResultsBase = GObject.registerClass({ +export const SearchResultsBase = GObject.registerClass({ GTypeFlags: GObject.TypeFlags.ABSTRACT, Properties: { 'focus-child': GObject.ParamSpec.object(