[gnome-shell-extensions/wip/fmuellner/cleanups: 11/13] style: Stop using string concatenation



commit 2bcd7f706c6814653f585806a17ff5c33d113cf9
Author: Florian Müllner <fmuellner gnome org>
Date:   Sat Jan 26 22:04:09 2019 +0100

    style: Stop using string concatenation
    
    String concatenation is considered bad style after ES6 added
    template strings. The latter is the replacement we generally
    want, except where the aforementioned xgettext bug would trip
    over the backtick/slash combination.
    
    https://gitlab.gnome.org/GNOME/gnome-shell-extensions/merge_requests/49

 extensions/apps-menu/extension.js           | 10 +++++-----
 extensions/auto-move-windows/prefs.js       |  8 ++++----
 extensions/places-menu/extension.js         |  2 +-
 extensions/user-theme/extension.js          |  4 ++--
 extensions/window-list/prefs.js             |  2 +-
 extensions/workspace-indicator/extension.js |  2 +-
 extensions/workspace-indicator/prefs.js     |  2 +-
 lib/convenience.js                          |  6 +++---
 8 files changed, 18 insertions(+), 18 deletions(-)
---
diff --git a/extensions/apps-menu/extension.js b/extensions/apps-menu/extension.js
index 04052d9..6d9ab2e 100644
--- a/extensions/apps-menu/extension.js
+++ b/extensions/apps-menu/extension.js
@@ -327,7 +327,7 @@ class DesktopTarget {
                 try {
                     o.set_attributes_finish(res);
                 } catch (e) {
-                    log('Failed to update access time: ' + e.message);
+                    log(`Failed to update access time: ${e.message}`);
                 }
             });
     }
@@ -354,7 +354,7 @@ class DesktopTarget {
                             this._touchFile(file);
                         });
                 } catch (e) {
-                    log('Failed to mark file as trusted: ' + e.message);
+                    log(`Failed to mark file as trusted: ${e.message}`);
                 }
             });
     }
@@ -392,7 +392,7 @@ class DesktopTarget {
             src.copy(dst, Gio.FileCopyFlags.OVERWRITE, null, null);
             this._markTrusted(dst);
         } catch (e) {
-            log('Failed to copy to desktop: ' + e.message);
+            log(`Failed to copy to desktop: ${e.message}`);
         }
 
         return true;
