[gnome-shell-extensions/wip/fmuellner/js-cleanup: 6/10] cleanup: Use arrow-notation for anonymous functions



commit e35c4103116d6a98709d1bfc3c941c4931982e54
Author: Florian Müllner <fmuellner gnome org>
Date:   Fri Oct 27 18:33:30 2017 +0200

    cleanup: Use arrow-notation for anonymous functions
    
    Arrow notation is great, but as we only started using it recently,
    we currently have a wild mix of Lang.bind(), function() and () => {}.
    To make the style consistent again, change all anonymous functions
    to arrow notation.
    
    Fixes https://gitlab.gnome.org/GNOME/gnome-shell-extensions/issues/30

 extensions/alternate-tab/prefs.js               |   7 +-
 extensions/apps-menu/extension.js               |  43 +++----
 extensions/auto-move-windows/extension.js       |   4 +-
 extensions/auto-move-windows/prefs.js           |  31 ++---
 extensions/drive-menu/extension.js              |  12 +-
 extensions/example/extension.js                 |   2 +-
 extensions/places-menu/extension.js             |   6 +-
 extensions/places-menu/placeDisplay.js          |  32 +++--
 extensions/screenshot-window-sizer/extension.js |   6 +-
 extensions/window-list/extension.js             | 151 ++++++++++--------------
 extensions/window-list/prefs.js                 |   5 +-
 extensions/windowsNavigator/extension.js        |   4 +-
 extensions/workspace-indicator/extension.js     |   4 +-
 extensions/workspace-indicator/prefs.js         |   9 +-
 14 files changed, 134 insertions(+), 182 deletions(-)
---
diff --git a/extensions/alternate-tab/prefs.js b/extensions/alternate-tab/prefs.js
index b8c4200..64cf4ed 100644
--- a/extensions/alternate-tab/prefs.js
+++ b/extensions/alternate-tab/prefs.js
@@ -3,11 +3,10 @@
 const Gio = imports.gi.Gio;
 const Gtk = imports.gi.Gtk;
 const GObject = imports.gi.GObject;
-const Lang = imports.lang;
 
 const Gettext = imports.gettext.domain('gnome-shell-extensions');
 const _ = Gettext.gettext;
-const N_ = function(e) { return e };
+const N_ = e => e;
 
 const ExtensionUtils = imports.misc.extensionUtils;
 const Me = ExtensionUtils.getCurrentExtension();
