cleanup: Avoid "lonely" ifs where it makes sense
If an else block only contains an if statement, the two can be combined into an if-else block, which cuts down on indentation and usually helps legibility. There are exceptions (for instance where the outer if and else blocks are mirrored), but where it makes sense, change the code to avoid lonely ifs. https://gitlab.gnome.org/GNOME/gnome-shell/merge_requests/805
This commit is contained in:
parent
67ea424525
commit
2e4e2500dd
@ -111,14 +111,12 @@ class AppSwitcherPopup extends SwitcherPopup.SwitcherPopup {
|
|||||||
|
|
||||||
_initialSelection(backward, binding) {
|
_initialSelection(backward, binding) {
|
||||||
if (binding == 'switch-group') {
|
if (binding == 'switch-group') {
|
||||||
if (backward) {
|
if (backward)
|
||||||
this._select(0, this._items[0].cachedWindows.length - 1);
|
this._select(0, this._items[0].cachedWindows.length - 1);
|
||||||
} else {
|
else if (this._items[0].cachedWindows.length > 1)
|
||||||
if (this._items[0].cachedWindows.length > 1)
|
this._select(0, 1);
|
||||||
this._select(0, 1);
|
else
|
||||||
else
|
this._select(0, 0);
|
||||||
this._select(0, 0);
|
|
||||||
}
|
|
||||||
} else if (binding == 'switch-group-backward') {
|
} else if (binding == 'switch-group-backward') {
|
||||||
this._select(0, this._items[0].cachedWindows.length - 1);
|
this._select(0, this._items[0].cachedWindows.length - 1);
|
||||||
} else if (binding == 'switch-applications-backward') {
|
} else if (binding == 'switch-applications-backward') {
|
||||||
@ -193,15 +191,14 @@ class AppSwitcherPopup extends SwitcherPopup.SwitcherPopup {
|
|||||||
this._closeAppWindow(this._selectedIndex, this._currentWindow);
|
this._closeAppWindow(this._selectedIndex, this._currentWindow);
|
||||||
else
|
else
|
||||||
return Clutter.EVENT_PROPAGATE;
|
return Clutter.EVENT_PROPAGATE;
|
||||||
|
} else if (keysym == Clutter.KEY_Left) {
|
||||||
|
this._select(this._previous());
|
||||||
|
} else if (keysym == Clutter.KEY_Right) {
|
||||||
|
this._select(this._next());
|
||||||
|
} else if (keysym == Clutter.KEY_Down) {
|
||||||
|
this._select(this._selectedIndex, 0);
|
||||||
} else {
|
} else {
|
||||||
if (keysym === Clutter.KEY_Left)
|
return Clutter.EVENT_PROPAGATE;
|
||||||
this._select(this._previous());
|
|
||||||
else if (keysym === Clutter.KEY_Right)
|
|
||||||
this._select(this._next());
|
|
||||||
else if (keysym === Clutter.KEY_Down)
|
|
||||||
this._select(this._selectedIndex, 0);
|
|
||||||
else
|
|
||||||
return Clutter.EVENT_PROPAGATE;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return Clutter.EVENT_STOP;
|
return Clutter.EVENT_STOP;
|
||||||
@ -591,20 +588,18 @@ class WindowSwitcherPopup extends SwitcherPopup.SwitcherPopup {
|
|||||||
}
|
}
|
||||||
|
|
||||||
_keyPressHandler(keysym, action) {
|
_keyPressHandler(keysym, action) {
|
||||||
if (action == Meta.KeyBindingAction.SWITCH_WINDOWS) {
|
if (action == Meta.KeyBindingAction.SWITCH_WINDOWS)
|
||||||
this._select(this._next());
|
this._select(this._next());
|
||||||
} else if (action == Meta.KeyBindingAction.SWITCH_WINDOWS_BACKWARD) {
|
else if (action == Meta.KeyBindingAction.SWITCH_WINDOWS_BACKWARD)
|
||||||
this._select(this._previous());
|
this._select(this._previous());
|
||||||
} else {
|
else if (keysym == Clutter.KEY_Left)
|
||||||
if (keysym === Clutter.KEY_Left)
|
this._select(this._previous());
|
||||||
this._select(this._previous());
|
else if (keysym == Clutter.KEY_Right)
|
||||||
else if (keysym === Clutter.KEY_Right)
|
this._select(this._next());
|
||||||
this._select(this._next());
|
else if (keysym == Clutter.KEY_w || keysym == Clutter.KEY_F4)
|
||||||
else if (keysym === Clutter.KEY_w || keysym === Clutter.KEY_F4)
|
this._closeWindow(this._selectedIndex);
|
||||||
this._closeWindow(this._selectedIndex);
|
else
|
||||||
else
|
return Clutter.EVENT_PROPAGATE;
|
||||||
return Clutter.EVENT_PROPAGATE;
|
|
||||||
}
|
|
||||||
|
|
||||||
return Clutter.EVENT_STOP;
|
return Clutter.EVENT_STOP;
|
||||||
}
|
}
|
||||||
|
@ -2212,10 +2212,11 @@ var WindowManager = class {
|
|||||||
|
|
||||||
this._resizePopup.set(rect, displayW, displayH);
|
this._resizePopup.set(rect, displayW, displayH);
|
||||||
} else {
|
} else {
|
||||||
if (this._resizePopup) {
|
if (!this._resizePopup)
|
||||||
this._resizePopup.destroy();
|
return;
|
||||||
this._resizePopup = null;
|
|
||||||
}
|
this._resizePopup.destroy();
|
||||||
|
this._resizePopup = null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@ -224,14 +224,13 @@ class WorkspacesView extends WorkspacesViewBase {
|
|||||||
|
|
||||||
for (let w = 0; w < this._workspaces.length; w++) {
|
for (let w = 0; w < this._workspaces.length; w++) {
|
||||||
let workspace = this._workspaces[w];
|
let workspace = this._workspaces[w];
|
||||||
if (this._animating || this._scrolling || this._gestureActive) {
|
|
||||||
|
if (this._animating || this._scrolling || this._gestureActive)
|
||||||
workspace.show();
|
workspace.show();
|
||||||
} else {
|
else if (this._inDrag)
|
||||||
if (this._inDrag)
|
workspace.visible = (Math.abs(w - active) <= 1);
|
||||||
workspace.visible = (Math.abs(w - active) <= 1);
|
else
|
||||||
else
|
workspace.visible = (w == active);
|
||||||
workspace.visible = (w == active);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -68,10 +68,11 @@ var XdndHandler = class {
|
|||||||
// Make sure that the clone has the same position as the source
|
// Make sure that the clone has the same position as the source
|
||||||
this._cursorWindowClone.add_constraint(constraintPosition);
|
this._cursorWindowClone.add_constraint(constraintPosition);
|
||||||
} else {
|
} else {
|
||||||
if (this._cursorWindowClone) {
|
if (!this._cursorWindowClone)
|
||||||
this._cursorWindowClone.destroy();
|
return;
|
||||||
this._cursorWindowClone = null;
|
|
||||||
}
|
this._cursorWindowClone.destroy();
|
||||||
|
this._cursorWindowClone = null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user