[gnome-shell] cleanup: Use more template strings



commit f309d98bc85f967c8f7501b2129a231f4b81d35c
Author: Florian Müllner <fmuellner gnome org>
Date:   Tue Oct 29 19:21:21 2019 +0100

    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 338460ce68..5a4ae3eeef 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 f98a10dcec..f6124e5eff 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 43b1860f80..cb08acceaf 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 b71cd0db58..99921a1426 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 63db238296..5e0de5e87a 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 06fa11e212..01f1da4850 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 + '<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);
diff --git a/js/ui/padOsd.js b/js/ui/padOsd.js
index 854e0f61ed..75e274f33f 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('<span size="larger"><b>' + title + '</b></span>');
+        this._titleLabel.clutter_text.set_markup(
+            `<span size="larger"><b>${title}</b></span>`);
     }
 
     _isEditedAction(type, number, dir) {
diff --git a/js/ui/runDialog.js b/js/ui/runDialog.js
index fba1dc7fb2..8154b94273 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 3712c198a4..71f8795ac7 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('<b>' + n.title + '</b> ' + body);
+            label.clutter_text.set_markup(`<b>${n.title}</b> ${body}`);
             textBox.add(label);
 
             visible = true;
diff --git a/js/ui/shellDBus.js b/js/ui/shellDBus.js
index fca0b64255..8b3db8fc0e 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));
     }
 


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]