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;
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");

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;
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();

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;
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';

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;
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;

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() {
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();

View File

@ -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;
}
}

View File

@ -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(