cleanup: Use more template strings

xgettext got better at recognizing template strings, so we can
replace more string concatenations. Alas xgettext is still buggy
(surprise, regular expressions are hard), so there are still a
handful of holdouts that prevent us from making a complete switch.

https://gitlab.gnome.org/GNOME/gnome-shell/merge_requests/792
This commit is contained in:
Florian Müllner 2019-10-29 19:21:21 +01:00 committed by Florian Müllner
parent 2c62e45168
commit f309d98bc8
10 changed files with 17 additions and 16 deletions

View File

@ -76,13 +76,13 @@ function loadInterfaceXML(iface) {
if (!_ifaceResource) {
// don't use global.datadir so the method is usable from tests/tools
let dir = GLib.getenv ('GNOME_SHELL_DATADIR') || Config.PKGDATADIR;
let path = dir + '/gnome-shell-dbus-interfaces.gresource';
let path = `${dir}/gnome-shell-dbus-interfaces.gresource`;
_ifaceResource = Gio.Resource.load(path);
_ifaceResource._register();
}
let xml = null;
let uri = 'resource:///org/gnome/shell/dbus-interfaces/' + iface + '.xml';
let uri = `resource:///org/gnome/shell/dbus-interfaces/${iface}.xml`;
let f = Gio.File.new_for_uri(uri);
try {

View File

@ -21,7 +21,7 @@ const PortalHelperSecurityLevel = {
};
const CONNECTIVITY_CHECK_HOST = 'nmcheck.gnome.org';
const CONNECTIVITY_CHECK_URI = 'http://' + CONNECTIVITY_CHECK_HOST;
const CONNECTIVITY_CHECK_URI = `http://${CONNECTIVITY_CHECK_HOST}`;
const CONNECTIVITY_RECHECK_RATELIMIT_TIMEOUT = 30 * GLib.USEC_PER_SEC;
const HelperDBusInterface = loadInterfaceXML('org.gnome.Shell.PortalHelper');

View File

@ -66,7 +66,7 @@ function _getFolderName(folder) {
if (folder.get_boolean('translate')) {
let keyfile = new GLib.KeyFile();
let path = 'desktop-directories/' + name;
let path = `desktop-directories/${name}`;
try {
keyfile.load_from_data_dirs(path, GLib.KeyFileFlags.NONE);
@ -469,7 +469,7 @@ var AllView = GObject.registerClass({
let folders = this._folderSettings.get_strv('folder-children');
folders.forEach(id => {
let path = this._folderSettings.path + 'folders/' + id + '/';
let path = `${this._folderSettings.path}folders/${id}/`;
let icon = this._items[id];
if (!icon) {
icon = new FolderIcon(id, path, this);

View File

@ -137,7 +137,7 @@ var ShellMagnifier = class ShellMagnifier {
}
if (!found) {
// Got a ZoomRegion with no DBus proxy, make one.
let newPath = ZOOM_SERVICE_PATH + '/zoomer' + _zoomRegionInstanceCount;
let newPath = `${ZOOM_SERVICE_PATH}/zoomer${_zoomRegionInstanceCount}`;
_zoomRegionInstanceCount++;
let zoomRegionProxy = new ShellMagnifierZoomRegion(newPath, aZoomRegion);
let proxyAndZoomer = {};

View File

@ -289,7 +289,7 @@ function _initializeUI() {
function _getStylesheet(name) {
let stylesheet;
stylesheet = Gio.File.new_for_uri('resource:///org/gnome/shell/theme/' + name);
stylesheet = Gio.File.new_for_uri(`resource:///org/gnome/shell/theme/${name}`);
if (stylesheet.query_exists(null))
return stylesheet;
@ -301,7 +301,7 @@ function _getStylesheet(name) {
return stylesheet;
}
stylesheet = Gio.File.new_for_path(global.datadir + '/theme/' + name);
stylesheet = Gio.File.new_for_path(`${global.datadir}/theme/${name}`);
if (stylesheet.query_exists(null))
return stylesheet;
@ -359,12 +359,12 @@ function reloadThemeResource() {
if (_themeResource)
_themeResource._unregister();
_themeResource = Gio.Resource.load(global.datadir + '/gnome-shell-theme.gresource');
_themeResource = Gio.Resource.load(`${global.datadir}/gnome-shell-theme.gresource`);
_themeResource._register();
}
function _loadOskLayouts() {
_oskResource = Gio.Resource.load(global.datadir + '/gnome-shell-osk-layouts.gresource');
_oskResource = Gio.Resource.load(`${global.datadir}/gnome-shell-osk-layouts.gresource`);
_oskResource._register();
}

View File

@ -79,7 +79,7 @@ class URLHighlighter extends St.Label {
if (urlId != -1) {
let url = this._urls[urlId].url;
if (!url.includes(':'))
url = 'http://' + url;
url = `http://${url}`;
Gio.app_info_launch_default_for_uri(
url, global.create_app_launch_context(0, -1));
@ -132,7 +132,7 @@ class URLHighlighter extends St.Label {
for (let i = 0; i < urls.length; i++) {
let url = urls[i];
let str = this._text.substr(pos, url.pos - pos);
markup += str + '<span foreground="' + this._linkColor + '"><u>' + url.url + '</u></span>';
markup += `${str}<span foreground="${this._linkColor}"><u>${url.url}</u></span>`;
pos = url.pos + url.url.length;
}
markup += this._text.substr(pos);

View File

@ -844,7 +844,8 @@ var PadOsd = GObject.registerClass({
this._tipLabel.set_text(_("Press any key to exit"));
}
this._titleLabel.clutter_text.set_markup('<span size="larger"><b>' + title + '</b></span>');
this._titleLabel.clutter_text.set_markup(
`<span size="larger"><b>${title}</b></span>`);
}
_isEditedAction(type, number, dir) {

View File

@ -210,7 +210,7 @@ class RunDialog extends ModalDialog.ModalDialog {
} else {
if (input.charAt(0) == '~')
input = input.slice(1);
path = GLib.get_home_dir() + '/' + input;
path = `${GLib.get_home_dir()}/${input}`;
}
if (GLib.file_test(path, GLib.FileTest.EXISTS)) {

View File

@ -189,7 +189,7 @@ var NotificationsBox = GObject.registerClass({
}
let label = new St.Label({ style_class: 'screen-shield-notification-count-text' });
label.clutter_text.set_markup('<b>' + n.title + '</b> ' + body);
label.clutter_text.set_markup(`<b>${n.title}</b> ${body}`);
textBox.add(label);
visible = true;

View File

@ -304,7 +304,7 @@ var GnomeShellExtensions = class {
let app = appSys.lookup_app('gnome-shell-extension-prefs.desktop');
let info = app.get_app_info();
let timestamp = global.display.get_current_time_roundtrip();
info.launch_uris(['extension:///' + uuid],
info.launch_uris([`extension:///${uuid}`],
global.create_app_launch_context(timestamp, -1));
}