@@ -56,10 +55,10 @@ const AltTabSettingsWidget = new GObject.Class({
             let name = Gettext.gettext(MODES[mode]);
 
             radio = new Gtk.RadioButton({ group: radio, label: name, valign: Gtk.Align.START });
-            radio.connect('toggled', Lang.bind(this, function(widget) {
+            radio.connect('toggled', widget => {
                 if (widget.active)
                     this._settings.set_string(SETTINGS_APP_ICON_MODE, modeCapture);
-            }));
+            });
             grid.add(radio);
 
             if (mode == currentMode)
diff --git a/extensions/apps-menu/extension.js b/extensions/apps-menu/extension.js
index e430140..c632455 100644
--- a/extensions/apps-menu/extension.js
+++ b/extensions/apps-menu/extension.js
@@ -68,10 +68,9 @@ const ApplicationMenuItem = new Lang.Class({
         let textureCache = St.TextureCache.get_default();
         let iconThemeChangedId = textureCache.connect('icon-theme-changed',
                                                       Lang.bind(this, this._updateIcon));
-        this.actor.connect('destroy', Lang.bind(this,
-            function() {
-                textureCache.disconnect(iconThemeChangedId);
-            }));
+        this.actor.connect('destroy', () => {
+            textureCache.disconnect(iconThemeChangedId);
+        });
         this._updateIcon();
 
         this.actor._delegate = this;
@@ -446,12 +445,12 @@ const ApplicationsButton = new Lang.Class({
         this.actor.connect('captured-event', Lang.bind(this, this._onCapturedEvent));
         this.actor.connect('destroy', Lang.bind(this, this._onDestroy));
 
-        this._showingId = Main.overview.connect('showing', Lang.bind(this, function() {
+        this._showingId = Main.overview.connect('showing', () => {
             this.actor.add_accessible_state (Atk.StateType.CHECKED);
-        }));
-        this._hidingId = Main.overview.connect('hiding', Lang.bind(this, function() {
+        });
+        this._hidingId = Main.overview.connect('hiding', () => {
             this.actor.remove_accessible_state (Atk.StateType.CHECKED);
-        }));
+        });
         Main.layoutManager.connect('startup-complete',
                                    Lang.bind(this, this._setKeybinding));
         this._setKeybinding();
@@ -470,14 +469,14 @@ const ApplicationsButton = new Lang.Class({
         this.reloadFlag = false;
         this._createLayout();
         this._display();
-        this._installedChangedId = appSys.connect('installed-changed', Lang.bind(this, function() {
+        this._installedChangedId = appSys.connect('installed-changed', () => {
             if (this.menu.isOpen) {
                 this._redisplay();
                 this.mainBox.show();
             } else {
                 this.reloadFlag = true;
             }
-        }));
+        });
     },
 
     get hotCorner() {
@@ -555,9 +554,7 @@ const ApplicationsButton = new Lang.Class({
         Main.wm.setCustomKeybindingHandler('panel-main-menu',
                                            Shell.ActionMode.NORMAL |
                                            Shell.ActionMode.OVERVIEW,
-                                           Lang.bind(this, function() {
-                                               this.menu.toggle();
-                                           }));
+                                           () => { this.menu.toggle(); });
     },
 
     _redisplay: function() {
@@ -631,23 +628,19 @@ const ApplicationsButton = new Lang.Class({
                                                          style_class: 'apps-menu vfade' });
         this.applicationsScrollBox.set_policy(Gtk.PolicyType.NEVER, Gtk.PolicyType.AUTOMATIC);
         let vscroll = this.applicationsScrollBox.get_vscroll_bar();
-        vscroll.connect('scroll-start', Lang.bind(this, function() {
+        vscroll.connect('scroll-start', () => {
             this.menu.passEvents = true;
-        }));
-        vscroll.connect('scroll-stop', Lang.bind(this, function() {
+        });
+        vscroll.connect('scroll-stop', () => {
             this.menu.passEvents = false;
-        }));
+        });
         this.categoriesScrollBox = new St.ScrollView({ x_fill: true, y_fill: false,
                                                        y_align: St.Align.START,
                                                        style_class: 'vfade' });
         this.categoriesScrollBox.set_policy(Gtk.PolicyType.NEVER, Gtk.PolicyType.AUTOMATIC);
         vscroll = this.categoriesScrollBox.get_vscroll_bar();
-        vscroll.connect('scroll-start', Lang.bind(this, function() {
-                              this.menu.passEvents = true;
-                          }));
-        vscroll.connect('scroll-stop', Lang.bind(this, function() {
-            this.menu.passEvents = false;
-        }));
+        vscroll.connect('scroll-start', () => { this.menu.passEvents = true; });
+        vscroll.connect('scroll-stop', () => { this.menu.passEvents = false; });
         this.leftBox.add(this.categoriesScrollBox, { expand: true,
                                                      x_fill: true, y_fill: true,
                                                      y_align: St.Align.START });
@@ -745,7 +738,7 @@ const ApplicationsButton = new Lang.Class({
 
         if (category_menu_id) {
             applist = this.applicationsByCategory[category_menu_id];
-            applist.sort(function(a,b) {
+            applist.sort((a, b) => {
                 return a.get_name().toLowerCase() > b.get_name().toLowerCase();
             });
         } else {
@@ -762,7 +755,7 @@ const ApplicationsButton = new Lang.Class({
     },
 
     destroy: function() {
-        this.menu.actor.get_children().forEach(function(c) { c.destroy() });
+        this.menu.actor.get_children().forEach(c => { c.destroy() });
         this.parent();
     }
 });
diff --git a/extensions/auto-move-windows/extension.js b/extensions/auto-move-windows/extension.js
index 05e6321..4d367d7 100644
--- a/extensions/auto-move-windows/extension.js
+++ b/extensions/auto-move-windows/extension.js
@@ -55,10 +55,10 @@ const WindowMover = new Lang.Class({
         if (!app) {
             if (!noRecurse) {
                 // window is not tracked yet
-                Mainloop.idle_add(Lang.bind(this, function() {
+                Mainloop.idle_add(() => {
                     this._findAndMove(display, window, true);
                     return false;
-                }));
+                });
             } else
                 log ('Cannot find application for window');
             return;
diff --git a/extensions/auto-move-windows/prefs.js b/extensions/auto-move-windows/prefs.js
index ebed660..e562a9d 100644
--- a/extensions/auto-move-windows/prefs.js
+++ b/extensions/auto-move-windows/prefs.js
@@ -8,7 +8,7 @@ const Lang = imports.lang;
 
 const Gettext = imports.gettext.domain('gnome-shell-extensions');
 const _ = Gettext.gettext;
-const N_ = function(e) { return e };
+const N_ = e => e;
 
 const ExtensionUtils = imports.misc.extensionUtils;
 const Me = ExtensionUtils.getCurrentExtension();
@@ -88,10 +88,9 @@ const Widget = new GObject.Class({
         toolbar.add(delButton);
 
         let selection = this._treeView.get_selection();
-        selection.connect('changed',
-            function() {
-                delButton.sensitive = selection.count_selected_rows() > 0;
-            });
+        selection.connect('changed', () => {
+            delButton.sensitive = selection.count_selected_rows() > 0;
+        });
         delButton.sensitive = selection.count_selected_rows() > 0;
 
         this._changedPermitted = true;
@@ -111,11 +110,9 @@ const Widget = new GObject.Class({
                                   row_spacing: 15,
                                   margin: 10 });
         dialog._appChooser = new Gtk.AppChooserWidget({ show_all: true });
-        dialog._appChooser.connect('application-selected', Lang.bind(this,
-            function(w, appInfo) {
-                addButton.sensitive = appInfo &&
-                                      this._checkId(appInfo.get_id());
-            }));
+        dialog._appChooser.connect('application-selected', (w, appInfo) => {
+            addButton.sensitive = appInfo && this._checkId(appInfo.get_id());
+        });
         let appInfo = dialog._appChooser.get_app_info();
         addButton.sensitive = appInfo && this._checkId(appInfo.get_id());
 
@@ -132,7 +129,7 @@ const Widget = new GObject.Class({
         grid.attach(dialog._spin, 1, 1, 1, 1);
         dialog.get_content_area().add(grid);
 
-        dialog.connect('response', Lang.bind(this, function(dialog, id) {
+        dialog.connect('response', (dialog, id) => {
             if (id != Gtk.ResponseType.OK) {
                 dialog.destroy();
                 return;
@@ -159,7 +156,7 @@ const Widget = new GObject.Class({
                             [appInfo, appInfo.get_icon(), appInfo.get_display_name(), index, adj]);
 
             dialog.destroy();
-        }));
+        });
         dialog.show_all();
     },
 
@@ -222,7 +219,7 @@ const Widget = new GObject.Class({
 
     _checkId: function(id) {
         let items = this._settings.get_strv(SETTINGS_KEY);
-        return !items.some(function(i) { return i.startsWith(id + ':'); });
+        return !items.some(i => i.startsWith(id + ':'));
     },
 
     _appendItem: function(id, workspace) {
@@ -233,9 +230,7 @@ const Widget = new GObject.Class({
 
     _removeItem: function(id) {
         let currentItems = this._settings.get_strv(SETTINGS_KEY);
-        let index = currentItems.map(function(el) {
-            return el.split(':')[0];
-        }).indexOf(id);
+        let index = currentItems.map(el => el.split(':')[0]).indexOf(id);
 
         if (index < 0)
             return;
@@ -245,9 +240,7 @@ const Widget = new GObject.Class({
 
     _changeItem: function(id, workspace) {
         let currentItems = this._settings.get_strv(SETTINGS_KEY);
-        let index = currentItems.map(function(el) {
-            return el.split(':')[0];
-        }).indexOf(id);
+        let index = currentItems.map(el => el.split(':')[0]).indexOf(id);
 
         if (index < 0)
             currentItems.push(id + ':' + workspace);
diff --git a/extensions/drive-menu/extension.js b/extensions/drive-menu/extension.js
index f63868c..249600c 100644
--- a/extensions/drive-menu/extension.js
+++ b/extensions/drive-menu/extension.js
@@ -133,21 +133,21 @@ const DriveMenu = new Lang.Class({
         this.actor.add_child(hbox);
 
         this._monitor = Gio.VolumeMonitor.get();
-        this._addedId = this._monitor.connect('mount-added', Lang.bind(this, function(monitor, mount) {
+        this._addedId = this._monitor.connect('mount-added', (monitor, mount) => {
             this._addMount(mount);
             this._updateMenuVisibility();
-        }));
-        this._removedId = this._monitor.connect('mount-removed', Lang.bind(this, function(monitor, mount) {
+        });
+        this._removedId = this._monitor.connect('mount-removed', (monitor, mount) => {
             this._removeMount(mount);
             this._updateMenuVisibility();
-        }));
+        });
 
         this._mounts = [ ];
 
         this._monitor.get_mounts().forEach(Lang.bind(this, this._addMount));
 
         this.menu.addMenuItem(new PopupMenu.PopupSeparatorMenuItem());
-        this.menu.addAction(_("Open Files"), function(event) {
+        this.menu.addAction(_("Open Files"), event => {
             let appSystem = Shell.AppSystem.get_default();
             let app = appSystem.lookup_app('org.gnome.Nautilus.desktop');
             app.activate_full(-1, event.get_time());
@@ -157,7 +157,7 @@ const DriveMenu = new Lang.Class({
     },
 
     _updateMenuVisibility: function() {
-        if (this._mounts.filter(function(i) i.actor.visible).length > 0)
+        if (this._mounts.filter(i => i.actor.visible).length > 0)
             this.actor.show();
         else
             this.actor.hide();
diff --git a/extensions/example/extension.js b/extensions/example/extension.js
index 96a6f78..b55a9b8 100644
--- a/extensions/example/extension.js
+++ b/extensions/example/extension.js
@@ -20,7 +20,7 @@ function _showHello() {
     let monitor = Main.layoutManager.primaryMonitor;
     global.stage.add_actor(label);
     label.set_position(Math.floor (monitor.width / 2 - label.width / 2), Math.floor(monitor.height / 2 - 
label.height / 2));
-    Mainloop.timeout_add(3000, function() { label.destroy(); });
+    Mainloop.timeout_add(3000, () => { label.destroy(); });
 }
 
 // Put your extension initialization code here
diff --git a/extensions/places-menu/extension.js b/extensions/places-menu/extension.js
index 70db0e6..3543f4c 100644
--- a/extensions/places-menu/extension.js
+++ b/extensions/places-menu/extension.js
@@ -14,7 +14,7 @@ const Panel = imports.ui.panel;
 
 const Gettext = imports.gettext.domain('gnome-shell-extensions');
 const _ = Gettext.gettext;
-const N_ = function(x) { return x; }
+const N_ = x => x;
 
 const ExtensionUtils = imports.misc.extensionUtils;
 const Me = ExtensionUtils.getCurrentExtension();
@@ -92,9 +92,9 @@ const PlacesMenu = new Lang.Class({
         for (let i=0; i < SECTIONS.length; i++) {
             let id = SECTIONS[i];
             this._sections[id] = new PopupMenu.PopupMenuSection();
-            this.placesManager.connect(id + '-updated', Lang.bind(this, function() {
+            this.placesManager.connect(id + '-updated', () => {
                 this._redisplay(id);
-            }));
+            });
 
             this._create(id);
             this.menu.addMenuItem(this._sections[id]);
diff --git a/extensions/places-menu/placeDisplay.js b/extensions/places-menu/placeDisplay.js
index 7a0b22a..8dd6214 100644
--- a/extensions/places-menu/placeDisplay.js
+++ b/extensions/places-menu/placeDisplay.js
@@ -17,7 +17,7 @@ const Util = imports.misc.util;
 
 const Gettext = imports.gettext.domain('gnome-shell-extensions');
 const _ = Gettext.gettext;
-const N_ = function(x) { return x; }
+const N_ = x => x;
 
 const BACKGROUND_SCHEMA = 'org.gnome.desktop.background';
 
@@ -91,7 +91,7 @@ const PlaceInfo = new Lang.Class({
 
     getIcon: function() {
         this.file.query_info_async('standard::symbolic-icon', 0, 0, null,
-                                   Lang.bind(this, function(file, result) {
+                                   (file, result) => {
                                        try {
                                            let info = file.query_info_finish(result);
                                            this.icon = info.get_symbolic_icon();
@@ -99,7 +99,7 @@ const PlaceInfo = new Lang.Class({
                                        } catch(e if e instanceof Gio.IOErrorEnum) {
                                            return;
                                        }
-                                   }));
+                                   });
 
         // return a generic icon for this kind for now, until we have the
         // icon from the query info above
@@ -139,14 +139,14 @@ const RootInfo = new Lang.Class({
         this._proxy = new Hostname1(Gio.DBus.system,
                                     'org.freedesktop.hostname1',
                                     '/org/freedesktop/hostname1',
-                                    Lang.bind(this, function(obj, error) {
+                                    (obj, error) => {
                                         if (error)
                                             return;
 
                                         this._proxy.connect('g-properties-changed',
                                                             Lang.bind(this, this._propertiesChanged));
                                         this._propertiesChanged(obj);
-                                    }));
+                                    });
     },
 
     getIcon: function() {
@@ -198,13 +198,13 @@ const PlaceVolumeInfo = new Lang.Class({
             return;
         }
 
-        this._volume.mount(0, null, null, Lang.bind(this, function(volume, result) {
+        this._volume.mount(0, null, null, (volume, result) => {
             volume.mount_finish(result);
 
             let mount = volume.get_mount();
             this.file = mount.get_root();
             this.parent(timestamp);
-        }));
+        });
     },
 
     getIcon: function() {
@@ -250,16 +250,16 @@ var PlacesManager = new Lang.Class({
 
         if (this._bookmarksFile) {
             this._monitor = this._bookmarksFile.monitor_file(Gio.FileMonitorFlags.NONE, null);
-            this._monitor.connect('changed', Lang.bind(this, function() {
+            this._monitor.connect('changed', () => {
                 if (this._bookmarkTimeoutId > 0)
                     return;
                 /* Defensive event compression */
-                this._bookmarkTimeoutId = Mainloop.timeout_add(100, Lang.bind(this, function() {
+                this._bookmarkTimeoutId = Mainloop.timeout_add(100, () => {
                     this._bookmarkTimeoutId = 0;
                     this._reloadBookmarks();
                     return false;
-                }));
-            }));
+                });
+            });
 
             this._reloadBookmarks();
         }
@@ -293,7 +293,7 @@ var PlacesManager = new Lang.Class({
     },
 
     _updateSpecials: function() {
-        this._places.special.forEach(function(p) { p.destroy(); });
+        this._places.special.forEach(p => { p.destroy(); });
         this._places.special = [];
 
         let homePath = GLib.get_home_dir();
@@ -323,9 +323,7 @@ var PlacesManager = new Lang.Class({
             specials.push(info);
         }
 
-        specials.sort(function(a, b) {
-            return GLib.utf8_collate(a.name, b.name);
-        });
+        specials.sort((a, b) => GLib.utf8_collate(a.name, b.name));
         this._places.special = this._places.special.concat(specials);
 
         this.emit('special-updated');
@@ -335,9 +333,9 @@ var PlacesManager = new Lang.Class({
         let networkMounts = [];
         let networkVolumes = [];
 
-        this._places.devices.forEach(function(p) { p.destroy(); });
+        this._places.devices.forEach(p => { p.destroy(); });
         this._places.devices = [];
-        this._places.network.forEach(function(p) { p.destroy(); });
+        this._places.network.forEach(p => { p.destroy(); });
         this._places.network = [];
 
         /* Add standard places */
diff --git a/extensions/screenshot-window-sizer/extension.js b/extensions/screenshot-window-sizer/extension.js
index e9f19da..681c30f 100644
--- a/extensions/screenshot-window-sizer/extension.js
+++ b/extensions/screenshot-window-sizer/extension.js
@@ -84,11 +84,7 @@ function cycleScreenshotSizes(display, screen, window, binding) {
 
     // Double both axes if on a hidpi display
     let scaleFactor = St.ThemeContext.get_for_stage(global.stage).scale_factor;
-    let scaledSizes = SIZES.map(function(size) {
-        return size.map(function(wh) {
-            return wh * scaleFactor;
-        });
-    });
+    let scaledSizes = SIZES.map(size => size.map(wh => wh * scaleFactor));
 
     // Find the nearest 16:9 size for the current window size
     let nearestIndex;
diff --git a/extensions/window-list/extension.js b/extensions/window-list/extension.js
index b005155..9f34b31 100644
--- a/extensions/window-list/extension.js
+++ b/extensions/window-list/extension.js
@@ -57,8 +57,8 @@ function _onMenuStateChanged(menu, isOpen) {
 }
 
 function _getAppStableSequence(app) {
-    let windows = app.get_windows().filter(function(w) { return !w.skip_taskbar; });
-    return windows.reduce(function(prev, cur) {
+    let windows = app.get_windows().filter(w => !w.skip_taskbar);
+    return windows.reduce((prev, cur) => {
         return Math.min(prev, cur.get_stable_sequence());
     }, Infinity);
 }
@@ -74,12 +74,12 @@ const WindowContextMenu = new Lang.Class({
         this._metaWindow = metaWindow;
 
         this._minimizeItem = new PopupMenu.PopupMenuItem('');
-        this._minimizeItem.connect('activate', Lang.bind(this, function() {
+        this._minimizeItem.connect('activate', () => {
             if (this._metaWindow.minimized)
                 this._metaWindow.unminimize();
             else
                 this._metaWindow.minimize();
-        }));
+        });
         this.addMenuItem(this._minimizeItem);
 
         this._notifyMinimizedId =
@@ -88,7 +88,7 @@ const WindowContextMenu = new Lang.Class({
         this._updateMinimizeItem();
 
         this._maximizeItem = new PopupMenu.PopupMenuItem('');
-        this._maximizeItem.connect('activate', Lang.bind(this, function() {
+        this._maximizeItem.connect('activate', () => {
             if (this._metaWindow.maximized_vertically &&
                 this._metaWindow.maximized_horizontally)
                 this._metaWindow.unmaximize(Meta.MaximizeFlags.HORIZONTAL |
@@ -96,7 +96,7 @@ const WindowContextMenu = new Lang.Class({
             else
                 this._metaWindow.maximize(Meta.MaximizeFlags.HORIZONTAL |
                                           Meta.MaximizeFlags.VERTICAL);
-        }));
+        });
         this.addMenuItem(this._maximizeItem);
 
         this._notifyMaximizedHId =
@@ -108,9 +108,9 @@ const WindowContextMenu = new Lang.Class({
         this._updateMaximizeItem();
 
         this._closeItem = new PopupMenu.PopupMenuItem(_("Close"));
-        this._closeItem.connect('activate', Lang.bind(this, function() {
+        this._closeItem.connect('activate', () => {
             this._metaWindow.delete(global.get_current_time());
-        }));
+        });
         this.addMenuItem(this._closeItem);
 
         this.actor.connect('destroy', Lang.bind(this, this._onDestroy));
@@ -418,60 +418,52 @@ const AppContextMenu = new Lang.Class({
         this._appButton = appButton;
 
         this._minimizeItem = new PopupMenu.PopupMenuItem(_("Minimize all"));
-        this._minimizeItem.connect('activate', Lang.bind(this, function() {
-            this._appButton.getWindowList().forEach(function(w) {
-                w.minimize();
-            });
-        }));
+        this._minimizeItem.connect('activate', () => {
+            this._appButton.getWindowList().forEach(w => { w.minimize(); });
+        });
         this.addMenuItem(this._minimizeItem);
 
         this._unminimizeItem = new PopupMenu.PopupMenuItem(_("Unminimize all"));
-        this._unminimizeItem.connect('activate', Lang.bind(this, function() {
-            this._appButton.getWindowList().forEach(function(w) {
-                w.unminimize();
-            });
-        }));
+        this._unminimizeItem.connect('activate', () => {
+            this._appButton.getWindowList().forEach(w => { w.unminimize(); });
+        });
         this.addMenuItem(this._unminimizeItem);
 
         this._maximizeItem = new PopupMenu.PopupMenuItem(_("Maximize all"));
-        this._maximizeItem.connect('activate', Lang.bind(this, function() {
-            this._appButton.getWindowList().forEach(function(w) {
+        this._maximizeItem.connect('activate', () => {
+            this._appButton.getWindowList().forEach(w => {
                 w.maximize(Meta.MaximizeFlags.HORIZONTAL |
                            Meta.MaximizeFlags.VERTICAL);
             });
-        }));
+        });
         this.addMenuItem(this._maximizeItem);
 
         this._unmaximizeItem = new PopupMenu.PopupMenuItem(_("Unmaximize all"));
-        this._unmaximizeItem.connect('activate', Lang.bind(this, function() {
-            this._appButton.getWindowList().forEach(function(w) {
+        this._unmaximizeItem.connect('activate', () => {
+            this._appButton.getWindowList().forEach(w => {
                 w.unmaximize(Meta.MaximizeFlags.HORIZONTAL |
                              Meta.MaximizeFlags.VERTICAL);
             });
-        }));
+        });
         this.addMenuItem(this._unmaximizeItem);
 
         let item = new PopupMenu.PopupMenuItem(_("Close all"));
-        item.connect('activate', Lang.bind(this, function() {
-            this._appButton.getWindowList().forEach(function(w) {
+        item.connect('activate', () => {
+            this._appButton.getWindowList().forEach(w => {
                 w.delete(global.get_current_time());
             });
-        }));
+        });
         this.addMenuItem(item);
     },
 
     open: function(animate) {
         let windows = this._appButton.getWindowList();
-        this._minimizeItem.actor.visible = windows.some(function(w) {
-            return !w.minimized;
-        });
-        this._unminimizeItem.actor.visible = windows.some(function(w) {
-            return w.minimized;
-        });
-        this._maximizeItem.actor.visible = windows.some(function(w) {
+        this._minimizeItem.actor.visible = windows.some(w => !w.minimized);
+        this._unminimizeItem.actor.visible = windows.some(w => w.minimized);
+        this._maximizeItem.actor.visible = windows.some(w => {
             return !(w.maximized_horizontally && w.maximized_vertically);
         });
-        this._unmaximizeItem.actor.visible = windows.some(function(w) {
+        this._unmaximizeItem.actor.visible = windows.some(w => {
             return w.maximized_horizontally && w.maximized_vertically;
         });
 
@@ -525,10 +517,9 @@ const AppButton = new Lang.Class({
 
         this._textureCache = St.TextureCache.get_default();
         this._iconThemeChangedId =
-            this._textureCache.connect('icon-theme-changed', Lang.bind(this,
-                function() {
-                    this._icon.child = app.create_icon_texture(ICON_TEXTURE_SIZE);
-                }));
+            this._textureCache.connect('icon-theme-changed', () => {
+                this._icon.child = app.create_icon_texture(ICON_TEXTURE_SIZE);
+            });
 
         this._windowsChangedId =
             this.app.connect('windows-changed',
@@ -568,15 +559,11 @@ const AppButton = new Lang.Class({
         let rect = this._getIconGeometry();
 
         let windows = this.app.get_windows();
-        windows.forEach(function(w) {
-            w.set_icon_geometry(rect);
-        });
+        windows.forEach(w => { w.set_icon_geometry(rect); });
     },
 
     getWindowList: function() {
-        return this.app.get_windows().filter(Lang.bind(this, function(win) {
-            return this._isWindowVisible(win);
-        }));
+        return this.app.get_windows().filter(win => this._isWindowVisible(win));
     },
 
     _windowsChanged: function() {
@@ -739,9 +726,9 @@ const WorkspaceIndicator = new Lang.Class({
             let item = new PopupMenu.PopupMenuItem(name);
             item.workspaceId = i;
 
-            item.connect('activate', Lang.bind(this, function(item, event) {
+            item.connect('activate', (item, event) => {
                 this._activate(item.workspaceId);
-            }));
+            });
 
             if (i == this._currentWorkspace)
                 item.setOrnament(PopupMenu.Ornament.DOT);
@@ -807,12 +794,11 @@ const WindowList = new Lang.Class({
                                            y_expand: true });
         box.add(this._windowList, { expand: true });
 
-        this._windowList.connect('style-changed', Lang.bind(this,
-            function() {
-                let node = this._windowList.get_theme_node();
-                let spacing = node.get_length('spacing');
-                this._windowList.layout_manager.spacing = spacing;
-            }));
+        this._windowList.connect('style-changed', () => {
+            let node = this._windowList.get_theme_node();
+            let spacing = node.get_length('spacing');
+            this._windowList.layout_manager.spacing = spacing;
+        });
         this._windowList.connect('scroll-event', Lang.bind(this, this._onScrollEvent));
 
         let indicatorsBox = new St.BoxLayout({ x_align: Clutter.ActorAlign.END });
@@ -851,7 +837,7 @@ const WindowList = new Lang.Class({
 
         this._keyboardVisiblechangedId =
             Main.layoutManager.connect('keyboard-visible-changed',
-                Lang.bind(this, function(o, state) {
+                (o, state) => {
                     Main.layoutManager.keyboardBox.visible = state;
                     let keyboardBox = Main.layoutManager.keyboardBox;
                     keyboardBox.visible = state;
@@ -861,7 +847,7 @@ const WindowList = new Lang.Class({
                         Main.uiGroup.set_child_above_sibling(this.actor,
                                                              Main.layoutManager.panelBox);
                     this._updateKeyboardAnchor();
-                }));
+                });
 
         this._workspaceSignals = new Map();
         this._nWorkspacesChangedId =
@@ -874,21 +860,21 @@ const WindowList = new Lang.Class({
                                           Lang.bind(this, this._checkGrouping));
 
         this._overviewShowingId =
-            Main.overview.connect('showing', Lang.bind(this, function() {
+            Main.overview.connect('showing', () => {
                 this.actor.hide();
                 this._updateKeyboardAnchor();
-            }));
+            });
 
         this._overviewHidingId =
-            Main.overview.connect('hiding', Lang.bind(this, function() {
+            Main.overview.connect('hiding', () => {
                 this.actor.visible = !Main.layoutManager.primaryMonitor.inFullscreen;
                 this._updateKeyboardAnchor();
-            }));
+            });
 
         this._fullscreenChangedId =
-            global.screen.connect('in-fullscreen-changed', Lang.bind(this, function() {
+            global.screen.connect('in-fullscreen-changed', () => {
                 this._updateKeyboardAnchor();
-            }));
+            });
 
         this._dragBeginId =
             Main.xdndHandler.connect('drag-begin',
@@ -934,9 +920,7 @@ const WindowList = new Lang.Class({
         else
             return;
 
-        let children = this._windowList.get_children().map(function(actor) {
-            return actor._delegate;
-        });
+        let children = this._windowList.get_children().map(a => a._delegate);
         let active = 0;
         for (let i = 0; i < children.length; i++) {
             if (children[i].active) {
@@ -973,11 +957,8 @@ const WindowList = new Lang.Class({
 
         let workspace = global.screen.get_active_workspace();
         let windows = global.display.get_tab_list(Meta.TabList.NORMAL, workspace);
-        if (this._perMonitor) {
-            windows = windows.filter(Lang.bind(this, function(window) {
-                return window.get_monitor() == this._monitor.index;
-            }));
-        }
+        if (this._perMonitor)
+            windows = windows.filter(w => w.get_monitor() == this._monitor.index);
         let nWindows = windows.length;
         if (nWindows == 0)
             return this._windowList.get_preferred_width(-1)[1];
@@ -1019,19 +1000,17 @@ const WindowList = new Lang.Class({
         this._windowList.destroy_all_children();
 
         if (!this._grouped) {
-            let windows = global.get_window_actors().sort(
-                function(w1, w2) {
-                    return w1.metaWindow.get_stable_sequence() -
-                           w2.metaWindow.get_stable_sequence();
-                });
+            let windows = global.get_window_actors().sort((w1, w2) => {
+                return w1.metaWindow.get_stable_sequence() -
+                       w2.metaWindow.get_stable_sequence();
+            });
             for (let i = 0; i < windows.length; i++)
                 this._onWindowAdded(null, windows[i].metaWindow);
         } else {
-            let apps = this._appSystem.get_running().sort(
-                function(a1, a2) {
-                    return _getAppStableSequence(a1) -
-                           _getAppStableSequence(a2);
-                });
+            let apps = this._appSystem.get_running().sort((a1, a2) => {
+                return _getAppStableSequence(a1) -
+                       _getAppStableSequence(a2);
+            });
             for (let i = 0; i < apps.length; i++)
                 this._addApp(apps[i]);
         }
@@ -1263,17 +1242,15 @@ const Extension = new Lang.Class({
     },
 
     _buildWindowLists: function() {
-        this._windowLists.forEach(function(windowList) {
-            windowList.actor.destroy();
-        });
+        this._windowLists.forEach(list => { list.actor.destroy(); });
         this._windowLists = [];
 
         let showOnAllMonitors = this._settings.get_boolean('show-on-all-monitors');
 
-        Main.layoutManager.monitors.forEach(Lang.bind(this, function(monitor) {
+        Main.layoutManager.monitors.forEach(monitor => {
             if (showOnAllMonitors || monitor == Main.layoutManager.primaryMonitor)
                 this._windowLists.push(new WindowList(showOnAllMonitors, monitor));
-        }));
+        });
     },
 
     disable: function() {
@@ -1286,7 +1263,7 @@ const Extension = new Lang.Class({
         Main.layoutManager.disconnect(this._monitorsChangedId);
         this._monitorsChangedId = 0;
 
-        this._windowLists.forEach(function(windowList) {
+        this._windowLists.forEach(windowList => {
             windowList.actor.hide();
             windowList.actor.destroy();
         });
@@ -1294,9 +1271,7 @@ const Extension = new Lang.Class({
     },
 
     someWindowListContains: function(actor) {
-        return this._windowLists.some(function(windowList) {
-            return windowList.actor.contains(actor);
-        });
+        return this._windowLists.some(list => list.actor.contains(actor));
     }
 });
 
diff --git a/extensions/window-list/prefs.js b/extensions/window-list/prefs.js
index dc20065..e7026ad 100644
--- a/extensions/window-list/prefs.js
+++ b/extensions/window-list/prefs.js
@@ -3,7 +3,6 @@
 const Gio = imports.gi.Gio;
 const GObject = imports.gi.GObject;
 const Gtk = imports.gi.Gtk;
-const Lang = imports.lang;
 
 const Gettext = imports.gettext.domain('gnome-shell-extensions');
 const _ = Gettext.gettext;
@@ -66,10 +65,10 @@ const WindowListPrefsWidget = new GObject.Class({
                                           group: radio });
             grid.add(radio);
 
-            radio.connect('toggled', Lang.bind(this, function(button) {
+            radio.connect('toggled', button => {
                 if (button.active)
                     this._settings.set_string('grouping-mode', mode);
-            }));
+            });
         }
 
         let check = new Gtk.CheckButton({ label: _("Show on all monitors"),
diff --git a/extensions/windowsNavigator/extension.js b/extensions/windowsNavigator/extension.js
index f674eff..a2a0257 100644
--- a/extensions/windowsNavigator/extension.js
+++ b/extensions/windowsNavigator/extension.js
@@ -233,9 +233,9 @@ function enable() {
                                                           visible: false }));
 
             this.actor.add_actor(this._tip);
-            let signalId = this.actor.connect('notify::scale-x', Lang.bind(this, function() {
+            let signalId = this.actor.connect('notify::scale-x', () => {
                 this._tip.set_scale(1 / this.actor.scale_x, 1 / this.actor.scale_x);
-            }));
+            });
             connectedSignals.push({ obj: this.actor, id: signalId });
         } else
             this._tip = null;
diff --git a/extensions/workspace-indicator/extension.js b/extensions/workspace-indicator/extension.js
index 628c5a2..810ffb6 100644
--- a/extensions/workspace-indicator/extension.js
+++ b/extensions/workspace-indicator/extension.js
@@ -94,9 +94,9 @@ const WorkspaceIndicator = new Lang.Class({
             this.workspacesItems[i].workspaceId = i;
             this.workspacesItems[i].label_actor = this.statusLabel;
             let self = this;
-            this.workspacesItems[i].connect('activate', Lang.bind(this, function(actor, event) {
+            this.workspacesItems[i].connect('activate', (actor, event) => {
                 this._activate(actor.workspaceId);
-            }));
+            });
 
             if (i == this._currentWorkspace)
                 this.workspacesItems[i].setOrnament(PopupMenu.Ornament.DOT);
diff --git a/extensions/workspace-indicator/prefs.js b/extensions/workspace-indicator/prefs.js
index e5dbebe..5913ab3 100644
--- a/extensions/workspace-indicator/prefs.js
+++ b/extensions/workspace-indicator/prefs.js
@@ -8,7 +8,7 @@ const Lang = imports.lang;
 
 const Gettext = imports.gettext.domain('gnome-shell-extensions');
 const _ = Gettext.gettext;
-const N_ = function(e) { return e };
+const N_ = e => e;
 
 const ExtensionUtils = imports.misc.extensionUtils;
 const Me = ExtensionUtils.getCurrentExtension();
@@ -175,10 +175,9 @@ const WorkspaceSettingsWidget = new GObject.Class({
         toolbar.add(delButton);
 
         let selection = this._treeView.get_selection();
-        selection.connect('changed',
-            function() {
-                delButton.sensitive = selection.count_selected_rows() > 0;
-            });
+        selection.connect('changed', () => {
+            delButton.sensitive = selection.count_selected_rows() > 0;
+        });
         delButton.sensitive = selection.count_selected_rows() > 0;
 
         this.add(toolbar);



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