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
This commit is contained in:
Florian Müllner
2019-01-28 06:37:28 +01:00
parent 3effc9cfc2
commit 8a2b9abc09
8 changed files with 18 additions and 18 deletions
+5 -5
View File
@@ -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) {
+4 -4
View File
@@ -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);
}
});
+1 -1
View File
@@ -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);
});
+2 -2
View File
@@ -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);
+1 -1
View File
@@ -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 }));
+1 -1
View File
@@ -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));
}
+1 -1
View File
@@ -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 }));
+3 -3
View File
@@ -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 });
}