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:
Florian Müllner
2017-10-31 01:03:21 +01:00
committed by Florian Müllner
parent cff0b81f32
commit 76f09b1e49
116 changed files with 3140 additions and 3140 deletions

View File

@ -63,7 +63,7 @@ var CURTAIN_SLIDE_TIME = 0.3;
var Clock = new Lang.Class({
Name: 'ScreenShieldClock',
_init: function() {
_init() {
this.actor = new St.BoxLayout({ style_class: 'screen-shield-clock',
vertical: true });
@ -79,7 +79,7 @@ var Clock = new Lang.Class({
this._updateClock();
},
_updateClock: function() {
_updateClock() {
this._time.text = this._wallClock.clock;
let date = new Date();
@ -89,7 +89,7 @@ var Clock = new Lang.Class({
this._date.text = date.toLocaleFormat(dateFormat);
},
destroy: function() {
destroy() {
this.actor.destroy();
this._wallClock.run_dispose();
}
@ -98,7 +98,7 @@ var Clock = new Lang.Class({
var NotificationsBox = new Lang.Class({
Name: 'NotificationsBox',
_init: function() {
_init() {
this.actor = new St.BoxLayout({ vertical: true,
name: 'screenShieldNotifications',
style_class: 'screen-shield-notifications-container' });
@ -120,7 +120,7 @@ var NotificationsBox = new Lang.Class({
this._sourceAddedId = Main.messageTray.connect('source-added', Lang.bind(this, this._sourceAdded));
},
destroy: function() {
destroy() {
if (this._sourceAddedId) {
Main.messageTray.disconnect(this._sourceAddedId);
this._sourceAddedId = 0;
@ -134,7 +134,7 @@ var NotificationsBox = new Lang.Class({
this.actor.destroy();
},
_updateVisibility: function() {
_updateVisibility() {
this._notificationBox.visible = this._notificationBox.get_children().some(function(a) {
return a.visible;
});
@ -142,14 +142,14 @@ var NotificationsBox = new Lang.Class({
this.actor.visible = this._notificationBox.visible;
},
_makeNotificationCountText: function(count, isChat) {
_makeNotificationCountText(count, isChat) {
if (isChat)
return ngettext("%d new message", "%d new messages", count).format(count);
else
return ngettext("%d new notification", "%d new notifications", count).format(count);
},
_makeNotificationSource: function(source, box) {
_makeNotificationSource(source, box) {
let sourceActor = new MessageTray.SourceActor(source, SUMMARY_ICON_SIZE);
box.add(sourceActor.actor, { y_fill: true });
@ -169,7 +169,7 @@ var NotificationsBox = new Lang.Class({
return [title, countLabel];
},
_makeNotificationDetailedSource: function(source, box) {
_makeNotificationDetailedSource(source, box) {
let sourceActor = new MessageTray.SourceActor(source, SUMMARY_ICON_SIZE);
let sourceBin = new St.Bin({ y_align: St.Align.START,
x_align: St.Align.START,
@ -207,7 +207,7 @@ var NotificationsBox = new Lang.Class({
return [title, null];
},
_showSource: function(source, obj, box) {
_showSource(source, obj, box) {
if (obj.detailed) {
[obj.titleLabel, obj.countLabel] = this._makeNotificationDetailedSource(source, box);
} else {
@ -217,7 +217,7 @@ var NotificationsBox = new Lang.Class({
box.visible = obj.visible && (source.unseenCount > 0);
},
_sourceAdded: function(tray, source, initial) {
_sourceAdded(tray, source, initial) {
let obj = {
visible: source.policy.showInLockScreen,
detailed: source.policy.detailsInLockScreen,
@ -266,7 +266,7 @@ var NotificationsBox = new Lang.Class({
{ height: natHeight,
transition: 'easeOutQuad',
time: 0.25,
onComplete: function() {
onComplete() {
this._scrollView.vscrollbar_policy = Gtk.PolicyType.AUTOMATIC;
widget.set_height(-1);
},
@ -279,11 +279,11 @@ var NotificationsBox = new Lang.Class({
}
},
_titleChanged: function(source, obj) {
_titleChanged(source, obj) {
obj.titleLabel.text = source.title;
},
_countChanged: function(source, obj) {
_countChanged(source, obj) {
if (obj.detailed) {
// A new notification was pushed, or a previous notification was destroyed.
// Give up, and build the list again.
@ -303,7 +303,7 @@ var NotificationsBox = new Lang.Class({
this.emit('wake-up-screen');
},
_visibleChanged: function(source, obj) {
_visibleChanged(source, obj) {
if (obj.visible == source.policy.showInLockScreen)
return;
@ -315,7 +315,7 @@ var NotificationsBox = new Lang.Class({
this.emit('wake-up-screen');
},
_detailedChanged: function(source, obj) {
_detailedChanged(source, obj) {
if (obj.detailed == source.policy.detailsInLockScreen)
return;
@ -326,12 +326,12 @@ var NotificationsBox = new Lang.Class({
this._showSource(source, obj, obj.sourceBox);
},
_onSourceDestroy: function(source, obj) {
_onSourceDestroy(source, obj) {
this._removeSource(source, obj);
this._updateVisibility();
},
_removeSource: function(source, obj) {
_removeSource(source, obj) {
obj.sourceBox.destroy();
obj.sourceBox = obj.titleLabel = obj.countLabel = null;
@ -349,7 +349,7 @@ var Arrow = new Lang.Class({
Name: 'Arrow',
Extends: St.Bin,
_init: function(params) {
_init(params) {
this.parent(params);
this.x_fill = this.y_fill = true;
@ -361,7 +361,7 @@ var Arrow = new Lang.Class({
this._shadowWidth = this._shadowHeight = 0;
},
_drawArrow: function(arrow) {
_drawArrow(arrow) {
let cr = arrow.get_context();
let [w, h] = arrow.get_surface_size();
let node = this.get_theme_node();
@ -379,7 +379,7 @@ var Arrow = new Lang.Class({
cr.$dispose();
},
vfunc_get_paint_volume: function(volume) {
vfunc_get_paint_volume(volume) {
if (!this.parent(volume))
return false;
@ -395,7 +395,7 @@ var Arrow = new Lang.Class({
return true;
},
vfunc_style_changed: function() {
vfunc_style_changed() {
let node = this.get_theme_node();
this._shadow = node.get_shadow('-arrow-shadow');
if (this._shadow)
@ -406,7 +406,7 @@ var Arrow = new Lang.Class({
this.parent();
},
vfunc_paint: function() {
vfunc_paint() {
if (this._shadowHelper) {
this._shadowHelper.update(this._drawingArea);
@ -434,7 +434,7 @@ function clamp(value, min, max) {
var ScreenShield = new Lang.Class({
Name: 'ScreenShield',
_init: function() {
_init() {
this.actor = Main.layoutManager.screenShieldGroup;
this._lockScreenState = MessageTray.State.HIDDEN;
@ -575,7 +575,7 @@ var ScreenShield = new Lang.Class({
this._syncInhibitor();
},
_setActive: function(active) {
_setActive(active) {
let prevIsActive = this._isActive;
this._isActive = active;
@ -588,7 +588,7 @@ var ScreenShield = new Lang.Class({
this._syncInhibitor();
},
_createBackground: function(monitorIndex) {
_createBackground(monitorIndex) {
let monitor = Main.layoutManager.monitors[monitorIndex];
let widget = new St.Widget({ style_class: 'screen-shield-background',
x: monitor.x,
@ -606,7 +606,7 @@ var ScreenShield = new Lang.Class({
this._backgroundGroup.add_child(widget);
},
_updateBackgrounds: function() {
_updateBackgrounds() {
for (let i = 0; i < this._bgManagers.length; i++)
this._bgManagers[i].destroy();
@ -617,7 +617,7 @@ var ScreenShield = new Lang.Class({
this._createBackground(i);
},
_liftShield: function(onPrimary, velocity) {
_liftShield(onPrimary, velocity) {
if (this._isLocked) {
if (this._ensureUnlockDialog(onPrimary, true /* allowCancel */))
this._hideLockScreen(true /* animate */, velocity);
@ -626,7 +626,7 @@ var ScreenShield = new Lang.Class({
}
},
_maybeCancelDialog: function() {
_maybeCancelDialog() {
if (!this._dialog)
return;
@ -641,7 +641,7 @@ var ScreenShield = new Lang.Class({
}
},
_becomeModal: function() {
_becomeModal() {
if (this._isModal)
return true;
@ -656,7 +656,7 @@ var ScreenShield = new Lang.Class({
return this._isModal;
},
_onLockScreenKeyPress: function(actor, event) {
_onLockScreenKeyPress(actor, event) {
let symbol = event.get_key_symbol();
let unichar = event.get_key_unicode();
@ -686,7 +686,7 @@ var ScreenShield = new Lang.Class({
return Clutter.EVENT_STOP;
},
_onLockScreenScroll: function(actor, event) {
_onLockScreenScroll(actor, event) {
if (this._lockScreenState != MessageTray.State.SHOWN)
return Clutter.EVENT_PROPAGATE;
@ -706,7 +706,7 @@ var ScreenShield = new Lang.Class({
return Clutter.EVENT_STOP;
},
_syncInhibitor: function() {
_syncInhibitor() {
let lockEnabled = this._settings.get_boolean(LOCK_ENABLED_KEY);
let lockLocked = this._lockSettings.get_boolean(DISABLE_LOCK_KEY);
let inhibit = (this._loginSession && this._loginSession.Active &&
@ -725,7 +725,7 @@ var ScreenShield = new Lang.Class({
}
},
_prepareForSleep: function(loginManager, aboutToSuspend) {
_prepareForSleep(loginManager, aboutToSuspend) {
if (aboutToSuspend) {
if (this._settings.get_boolean(LOCK_ENABLED_KEY))
this.lock(true);
@ -734,7 +734,7 @@ var ScreenShield = new Lang.Class({
}
},
_animateArrows: function() {
_animateArrows() {
let arrows = this._arrowContainer.get_children();
let unitaryDelay = ARROW_ANIMATION_TIME / (arrows.length + 1);
let maxOpacity = 255 * ARROW_ANIMATION_PEAK_OPACITY;
@ -744,7 +744,7 @@ var ScreenShield = new Lang.Class({
{ opacity: 0,
delay: unitaryDelay * (N_ARROWS - (i + 1)),
time: ARROW_ANIMATION_TIME,
transition: function(t, b, c, d) {
transition(t, b, c, d) {
if (t < d/2)
return TweenerEquations.easeOutQuad(t, 0, maxOpacity, d/2);
else
@ -756,7 +756,7 @@ var ScreenShield = new Lang.Class({
return GLib.SOURCE_CONTINUE;
},
_onDragBegin: function() {
_onDragBegin() {
Tweener.removeTweens(this._lockScreenGroup);
this._lockScreenState = MessageTray.State.HIDING;
@ -766,7 +766,7 @@ var ScreenShield = new Lang.Class({
return true;
},
_onDragMotion: function() {
_onDragMotion() {
let [origX, origY] = this._dragAction.get_press_coords(0);
let [currentX, currentY] = this._dragAction.get_motion_coords(0);
@ -778,7 +778,7 @@ var ScreenShield = new Lang.Class({
return true;
},
_onDragEnd: function(action, actor, eventX, eventY, modifiers) {
_onDragEnd(action, actor, eventX, eventY, modifiers) {
if (this._lockScreenState != MessageTray.State.HIDING)
return;
if (this._lockScreenGroup.y < -(ARROW_DRAG_THRESHOLD * global.stage.height)) {
@ -795,7 +795,7 @@ var ScreenShield = new Lang.Class({
{ y: 0,
time: time,
transition: 'easeInQuad',
onComplete: function() {
onComplete() {
this._lockScreenGroup.fixed_position_set = false;
this._lockScreenState = MessageTray.State.SHOWN;
},
@ -806,7 +806,7 @@ var ScreenShield = new Lang.Class({
}
},
_onStatusChanged: function(status) {
_onStatusChanged(status) {
if (status != GnomeSession.PresenceStatus.IDLE)
return;
@ -857,7 +857,7 @@ var ScreenShield = new Lang.Class({
this._activateFade(this._longLightbox, STANDARD_FADE_TIME);
},
_activateFade: function(lightbox, time) {
_activateFade(lightbox, time) {
Main.uiGroup.set_child_above_sibling(lightbox.actor, null);
lightbox.show(time);
@ -865,7 +865,7 @@ var ScreenShield = new Lang.Class({
this._becameActiveId = this.idleMonitor.add_user_active_watch(Lang.bind(this, this._onUserBecameActive));
},
_onUserBecameActive: function() {
_onUserBecameActive() {
// This function gets called here when the user becomes active
// after we activated a lightbox
// There are two possibilities here:
@ -895,15 +895,15 @@ var ScreenShield = new Lang.Class({
}
},
_onLongLightboxShown: function() {
_onLongLightboxShown() {
this.activate(false);
},
_onShortLightboxShown: function() {
_onShortLightboxShown() {
this._completeLockScreenShown();
},
showDialog: function() {
showDialog() {
if (!this._becomeModal()) {
// In the login screen, this is a hard error. Fail-whale
log('Could not acquire modal grab for the login screen. Aborting login process.');
@ -917,7 +917,7 @@ var ScreenShield = new Lang.Class({
this._hideLockScreen(false, 0);
},
_hideLockScreenComplete: function() {
_hideLockScreenComplete() {
if (Main.sessionMode.currentMode == 'lock-screen')
Main.sessionMode.popMode('lock-screen');
@ -930,7 +930,7 @@ var ScreenShield = new Lang.Class({
}
},
_hideLockScreen: function(animate, velocity) {
_hideLockScreen(animate, velocity) {
if (this._lockScreenState == MessageTray.State.HIDDEN)
return;
@ -963,7 +963,7 @@ var ScreenShield = new Lang.Class({
this._cursorTracker.set_pointer_visible(true);
},
_ensureUnlockDialog: function(onPrimary, allowCancel) {
_ensureUnlockDialog(onPrimary, allowCancel) {
if (!this._dialog) {
let constructor = Main.sessionMode.unlockDialog;
if (!constructor) {
@ -991,12 +991,12 @@ var ScreenShield = new Lang.Class({
return true;
},
_onUnlockFailed: function() {
_onUnlockFailed() {
this._resetLockScreen({ animateLockScreen: true,
fadeToBlack: false });
},
_resetLockScreen: function(params) {
_resetLockScreen(params) {
// Don't reset the lock screen unless it is completely hidden
// This prevents the shield going down if the lock-delay timeout
// fires while the user is dragging (which has the potential
@ -1020,7 +1020,7 @@ var ScreenShield = new Lang.Class({
{ y: 0,
time: MANUAL_FADE_TIME,
transition: 'easeOutQuad',
onComplete: function() {
onComplete() {
this._lockScreenShown({ fadeToBlack: fadeToBlack,
animateFade: true });
},
@ -1038,7 +1038,7 @@ var ScreenShield = new Lang.Class({
Main.sessionMode.pushMode('lock-screen');
},
_startArrowAnimation: function() {
_startArrowAnimation() {
this._arrowActiveWatchId = 0;
if (!this._arrowAnimationId) {
@ -1052,7 +1052,7 @@ var ScreenShield = new Lang.Class({
Lang.bind(this, this._pauseArrowAnimation));
},
_pauseArrowAnimation: function() {
_pauseArrowAnimation() {
if (this._arrowAnimationId) {
Mainloop.source_remove(this._arrowAnimationId);
this._arrowAnimationId = 0;
@ -1062,7 +1062,7 @@ var ScreenShield = new Lang.Class({
this._arrowActiveWatchId = this.idleMonitor.add_user_active_watch(Lang.bind(this, this._startArrowAnimation));
},
_stopArrowAnimation: function() {
_stopArrowAnimation() {
if (this._arrowAnimationId) {
Mainloop.source_remove(this._arrowAnimationId);
this._arrowAnimationId = 0;
@ -1077,7 +1077,7 @@ var ScreenShield = new Lang.Class({
}
},
_checkArrowAnimation: function() {
_checkArrowAnimation() {
let idleTime = this.idleMonitor.get_idletime();
if (idleTime < ARROW_IDLE_TIME)
@ -1086,7 +1086,7 @@ var ScreenShield = new Lang.Class({
this._pauseArrowAnimation();
},
_lockScreenShown: function(params) {
_lockScreenShown(params) {
if (this._dialog && !this._isGreeter) {
this._dialog.destroy();
this._dialog = null;
@ -1124,14 +1124,14 @@ var ScreenShield = new Lang.Class({
}
},
_completeLockScreenShown: function() {
_completeLockScreenShown() {
this._setActive(true);
this.emit('lock-screen-shown');
},
// Some of the actors in the lock screen are heavy in
// resources, so we only create them when needed
_ensureLockScreen: function() {
_ensureLockScreen() {
if (this._hasLockScreen)
return;
@ -1156,12 +1156,12 @@ var ScreenShield = new Lang.Class({
this._hasLockScreen = true;
},
_wakeUpScreen: function() {
_wakeUpScreen() {
this._onUserBecameActive();
this.emit('wake-up-screen');
},
_clearLockScreen: function() {
_clearLockScreen() {
this._clock.destroy();
this._clock = null;
@ -1190,7 +1190,7 @@ var ScreenShield = new Lang.Class({
return this._activationTime;
},
deactivate: function(animate) {
deactivate(animate) {
if (this._dialog)
this._dialog.finish(Lang.bind(this, function() {
this._continueDeactivate(animate);
@ -1199,7 +1199,7 @@ var ScreenShield = new Lang.Class({
this._continueDeactivate(animate);
},
_continueDeactivate: function(animate) {
_continueDeactivate(animate) {
this._hideLockScreen(animate, 0);
if (this._hasLockScreen)
@ -1241,7 +1241,7 @@ var ScreenShield = new Lang.Class({
});
},
_completeDeactivate: function() {
_completeDeactivate() {
if (this._dialog) {
this._dialog.destroy();
this._dialog = null;
@ -1268,7 +1268,7 @@ var ScreenShield = new Lang.Class({
global.set_runtime_state(LOCKED_STATE_STR, null);
},
activate: function(animate) {
activate(animate) {
if (this._activationTime == 0)
this._activationTime = GLib.get_monotonic_time();
@ -1300,7 +1300,7 @@ var ScreenShield = new Lang.Class({
// activate without animation in that case.
},
lock: function(animate) {
lock(animate) {
if (this._lockSettings.get_boolean(DISABLE_LOCK_KEY)) {
log('Screen lock is locked down, not locking') // lock, lock - who's there?
return;
@ -1333,7 +1333,7 @@ var ScreenShield = new Lang.Class({
},
// If the previous shell crashed, and gnome-session restarted us, then re-lock
lockIfWasLocked: function() {
lockIfWasLocked() {
if (!this._settings.get_boolean(LOCK_ENABLED_KEY))
return;
let wasLocked = global.get_runtime_state('b', LOCKED_STATE_STR);