cleanup: Don't shadow variables

Having variables that share the same name in overlapping scopes is
confusing and error-prone, and is best avoided.

https://gitlab.gnome.org/GNOME/gnome-shell-extensions/merge_requests/91
This commit is contained in:
Florian Müllner
2019-08-07 04:05:17 +02:00
committed by Florian Müllner
parent fdc3dda484
commit 63c07bdc73
5 changed files with 15 additions and 15 deletions

View File

@@ -77,8 +77,8 @@ class ApplicationMenuItem extends PopupMenu.PopupBaseMenuItem {
super.setActive(active, params);
}
setDragEnabled(enable) {
this._dragEnabled = enable;
setDragEnabled(enabled) {
this._dragEnabled = enabled;
}
getDragActor() {
@@ -630,7 +630,7 @@ class ApplicationsButton extends PanelMenu.Button {
this.applicationsByCategory[categoryId] = [];
this._loadCategory(categoryId, dir);
if (this.applicationsByCategory[categoryId].length > 0) {
let categoryMenuItem = new CategoryMenuItem(this, dir);
categoryMenuItem = new CategoryMenuItem(this, dir);
this.categoriesBox.add_actor(categoryMenuItem);
}
}

View File

@@ -147,13 +147,13 @@ const Widget = GObject.registerClass({
grid.attach(dialog._spin, 1, 1, 1, 1);
dialog.get_content_area().add(grid);
dialog.connect('response', (dialog, id) => {
dialog.connect('response', (dlg, id) => {
if (id != Gtk.ResponseType.OK) {
dialog.destroy();
return;
}
let appInfo = dialog._appChooser.get_app_info();
appInfo = dialog._appChooser.get_app_info();
if (!appInfo)
return;
let index = Math.floor(dialog._spin.value);

View File

@@ -157,7 +157,7 @@ class NaturalLayoutStrategy extends Workspace.LayoutStrategy {
let xSection = Math.round((rects[i].x - bounds.x) / (bounds.width / 3));
let ySection = Math.round((rects[i].y - bounds.y) / (bounds.height / 3));
let iCenter = rects[i].center();
iCenter = rects[i].center();
diff[0] = 0;
diff[1] = 0;
if (xSection != 1 || ySection != 1) { // Remove this if you want the center to pull as well
@@ -183,7 +183,7 @@ class NaturalLayoutStrategy extends Workspace.LayoutStrategy {
diff[1] = bounds.y + bounds.height - iCenter[1];
}
if (diff[0] != 0 || diff[1] != 0) {
let length = Math.sqrt(diff[0] * diff[0] + diff[1] * diff[1]);
length = Math.sqrt(diff[0] * diff[0] + diff[1] * diff[1]);
diff[0] *= WINDOW_PLACEMENT_NATURAL_ACCURACY / length / 2; // /2 to make it less influencing than the normal center-move above
diff[1] *= WINDOW_PLACEMENT_NATURAL_ACCURACY / length / 2;
rects[i].translate(diff[0], diff[1]);

View File

@@ -41,9 +41,9 @@ class PlaceInfo {
async _ensureMountAndLaunch(context, tryMount) {
try {
await this._launchDefaultForUri(this.file.get_uri(), context, null);
} catch (e) {
if (!e.matches(Gio.IOErrorEnum, Gio.IOErrorEnum.NOT_MOUNTED)) {
Main.notifyError(_('Failed to launch “%s”').format(this.name), e.message);
} catch (err) {
if (!err.matches(Gio.IOErrorEnum, Gio.IOErrorEnum.NOT_MOUNTED)) {
Main.notifyError(_('Failed to launch “%s”').format(this.name), err.message);
return;
}
@@ -505,16 +505,16 @@ var PlacesManager = class {
continue;
let duplicate = false;
for (let i = 0; i < this._places.special.length; i++) {
if (file.equal(this._places.special[i].file)) {
for (let j = 0; i < this._places.special.length; j++) {
if (file.equal(this._places.special[j].file)) {
duplicate = true;
break;
}
}
if (duplicate)
continue;
for (let i = 0; i < bookmarks.length; i++) {
if (file.equal(bookmarks[i].file)) {
for (let j = 0; j < bookmarks.length; j++) {
if (file.equal(bookmarks[j].file)) {
duplicate = true;
break;
}

View File

@@ -344,7 +344,7 @@ var WorkspaceIndicator = GObject.registerClass({
let item = new PopupMenu.PopupMenuItem(name);
item.workspaceId = i;
item.connect('activate', (item, _event) => {
item.connect('activate', () => {
this._activate(item.workspaceId);
});