From 7c170e7e90780fc6d9e772395e31c9729946c849 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Florian=20M=C3=BCllner?= Date: Wed, 7 Aug 2019 03:58:03 +0200 Subject: [PATCH] cleanup: Always use type-safe comparisons The type coercion performed by the regular == and != operators can have surprising results. It is therefore considered good practice to use the type-safe === and !== variants instead. https://gitlab.gnome.org/GNOME/gnome-shell-extensions/merge_requests/91 --- extensions/apps-menu/extension.js | 24 +++---- extensions/auto-move-windows/extension.js | 2 +- extensions/auto-move-windows/prefs.js | 4 +- extensions/drive-menu/extension.js | 4 +- .../native-window-placement/extension.js | 22 +++---- extensions/places-menu/placeDisplay.js | 2 +- .../screenshot-window-sizer/extension.js | 6 +- extensions/window-list/extension.js | 66 +++++++++---------- extensions/window-list/prefs.js | 2 +- extensions/window-list/windowPicker.js | 2 +- extensions/window-list/workspaceIndicator.js | 18 ++--- extensions/windowsNavigator/extension.js | 30 ++++----- extensions/workspace-indicator/extension.js | 20 +++--- 13 files changed, 101 insertions(+), 101 deletions(-) diff --git a/extensions/apps-menu/extension.js b/extensions/apps-menu/extension.js index 1236f820..7144f5d4 100644 --- a/extensions/apps-menu/extension.js +++ b/extensions/apps-menu/extension.js @@ -126,7 +126,7 @@ class CategoryMenuItem extends PopupMenu.PopupBaseMenuItem { _isNavigatingSubmenu([x, y]) { let [posX, posY] = this.get_transformed_position(); - if (this._oldX == -1) { + if (this._oldX === -1) { this._oldX = x; this._oldY = y; return true; @@ -244,14 +244,14 @@ class DesktopTarget { } get hasDesktop() { - return this._desktop != null; + return this._desktop !== null; } _onWindowAdded(group, actor) { if (!(actor instanceof Meta.WindowActor)) return; - if (actor.meta_window.get_window_type() == Meta.WindowType.DESKTOP) + if (actor.meta_window.get_window_type() === Meta.WindowType.DESKTOP) this._setDesktop(actor); } @@ -446,7 +446,7 @@ class ApplicationsButton extends PanelMenu.Button { _onMenuKeyPress(actor, event) { let symbol = event.get_key_symbol(); - if (symbol == Clutter.KEY_Left || symbol == Clutter.KEY_Right) { + if (symbol === Clutter.KEY_Left || symbol === Clutter.KEY_Right) { let direction = symbol === Clutter.KEY_Left ? Gtk.DirectionType.LEFT : Gtk.DirectionType.RIGHT; if (this.menu.actor.navigate_focus(global.stage.key_focus, direction, false)) @@ -496,8 +496,8 @@ class ApplicationsButton extends PanelMenu.Button { _loadCategory(categoryId, dir) { let iter = dir.iter(); let nextType; - while ((nextType = iter.next()) != GMenu.TreeItemType.INVALID) { - if (nextType == GMenu.TreeItemType.ENTRY) { + while ((nextType = iter.next()) !== GMenu.TreeItemType.INVALID) { + if (nextType === GMenu.TreeItemType.ENTRY) { let entry = iter.get_entry(); let id; try { @@ -510,9 +510,9 @@ class ApplicationsButton extends PanelMenu.Button { app = new Shell.App({ app_info: entry.get_app_info() }); if (app.get_app_info().should_show()) this.applicationsByCategory[categoryId].push(app); - } else if (nextType == GMenu.TreeItemType.SEPARATOR) { + } else if (nextType === GMenu.TreeItemType.SEPARATOR) { this.applicationsByCategory[categoryId].push('separator'); - } else if (nextType == GMenu.TreeItemType.DIRECTORY) { + } else if (nextType === GMenu.TreeItemType.DIRECTORY) { let subdir = iter.get_directory(); if (!subdir.get_is_nodisplay()) this._loadCategory(categoryId, subdir); @@ -531,7 +531,7 @@ class ApplicationsButton extends PanelMenu.Button { newScrollValue = buttonAlloc.y1 - 10; if (boxHeight + currentScrollValue < buttonAlloc.y2 + 10) newScrollValue = buttonAlloc.y2 - boxHeight + 10; - if (newScrollValue != currentScrollValue) + if (newScrollValue !== currentScrollValue) appsScrollBoxAdj.set_value(newScrollValue); } @@ -546,7 +546,7 @@ class ApplicationsButton extends PanelMenu.Button { newScrollValue = buttonAlloc.y1 - 10; if (boxHeight + currentScrollValue < buttonAlloc.y2 + 10) newScrollValue = buttonAlloc.y2 - boxHeight + 10; - if (newScrollValue != currentScrollValue) + if (newScrollValue !== currentScrollValue) catsScrollBoxAdj.set_value(newScrollValue); } @@ -618,8 +618,8 @@ class ApplicationsButton extends PanelMenu.Button { this.categoriesBox.add_actor(categoryMenuItem); let iter = root.iter(); let nextType; - while ((nextType = iter.next()) != GMenu.TreeItemType.INVALID) { - if (nextType != GMenu.TreeItemType.DIRECTORY) + while ((nextType = iter.next()) !== GMenu.TreeItemType.INVALID) { + if (nextType !== GMenu.TreeItemType.DIRECTORY) continue; let dir = iter.get_directory(); diff --git a/extensions/auto-move-windows/extension.js b/extensions/auto-move-windows/extension.js index de9f3b51..724d7669 100644 --- a/extensions/auto-move-windows/extension.js +++ b/extensions/auto-move-windows/extension.js @@ -95,7 +95,7 @@ class WindowMover { // or something; assume it'll be added back immediately, so keep it // to avoid moving it again windows.push(...data.windows.filter( - w => !windows.includes(w) && w.get_compositor_private() != null + w => !windows.includes(w) && w.get_compositor_private() !== null )); let workspaceNum = this._appConfigs.get(app.id); diff --git a/extensions/auto-move-windows/prefs.js b/extensions/auto-move-windows/prefs.js index e83798a2..eed46be3 100644 --- a/extensions/auto-move-windows/prefs.js +++ b/extensions/auto-move-windows/prefs.js @@ -148,7 +148,7 @@ const Widget = GObject.registerClass({ dialog.get_content_area().add(grid); dialog.connect('response', (dlg, id) => { - if (id != Gtk.ResponseType.OK) { + if (id !== Gtk.ResponseType.OK) { dialog.destroy(); return; } @@ -217,7 +217,7 @@ const Widget = GObject.registerClass({ this._appendRow(appInfo, parseInt(index)); } - if (validItems.length != currentItems.length) // some items were filtered out + if (validItems.length !== currentItems.length) // some items were filtered out this._settings.set_strv(SETTINGS_KEY, validItems); } diff --git a/extensions/drive-menu/extension.js b/extensions/drive-menu/extension.js index 365e2449..f2c32a36 100644 --- a/extensions/drive-menu/extension.js +++ b/extensions/drive-menu/extension.js @@ -59,7 +59,7 @@ class MountMenuItem extends PopupMenu.PopupBaseMenuItem { return true; } - return volume.get_identifier('class') != 'network'; + return volume.get_identifier('class') !== 'network'; } _syncVisibility() { @@ -168,7 +168,7 @@ class DriveMenu extends PanelMenu.Button { _removeMount(mount) { for (let i = 0; i < this._mounts.length; i++) { let item = this._mounts[i]; - if (item.mount == mount) { + if (item.mount === mount) { item.destroy(); this._mounts.splice(i, 1); return; diff --git a/extensions/native-window-placement/extension.js b/extensions/native-window-placement/extension.js index e58832d9..a91d1935 100644 --- a/extensions/native-window-placement/extension.js +++ b/extensions/native-window-placement/extension.js @@ -98,7 +98,7 @@ class NaturalLayoutStrategy extends Workspace.LayoutStrategy { // This is used when the window is on the edge of the screen to try to use as much screen real estate as possible. directions[i] = direction; direction++; - if (direction == 4) + if (direction === 4) direction = 0; } @@ -113,7 +113,7 @@ class NaturalLayoutStrategy extends Workspace.LayoutStrategy { .map(v => (v *= WINDOW_PLACEMENT_NATURAL_GAPS)); let iAdjusted = rects[i].adjusted(...adjustments); let jAdjusted = rects[j].adjusted(...adjustments); - if (i != j && iAdjusted.overlap(jAdjusted)) { + if (i !== j && iAdjusted.overlap(jAdjusted)) { loopCounter++; overlap = true; @@ -125,7 +125,7 @@ class NaturalLayoutStrategy extends Workspace.LayoutStrategy { let diff = [jCenter[0] - iCenter[0], jCenter[1] - iCenter[1]]; // Prevent dividing by zero and non-movement - if (diff[0] == 0 && diff[1] == 0) + if (diff[0] === 0 && diff[1] === 0) diff[0] = 1; // Try to keep screen/workspace aspect ratio if (bounds.height / bounds.width > areaRect.height / areaRect.width) @@ -160,29 +160,29 @@ class NaturalLayoutStrategy extends Workspace.LayoutStrategy { 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 - if (xSection == 1) + if (xSection !== 1 || ySection !== 1) { // Remove this if you want the center to pull as well + if (xSection === 1) xSection = directions[i] / 2 ? 2 : 0; - if (ySection == 1) + if (ySection === 1) ySection = directions[i] % 2 ? 2 : 0; } - if (xSection == 0 && ySection == 0) { + if (xSection === 0 && ySection === 0) { diff[0] = bounds.x - iCenter[0]; diff[1] = bounds.y - iCenter[1]; } - if (xSection == 2 && ySection == 0) { + if (xSection === 2 && ySection === 0) { diff[0] = bounds.x + bounds.width - iCenter[0]; diff[1] = bounds.y - iCenter[1]; } - if (xSection == 2 && ySection == 2) { + if (xSection === 2 && ySection === 2) { diff[0] = bounds.x + bounds.width - iCenter[0]; diff[1] = bounds.y + bounds.height - iCenter[1]; } - if (xSection == 0 && ySection == 2) { + if (xSection === 0 && ySection === 2) { diff[0] = bounds.x - iCenter[0]; diff[1] = bounds.y + bounds.height - iCenter[1]; } - if (diff[0] != 0 || diff[1] != 0) { + if (diff[0] !== 0 || diff[1] !== 0) { 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; diff --git a/extensions/places-menu/placeDisplay.js b/extensions/places-menu/placeDisplay.js index 1612a835..5b1da65b 100644 --- a/extensions/places-menu/placeDisplay.js +++ b/extensions/places-menu/placeDisplay.js @@ -366,7 +366,7 @@ var PlacesManager = class { for (let i = 0; i < dirs.length; i++) { let specialPath = GLib.get_user_special_dir(dirs[i]); - if (!specialPath || specialPath == homePath) + if (!specialPath || specialPath === homePath) continue; let file = Gio.File.new_for_path(specialPath), info; diff --git a/extensions/screenshot-window-sizer/extension.js b/extensions/screenshot-window-sizer/extension.js index 043ecb5d..c135be6c 100644 --- a/extensions/screenshot-window-sizer/extension.js +++ b/extensions/screenshot-window-sizer/extension.js @@ -71,10 +71,10 @@ function cycleScreenshotSizes(display, window, binding) { // Probably this isn't useful with 5 sizes, but you can decrease instead // of increase by holding down shift. let modifiers = binding.get_modifiers(); - let backwards = (modifiers & Meta.VirtualModifier.SHIFT_MASK) != 0; + let backwards = (modifiers & Meta.VirtualModifier.SHIFT_MASK) !== 0; // Unmaximize first - if (window.get_maximized() != 0) + if (window.get_maximized() !== 0) window.unmaximize(Meta.MaximizeFlags.BOTH); let workArea = window.get_work_area_current_monitor(); @@ -97,7 +97,7 @@ function cycleScreenshotSizes(display, window, binding) { // get the best initial window size let error = Math.abs(width - outerRect.width) + Math.abs(height - outerRect.height); - if (nearestIndex == null || error < nearestError) { + if (nearestIndex === undefined || error < nearestError) { nearestIndex = i; nearestError = error; } diff --git a/extensions/window-list/extension.js b/extensions/window-list/extension.js index eb787fc7..65215523 100644 --- a/extensions/window-list/extension.js +++ b/extensions/window-list/extension.js @@ -26,8 +26,8 @@ const GroupingMode = { function _minimizeOrActivateWindow(window) { let focusWindow = global.display.focus_window; - if (focusWindow == window || - focusWindow && focusWindow.get_transient_for() == window) + if (focusWindow === window || + focusWindow && focusWindow.get_transient_for() === window) window.minimize(); else window.activate(global.get_current_time()); @@ -37,7 +37,7 @@ function _openMenu(menu) { menu.open(); let event = Clutter.get_current_event(); - if (event && event.type() == Clutter.EventType.KEY_RELEASE) + if (event && event.type() === Clutter.EventType.KEY_RELEASE) menu.actor.navigate_focus(null, Gtk.DirectionType.TAB_FORWARD, false); } @@ -80,7 +80,7 @@ class WindowContextMenu extends PopupMenu.PopupMenu { this._maximizeItem = new PopupMenu.PopupMenuItem(''); this._maximizeItem.connect('activate', () => { - if (this._metaWindow.get_maximized() == Meta.MaximizeFlags.BOTH) + if (this._metaWindow.get_maximized() === Meta.MaximizeFlags.BOTH) this._metaWindow.unmaximize(Meta.MaximizeFlags.BOTH); else this._metaWindow.maximize(Meta.MaximizeFlags.BOTH); @@ -259,7 +259,7 @@ const BaseButton = GObject.registerClass({ // eslint-disable-next-line camelcase set ignore_workspace(ignore) { - if (this._ignoreWorkspace == ignore) + if (this._ignoreWorkspace === ignore) return; this._ignoreWorkspace = ignore; @@ -312,7 +312,7 @@ const BaseButton = GObject.registerClass({ return !window.skip_taskbar && (this._ignoreWorkspace || window.located_on_workspace(workspace)) && - (!this._perMonitor || window.get_monitor() == this._monitorIndex); + (!this._perMonitor || window.get_monitor() === this._monitorIndex); } _updateVisibility() { @@ -381,14 +381,14 @@ const WindowButton = GObject.registerClass({ return; } - if (button == 1) + if (button === 1) _minimizeOrActivateWindow(this.metaWindow); else _openMenu(this._contextMenu); } _isFocused() { - return global.display.focus_window == this.metaWindow; + return global.display.focus_window === this.metaWindow; } _updateStyle() { @@ -401,7 +401,7 @@ const WindowButton = GObject.registerClass({ } _windowEnteredOrLeftMonitor(metaDisplay, monitorIndex, metaWindow) { - if (monitorIndex == this._monitorIndex && metaWindow == this.metaWindow) + if (monitorIndex === this._monitorIndex && metaWindow === this.metaWindow) this._updateVisibility(); } @@ -470,10 +470,10 @@ class AppContextMenu extends PopupMenu.PopupMenu { this._minimizeItem.visible = windows.some(w => !w.minimized); this._unminimizeItem.visible = windows.some(w => w.minimized); this._maximizeItem.visible = windows.some(w => { - return w.get_maximized() != Meta.MaximizeFlags.BOTH; + return w.get_maximized() !== Meta.MaximizeFlags.BOTH; }); this._unmaximizeItem.visible = windows.some(w => { - return w.get_maximized() == Meta.MaximizeFlags.BOTH; + return w.get_maximized() === Meta.MaximizeFlags.BOTH; }); super.open(animate); @@ -548,8 +548,8 @@ const AppButton = GObject.registerClass({ } _windowEnteredOrLeftMonitor(metaDisplay, monitorIndex, metaWindow) { - if (this._windowTracker.get_window_app(metaWindow) == this.app && - monitorIndex == this._monitorIndex) { + if (this._windowTracker.get_window_app(metaWindow) === this.app && + monitorIndex === this._monitorIndex) { this._updateVisibility(); this._windowsChanged(); } @@ -568,7 +568,7 @@ const AppButton = GObject.registerClass({ } _isFocused() { - return this._windowTracker.focus_app == this.app; + return this._windowTracker.focus_app === this.app; } _updateIconGeometry() { @@ -584,7 +584,7 @@ const AppButton = GObject.registerClass({ _windowsChanged() { let windows = this.getWindowList(); - this._singleWindowTitle.visible = windows.length == 1; + this._singleWindowTitle.visible = windows.length === 1; this._multiWindowTitle.visible = !this._singleWindowTitle.visible; if (this._singleWindowTitle.visible) { @@ -626,12 +626,12 @@ const AppButton = GObject.registerClass({ if (contextMenuWasOpen) this._contextMenu.close(); - if (button == 1) { + if (button === 1) { if (menuWasOpen) return; let windows = this.getWindowList(); - if (windows.length == 1) { + if (windows.length === 1) { if (contextMenuWasOpen) return; _minimizeOrActivateWindow(windows[0]); @@ -810,9 +810,9 @@ const WindowList = GObject.registerClass({ _onScrollEvent(actor, event) { let direction = event.get_scroll_direction(); let diff = 0; - if (direction == Clutter.ScrollDirection.DOWN) + if (direction === Clutter.ScrollDirection.DOWN) diff = 1; - else if (direction == Clutter.ScrollDirection.UP) + else if (direction === Clutter.ScrollDirection.UP) diff = -1; else return; @@ -834,7 +834,7 @@ const WindowList = GObject.registerClass({ let workspaceManager = global.workspace_manager; let hasWorkspaces = this._mutterSettings.get_boolean('dynamic-workspaces') || workspaceManager.n_workspaces > 1; - let workspacesOnMonitor = this._monitor == Main.layoutManager.primaryMonitor || + let workspacesOnMonitor = this._monitor === Main.layoutManager.primaryMonitor || !this._mutterSettings.get_boolean('workspaces-only-on-primary'); this._workspaceIndicator.visible = hasWorkspaces && workspacesOnMonitor; @@ -854,7 +854,7 @@ const WindowList = GObject.registerClass({ } _getPreferredUngroupedWindowListWidth() { - if (this._windowList.get_n_children() == 0) + if (this._windowList.get_n_children() === 0) return this._windowList.get_preferred_width(-1)[1]; let children = this._windowList.get_children(); @@ -864,9 +864,9 @@ const WindowList = GObject.registerClass({ let workspace = global.workspace_manager.get_active_workspace(); let windows = global.display.get_tab_list(Meta.TabList.NORMAL, workspace); if (this._perMonitor) - windows = windows.filter(w => w.get_monitor() == this._monitor.index); + windows = windows.filter(w => w.get_monitor() === this._monitor.index); let nWindows = windows.length; - if (nWindows == 0) + if (nWindows === 0) return this._windowList.get_preferred_width(-1)[1]; return nWindows * childWidth + (nWindows - 1) * spacing; @@ -880,16 +880,16 @@ const WindowList = GObject.registerClass({ _groupingModeChanged() { this._groupingMode = this._settings.get_enum('grouping-mode'); - if (this._groupingMode == GroupingMode.AUTO) { + if (this._groupingMode === GroupingMode.AUTO) { this._checkGrouping(); } else { - this._grouped = this._groupingMode == GroupingMode.ALWAYS; + this._grouped = this._groupingMode === GroupingMode.ALWAYS; this._populateWindowList(); } } _checkGrouping() { - if (this._groupingMode != GroupingMode.AUTO) + if (this._groupingMode !== GroupingMode.AUTO) return; let maxWidth = this._getMaxWindowListWidth(); @@ -934,9 +934,9 @@ const WindowList = GObject.registerClass({ if (!this._grouped) return; - if (app.state == Shell.AppState.RUNNING) + if (app.state === Shell.AppState.RUNNING) this._addApp(app); - else if (app.state == Shell.AppState.STOPPED) + else if (app.state === Shell.AppState.STOPPED) this._removeApp(app); } @@ -952,7 +952,7 @@ const WindowList = GObject.registerClass({ _removeApp(app) { let children = this._windowList.get_children(); - let child = children.find(c => c.app == app); + let child = children.find(c => c.app === app); if (child) child.destroy(); } @@ -968,7 +968,7 @@ const WindowList = GObject.registerClass({ return; let children = this._windowList.get_children(); - if (children.find(c => c.metaWindow == win)) + if (children.find(c => c.metaWindow === win)) return; let button = new WindowButton(win, this._perMonitor, this._monitor.index); @@ -991,7 +991,7 @@ const WindowList = GObject.registerClass({ return; // not actually removed, just moved to another workspace let children = this._windowList.get_children(); - let child = children.find(c => c.metaWindow == win); + let child = children.find(c => c.metaWindow === win); if (child) child.destroy(); } @@ -1047,7 +1047,7 @@ const WindowList = GObject.registerClass({ let hoveredWindow = dragEvent.targetActor.metaWindow; if (!hoveredWindow || - this._dndWindow == hoveredWindow) + this._dndWindow === hoveredWindow) return DND.DragMotionResult.CONTINUE; this._removeActivateTimeout(); @@ -1151,7 +1151,7 @@ class Extension { let showOnAllMonitors = this._settings.get_boolean('show-on-all-monitors'); Main.layoutManager.monitors.forEach(monitor => { - if (showOnAllMonitors || monitor == Main.layoutManager.primaryMonitor) + if (showOnAllMonitors || monitor === Main.layoutManager.primaryMonitor) this._windowLists.push(new WindowList(showOnAllMonitors, monitor)); }); } diff --git a/extensions/window-list/prefs.js b/extensions/window-list/prefs.js index 8a4102fb..82bc59e4 100644 --- a/extensions/window-list/prefs.js +++ b/extensions/window-list/prefs.js @@ -59,7 +59,7 @@ class WindowListPrefsWidget extends Gtk.Grid { } radio = new Gtk.RadioButton({ - active: currentMode == mode, + active: currentMode === mode, label, group: radio, }); diff --git a/extensions/window-list/windowPicker.js b/extensions/window-list/windowPicker.js index 901475dc..5a26bd26 100644 --- a/extensions/window-list/windowPicker.js +++ b/extensions/window-list/windowPicker.js @@ -141,7 +141,7 @@ var WindowPicker = GObject.registerClass({ this._stageKeyPressId = global.stage.connect('key-press-event', (a, event) => { let sym = event.get_key_symbol(); - if (sym == Clutter.KEY_Escape) { + if (sym === Clutter.KEY_Escape) { this.close(); return Clutter.EVENT_STOP; } diff --git a/extensions/window-list/workspaceIndicator.js b/extensions/window-list/workspaceIndicator.js index eb694b12..b5cb8e32 100644 --- a/extensions/window-list/workspaceIndicator.js +++ b/extensions/window-list/workspaceIndicator.js @@ -69,7 +69,7 @@ let WindowPreview = GObject.registerClass({ } _onFocusChanged() { - if (global.display.focus_window == this._window) + if (global.display.focus_window === this._window) this.add_style_class_name('active'); else this.remove_style_class_name('active'); @@ -77,7 +77,7 @@ let WindowPreview = GObject.registerClass({ _relayout() { let monitor = Main.layoutManager.findIndexForActor(this); - this.visible = monitor == this._window.get_monitor() && + this.visible = monitor === this._window.get_monitor() && this._window.showing_on_its_workspace(); if (!this.visible) @@ -186,7 +186,7 @@ let WorkspaceThumbnail = GObject.registerClass({ _moveWindow(window) { let monitorIndex = Main.layoutManager.findIndexForActor(this); - if (monitorIndex != window.get_monitor()) + if (monitorIndex !== window.get_monitor()) window.move_to_monitor(monitorIndex); window.change_workspace_by_index(this._index, false); } @@ -276,7 +276,7 @@ var WorkspaceIndicator = GObject.registerClass({ } _onWorkspaceOrientationChanged() { - let vertical = global.workspace_manager.layout_rows == -1; + let vertical = global.workspace_manager.layout_rows === -1; this.reactive = vertical; this._statusBin.visible = vertical; @@ -300,7 +300,7 @@ var WorkspaceIndicator = GObject.registerClass({ _updateMenuOrnament() { for (let i = 0; i < this._workspacesItems.length; i++) { - this._workspacesItems[i].setOrnament(i == this._currentWorkspace + this._workspacesItems[i].setOrnament(i === this._currentWorkspace ? PopupMenu.Ornament.DOT : PopupMenu.Ornament.NONE); } @@ -309,7 +309,7 @@ var WorkspaceIndicator = GObject.registerClass({ _updateActiveThumbnail() { let thumbs = this._thumbnailsBox.get_children(); for (let i = 0; i < thumbs.length; i++) { - if (i == this._currentWorkspace) + if (i === this._currentWorkspace) thumbs[i].add_style_class_name('active'); else thumbs[i].remove_style_class_name('active'); @@ -348,7 +348,7 @@ var WorkspaceIndicator = GObject.registerClass({ this._activate(item.workspaceId); }); - if (i == this._currentWorkspace) + if (i === this._currentWorkspace) item.setOrnament(PopupMenu.Ornament.DOT); this.menu.addMenuItem(item); @@ -382,9 +382,9 @@ var WorkspaceIndicator = GObject.registerClass({ _onScrollEvent(actor, event) { let direction = event.get_scroll_direction(); let diff = 0; - if (direction == Clutter.ScrollDirection.DOWN) + if (direction === Clutter.ScrollDirection.DOWN) diff = 1; - else if (direction == Clutter.ScrollDirection.UP) + else if (direction === Clutter.ScrollDirection.UP) diff = -1; else return; diff --git a/extensions/windowsNavigator/extension.js b/extensions/windowsNavigator/extension.js index f5175b19..99a2d5d3 100644 --- a/extensions/windowsNavigator/extension.js +++ b/extensions/windowsNavigator/extension.js @@ -92,7 +92,7 @@ var MyWorkspace = class extends Workspace.Workspace { getWindowWithTooltip(id) { for (let i = 0; i < this._windows.length; i++) { - if (this._windows[i].slotId + 1 == id) + if (this._windows[i].slotId + 1 === id) return this._windows[i].metaWindow; } return null; @@ -133,7 +133,7 @@ var MyWorkspacesView = class extends WorkspacesView.WorkspacesView { } _hideTooltips() { - if (global.stage.get_key_focus() == global.stage) + if (global.stage.get_key_focus() === global.stage) global.stage.set_key_focus(this._prevFocusActor); this._pickWindow = false; for (let i = 0; i < this._workspaces.length; i++) @@ -149,24 +149,24 @@ var MyWorkspacesView = class extends WorkspacesView.WorkspacesView { _onKeyRelease(s, o) { if (this._pickWindow && - (o.get_key_symbol() == Clutter.KEY_Alt_L || - o.get_key_symbol() == Clutter.KEY_Alt_R)) + (o.get_key_symbol() === Clutter.KEY_Alt_L || + o.get_key_symbol() === Clutter.KEY_Alt_R)) this._hideTooltips(); if (this._pickWorkspace && - (o.get_key_symbol() == Clutter.KEY_Control_L || - o.get_key_symbol() == Clutter.KEY_Control_R)) + (o.get_key_symbol() === Clutter.KEY_Control_L || + o.get_key_symbol() === Clutter.KEY_Control_R)) this._hideWorkspacesTooltips(); } _onKeyPress(s, o) { let { viewSelector } = Main.overview; - if (viewSelector._activePage != viewSelector._workspacesPage) + if (viewSelector._activePage !== viewSelector._workspacesPage) return false; let workspaceManager = global.workspace_manager; - if ((o.get_key_symbol() == Clutter.KEY_Alt_L || - o.get_key_symbol() == Clutter.KEY_Alt_R) && + if ((o.get_key_symbol() === Clutter.KEY_Alt_L || + o.get_key_symbol() === Clutter.KEY_Alt_R) && !this._pickWorkspace) { this._prevFocusActor = global.stage.get_key_focus(); global.stage.set_key_focus(null); @@ -175,8 +175,8 @@ var MyWorkspacesView = class extends WorkspacesView.WorkspacesView { this._workspaces[workspaceManager.get_active_workspace_index()].showWindowsTooltips(); return true; } - if ((o.get_key_symbol() == Clutter.KEY_Control_L || - o.get_key_symbol() == Clutter.KEY_Control_R) && + if ((o.get_key_symbol() === Clutter.KEY_Control_L || + o.get_key_symbol() === Clutter.KEY_Control_R) && !this._pickWindow) { this._prevFocusActor = global.stage.get_key_focus(); global.stage.set_key_focus(null); @@ -186,17 +186,17 @@ var MyWorkspacesView = class extends WorkspacesView.WorkspacesView { return true; } - if (global.stage.get_key_focus() != global.stage) + if (global.stage.get_key_focus() !== global.stage) return false; // ignore shift presses, they're required to get numerals in azerty keyboards if ((this._pickWindow || this._pickWorkspace) && - (o.get_key_symbol() == Clutter.KEY_Shift_L || - o.get_key_symbol() == Clutter.KEY_Shift_R)) + (o.get_key_symbol() === Clutter.KEY_Shift_L || + o.get_key_symbol() === Clutter.KEY_Shift_R)) return true; if (this._pickWindow) { - if (this._active != workspaceManager.get_active_workspace_index()) { + if (this._active !== workspaceManager.get_active_workspace_index()) { this._hideTooltips(); return false; } diff --git a/extensions/workspace-indicator/extension.js b/extensions/workspace-indicator/extension.js index 085d4665..6ed57762 100644 --- a/extensions/workspace-indicator/extension.js +++ b/extensions/workspace-indicator/extension.js @@ -75,7 +75,7 @@ let WindowPreview = GObject.registerClass({ } _onFocusChanged() { - if (global.display.focus_window == this._window) + if (global.display.focus_window === this._window) this.add_style_class_name('active'); else this.remove_style_class_name('active'); @@ -83,7 +83,7 @@ let WindowPreview = GObject.registerClass({ _relayout() { let monitor = Main.layoutManager.findIndexForActor(this); - this.visible = monitor == this._window.get_monitor() && + this.visible = monitor === this._window.get_monitor() && this._window.showing_on_its_workspace(); if (!this.visible) @@ -192,7 +192,7 @@ let WorkspaceThumbnail = GObject.registerClass({ _moveWindow(window) { let monitorIndex = Main.layoutManager.findIndexForActor(this); - if (monitorIndex != window.get_monitor()) + if (monitorIndex !== window.get_monitor()) window.move_to_monitor(monitorIndex); window.change_workspace_by_index(this._index, false); } @@ -281,7 +281,7 @@ class WorkspaceIndicator extends PanelMenu.Button { } _onWorkspaceOrientationChanged() { - let vertical = global.workspace_manager.layout_rows == -1; + let vertical = global.workspace_manager.layout_rows === -1; this.reactive = vertical; this._statusLabel.visible = vertical; @@ -310,7 +310,7 @@ class WorkspaceIndicator extends PanelMenu.Button { _updateMenuOrnament() { for (let i = 0; i < this._workspacesItems.length; i++) { - this._workspacesItems[i].setOrnament(i == this._currentWorkspace + this._workspacesItems[i].setOrnament(i === this._currentWorkspace ? PopupMenu.Ornament.DOT : PopupMenu.Ornament.NONE); } @@ -319,7 +319,7 @@ class WorkspaceIndicator extends PanelMenu.Button { _updateActiveThumbnail() { let thumbs = this._thumbnailsBox.get_children(); for (let i = 0; i < thumbs.length; i++) { - if (i == this._currentWorkspace) + if (i === this._currentWorkspace) thumbs[i].add_style_class_name('active'); else thumbs[i].remove_style_class_name('active'); @@ -327,7 +327,7 @@ class WorkspaceIndicator extends PanelMenu.Button { } _labelText(workspaceIndex) { - if (workspaceIndex == undefined) { + if (workspaceIndex === undefined) { workspaceIndex = this._currentWorkspace; return (workspaceIndex + 1).toString(); } @@ -356,7 +356,7 @@ class WorkspaceIndicator extends PanelMenu.Button { this._activate(actor.workspaceId); }); - if (i == this._currentWorkspace) + if (i === this._currentWorkspace) this._workspacesItems[i].setOrnament(PopupMenu.Ornament.DOT); } @@ -387,9 +387,9 @@ class WorkspaceIndicator extends PanelMenu.Button { _onScrollEvent(actor, event) { let direction = event.get_scroll_direction(); let diff = 0; - if (direction == Clutter.ScrollDirection.DOWN) + if (direction === Clutter.ScrollDirection.DOWN) diff = 1; - else if (direction == Clutter.ScrollDirection.UP) + else if (direction === Clutter.ScrollDirection.UP) diff = -1; else return;