cleanup: Use arrow notation for anonymous functions

Arrow notation is great, use it consistently through-out the code base
to bind `this` to anonymous functions, replacing the more overbose
Lang.bind(this, function() {}).

https://gitlab.gnome.org/GNOME/gnome-shell/merge_requests/23
This commit is contained in:
Florian Müllner
2017-10-31 01:38:18 +01:00
committed by Florian Müllner
parent 76f09b1e49
commit 213e38c2ef
105 changed files with 2165 additions and 2408 deletions

View File

@ -114,9 +114,9 @@ var ScreenshotService = new Lang.Class({
if (result) {
if (flash) {
let flashspot = new Flashspot(area);
flashspot.fire(Lang.bind(this, function() {
flashspot.fire(() => {
this._removeShooterForSender(invocation.get_sender());
}));
});
}
else
this._removeShooterForSender(invocation.get_sender());
@ -184,18 +184,17 @@ var ScreenshotService = new Lang.Class({
SelectAreaAsync(params, invocation) {
let selectArea = new SelectArea();
selectArea.show();
selectArea.connect('finished', Lang.bind(this,
function(selectArea, areaRectangle) {
if (areaRectangle) {
let retRectangle = this._unscaleArea(areaRectangle.x, areaRectangle.y,
areaRectangle.width, areaRectangle.height);
let retval = GLib.Variant.new('(iiii)', retRectangle);
invocation.return_value(retval);
} else {
invocation.return_error_literal(Gio.IOErrorEnum, Gio.IOErrorEnum.CANCELLED,
"Operation was cancelled");
}
}));
selectArea.connect('finished', (selectArea, areaRectangle) => {
if (areaRectangle) {
let retRectangle = this._unscaleArea(areaRectangle.x, areaRectangle.y,
areaRectangle.width, areaRectangle.height);
let retval = GLib.Variant.new('(iiii)', retRectangle);
invocation.return_value(retval);
} else {
invocation.return_error_literal(Gio.IOErrorEnum, Gio.IOErrorEnum.CANCELLED,
"Operation was cancelled");
}
});
},
FlashAreaAsync(params, invocation) {
@ -317,10 +316,9 @@ var SelectArea = new Lang.Class({
{ opacity: 0,
time: 0.2,
transition: 'easeOutQuad',
onComplete: Lang.bind(this,
function() {
this._grabHelper.ungrab();
})
onComplete: () => {
this._grabHelper.ungrab();
}
});
return Clutter.EVENT_PROPAGATE;
},
@ -329,11 +327,10 @@ var SelectArea = new Lang.Class({
global.screen.set_cursor(Meta.Cursor.DEFAULT);
this.emit('finished', this._result);
GLib.idle_add(GLib.PRIORITY_DEFAULT, Lang.bind(this,
function() {
this._group.destroy();
return GLib.SOURCE_REMOVE;
}));
GLib.idle_add(GLib.PRIORITY_DEFAULT, () => {
this._group.destroy();
return GLib.SOURCE_REMOVE;
});
}
});
Signals.addSignalMethods(SelectArea.prototype);
@ -360,11 +357,11 @@ var Flashspot = new Lang.Class({
{ opacity: 0,
time: FLASHSPOT_ANIMATION_OUT_TIME,
transition: 'easeOutQuad',
onComplete: Lang.bind(this, function() {
onComplete: () => {
if (doneCallback)
doneCallback();
this.destroy();
})
}
});
}
});