Convert remaining uses of "let me = this;" to Lang.bind

https://bugzilla.gnome.org/show_bug.cgi?id=595293
This commit is contained in:
Dan Winship 2009-09-15 13:09:51 -04:00
parent 9feda69888
commit ceefc5eea4
6 changed files with 59 additions and 105 deletions

View File

@ -358,7 +358,6 @@ AppDisplay.prototype = {
// Gets information about all applications by calling Gio.app_info_get_all(). // Gets information about all applications by calling Gio.app_info_get_all().
_refreshCache : function() { _refreshCache : function() {
let me = this;
if (!this._appsStale) if (!this._appsStale)
return; return;
this._allItems = {}; this._allItems = {};

View File

@ -28,8 +28,6 @@ function Button(widget, buttonColor, pressedButtonColor, textColor, font) {
Button.prototype = { Button.prototype = {
_init : function(widgetOrText, buttonColor, pressedButtonColor, textColor, font) { _init : function(widgetOrText, buttonColor, pressedButtonColor, textColor, font) {
let me = this;
this._buttonColor = buttonColor this._buttonColor = buttonColor
if (buttonColor == null) if (buttonColor == null)
this._buttonColor = DEFAULT_BUTTON_COLOR; this._buttonColor = DEFAULT_BUTTON_COLOR;

View File

@ -120,8 +120,6 @@ DocDisplay.prototype = {
_init : function() { _init : function() {
GenericDisplay.GenericDisplay.prototype._init.call(this); GenericDisplay.GenericDisplay.prototype._init.call(this);
let me = this;
// We keep a single timeout callback for updating last visited times // We keep a single timeout callback for updating last visited times
// for all the items in the display. This avoids creating individual // for all the items in the display. This avoids creating individual
// callbacks for each item in the display. So proper time updates // callbacks for each item in the display. So proper time updates
@ -132,14 +130,14 @@ DocDisplay.prototype = {
this._docManager = DocInfo.getDocManager(); this._docManager = DocInfo.getDocManager();
this._docsStale = true; this._docsStale = true;
this._docManager.connect('changed', function(mgr, userData) { this._docManager.connect('changed', Lang.bind(this, function(mgr, userData) {
me._docsStale = true; this._docsStale = true;
// Changes in local recent files should not happen when we are in the Overview mode, // Changes in local recent files should not happen when we are in the Overview mode,
// but redisplaying right away is cool when we use Zephyr. // but redisplaying right away is cool when we use Zephyr.
// Also, we might be displaying remote documents, like Google Docs, in the future // Also, we might be displaying remote documents, like Google Docs, in the future
// which might be edited by someone else. // which might be edited by someone else.
me._redisplay(false); this._redisplay(false);
}); }));
this.connect('destroy', Lang.bind(this, function (o) { this.connect('destroy', Lang.bind(this, function (o) {
if (this._updateTimeoutId > 0) if (this._updateTimeoutId > 0)

View File

@ -81,8 +81,6 @@ function Overview() {
Overview.prototype = { Overview.prototype = {
_init : function() { _init : function() {
let me = this;
this._group = new Clutter.Group(); this._group = new Clutter.Group();
this._group._delegate = this; this._group._delegate = this;

View File

@ -1,6 +1,7 @@
/* -*- mode: js2; js2-basic-offset: 4; indent-tabs-mode: nil -*- */ /* -*- mode: js2; js2-basic-offset: 4; indent-tabs-mode: nil -*- */
const Clutter = imports.gi.Clutter; const Clutter = imports.gi.Clutter;
const Lang = imports.lang;
const Mainloop = imports.mainloop; const Mainloop = imports.mainloop;
const Meta = imports.gi.Meta; const Meta = imports.gi.Meta;
@ -16,9 +17,8 @@ function WindowManager() {
WindowManager.prototype = { WindowManager.prototype = {
_init : function() { _init : function() {
let me = this; let shellwm = global.window_manager;
this._shellwm = global.window_manager;
this._minimizing = []; this._minimizing = [];
this._maximizing = []; this._maximizing = [];
this._unmaximizing = []; this._unmaximizing = [];
@ -26,60 +26,20 @@ WindowManager.prototype = {
this._destroying = []; this._destroying = [];
this._switchData = null; this._switchData = null;
this._shellwm.connect('switch-workspace', shellwm.connect('switch-workspace', Lang.bind(this, this._switchWorkspace));
function(o, from, to, direction) { shellwm.connect('kill-switch-workspace', Lang.bind(this, this._switchWorkspaceDone));
let actors = me._shellwm.get_switch_workspace_actors(); shellwm.connect('minimize', Lang.bind(this, this._minimizeWindow));
me._switchWorkspace(actors, from, to, direction); shellwm.connect('kill-minimize', Lang.bind(this, this._minimizeWindowDone));
}); shellwm.connect('maximize', Lang.bind(this, this._maximizeWindow));
this._shellwm.connect('kill-switch-workspace', shellwm.connect('kill-maximize', Lang.bind(this, this._maximizeWindowDone));
function(o) { shellwm.connect('unmaximize', Lang.bind(this, this._unmaximizeWindow));
me._switchWorkspaceDone(); shellwm.connect('kill-unmaximize', Lang.bind(this, this._unmaximizeWindowDone));
}); shellwm.connect('map', Lang.bind(this, this._mapWindow));
this._shellwm.connect('minimize', shellwm.connect('kill-map', Lang.bind(this, this._mapWindowDone));
function(o, actor) { shellwm.connect('destroy', Lang.bind(this, this._destroyWindow));
me._minimizeWindow(actor); shellwm.connect('kill-destroy', Lang.bind(this, this._destroyWindowDone));
});
this._shellwm.connect('kill-minimize',
function(o, actor) {
me._minimizeWindowDone(actor);
});
this._shellwm.connect('maximize',
function(o, actor, tx, ty, tw, th) {
me._maximizeWindow(actor, tx, ty, tw, th);
});
this._shellwm.connect('kill-maximize',
function(o, actor) {
me._maximizeWindowDone(actor);
});
this._shellwm.connect('unmaximize',
function(o, actor, tx, ty, tw, th) {
me._unmaximizeWindow(actor, tx, ty, tw, th);
});
this._shellwm.connect('kill-unmaximize',
function(o, actor) {
me._unmaximizeWindowDone(actor);
});
this._shellwm.connect('map',
function(o, actor) {
me._mapWindow(actor);
});
this._shellwm.connect('kill-map',
function(o, actor) {
me._mapWindowDone(actor);
});
this._shellwm.connect('destroy',
function(o, actor) {
me._destroyWindow(actor);
});
this._shellwm.connect('kill-destroy',
function(o, actor) {
me._destroyWindowDone(actor);
});
this._shellwm.connect('begin-alt-tab', shellwm.connect('begin-alt-tab', Lang.bind(this, this._beginAltTab));
function(o, handler) {
me._beginAltTab(handler);
});
}, },
_shouldAnimate : function(actor) { _shouldAnimate : function(actor) {
@ -99,9 +59,9 @@ WindowManager.prototype = {
return false; return false;
}, },
_minimizeWindow : function(actor) { _minimizeWindow : function(shellwm, actor) {
if (!this._shouldAnimate(actor)) { if (!this._shouldAnimate(actor)) {
this._shellwm.completed_minimize(actor); shellwm.completed_minimize(actor);
return; return;
} }
@ -119,49 +79,49 @@ WindowManager.prototype = {
transition: "easeOutQuad", transition: "easeOutQuad",
onComplete: this._minimizeWindowDone, onComplete: this._minimizeWindowDone,
onCompleteScope: this, onCompleteScope: this,
onCompleteParams: [actor], onCompleteParams: [shellwm, actor],
onOverwrite: this._minimizeWindowOverwritten, onOverwrite: this._minimizeWindowOverwritten,
onOverwriteScope: this, onOverwriteScope: this,
onOverwriteParams: [actor] onOverwriteParams: [shellwm, actor]
}); });
}, },
_minimizeWindowDone : function(actor) { _minimizeWindowDone : function(shellwm, actor) {
if (this._removeEffect(this._minimizing, actor)) { if (this._removeEffect(this._minimizing, actor)) {
Tweener.removeTweens(actor); Tweener.removeTweens(actor);
actor.set_scale(1.0, 1.0); actor.set_scale(1.0, 1.0);
actor.move_anchor_point_from_gravity(Clutter.Gravity.NORTH_WEST); actor.move_anchor_point_from_gravity(Clutter.Gravity.NORTH_WEST);
this._shellwm.completed_minimize(actor); shellwm.completed_minimize(actor);
} }
}, },
_minimizeWindowOverwritten : function(actor) { _minimizeWindowOverwritten : function(shellwm, actor) {
if (this._removeEffect(this._minimizing, actor)) { if (this._removeEffect(this._minimizing, actor)) {
this._shellwm.completed_minimize(actor); shellwm.completed_minimize(actor);
} }
}, },
_maximizeWindow : function(actor, targetX, targetY, targetWidth, targetHeight) { _maximizeWindow : function(shellwm, actor, targetX, targetY, targetWidth, targetHeight) {
this._shellwm.completed_maximize(actor); shellwm.completed_maximize(actor);
}, },
_maximizeWindowDone : function(actor) { _maximizeWindowDone : function(shellwm, actor) {
}, },
_maximizeWindowOverwrite : function(actor) { _maximizeWindowOverwrite : function(shellwm, actor) {
}, },
_unmaximizeWindow : function(actor, targetX, targetY, targetWidth, targetHeight) { _unmaximizeWindow : function(shellwm, actor, targetX, targetY, targetWidth, targetHeight) {
this._shellwm.completed_unmaximize(actor); shellwm.completed_unmaximize(actor);
}, },
_unmaximizeWindowDone : function(actor) { _unmaximizeWindowDone : function(shellwm, actor) {
}, },
_mapWindow : function(actor) { _mapWindow : function(shellwm, actor) {
if (!this._shouldAnimate(actor)) { if (!this._shouldAnimate(actor)) {
this._shellwm.completed_map(actor); shellwm.completed_map(actor);
return; return;
} }
@ -178,31 +138,31 @@ WindowManager.prototype = {
transition: "easeOutQuad", transition: "easeOutQuad",
onComplete: this._mapWindowDone, onComplete: this._mapWindowDone,
onCompleteScope: this, onCompleteScope: this,
onCompleteParams: [actor], onCompleteParams: [shellwm, actor],
onOverwrite: this._mapWindowOverwrite, onOverwrite: this._mapWindowOverwrite,
onOverwriteScope: this, onOverwriteScope: this,
onOverwriteParams: [actor] onOverwriteParams: [shellwm, actor]
}); });
}, },
_mapWindowDone : function(actor) { _mapWindowDone : function(shellwm, actor) {
if (this._removeEffect(this._mapping, actor)) { if (this._removeEffect(this._mapping, actor)) {
Tweener.removeTweens(actor); Tweener.removeTweens(actor);
actor.set_scale(1.0, 1.0); actor.set_scale(1.0, 1.0);
actor.move_anchor_point_from_gravity(Clutter.Gravity.NORTH_WEST); actor.move_anchor_point_from_gravity(Clutter.Gravity.NORTH_WEST);
this._shellwm.completed_map(actor); shellwm.completed_map(actor);
} }
}, },
_mapWindowOverwrite : function(actor) { _mapWindowOverwrite : function(shellwm, actor) {
if (this._removeEffect(this._mapping, actor)) { if (this._removeEffect(this._mapping, actor)) {
this._shellwm.completed_map(actor); shellwm.completed_map(actor);
} }
}, },
_destroyWindow : function(actor) { _destroyWindow : function(shellwm, actor) {
if (!this._shouldAnimate(actor)) { if (!this._shouldAnimate(actor)) {
this._shellwm.completed_destroy(actor); shellwm.completed_destroy(actor);
return; return;
} }
@ -217,33 +177,35 @@ WindowManager.prototype = {
transition: "easeOutQuad", transition: "easeOutQuad",
onComplete: this._destroyWindowDone, onComplete: this._destroyWindowDone,
onCompleteScope: this, onCompleteScope: this,
onCompleteParams: [actor], onCompleteParams: [shellwm, actor],
onOverwrite: this._destroyWindowOverwrite, onOverwrite: this._destroyWindowOverwrite,
onOverwriteScope: this, onOverwriteScope: this,
onOverwriteParams: [actor] onOverwriteParams: [shellwm, actor]
}); });
}, },
_destroyWindowDone : function(actor) { _destroyWindowDone : function(shellwm, actor) {
if (this._removeEffect(this._destroying, actor)) { if (this._removeEffect(this._destroying, actor)) {
this._shellwm.completed_destroy(actor); shellwm.completed_destroy(actor);
Tweener.removeTweens(actor); Tweener.removeTweens(actor);
actor.set_scale(1.0, 1.0); actor.set_scale(1.0, 1.0);
} }
}, },
_destroyWindowOverwrite : function(actor) { _destroyWindowOverwrite : function(shellwm, actor) {
if (this._removeEffect(this._destroying, actor)) { if (this._removeEffect(this._destroying, actor)) {
this._shellwm.completed_destroy(actor); shellwm.completed_destroy(actor);
} }
}, },
_switchWorkspace : function(windows, from, to, direction) { _switchWorkspace : function(shellwm, from, to, direction) {
if (!this._shouldAnimate()) { if (!this._shouldAnimate()) {
this._shellwm.completed_switch_workspace(); shellwm.completed_switch_workspace();
return; return;
} }
let windows = shellwm.get_switch_workspace_actors();
/* @direction is the direction that the "camera" moves, so the /* @direction is the direction that the "camera" moves, so the
* screen contents have to move one screen's worth in the * screen contents have to move one screen's worth in the
* opposite direction. * opposite direction.
@ -305,7 +267,8 @@ WindowManager.prototype = {
time: WINDOW_ANIMATION_TIME, time: WINDOW_ANIMATION_TIME,
transition: "easeOutQuad", transition: "easeOutQuad",
onComplete: this._switchWorkspaceDone, onComplete: this._switchWorkspaceDone,
onCompleteScope: this onCompleteScope: this,
onCompleteParams: [shellwm]
}); });
Tweener.addTween(switchData.inGroup, Tweener.addTween(switchData.inGroup,
{ x: 0, { x: 0,
@ -315,7 +278,7 @@ WindowManager.prototype = {
}); });
}, },
_switchWorkspaceDone : function() { _switchWorkspaceDone : function(shellwm) {
let switchData = this._switchData; let switchData = this._switchData;
if (!switchData) if (!switchData)
return; return;
@ -334,10 +297,10 @@ WindowManager.prototype = {
switchData.inGroup.destroy(); switchData.inGroup.destroy();
switchData.outGroup.destroy(); switchData.outGroup.destroy();
this._shellwm.completed_switch_workspace(); shellwm.completed_switch_workspace();
}, },
_beginAltTab : function(handler) { _beginAltTab : function(shellwm, handler) {
let popup = new AltTab.AltTabPopup(); let popup = new AltTab.AltTabPopup();
handler.connect('window-added', function(handler, window) { popup.addWindow(window); }); handler.connect('window-added', function(handler, window) { popup.addWindow(window); });

View File

@ -416,8 +416,6 @@ function Workspace(workspaceNum, parentActor) {
Workspace.prototype = { Workspace.prototype = {
_init : function(workspaceNum, parentActor) { _init : function(workspaceNum, parentActor) {
let me = this;
this.workspaceNum = workspaceNum; this.workspaceNum = workspaceNum;
this._metaWorkspace = global.screen.get_workspace_by_index(workspaceNum); this._metaWorkspace = global.screen.get_workspace_by_index(workspaceNum);