cleanup: Replace non-standard ByteArray module
gjs landed support for TextDecoder/TextEncoder. Use those instead of gjs' own ByteArray module. Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/1946>
This commit is contained in:
parent
b21b43e318
commit
ef70364e81
@ -31,7 +31,7 @@ variables:
|
|||||||
LINT_LOG: "eslint-report.xml"
|
LINT_LOG: "eslint-report.xml"
|
||||||
LINT_MR_LOG: "eslint-mr-report.xml"
|
LINT_MR_LOG: "eslint-mr-report.xml"
|
||||||
|
|
||||||
image: registry.gitlab.gnome.org/gnome/mutter/fedora/34:x86_64-2021-08-01.0
|
image: registry.gitlab.gnome.org/gnome/mutter/fedora/34:x86_64-2021-08-25.0
|
||||||
|
|
||||||
workflow:
|
workflow:
|
||||||
rules:
|
rules:
|
||||||
|
@ -86,7 +86,7 @@ function loadInterfaceXML(iface) {
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
let [ok_, bytes] = f.load_contents(null);
|
let [ok_, bytes] = f.load_contents(null);
|
||||||
return imports.byteArray.toString(bytes);
|
return new TextDecoder().decode(bytes);
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
log(`Failed to load D-Bus interface ${iface}`);
|
log(`Failed to load D-Bus interface ${iface}`);
|
||||||
}
|
}
|
||||||
|
@ -2,7 +2,6 @@
|
|||||||
/* exported Component */
|
/* exported Component */
|
||||||
|
|
||||||
const { Clutter, Gio, GLib, GObject, NM, Pango, Shell, St } = imports.gi;
|
const { Clutter, Gio, GLib, GObject, NM, Pango, Shell, St } = imports.gi;
|
||||||
const ByteArray = imports.byteArray;
|
|
||||||
const Signals = imports.signals;
|
const Signals = imports.signals;
|
||||||
|
|
||||||
const Dialog = imports.ui.dialog;
|
const Dialog = imports.ui.dialog;
|
||||||
@ -498,7 +497,8 @@ var VPNRequestHandler = class {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
this._vpnChildProcessLineOldStyle(ByteArray.toString(line));
|
const decoder = new TextDecoder();
|
||||||
|
this._vpnChildProcessLineOldStyle(decoder.decode(line));
|
||||||
|
|
||||||
// try to read more!
|
// try to read more!
|
||||||
this._readStdoutOldStyle();
|
this._readStdoutOldStyle();
|
||||||
@ -527,7 +527,7 @@ var VPNRequestHandler = class {
|
|||||||
let contentOverride;
|
let contentOverride;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
data = ByteArray.toGBytes(this._dataStdout.peek_buffer());
|
data = new GLib.Bytes(this._dataStdout.peek_buffer());
|
||||||
keyfile.load_from_bytes(data, GLib.KeyFileFlags.NONE);
|
keyfile.load_from_bytes(data, GLib.KeyFileFlags.NONE);
|
||||||
|
|
||||||
if (keyfile.get_integer(VPN_UI_GROUP, 'Version') != 2)
|
if (keyfile.get_integer(VPN_UI_GROUP, 'Version') != 2)
|
||||||
|
@ -86,8 +86,6 @@ function _patchLayoutClass(layoutClass, styleProps) {
|
|||||||
* @returns {void}
|
* @returns {void}
|
||||||
*/
|
*/
|
||||||
function _injectSoup3Compat(Soup) {
|
function _injectSoup3Compat(Soup) {
|
||||||
const ByteArray = imports.byteArray;
|
|
||||||
|
|
||||||
Soup.StatusCode = Soup.KnownStatusCode;
|
Soup.StatusCode = Soup.KnownStatusCode;
|
||||||
|
|
||||||
Soup.Message.new_from_encoded_form =
|
Soup.Message.new_from_encoded_form =
|
||||||
@ -101,7 +99,7 @@ function _injectSoup3Compat(Soup) {
|
|||||||
this.set_request(
|
this.set_request(
|
||||||
contentType,
|
contentType,
|
||||||
Soup.MemoryUse.COPY,
|
Soup.MemoryUse.COPY,
|
||||||
ByteArray.toString(bytes.get_data()));
|
new TextDecoder().decode(bytes.get_data()));
|
||||||
};
|
};
|
||||||
|
|
||||||
Soup.Session.prototype.send_and_read_async =
|
Soup.Session.prototype.send_and_read_async =
|
||||||
|
@ -3,8 +3,6 @@
|
|||||||
|
|
||||||
const { Clutter, Gio, GLib, GObject, Soup } = imports.gi;
|
const { Clutter, Gio, GLib, GObject, Soup } = imports.gi;
|
||||||
|
|
||||||
const ByteArray = imports.byteArray;
|
|
||||||
|
|
||||||
const Config = imports.misc.config;
|
const Config = imports.misc.config;
|
||||||
const Dialog = imports.ui.dialog;
|
const Dialog = imports.ui.dialog;
|
||||||
const ExtensionUtils = imports.misc.extensionUtils;
|
const ExtensionUtils = imports.misc.extensionUtils;
|
||||||
@ -49,7 +47,8 @@ async function installExtension(uuid, invocation) {
|
|||||||
GLib.PRIORITY_DEFAULT,
|
GLib.PRIORITY_DEFAULT,
|
||||||
null);
|
null);
|
||||||
checkResponse(message);
|
checkResponse(message);
|
||||||
info = JSON.parse(ByteArray.toString(bytes.get_data()));
|
const decoder = new TextDecoder();
|
||||||
|
info = JSON.parse(decoder.decode(bytes.get_data()));
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
Main.extensionManager.logExtensionError(uuid, e);
|
Main.extensionManager.logExtensionError(uuid, e);
|
||||||
invocation.return_dbus_error(
|
invocation.return_dbus_error(
|
||||||
@ -181,8 +180,7 @@ async function checkForUpdates() {
|
|||||||
shell_version: Config.PACKAGE_VERSION,
|
shell_version: Config.PACKAGE_VERSION,
|
||||||
disable_version_validation: versionCheck.toString(),
|
disable_version_validation: versionCheck.toString(),
|
||||||
};
|
};
|
||||||
const requestBody = new GLib.Bytes(
|
const requestBody = new GLib.Bytes(JSON.stringify(metadatas));
|
||||||
ByteArray.fromString(JSON.stringify(metadatas)));
|
|
||||||
|
|
||||||
const message = Soup.Message.new('POST',
|
const message = Soup.Message.new('POST',
|
||||||
'%s?%s'.format(REPOSITORY_URL_UPDATE, Soup.form_encode_hash(params)));
|
'%s?%s'.format(REPOSITORY_URL_UPDATE, Soup.form_encode_hash(params)));
|
||||||
@ -195,7 +193,7 @@ async function checkForUpdates() {
|
|||||||
GLib.PRIORITY_DEFAULT,
|
GLib.PRIORITY_DEFAULT,
|
||||||
null);
|
null);
|
||||||
checkResponse(message);
|
checkResponse(message);
|
||||||
json = ByteArray.toString(bytes.get_data());
|
json = new TextDecoder().decode(bytes.get_data());
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
log('Update check failed: %s'.format(e.message));
|
log('Update check failed: %s'.format(e.message));
|
||||||
return;
|
return;
|
||||||
|
@ -2,7 +2,6 @@
|
|||||||
/* exported init connect disconnect */
|
/* exported init connect disconnect */
|
||||||
|
|
||||||
const { GLib, Gio, GObject, Shell, St } = imports.gi;
|
const { GLib, Gio, GObject, Shell, St } = imports.gi;
|
||||||
const ByteArray = imports.byteArray;
|
|
||||||
const Signals = imports.signals;
|
const Signals = imports.signals;
|
||||||
|
|
||||||
const ExtensionDownloader = imports.ui.extensionDownloader;
|
const ExtensionDownloader = imports.ui.extensionDownloader;
|
||||||
@ -285,7 +284,7 @@ var ExtensionManager = class {
|
|||||||
let metadataContents, success_;
|
let metadataContents, success_;
|
||||||
try {
|
try {
|
||||||
[success_, metadataContents] = metadataFile.load_contents(null);
|
[success_, metadataContents] = metadataFile.load_contents(null);
|
||||||
metadataContents = ByteArray.toString(metadataContents);
|
metadataContents = new TextDecoder().decode(metadataContents);
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
throw new Error('Failed to load metadata.json: %s'.format(e.toString()));
|
throw new Error('Failed to load metadata.json: %s'.format(e.toString()));
|
||||||
}
|
}
|
||||||
|
@ -2,7 +2,6 @@
|
|||||||
/* exported KeyboardManager */
|
/* exported KeyboardManager */
|
||||||
|
|
||||||
const { Clutter, Gio, GLib, GObject, Graphene, Meta, Shell, St } = imports.gi;
|
const { Clutter, Gio, GLib, GObject, Graphene, Meta, Shell, St } = imports.gi;
|
||||||
const ByteArray = imports.byteArray;
|
|
||||||
const Signals = imports.signals;
|
const Signals = imports.signals;
|
||||||
|
|
||||||
const EdgeDragAction = imports.ui.edgeDragAction;
|
const EdgeDragAction = imports.ui.edgeDragAction;
|
||||||
@ -536,9 +535,9 @@ var KeyboardModel = class {
|
|||||||
_loadModel(groupName) {
|
_loadModel(groupName) {
|
||||||
let file = Gio.File.new_for_uri('resource:///org/gnome/shell/osk-layouts/%s.json'.format(groupName));
|
let file = Gio.File.new_for_uri('resource:///org/gnome/shell/osk-layouts/%s.json'.format(groupName));
|
||||||
let [success_, contents] = file.load_contents(null);
|
let [success_, contents] = file.load_contents(null);
|
||||||
contents = ByteArray.toString(contents);
|
|
||||||
|
|
||||||
return JSON.parse(contents);
|
const decoder = new TextDecoder();
|
||||||
|
return JSON.parse(decoder.decode(contents));
|
||||||
}
|
}
|
||||||
|
|
||||||
getLevels() {
|
getLevels() {
|
||||||
@ -1039,9 +1038,7 @@ var EmojiSelection = GObject.registerClass({
|
|||||||
let file = Gio.File.new_for_uri('resource:///org/gnome/shell/osk-layouts/emoji.json');
|
let file = Gio.File.new_for_uri('resource:///org/gnome/shell/osk-layouts/emoji.json');
|
||||||
let [success_, contents] = file.load_contents(null);
|
let [success_, contents] = file.load_contents(null);
|
||||||
|
|
||||||
if (contents instanceof Uint8Array)
|
let emoji = JSON.parse(new TextDecoder().decode(contents));
|
||||||
contents = imports.byteArray.toString(contents);
|
|
||||||
let emoji = JSON.parse(contents);
|
|
||||||
|
|
||||||
let variants = [];
|
let variants = [];
|
||||||
let currentKey = 0;
|
let currentKey = 0;
|
||||||
|
@ -3,7 +3,6 @@
|
|||||||
|
|
||||||
const { Atk, Clutter, GDesktopEnums, Gio,
|
const { Atk, Clutter, GDesktopEnums, Gio,
|
||||||
GLib, GObject, Gtk, Meta, Pango, Rsvg, St } = imports.gi;
|
GLib, GObject, Gtk, Meta, Pango, Rsvg, St } = imports.gi;
|
||||||
const ByteArray = imports.byteArray;
|
|
||||||
const Signals = imports.signals;
|
const Signals = imports.signals;
|
||||||
|
|
||||||
const Main = imports.ui.main;
|
const Main = imports.ui.main;
|
||||||
@ -298,10 +297,9 @@ var PadDiagram = GObject.registerClass({
|
|||||||
_init(params) {
|
_init(params) {
|
||||||
let file = Gio.File.new_for_uri('resource:///org/gnome/shell/theme/pad-osd.css');
|
let file = Gio.File.new_for_uri('resource:///org/gnome/shell/theme/pad-osd.css');
|
||||||
let [success_, css] = file.load_contents(null);
|
let [success_, css] = file.load_contents(null);
|
||||||
css = ByteArray.toString(css);
|
|
||||||
this._curEdited = null;
|
this._curEdited = null;
|
||||||
this._prevEdited = null;
|
this._prevEdited = null;
|
||||||
this._css = css;
|
this._css = new TextDecoder().decode(css);
|
||||||
this._labels = [];
|
this._labels = [];
|
||||||
this._activeButtons = [];
|
this._activeButtons = [];
|
||||||
super._init(params);
|
super._init(params);
|
||||||
|
@ -1,7 +1,6 @@
|
|||||||
// -*- mode: js; js-indent-level: 4; indent-tabs-mode: nil -*-
|
// -*- mode: js; js-indent-level: 4; indent-tabs-mode: nil -*-
|
||||||
/* exported SessionMode, listModes */
|
/* exported SessionMode, listModes */
|
||||||
|
|
||||||
const ByteArray = imports.byteArray;
|
|
||||||
const GLib = imports.gi.GLib;
|
const GLib = imports.gi.GLib;
|
||||||
const Signals = imports.signals;
|
const Signals = imports.signals;
|
||||||
|
|
||||||
@ -110,8 +109,8 @@ function _loadMode(file, info) {
|
|||||||
let fileContent, success_, newMode;
|
let fileContent, success_, newMode;
|
||||||
try {
|
try {
|
||||||
[success_, fileContent] = file.load_contents(null);
|
[success_, fileContent] = file.load_contents(null);
|
||||||
fileContent = ByteArray.toString(fileContent);
|
const decoder = new TextDecoder();
|
||||||
newMode = JSON.parse(fileContent);
|
newMode = JSON.parse(decoder.decode(fileContent));
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -24,7 +24,7 @@ eds_req = '>= 3.33.1'
|
|||||||
gcr_req = '>= 3.7.5'
|
gcr_req = '>= 3.7.5'
|
||||||
gio_req = '>= 2.56.0'
|
gio_req = '>= 2.56.0'
|
||||||
gi_req = '>= 1.49.1'
|
gi_req = '>= 1.49.1'
|
||||||
gjs_req = '>= 1.68.1'
|
gjs_req = '>= 1.69.2'
|
||||||
gtk_req = '>= 3.15.0'
|
gtk_req = '>= 3.15.0'
|
||||||
mutter_req = '>= 41.beta'
|
mutter_req = '>= 41.beta'
|
||||||
polkit_req = '>= 0.100'
|
polkit_req = '>= 0.100'
|
||||||
|
@ -24,7 +24,7 @@ function loadInterfaceXML(iface) {
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
let [ok_, bytes] = f.load_contents(null);
|
let [ok_, bytes] = f.load_contents(null);
|
||||||
return imports.byteArray.toString(bytes);
|
return new TextDecoder().decode(bytes);
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
log('Failed to load D-Bus interface %s'.format(iface));
|
log('Failed to load D-Bus interface %s'.format(iface));
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user