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
@ -29,7 +29,7 @@ const OVERRIDE_SCHEMA = 'org.gnome.shell.overrides';
|
||||
var WorkspacesViewBase = new Lang.Class({
|
||||
Name: 'WorkspacesViewBase',
|
||||
|
||||
_init: function(monitorIndex) {
|
||||
_init(monitorIndex) {
|
||||
this.actor = new St.Widget({ style_class: 'workspaces-view',
|
||||
reactive: true });
|
||||
this.actor.connect('destroy', Lang.bind(this, this._onDestroy));
|
||||
@ -48,7 +48,7 @@ var WorkspacesViewBase = new Lang.Class({
|
||||
this._windowDragEndId = Main.overview.connect('window-drag-end', Lang.bind(this, this._dragEnd));
|
||||
},
|
||||
|
||||
_onDestroy: function() {
|
||||
_onDestroy() {
|
||||
this._dragEnd();
|
||||
|
||||
if (this._windowDragBeginId > 0) {
|
||||
@ -61,26 +61,26 @@ var WorkspacesViewBase = new Lang.Class({
|
||||
}
|
||||
},
|
||||
|
||||
_dragBegin: function(overview, window) {
|
||||
_dragBegin(overview, window) {
|
||||
this._inDrag = true;
|
||||
this._setReservedSlot(window);
|
||||
},
|
||||
|
||||
_dragEnd: function() {
|
||||
_dragEnd() {
|
||||
this._inDrag = false;
|
||||
this._setReservedSlot(null);
|
||||
},
|
||||
|
||||
destroy: function() {
|
||||
destroy() {
|
||||
this.actor.destroy();
|
||||
},
|
||||
|
||||
setFullGeometry: function(geom) {
|
||||
setFullGeometry(geom) {
|
||||
this._fullGeometry = geom;
|
||||
this._syncFullGeometry();
|
||||
},
|
||||
|
||||
setActualGeometry: function(geom) {
|
||||
setActualGeometry(geom) {
|
||||
this._actualGeometry = geom;
|
||||
this._syncActualGeometry();
|
||||
},
|
||||
@ -90,7 +90,7 @@ var WorkspacesView = new Lang.Class({
|
||||
Name: 'WorkspacesView',
|
||||
Extends: WorkspacesViewBase,
|
||||
|
||||
_init: function(monitorIndex) {
|
||||
_init(monitorIndex) {
|
||||
this.parent(monitorIndex);
|
||||
|
||||
this._animating = false; // tweening
|
||||
@ -123,27 +123,27 @@ var WorkspacesView = new Lang.Class({
|
||||
Lang.bind(this, this._activeWorkspaceChanged));
|
||||
},
|
||||
|
||||
_setReservedSlot: function(window) {
|
||||
_setReservedSlot(window) {
|
||||
for (let i = 0; i < this._workspaces.length; i++)
|
||||
this._workspaces[i].setReservedSlot(window);
|
||||
},
|
||||
|
||||
_syncFullGeometry: function() {
|
||||
_syncFullGeometry() {
|
||||
for (let i = 0; i < this._workspaces.length; i++)
|
||||
this._workspaces[i].setFullGeometry(this._fullGeometry);
|
||||
},
|
||||
|
||||
_syncActualGeometry: function() {
|
||||
_syncActualGeometry() {
|
||||
for (let i = 0; i < this._workspaces.length; i++)
|
||||
this._workspaces[i].setActualGeometry(this._actualGeometry);
|
||||
},
|
||||
|
||||
getActiveWorkspace: function() {
|
||||
getActiveWorkspace() {
|
||||
let active = global.screen.get_active_workspace_index();
|
||||
return this._workspaces[active];
|
||||
},
|
||||
|
||||
animateToOverview: function(animationType) {
|
||||
animateToOverview(animationType) {
|
||||
for (let w = 0; w < this._workspaces.length; w++) {
|
||||
if (animationType == AnimationType.ZOOM)
|
||||
this._workspaces[w].zoomToOverview();
|
||||
@ -153,7 +153,7 @@ var WorkspacesView = new Lang.Class({
|
||||
this._updateWorkspaceActors(false);
|
||||
},
|
||||
|
||||
animateFromOverview: function(animationType) {
|
||||
animateFromOverview(animationType) {
|
||||
this.actor.remove_clip();
|
||||
|
||||
for (let w = 0; w < this._workspaces.length; w++) {
|
||||
@ -164,12 +164,12 @@ var WorkspacesView = new Lang.Class({
|
||||
}
|
||||
},
|
||||
|
||||
syncStacking: function(stackIndices) {
|
||||
syncStacking(stackIndices) {
|
||||
for (let i = 0; i < this._workspaces.length; i++)
|
||||
this._workspaces[i].syncStacking(stackIndices);
|
||||
},
|
||||
|
||||
_scrollToActive: function() {
|
||||
_scrollToActive() {
|
||||
let active = global.screen.get_active_workspace_index();
|
||||
|
||||
this._updateWorkspaceActors(true);
|
||||
@ -178,7 +178,7 @@ var WorkspacesView = new Lang.Class({
|
||||
|
||||
// Update workspace actors parameters
|
||||
// @showAnimation: iff %true, transition between states
|
||||
_updateWorkspaceActors: function(showAnimation) {
|
||||
_updateWorkspaceActors(showAnimation) {
|
||||
let active = global.screen.get_active_workspace_index();
|
||||
|
||||
this._animating = showAnimation;
|
||||
@ -215,7 +215,7 @@ var WorkspacesView = new Lang.Class({
|
||||
}
|
||||
},
|
||||
|
||||
_updateVisibility: function() {
|
||||
_updateVisibility() {
|
||||
let active = global.screen.get_active_workspace_index();
|
||||
|
||||
for (let w = 0; w < this._workspaces.length; w++) {
|
||||
@ -231,7 +231,7 @@ var WorkspacesView = new Lang.Class({
|
||||
}
|
||||
},
|
||||
|
||||
_updateScrollAdjustment: function(index) {
|
||||
_updateScrollAdjustment(index) {
|
||||
if (this._scrolling)
|
||||
return;
|
||||
|
||||
@ -248,7 +248,7 @@ var WorkspacesView = new Lang.Class({
|
||||
});
|
||||
},
|
||||
|
||||
_updateWorkspaces: function() {
|
||||
_updateWorkspaces() {
|
||||
let newNumWorkspaces = global.screen.n_workspaces;
|
||||
|
||||
this.scrollAdjustment.upper = newNumWorkspaces;
|
||||
@ -280,14 +280,14 @@ var WorkspacesView = new Lang.Class({
|
||||
this._syncActualGeometry();
|
||||
},
|
||||
|
||||
_activeWorkspaceChanged: function(wm, from, to, direction) {
|
||||
_activeWorkspaceChanged(wm, from, to, direction) {
|
||||
if (this._scrolling)
|
||||
return;
|
||||
|
||||
this._scrollToActive();
|
||||
},
|
||||
|
||||
_onDestroy: function() {
|
||||
_onDestroy() {
|
||||
this.parent();
|
||||
|
||||
this.scrollAdjustment.run_dispose();
|
||||
@ -296,11 +296,11 @@ var WorkspacesView = new Lang.Class({
|
||||
global.screen.disconnect(this._updateWorkspacesId);
|
||||
},
|
||||
|
||||
startSwipeScroll: function() {
|
||||
startSwipeScroll() {
|
||||
this._scrolling = true;
|
||||
},
|
||||
|
||||
endSwipeScroll: function() {
|
||||
endSwipeScroll() {
|
||||
this._scrolling = false;
|
||||
|
||||
// Make sure title captions etc are shown as necessary
|
||||
@ -310,7 +310,7 @@ var WorkspacesView = new Lang.Class({
|
||||
|
||||
// sync the workspaces' positions to the value of the scroll adjustment
|
||||
// and change the active workspace if appropriate
|
||||
_onScroll: function(adj) {
|
||||
_onScroll(adj) {
|
||||
if (this._animatingScroll)
|
||||
return;
|
||||
|
||||
@ -356,49 +356,49 @@ var ExtraWorkspaceView = new Lang.Class({
|
||||
Name: 'ExtraWorkspaceView',
|
||||
Extends: WorkspacesViewBase,
|
||||
|
||||
_init: function(monitorIndex) {
|
||||
_init(monitorIndex) {
|
||||
this.parent(monitorIndex);
|
||||
this._workspace = new Workspace.Workspace(null, monitorIndex);
|
||||
this.actor.add_actor(this._workspace.actor);
|
||||
},
|
||||
|
||||
_setReservedSlot: function(window) {
|
||||
_setReservedSlot(window) {
|
||||
this._workspace.setReservedSlot(window);
|
||||
},
|
||||
|
||||
_syncFullGeometry: function() {
|
||||
_syncFullGeometry() {
|
||||
this._workspace.setFullGeometry(this._fullGeometry);
|
||||
},
|
||||
|
||||
_syncActualGeometry: function() {
|
||||
_syncActualGeometry() {
|
||||
this._workspace.setActualGeometry(this._actualGeometry);
|
||||
},
|
||||
|
||||
getActiveWorkspace: function() {
|
||||
getActiveWorkspace() {
|
||||
return this._workspace;
|
||||
},
|
||||
|
||||
animateToOverview: function(animationType) {
|
||||
animateToOverview(animationType) {
|
||||
if (animationType == AnimationType.ZOOM)
|
||||
this._workspace.zoomToOverview();
|
||||
else
|
||||
this._workspace.fadeToOverview();
|
||||
},
|
||||
|
||||
animateFromOverview: function(animationType) {
|
||||
animateFromOverview(animationType) {
|
||||
if (animationType == AnimationType.ZOOM)
|
||||
this._workspace.zoomFromOverview();
|
||||
else
|
||||
this._workspace.fadeFromOverview();
|
||||
},
|
||||
|
||||
syncStacking: function(stackIndices) {
|
||||
syncStacking(stackIndices) {
|
||||
this._workspace.syncStacking(stackIndices);
|
||||
},
|
||||
|
||||
startSwipeScroll: function() {
|
||||
startSwipeScroll() {
|
||||
},
|
||||
endSwipeScroll: function() {
|
||||
endSwipeScroll() {
|
||||
},
|
||||
});
|
||||
|
||||
@ -406,7 +406,7 @@ var DelegateFocusNavigator = new Lang.Class({
|
||||
Name: 'DelegateFocusNavigator',
|
||||
Extends: St.Widget,
|
||||
|
||||
vfunc_navigate_focus: function(from, direction) {
|
||||
vfunc_navigate_focus(from, direction) {
|
||||
return this._delegate.navigateFocus(from, direction);
|
||||
},
|
||||
});
|
||||
@ -414,7 +414,7 @@ var DelegateFocusNavigator = new Lang.Class({
|
||||
var WorkspacesDisplay = new Lang.Class({
|
||||
Name: 'WorkspacesDisplay',
|
||||
|
||||
_init: function() {
|
||||
_init() {
|
||||
this.actor = new DelegateFocusNavigator({ clip_to_allocation: true });
|
||||
this.actor._delegate = this;
|
||||
this.actor.connect('notify::allocation', Lang.bind(this, this._updateWorkspacesActualGeometry));
|
||||
@ -480,18 +480,18 @@ var WorkspacesDisplay = new Lang.Class({
|
||||
this._fullGeometry = null;
|
||||
},
|
||||
|
||||
_onPan: function(action) {
|
||||
_onPan(action) {
|
||||
let [dist, dx, dy] = action.get_motion_delta(0);
|
||||
let adjustment = this._scrollAdjustment;
|
||||
adjustment.value -= (dy / this.actor.height) * adjustment.page_size;
|
||||
return false;
|
||||
},
|
||||
|
||||
navigateFocus: function(from, direction) {
|
||||
navigateFocus(from, direction) {
|
||||
return this._getPrimaryView().actor.navigate_focus(from, direction, false);
|
||||
},
|
||||
|
||||
show: function(fadeOnPrimary) {
|
||||
show(fadeOnPrimary) {
|
||||
this._updateWorkspacesViews();
|
||||
for (let i = 0; i < this._workspacesViews.length; i++) {
|
||||
let animationType;
|
||||
@ -512,7 +512,7 @@ var WorkspacesDisplay = new Lang.Class({
|
||||
this._keyPressEventId = global.stage.connect('key-press-event', Lang.bind(this, this._onKeyPressEvent));
|
||||
},
|
||||
|
||||
animateFromOverview: function(fadeOnPrimary) {
|
||||
animateFromOverview(fadeOnPrimary) {
|
||||
for (let i = 0; i < this._workspacesViews.length; i++) {
|
||||
let animationType;
|
||||
if (fadeOnPrimary && i == this._primaryIndex)
|
||||
@ -523,7 +523,7 @@ var WorkspacesDisplay = new Lang.Class({
|
||||
}
|
||||
},
|
||||
|
||||
hide: function() {
|
||||
hide() {
|
||||
if (this._restackedNotifyId > 0){
|
||||
Main.overview.disconnect(this._restackedNotifyId);
|
||||
this._restackedNotifyId = 0;
|
||||
@ -541,7 +541,7 @@ var WorkspacesDisplay = new Lang.Class({
|
||||
this._workspacesViews = [];
|
||||
},
|
||||
|
||||
_workspacesOnlyOnPrimaryChanged: function() {
|
||||
_workspacesOnlyOnPrimaryChanged() {
|
||||
this._workspacesOnlyOnPrimary = this._settings.get_boolean('workspaces-only-on-primary');
|
||||
|
||||
if (!Main.overview.visible)
|
||||
@ -550,7 +550,7 @@ var WorkspacesDisplay = new Lang.Class({
|
||||
this._updateWorkspacesViews();
|
||||
},
|
||||
|
||||
_updateWorkspacesViews: function() {
|
||||
_updateWorkspacesViews() {
|
||||
for (let i = 0; i < this._workspacesViews.length; i++)
|
||||
this._workspacesViews[i].destroy();
|
||||
|
||||
@ -579,7 +579,7 @@ var WorkspacesDisplay = new Lang.Class({
|
||||
this._updateWorkspacesActualGeometry();
|
||||
},
|
||||
|
||||
_scrollValueChanged: function() {
|
||||
_scrollValueChanged() {
|
||||
for (let i = 0; i < this._workspacesViews.length; i++) {
|
||||
if (i == this._primaryIndex)
|
||||
continue;
|
||||
@ -594,23 +594,23 @@ var WorkspacesDisplay = new Lang.Class({
|
||||
}
|
||||
},
|
||||
|
||||
_getMonitorIndexForEvent: function(event) {
|
||||
_getMonitorIndexForEvent(event) {
|
||||
let [x, y] = event.get_coords();
|
||||
let rect = new Meta.Rectangle({ x: x, y: y, width: 1, height: 1 });
|
||||
return global.screen.get_monitor_index_for_rect(rect);
|
||||
},
|
||||
|
||||
_getPrimaryView: function() {
|
||||
_getPrimaryView() {
|
||||
if (!this._workspacesViews.length)
|
||||
return null;
|
||||
return this._workspacesViews[this._primaryIndex];
|
||||
},
|
||||
|
||||
activeWorkspaceHasMaximizedWindows: function() {
|
||||
activeWorkspaceHasMaximizedWindows() {
|
||||
return this._getPrimaryView().getActiveWorkspace().hasMaximizedWindows();
|
||||
},
|
||||
|
||||
_parentSet: function(actor, oldParent) {
|
||||
_parentSet(actor, oldParent) {
|
||||
if (oldParent && this._notifyOpacityId)
|
||||
oldParent.disconnect(this._notifyOpacityId);
|
||||
this._notifyOpacityId = 0;
|
||||
@ -639,12 +639,12 @@ var WorkspacesDisplay = new Lang.Class({
|
||||
// This geometry should always be the fullest geometry
|
||||
// the workspaces switcher can ever be allocated, as if
|
||||
// the sliding controls were never slid in at all.
|
||||
setWorkspacesFullGeometry: function(geom) {
|
||||
setWorkspacesFullGeometry(geom) {
|
||||
this._fullGeometry = geom;
|
||||
this._updateWorkspacesFullGeometry();
|
||||
},
|
||||
|
||||
_updateWorkspacesFullGeometry: function() {
|
||||
_updateWorkspacesFullGeometry() {
|
||||
if (!this._workspacesViews.length)
|
||||
return;
|
||||
|
||||
@ -655,7 +655,7 @@ var WorkspacesDisplay = new Lang.Class({
|
||||
}
|
||||
},
|
||||
|
||||
_updateWorkspacesActualGeometry: function() {
|
||||
_updateWorkspacesActualGeometry() {
|
||||
if (!this._workspacesViews.length)
|
||||
return;
|
||||
|
||||
@ -672,12 +672,12 @@ var WorkspacesDisplay = new Lang.Class({
|
||||
}
|
||||
},
|
||||
|
||||
_onRestacked: function(overview, stackIndices) {
|
||||
_onRestacked(overview, stackIndices) {
|
||||
for (let i = 0; i < this._workspacesViews.length; i++)
|
||||
this._workspacesViews[i].syncStacking(stackIndices);
|
||||
},
|
||||
|
||||
_onScrollEvent: function(actor, event) {
|
||||
_onScrollEvent(actor, event) {
|
||||
if (!this.actor.mapped)
|
||||
return Clutter.EVENT_PROPAGATE;
|
||||
|
||||
@ -701,7 +701,7 @@ var WorkspacesDisplay = new Lang.Class({
|
||||
return Clutter.EVENT_STOP;
|
||||
},
|
||||
|
||||
_onKeyPressEvent: function(actor, event) {
|
||||
_onKeyPressEvent(actor, event) {
|
||||
if (!this.actor.mapped)
|
||||
return Clutter.EVENT_PROPAGATE;
|
||||
let activeWs = global.screen.get_active_workspace();
|
||||
|
Reference in New Issue
Block a user