Convert to use ESM modules

See: https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/1499
This commit is contained in:
Bruce Leidl 2023-09-25 12:59:10 -04:00
parent a0a1a90d76
commit 849eab74bb
7 changed files with 63 additions and 42 deletions

View File

@ -1,7 +1,11 @@
const { Clutter, GObject, Shell, St } = imports.gi; import Clutter from 'gi://Clutter';
const PanelMenu = imports.ui.panelMenu; 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 { class RealmPanelIndicator extends PanelMenu.Button {
_init() { _init() {
super._init(0.5, "Current Realm"); super._init(0.5, "Current Realm");

View File

@ -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; import * as Main from '../main.js';
const RealmIndicator = imports.ui.realms.realmIndicator; import * as RealmIndicator from './realmIndicator.js';
const RealmSwitcher = imports.ui.realms.realmSwitcher; import * as RealmSwitcher from './realmSwitcher.js';
const Lightbox = imports.ui.lightbox; import * as Lightbox from '../lightbox.js';
const RealmSearchProvider = imports.ui.realms.realmSearchProvider; import * as RealmSearchProvider from './realmSearchProvider.js';
const RealmWindowFrame = imports.ui.realms.realmWindowFrame; import * as RealmWindowFrame from './realmWindowFrame.js';
var RealmManager = class { export const RealmManager = class {
constructor() { constructor() {
this._realmIndicator = new RealmIndicator.RealmPanelIndicator(); this._realmIndicator = new RealmIndicator.RealmPanelIndicator();

View File

@ -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; import * as Search from '../search.js';
const Main = imports.ui.main; import * as Main from '../main.js';
const Util = imports.misc.util; import * as Util from '../../misc/util.js';
// Based on ProviderInfo in search.js // Based on ProviderInfo in search.js
var RealmProviderInfo = GObject.registerClass( const RealmProviderInfo = GObject.registerClass(
class RealmProviderInfo extends St.Button { class RealmProviderInfo extends St.Button {
_init() { _init() {
super._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 // Based on ListSearchResult in search.js
var RealmSearchResult = GObject.registerClass( const RealmSearchResult = GObject.registerClass(
class ListSearchResult extends Search.SearchResult { class ListSearchResult extends Search.SearchResult {
_init(provider, metaInfo, resultsView) { _init(provider, metaInfo, resultsView) {
super._init(provider, metaInfo, resultsView); super._init(provider, metaInfo, resultsView);
@ -152,7 +156,7 @@ class ListSearchResult extends Search.SearchResult {
}); });
// Based on ListSearchResults in search.js // Based on ListSearchResults in search.js
var RealmSearchResults = GObject.registerClass( const RealmSearchResults = GObject.registerClass(
class RealmSearchResults extends Search.SearchResultsBase { class RealmSearchResults extends Search.SearchResultsBase {
_init(provider, resultsView) { _init(provider, resultsView) {
super._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() { constructor() {
this._shellRealms = Shell.Realms.get_default(); this._shellRealms = Shell.Realms.get_default();
this.id = 'realms'; this.id = 'realms';

View File

@ -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; import * as Background from '../background.js';
import * as SwitcherPopup from '../switcherPopup.js';
const Background = imports.ui.background; import * as Layout from '../layout.js';
const SwitcherPopup = imports.ui.switcherPopup; import * as Main from '../main.js';
const Layout = imports.ui.layout;
const Main = imports.ui.main;
const WINDOW_ANIMATION_TIME = 2000; 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 { class RealmItem extends St.BoxLayout {
_init(realm, workspace_group) { _init(realm, workspace_group) {
super._init({ vertical: true }); super._init({ vertical: true });
@ -48,7 +51,7 @@ function getRealmItems() {
return items; return items;
} }
var SwitchRealmList = GObject.registerClass( const SwitchRealmList = GObject.registerClass(
class SwitchRealmList extends SwitcherPopup.SwitcherList { class SwitchRealmList extends SwitcherPopup.SwitcherList {
_init(items) { _init(items) {
super._init(false); 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 { class SwitchRealmPopup extends SwitcherPopup.SwitcherPopup {
_init(action, actionBackward) { _init(action, actionBackward) {
super._init(); super._init();
@ -268,7 +271,7 @@ const MonitorGroup = GObject.registerClass({
} }
}); });
var ContextSwitchAnimationController = class { export const ContextSwitchAnimationController = class {
constructor(indicator) { constructor(indicator) {
this._switchData = null; this._switchData = null;
this._indicator = indicator; this._indicator = indicator;

View File

@ -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() { constructor() {
this._realms = Shell.Realms.get_default(); this._realms = Shell.Realms.get_default();
let frames = this._realms.window_frames(); 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 { class RealmFrameEffect extends Clutter.Effect {
_init(actor, color, label_text) { _init(actor, color, label_text) {
super._init(); super._init();

View File

@ -1,7 +1,7 @@
import GObject from 'gi://GObject';
import Shell from 'gi://Shell';
const { Shell, GObject } = imports.gi; import * as PopupMenu from '../popupMenu.js';
const PopupMenu = imports.ui.popupMenu;
function _windowAppId(window) { function _windowAppId(window) {
const tracker = Shell.WindowTracker.get_default(); 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 id = _windowAppId(window);
const realm_name = windowRealmName(window); const realm_name = windowRealmName(window);
const realms = Shell.Realms.get_default(); const realms = Shell.Realms.get_default();
@ -78,7 +78,8 @@ function windowContextRealmName(window) {
return null; return null;
} }
} }
function enableFrameItem(window) {
export function enableFrameItem(window) {
const realms = Shell.Realms.get_default(); const realms = Shell.Realms.get_default();
const frames = realms.window_frames(); const frames = realms.window_frames();
if (!frames.has_frame(window)) { if (!frames.has_frame(window)) {
@ -99,7 +100,7 @@ function enableFrameItem(window) {
return item; return item;
} }
function realmWindowMenu(window) { export function realmWindowMenu(window) {
const realm_name = windowContextRealmName(window); const realm_name = windowContextRealmName(window);
@ -131,4 +132,4 @@ function realmWindowMenu(window) {
subMenu.menu.addMenuItem(item); subMenu.menu.addMenuItem(item);
}); });
return subMenu; return subMenu;
} }

View File

@ -149,7 +149,7 @@ class GridSearchResult extends SearchResult {
} }
}); });
const SearchResultsBase = GObject.registerClass({ export const SearchResultsBase = GObject.registerClass({
GTypeFlags: GObject.TypeFlags.ABSTRACT, GTypeFlags: GObject.TypeFlags.ABSTRACT,
Properties: { Properties: {
'focus-child': GObject.ParamSpec.object( 'focus-child': GObject.ParamSpec.object(