@@ -688,8 +688,8 @@ class ApplicationsButton extends PanelMenu.Button {
         let themeContext = St.ThemeContext.get_for_stage(global.stage);
         let scaleFactor = themeContext.scale_factor;
         let categoriesHeight = this.categoriesBox.height / scaleFactor;
-        let height = Math.round(categoriesHeight) + MENU_HEIGHT_OFFSET + 'px';
-        this.mainBox.style+=('height: ' + height);
+        let height = Math.round(categoriesHeight) + MENU_HEIGHT_OFFSET;
+        this.mainBox.style += `height: ${height}px`;
     }
 
     selectCategory(dir) {
diff --git a/extensions/auto-move-windows/prefs.js b/extensions/auto-move-windows/prefs.js
index 56f50e7..893cc6d 100644
--- a/extensions/auto-move-windows/prefs.js
+++ b/extensions/auto-move-windows/prefs.js
@@ -216,12 +216,12 @@ const Widget = GObject.registerClass({
 
     _checkId(id) {
         let items = this._settings.get_strv(SETTINGS_KEY);
-        return !items.some(i => i.startsWith(id + ':'));
+        return !items.some(i => i.startsWith(`${id}:`));
     }
 
     _appendItem(id, workspace) {
         let currentItems = this._settings.get_strv(SETTINGS_KEY);
-        currentItems.push(id + ':' + workspace);
+        currentItems.push(`${id}:${workspace}`);
         this._settings.set_strv(SETTINGS_KEY, currentItems);
     }
 
@@ -240,9 +240,9 @@ const Widget = GObject.registerClass({
         let index = currentItems.map(el => el.split(':')[0]).indexOf(id);
 
         if (index < 0)
-            currentItems.push(id + ':' + workspace);
+            currentItems.push(`${id}:${workspace}`);
         else
-            currentItems[index] = id + ':' + workspace;
+            currentItems[index] = `${id}:${workspace}`;
         this._settings.set_strv(SETTINGS_KEY, currentItems);
     }
 });
diff --git a/extensions/places-menu/extension.js b/extensions/places-menu/extension.js
index e9e9914..968a45e 100644
--- a/extensions/places-menu/extension.js
+++ b/extensions/places-menu/extension.js
@@ -91,7 +91,7 @@ class PlacesMenu extends PanelMenu.Button {
         for (let i = 0; i < SECTIONS.length; i++) {
             let id = SECTIONS[i];
             this._sections[id] = new PopupMenu.PopupMenuSection();
-            this.placesManager.connect(id + '-updated', () => {
+            this.placesManager.connect(`${id}-updated`, () => {
                 this._redisplay(id);
             });
 
diff --git a/extensions/user-theme/extension.js b/extensions/user-theme/extension.js
index 24a34a7..9a0bd21 100644
--- a/extensions/user-theme/extension.js
+++ b/extensions/user-theme/extension.js
@@ -17,7 +17,7 @@ class ThemeManager {
     }
 
     enable() {
-        this._changedId = this._settings.connect('changed::'+SETTINGS_KEY, this._changeTheme.bind(this));
+        this._changedId = this._settings.connect(`changed::${SETTINGS_KEY}`, this._changeTheme.bind(this));
         this._changeTheme();
     }
 
@@ -59,7 +59,7 @@ class ThemeManager {
         }
 
         if (_stylesheet)
-            global.log('loading user theme: ' + _stylesheet);
+            global.log(`loading user theme: ${_stylesheet}`);
         else
             global.log('loading default theme (Adwaita)');
         Main.setThemeStylesheet(_stylesheet);
diff --git a/extensions/window-list/prefs.js b/extensions/window-list/prefs.js
index 8cc90f1..f7bb3ee 100644
--- a/extensions/window-list/prefs.js
+++ b/extensions/window-list/prefs.js
@@ -25,7 +25,7 @@ class WindowListPrefsWidget extends Gtk.Grid {
         this.row_spacing = 6;
         this.orientation = Gtk.Orientation.VERTICAL;
 
-        let groupingLabel = '<b>' + _("Window Grouping") + '</b>';
+        let groupingLabel = '<b>%s</b>'.format(_("Window Grouping"));
         this.add(new Gtk.Label({ label: groupingLabel, use_markup: true,
                                  halign: Gtk.Align.START }));
 
diff --git a/extensions/workspace-indicator/extension.js b/extensions/workspace-indicator/extension.js
index bd36b77..cdd841b 100644
--- a/extensions/workspace-indicator/extension.js
+++ b/extensions/workspace-indicator/extension.js
@@ -53,7 +53,7 @@ class WorkspaceIndicator extends PanelMenu.Button {
 
         this._settings = new Gio.Settings({ schema_id: WORKSPACE_SCHEMA });
         this._settingsChangedId =
-            this._settings.connect('changed::' + WORKSPACE_KEY,
+            this._settings.connect(`changed::${WORKSPACE_KEY}`,
                                    this._createWorkspacesSection.bind(this));
     }
 
diff --git a/extensions/workspace-indicator/prefs.js b/extensions/workspace-indicator/prefs.js
index f5b33dc..444148f 100644
--- a/extensions/workspace-indicator/prefs.js
+++ b/extensions/workspace-indicator/prefs.js
@@ -130,7 +130,7 @@ class WorkspaceSettingsWidget extends Gtk.Grid {
         this.margin = 12;
         this.orientation = Gtk.Orientation.VERTICAL;
 
-        this.add(new Gtk.Label({ label: '<b>' + _("Workspace Names") + '</b>',
+        this.add(new Gtk.Label({ label: '<b>%s</b>'.format(_("Workspace Names")),
                                  use_markup: true, margin_bottom: 6,
                                  hexpand: true, halign: Gtk.Align.START }));
 
diff --git a/lib/convenience.js b/lib/convenience.js
index bbc8608..4775edd 100644
--- a/lib/convenience.js
+++ b/lib/convenience.js
@@ -85,9 +85,9 @@ function getSettings(schema) {
 
     let schemaObj = schemaSource.lookup(schema, true);
     if (!schemaObj)
-        throw new Error('Schema ' + schema + ' could not be found for extension '
-                        + extension.metadata.uuid + '. Please check your installation.');
+        throw new Error(
+            `Schema ${schema} could not be found for extension ${extension.metadata.uuid}. Please check your 
installation.`
+        );
 
     return new Gio.Settings({ settings_schema: schemaObj });
 }
-                                                                 


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