From f309d98bc85f967c8f7501b2129a231f4b81d35c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Florian=20M=C3=BCllner?= Date: Tue, 29 Oct 2019 19:21:21 +0100 Subject: [PATCH] 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 --- js/misc/fileUtils.js | 4 ++-- js/portalHelper/main.js | 2 +- js/ui/appDisplay.js | 4 ++-- js/ui/magnifierDBus.js | 2 +- js/ui/main.js | 8 ++++---- js/ui/messageList.js | 4 ++-- js/ui/padOsd.js | 3 ++- js/ui/runDialog.js | 2 +- js/ui/screenShield.js | 2 +- js/ui/shellDBus.js | 2 +- 10 files changed, 17 insertions(+), 16 deletions(-) diff --git a/js/misc/fileUtils.js b/js/misc/fileUtils.js index 338460ce6..5a4ae3eee 100644 --- a/js/misc/fileUtils.js +++ b/js/misc/fileUtils.js @@ -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 { diff --git a/js/portalHelper/main.js b/js/portalHelper/main.js index f98a10dce..f6124e5ef 100644 --- a/js/portalHelper/main.js +++ b/js/portalHelper/main.js @@ -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'); diff --git a/js/ui/appDisplay.js b/js/ui/appDisplay.js index 43b1860f8..cb08accea 100644 --- a/js/ui/appDisplay.js +++ b/js/ui/appDisplay.js @@ -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); diff --git a/js/ui/magnifierDBus.js b/js/ui/magnifierDBus.js index b71cd0db5..99921a142 100644 --- a/js/ui/magnifierDBus.js +++ b/js/ui/magnifierDBus.js @@ -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 = {}; diff --git a/js/ui/main.js b/js/ui/main.js index 63db23829..5e0de5e87 100644 --- a/js/ui/main.js +++ b/js/ui/main.js @@ -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(); } diff --git a/js/ui/messageList.js b/js/ui/messageList.js index 06fa11e21..01f1da485 100644 --- a/js/ui/messageList.js +++ b/js/ui/messageList.js @@ -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 + '' + url.url + ''; + markup += `${str}${url.url}`; pos = url.pos + url.url.length; } markup += this._text.substr(pos); diff --git a/js/ui/padOsd.js b/js/ui/padOsd.js index 854e0f61e..75e274f33 100644 --- a/js/ui/padOsd.js +++ b/js/ui/padOsd.js @@ -844,7 +844,8 @@ var PadOsd = GObject.registerClass({ this._tipLabel.set_text(_("Press any key to exit")); } - this._titleLabel.clutter_text.set_markup('' + title + ''); + this._titleLabel.clutter_text.set_markup( + `${title}`); } _isEditedAction(type, number, dir) { diff --git a/js/ui/runDialog.js b/js/ui/runDialog.js index fba1dc7fb..8154b9427 100644 --- a/js/ui/runDialog.js +++ b/js/ui/runDialog.js @@ -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)) { diff --git a/js/ui/screenShield.js b/js/ui/screenShield.js index 3712c198a..71f8795ac 100644 --- a/js/ui/screenShield.js +++ b/js/ui/screenShield.js @@ -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('' + n.title + ' ' + body); + label.clutter_text.set_markup(`${n.title} ${body}`); textBox.add(label); visible = true; diff --git a/js/ui/shellDBus.js b/js/ui/shellDBus.js index fca0b6425..8b3db8fc0 100644 --- a/js/ui/shellDBus.js +++ b/js/ui/shellDBus.js @@ -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)); }