js: Port to modules
Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/1499>
This commit is contained in:

committed by
Florian Müllner

parent
d9198317ae
commit
a751e213f6
@ -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();
|
||||
}
|
||||
|
Reference in New Issue
Block a user