cleanup: Use method syntax
Modern javascript has a short-hand for function properties, embrace it for better readability and to prepare for an eventual port to ES6 classes. https://gitlab.gnome.org/GNOME/gnome-shell/merge_requests/23
This commit is contained in:

committed by
Florian Müllner

parent
cff0b81f32
commit
76f09b1e49
@ -38,12 +38,12 @@ var OVERVIEW_ACTIVATION_TIMEOUT = 0.5;
|
||||
var ShellInfo = new Lang.Class({
|
||||
Name: 'ShellInfo',
|
||||
|
||||
_init: function() {
|
||||
_init() {
|
||||
this._source = null;
|
||||
this._undoCallback = null;
|
||||
},
|
||||
|
||||
_onUndoClicked: function() {
|
||||
_onUndoClicked() {
|
||||
if (this._undoCallback)
|
||||
this._undoCallback();
|
||||
this._undoCallback = null;
|
||||
@ -52,7 +52,7 @@ var ShellInfo = new Lang.Class({
|
||||
this._source.destroy();
|
||||
},
|
||||
|
||||
setMessage: function(text, options) {
|
||||
setMessage(text, options) {
|
||||
options = Params.parse(options, { undoCallback: null,
|
||||
forFeedback: false
|
||||
});
|
||||
@ -90,7 +90,7 @@ var ShellInfo = new Lang.Class({
|
||||
var Overview = new Lang.Class({
|
||||
Name: 'Overview',
|
||||
|
||||
_init: function() {
|
||||
_init() {
|
||||
this._overviewCreated = false;
|
||||
this._initCalled = false;
|
||||
|
||||
@ -98,7 +98,7 @@ var Overview = new Lang.Class({
|
||||
this._sessionUpdated();
|
||||
},
|
||||
|
||||
_createOverview: function() {
|
||||
_createOverview() {
|
||||
if (this._overviewCreated)
|
||||
return;
|
||||
|
||||
@ -170,7 +170,7 @@ var Overview = new Lang.Class({
|
||||
this.init();
|
||||
},
|
||||
|
||||
_updateBackgrounds: function() {
|
||||
_updateBackgrounds() {
|
||||
for (let i = 0; i < this._bgManagers.length; i++)
|
||||
this._bgManagers[i].destroy();
|
||||
|
||||
@ -184,7 +184,7 @@ var Overview = new Lang.Class({
|
||||
}
|
||||
},
|
||||
|
||||
_unshadeBackgrounds: function() {
|
||||
_unshadeBackgrounds() {
|
||||
let backgrounds = this._backgroundGroup.get_children();
|
||||
for (let i = 0; i < backgrounds.length; i++) {
|
||||
Tweener.addTween(backgrounds[i],
|
||||
@ -196,7 +196,7 @@ var Overview = new Lang.Class({
|
||||
}
|
||||
},
|
||||
|
||||
_shadeBackgrounds: function() {
|
||||
_shadeBackgrounds() {
|
||||
let backgrounds = this._backgroundGroup.get_children();
|
||||
for (let i = 0; i < backgrounds.length; i++) {
|
||||
Tweener.addTween(backgrounds[i],
|
||||
@ -208,7 +208,7 @@ var Overview = new Lang.Class({
|
||||
}
|
||||
},
|
||||
|
||||
_sessionUpdated: function() {
|
||||
_sessionUpdated() {
|
||||
this.isDummy = !Main.sessionMode.hasOverview;
|
||||
this._createOverview();
|
||||
},
|
||||
@ -217,7 +217,7 @@ var Overview = new Lang.Class({
|
||||
// want to access the overview as Main.overview to connect
|
||||
// signal handlers and so forth. So we create them after
|
||||
// construction in this init() method.
|
||||
init: function() {
|
||||
init() {
|
||||
this._initCalled = true;
|
||||
|
||||
if (this.isDummy)
|
||||
@ -263,11 +263,11 @@ var Overview = new Lang.Class({
|
||||
this._relayout();
|
||||
},
|
||||
|
||||
addSearchProvider: function(provider) {
|
||||
addSearchProvider(provider) {
|
||||
this.viewSelector.addSearchProvider(provider);
|
||||
},
|
||||
|
||||
removeSearchProvider: function(provider) {
|
||||
removeSearchProvider(provider) {
|
||||
this.viewSelector.removeSearchProvider(provider);
|
||||
},
|
||||
|
||||
@ -276,14 +276,14 @@ var Overview = new Lang.Class({
|
||||
// - undoCallback (function): the callback to be called if undo support is needed
|
||||
// - forFeedback (boolean): whether the message is for direct feedback of a user action
|
||||
//
|
||||
setMessage: function(text, options) {
|
||||
setMessage(text, options) {
|
||||
if (this.isDummy)
|
||||
return;
|
||||
|
||||
this._shellInfo.setMessage(text, options);
|
||||
},
|
||||
|
||||
_onDragBegin: function() {
|
||||
_onDragBegin() {
|
||||
this._inXdndDrag = true;
|
||||
|
||||
DND.addDragMonitor(this._dragMonitor);
|
||||
@ -291,7 +291,7 @@ var Overview = new Lang.Class({
|
||||
this._lastActiveWorkspaceIndex = global.screen.get_active_workspace_index();
|
||||
},
|
||||
|
||||
_onDragEnd: function(time) {
|
||||
_onDragEnd(time) {
|
||||
this._inXdndDrag = false;
|
||||
|
||||
// In case the drag was canceled while in the overview
|
||||
@ -307,7 +307,7 @@ var Overview = new Lang.Class({
|
||||
this.endItemDrag();
|
||||
},
|
||||
|
||||
_resetWindowSwitchTimeout: function() {
|
||||
_resetWindowSwitchTimeout() {
|
||||
if (this._windowSwitchTimeoutId != 0) {
|
||||
Mainloop.source_remove(this._windowSwitchTimeoutId);
|
||||
this._windowSwitchTimeoutId = 0;
|
||||
@ -315,7 +315,7 @@ var Overview = new Lang.Class({
|
||||
}
|
||||
},
|
||||
|
||||
_fakePointerEvent: function() {
|
||||
_fakePointerEvent() {
|
||||
let display = Gdk.Display.get_default();
|
||||
let deviceManager = display.get_device_manager();
|
||||
let pointer = deviceManager.get_client_pointer();
|
||||
@ -324,7 +324,7 @@ var Overview = new Lang.Class({
|
||||
pointer.warp(screen, pointerX, pointerY);
|
||||
},
|
||||
|
||||
_onDragMotion: function(dragEvent) {
|
||||
_onDragMotion(dragEvent) {
|
||||
let targetIsWindow = dragEvent.targetActor &&
|
||||
dragEvent.targetActor._delegate &&
|
||||
dragEvent.targetActor._delegate.metaWindow &&
|
||||
@ -358,19 +358,19 @@ var Overview = new Lang.Class({
|
||||
return DND.DragMotionResult.CONTINUE;
|
||||
},
|
||||
|
||||
_onScrollEvent: function(actor, event) {
|
||||
_onScrollEvent(actor, event) {
|
||||
this.emit('scroll-event', event);
|
||||
return Clutter.EVENT_PROPAGATE;
|
||||
},
|
||||
|
||||
addAction: function(action) {
|
||||
addAction(action) {
|
||||
if (this.isDummy)
|
||||
return;
|
||||
|
||||
this._backgroundGroup.add_action(action);
|
||||
},
|
||||
|
||||
_getDesktopClone: function() {
|
||||
_getDesktopClone() {
|
||||
let windows = global.get_window_actors().filter(function(w) {
|
||||
return w.meta_window.get_window_type() == Meta.WindowType.DESKTOP;
|
||||
});
|
||||
@ -386,7 +386,7 @@ var Overview = new Lang.Class({
|
||||
return clone;
|
||||
},
|
||||
|
||||
_relayout: function () {
|
||||
_relayout() {
|
||||
// To avoid updating the position and size of the workspaces
|
||||
// we just hide the overview. The positions will be updated
|
||||
// when it is next shown.
|
||||
@ -403,7 +403,7 @@ var Overview = new Lang.Class({
|
||||
this._updateBackgrounds();
|
||||
},
|
||||
|
||||
_onRestacked: function() {
|
||||
_onRestacked() {
|
||||
let stack = global.get_window_actors();
|
||||
let stackIndices = {};
|
||||
|
||||
@ -415,44 +415,44 @@ var Overview = new Lang.Class({
|
||||
this.emit('windows-restacked', stackIndices);
|
||||
},
|
||||
|
||||
beginItemDrag: function(source) {
|
||||
beginItemDrag(source) {
|
||||
this.emit('item-drag-begin');
|
||||
this._inItemDrag = true;
|
||||
},
|
||||
|
||||
cancelledItemDrag: function(source) {
|
||||
cancelledItemDrag(source) {
|
||||
this.emit('item-drag-cancelled');
|
||||
},
|
||||
|
||||
endItemDrag: function(source) {
|
||||
endItemDrag(source) {
|
||||
if (!this._inItemDrag)
|
||||
return;
|
||||
this.emit('item-drag-end');
|
||||
this._inItemDrag = false;
|
||||
},
|
||||
|
||||
beginWindowDrag: function(window) {
|
||||
beginWindowDrag(window) {
|
||||
this.emit('window-drag-begin', window);
|
||||
this._inWindowDrag = true;
|
||||
},
|
||||
|
||||
cancelledWindowDrag: function(window) {
|
||||
cancelledWindowDrag(window) {
|
||||
this.emit('window-drag-cancelled', window);
|
||||
},
|
||||
|
||||
endWindowDrag: function(window) {
|
||||
endWindowDrag(window) {
|
||||
if (!this._inWindowDrag)
|
||||
return;
|
||||
this.emit('window-drag-end', window);
|
||||
this._inWindowDrag = false;
|
||||
},
|
||||
|
||||
focusSearch: function() {
|
||||
focusSearch() {
|
||||
this.show();
|
||||
this._searchEntry.grab_key_focus();
|
||||
},
|
||||
|
||||
fadeInDesktop: function() {
|
||||
fadeInDesktop() {
|
||||
this._desktopFade.opacity = 0;
|
||||
this._desktopFade.show();
|
||||
Tweener.addTween(this._desktopFade,
|
||||
@ -461,7 +461,7 @@ var Overview = new Lang.Class({
|
||||
transition: 'easeOutQuad' });
|
||||
},
|
||||
|
||||
fadeOutDesktop: function() {
|
||||
fadeOutDesktop() {
|
||||
if (!this._desktopFade.get_n_children()) {
|
||||
let clone = this._getDesktopClone();
|
||||
if (!clone)
|
||||
@ -485,7 +485,7 @@ var Overview = new Lang.Class({
|
||||
// triggered will return false. This avoids opening and closing
|
||||
// the overview if the user both triggered the hot corner and
|
||||
// clicked the Activities button.
|
||||
shouldToggleByCornerOrButton: function() {
|
||||
shouldToggleByCornerOrButton() {
|
||||
if (this.animationInProgress)
|
||||
return false;
|
||||
if (this._inItemDrag || this._inWindowDrag)
|
||||
@ -495,7 +495,7 @@ var Overview = new Lang.Class({
|
||||
return false;
|
||||
},
|
||||
|
||||
_syncGrab: function() {
|
||||
_syncGrab() {
|
||||
// We delay grab changes during animation so that when removing the
|
||||
// overview we don't have a problem with the release of a press/release
|
||||
// going to an application.
|
||||
@ -527,7 +527,7 @@ var Overview = new Lang.Class({
|
||||
// show:
|
||||
//
|
||||
// Animates the overview visible and grabs mouse and keyboard input
|
||||
show: function() {
|
||||
show() {
|
||||
if (this.isDummy)
|
||||
return;
|
||||
if (this._shown)
|
||||
@ -542,7 +542,7 @@ var Overview = new Lang.Class({
|
||||
},
|
||||
|
||||
|
||||
_animateVisible: function() {
|
||||
_animateVisible() {
|
||||
if (this.visible || this.animationInProgress)
|
||||
return;
|
||||
|
||||
@ -569,7 +569,7 @@ var Overview = new Lang.Class({
|
||||
this.emit('showing');
|
||||
},
|
||||
|
||||
_showDone: function() {
|
||||
_showDone() {
|
||||
this.animationInProgress = false;
|
||||
this._desktopFade.hide();
|
||||
this._coverPane.hide();
|
||||
@ -586,7 +586,7 @@ var Overview = new Lang.Class({
|
||||
// hide:
|
||||
//
|
||||
// Reverses the effect of show()
|
||||
hide: function() {
|
||||
hide() {
|
||||
if (this.isDummy)
|
||||
return;
|
||||
|
||||
@ -610,7 +610,7 @@ var Overview = new Lang.Class({
|
||||
},
|
||||
|
||||
|
||||
_animateNotVisible: function() {
|
||||
_animateNotVisible() {
|
||||
if (!this.visible || this.animationInProgress)
|
||||
return;
|
||||
|
||||
@ -634,7 +634,7 @@ var Overview = new Lang.Class({
|
||||
this.emit('hiding');
|
||||
},
|
||||
|
||||
_hideDone: function() {
|
||||
_hideDone() {
|
||||
// Re-enable unredirection
|
||||
Meta.enable_unredirect_for_screen(global.screen);
|
||||
|
||||
@ -661,7 +661,7 @@ var Overview = new Lang.Class({
|
||||
}
|
||||
},
|
||||
|
||||
toggle: function() {
|
||||
toggle() {
|
||||
if (this.isDummy)
|
||||
return;
|
||||
|
||||
@ -671,7 +671,7 @@ var Overview = new Lang.Class({
|
||||
this.show();
|
||||
},
|
||||
|
||||
getShowAppsButton: function() {
|
||||
getShowAppsButton() {
|
||||
return this._dash.showAppsButton;
|
||||
}
|
||||
});
|
||||
|
Reference in New Issue
Block a user