cleanup: Port non-GObject classes to JS6 classes
ES6 finally adds standard class syntax to the language, so we can replace our custom Lang.Class framework with the new syntax. Any classes that inherit from GObject will need special treatment, so limit the port to regular javascript classes for now. https://gitlab.gnome.org/GNOME/gnome-shell/merge_requests/361
This commit is contained in:

committed by
Georges Basile Stavracas Neto

parent
99ce3deeb0
commit
bacfdbbb03
@ -72,15 +72,13 @@ var Urgency = {
|
||||
CRITICAL: 3
|
||||
};
|
||||
|
||||
var FocusGrabber = new Lang.Class({
|
||||
Name: 'FocusGrabber',
|
||||
|
||||
_init(actor) {
|
||||
var FocusGrabber = class FocusGrabber {
|
||||
constructor(actor) {
|
||||
this._actor = actor;
|
||||
this._prevKeyFocusActor = null;
|
||||
this._focusActorChangedId = 0;
|
||||
this._focused = false;
|
||||
},
|
||||
}
|
||||
|
||||
grabFocus() {
|
||||
if (this._focused)
|
||||
@ -94,7 +92,7 @@ var FocusGrabber = new Lang.Class({
|
||||
this._actor.grab_key_focus();
|
||||
|
||||
this._focused = true;
|
||||
},
|
||||
}
|
||||
|
||||
_focusUngrabbed() {
|
||||
if (!this._focused)
|
||||
@ -107,13 +105,13 @@ var FocusGrabber = new Lang.Class({
|
||||
|
||||
this._focused = false;
|
||||
return true;
|
||||
},
|
||||
}
|
||||
|
||||
_focusActorChanged() {
|
||||
let focusedActor = global.stage.get_key_focus();
|
||||
if (!focusedActor || !this._actor.contains(focusedActor))
|
||||
this._focusUngrabbed();
|
||||
},
|
||||
}
|
||||
|
||||
ungrabFocus() {
|
||||
if (!this._focusUngrabbed())
|
||||
@ -128,17 +126,15 @@ var FocusGrabber = new Lang.Class({
|
||||
global.stage.set_key_focus(null);
|
||||
}
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
// NotificationPolicy:
|
||||
// An object that holds all bits of configurable policy related to a notification
|
||||
// source, such as whether to play sound or honour the critical bit.
|
||||
//
|
||||
// A notification without a policy object will inherit the default one.
|
||||
var NotificationPolicy = new Lang.Class({
|
||||
Name: 'NotificationPolicy',
|
||||
|
||||
_init(params) {
|
||||
var NotificationPolicy = class NotificationPolicy {
|
||||
constructor(params) {
|
||||
params = Params.parse(params, { enable: true,
|
||||
enableSound: true,
|
||||
showBanners: true,
|
||||
@ -150,77 +146,72 @@ var NotificationPolicy = new Lang.Class({
|
||||
let desc = Object.getOwnPropertyDescriptor(params, key);
|
||||
Object.defineProperty(this, `_${key}`, desc);
|
||||
});
|
||||
},
|
||||
}
|
||||
|
||||
// Do nothing for the default policy. These methods are only useful for the
|
||||
// GSettings policy.
|
||||
store() { },
|
||||
destroy() { },
|
||||
store() { }
|
||||
destroy() { }
|
||||
|
||||
get enable() {
|
||||
return this._enable;
|
||||
},
|
||||
}
|
||||
|
||||
get enableSound() {
|
||||
return this._enableSound;
|
||||
},
|
||||
}
|
||||
|
||||
get showBanners() {
|
||||
return this._showBanners;
|
||||
},
|
||||
}
|
||||
|
||||
get forceExpanded() {
|
||||
return this._forceExpanded;
|
||||
},
|
||||
}
|
||||
|
||||
get showInLockScreen() {
|
||||
return this._showInLockScreen;
|
||||
},
|
||||
}
|
||||
|
||||
get detailsInLockScreen() {
|
||||
return this._detailsInLockScreen;
|
||||
}
|
||||
});
|
||||
};
|
||||
Signals.addSignalMethods(NotificationPolicy.prototype);
|
||||
|
||||
var NotificationGenericPolicy = new Lang.Class({
|
||||
Name: 'NotificationGenericPolicy',
|
||||
Extends: NotificationPolicy,
|
||||
|
||||
_init() {
|
||||
this.parent();
|
||||
|
||||
var NotificationGenericPolicy =
|
||||
class NotificationGenericPolicy extends NotificationPolicy {
|
||||
constructor() {
|
||||
super();
|
||||
this.id = 'generic';
|
||||
|
||||
this._masterSettings = new Gio.Settings({ schema_id: 'org.gnome.desktop.notifications' });
|
||||
this._masterSettings.connect('changed', this._changed.bind(this));
|
||||
},
|
||||
}
|
||||
|
||||
store() { },
|
||||
store() { }
|
||||
|
||||
destroy() {
|
||||
this._masterSettings.run_dispose();
|
||||
},
|
||||
}
|
||||
|
||||
_changed(settings, key) {
|
||||
this.emit('policy-changed', key);
|
||||
},
|
||||
}
|
||||
|
||||
get showBanners() {
|
||||
return this._masterSettings.get_boolean('show-banners');
|
||||
},
|
||||
}
|
||||
|
||||
get showInLockScreen() {
|
||||
return this._masterSettings.get_boolean('show-in-lock-screen');
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
var NotificationApplicationPolicy = new Lang.Class({
|
||||
Name: 'NotificationApplicationPolicy',
|
||||
Extends: NotificationPolicy,
|
||||
|
||||
_init(id) {
|
||||
this.parent();
|
||||
var NotificationApplicationPolicy =
|
||||
class NotificationApplicationPolicy extends NotificationPolicy {
|
||||
constructor(id) {
|
||||
super();
|
||||
|
||||
this.id = id;
|
||||
this._canonicalId = this._canonicalizeId(id);
|
||||
@ -231,7 +222,7 @@ var NotificationApplicationPolicy = new Lang.Class({
|
||||
|
||||
this._masterSettings.connect('changed', this._changed.bind(this));
|
||||
this._settings.connect('changed', this._changed.bind(this));
|
||||
},
|
||||
}
|
||||
|
||||
store() {
|
||||
this._settings.set_string('application-id', this.id + '.desktop');
|
||||
@ -241,51 +232,51 @@ var NotificationApplicationPolicy = new Lang.Class({
|
||||
apps.push(this._canonicalId);
|
||||
this._masterSettings.set_strv('application-children', apps);
|
||||
}
|
||||
},
|
||||
}
|
||||
|
||||
destroy() {
|
||||
this._masterSettings.run_dispose();
|
||||
this._settings.run_dispose();
|
||||
},
|
||||
}
|
||||
|
||||
_changed(settings, key) {
|
||||
this.emit('policy-changed', key);
|
||||
if (key == 'enable')
|
||||
this.emit('enable-changed');
|
||||
},
|
||||
}
|
||||
|
||||
_canonicalizeId(id) {
|
||||
// Keys are restricted to lowercase alphanumeric characters and dash,
|
||||
// and two dashes cannot be in succession
|
||||
return id.toLowerCase().replace(/[^a-z0-9\-]/g, '-').replace(/--+/g, '-');
|
||||
},
|
||||
}
|
||||
|
||||
get enable() {
|
||||
return this._settings.get_boolean('enable');
|
||||
},
|
||||
}
|
||||
|
||||
get enableSound() {
|
||||
return this._settings.get_boolean('enable-sound-alerts');
|
||||
},
|
||||
}
|
||||
|
||||
get showBanners() {
|
||||
return this._masterSettings.get_boolean('show-banners') &&
|
||||
this._settings.get_boolean('show-banners');
|
||||
},
|
||||
}
|
||||
|
||||
get forceExpanded() {
|
||||
return this._settings.get_boolean('force-expanded');
|
||||
},
|
||||
}
|
||||
|
||||
get showInLockScreen() {
|
||||
return this._masterSettings.get_boolean('show-in-lock-screen') &&
|
||||
this._settings.get_boolean('show-in-lock-screen');
|
||||
},
|
||||
}
|
||||
|
||||
get detailsInLockScreen() {
|
||||
return this._settings.get_boolean('details-in-lock-screen');
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
// Notification:
|
||||
// @source: the notification's Source
|
||||
@ -342,10 +333,8 @@ var NotificationApplicationPolicy = new Lang.Class({
|
||||
// @source allows playing sounds).
|
||||
//
|
||||
// [1] https://developer.gnome.org/notification-spec/#markup
|
||||
var Notification = new Lang.Class({
|
||||
Name: 'Notification',
|
||||
|
||||
_init(source, title, banner, params) {
|
||||
var Notification = class Notification {
|
||||
constructor(source, title, banner, params) {
|
||||
this.source = source;
|
||||
this.title = title;
|
||||
this.urgency = Urgency.NORMAL;
|
||||
@ -367,7 +356,7 @@ var Notification = new Lang.Class({
|
||||
// for new and updated notifications
|
||||
if (arguments.length != 1)
|
||||
this.update(title, banner, params);
|
||||
},
|
||||
}
|
||||
|
||||
// update:
|
||||
// @title: the new title
|
||||
@ -412,41 +401,41 @@ var Notification = new Lang.Class({
|
||||
}
|
||||
|
||||
this.emit('updated', params.clear);
|
||||
},
|
||||
}
|
||||
|
||||
// addAction:
|
||||
// @label: the label for the action's button
|
||||
// @callback: the callback for the action
|
||||
addAction(label, callback) {
|
||||
this.actions.push({ label: label, callback: callback });
|
||||
},
|
||||
}
|
||||
|
||||
get acknowledged() {
|
||||
return this._acknowledged;
|
||||
},
|
||||
}
|
||||
|
||||
set acknowledged(v) {
|
||||
if (this._acknowledged == v)
|
||||
return;
|
||||
this._acknowledged = v;
|
||||
this.emit('acknowledged-changed');
|
||||
},
|
||||
}
|
||||
|
||||
setUrgency(urgency) {
|
||||
this.urgency = urgency;
|
||||
},
|
||||
}
|
||||
|
||||
setResident(resident) {
|
||||
this.resident = resident;
|
||||
},
|
||||
}
|
||||
|
||||
setTransient(isTransient) {
|
||||
this.isTransient = isTransient;
|
||||
},
|
||||
}
|
||||
|
||||
setForFeedback(forFeedback) {
|
||||
this.forFeedback = forFeedback;
|
||||
},
|
||||
}
|
||||
|
||||
playSound() {
|
||||
if (this._soundPlayed)
|
||||
@ -462,7 +451,7 @@ var Notification = new Lang.Class({
|
||||
player.play_from_theme(this._soundName, this.title, null);
|
||||
else if (this._soundFile)
|
||||
player.play_from_file(this._soundFile, this.title, null);
|
||||
},
|
||||
}
|
||||
|
||||
// Allow customizing the banner UI:
|
||||
// the default implementation defers the creation to
|
||||
@ -471,28 +460,26 @@ var Notification = new Lang.Class({
|
||||
// Notification or Source
|
||||
createBanner() {
|
||||
return this.source.createBanner(this);
|
||||
},
|
||||
}
|
||||
|
||||
activate() {
|
||||
this.emit('activated');
|
||||
if (!this.resident)
|
||||
this.destroy();
|
||||
},
|
||||
}
|
||||
|
||||
destroy(reason) {
|
||||
if (!reason)
|
||||
reason = NotificationDestroyedReason.DISMISSED;
|
||||
this.emit('destroy', reason);
|
||||
}
|
||||
});
|
||||
};
|
||||
Signals.addSignalMethods(Notification.prototype);
|
||||
|
||||
var NotificationBanner = new Lang.Class({
|
||||
Name: 'NotificationBanner',
|
||||
Extends: Calendar.NotificationMessage,
|
||||
|
||||
_init(notification) {
|
||||
this.parent(notification);
|
||||
var NotificationBanner =
|
||||
class NotificationBanner extends Calendar.NotificationMessage {
|
||||
constructor(notification) {
|
||||
super(notification);
|
||||
|
||||
this.actor.can_focus = false;
|
||||
this.actor.add_style_class_name('notification-banner');
|
||||
@ -509,15 +496,15 @@ var NotificationBanner = new Lang.Class({
|
||||
// attention switching to the window.
|
||||
this.emit('done-displaying');
|
||||
});
|
||||
},
|
||||
}
|
||||
|
||||
_onDestroy() {
|
||||
this.parent();
|
||||
super._onDestroy();
|
||||
this.notification.disconnect(this._activatedId);
|
||||
},
|
||||
}
|
||||
|
||||
_onUpdated(n, clear) {
|
||||
this.parent(n, clear);
|
||||
super._onUpdated(n, clear);
|
||||
|
||||
if (clear) {
|
||||
this.setSecondaryActor(null);
|
||||
@ -527,13 +514,13 @@ var NotificationBanner = new Lang.Class({
|
||||
|
||||
this._addActions();
|
||||
this._addSecondaryIcon();
|
||||
},
|
||||
}
|
||||
|
||||
_addActions() {
|
||||
this.notification.actions.forEach(action => {
|
||||
this.addAction(action.label, action.callback);
|
||||
});
|
||||
},
|
||||
}
|
||||
|
||||
_addSecondaryIcon() {
|
||||
if (this.notification.secondaryGIcon) {
|
||||
@ -541,7 +528,7 @@ var NotificationBanner = new Lang.Class({
|
||||
x_align: Clutter.ActorAlign.END });
|
||||
this.setSecondaryActor(icon);
|
||||
}
|
||||
},
|
||||
}
|
||||
|
||||
addButton(button, callback) {
|
||||
if (!this._buttonBox) {
|
||||
@ -569,7 +556,7 @@ var NotificationBanner = new Lang.Class({
|
||||
});
|
||||
|
||||
return button;
|
||||
},
|
||||
}
|
||||
|
||||
addAction(label, callback) {
|
||||
let button = new St.Button({ style_class: 'notification-button',
|
||||
@ -579,7 +566,7 @@ var NotificationBanner = new Lang.Class({
|
||||
|
||||
return this.addButton(button, callback);
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
var SourceActor = new Lang.Class({
|
||||
Name: 'SourceActor',
|
||||
@ -697,12 +684,10 @@ var SourceActorWithLabel = new Lang.Class({
|
||||
}
|
||||
});
|
||||
|
||||
var Source = new Lang.Class({
|
||||
Name: 'MessageTraySource',
|
||||
var Source = class Source {
|
||||
constructor(title, iconName) {
|
||||
this.SOURCE_ICON_SIZE = 48;
|
||||
|
||||
SOURCE_ICON_SIZE: 48,
|
||||
|
||||
_init(title, iconName) {
|
||||
this.title = title;
|
||||
this.iconName = iconName;
|
||||
|
||||
@ -711,42 +696,42 @@ var Source = new Lang.Class({
|
||||
this.notifications = [];
|
||||
|
||||
this._policy = null;
|
||||
},
|
||||
}
|
||||
|
||||
get policy() {
|
||||
if (!this._policy)
|
||||
this._policy = this._createPolicy();
|
||||
return this._policy;
|
||||
},
|
||||
}
|
||||
|
||||
get count() {
|
||||
return this.notifications.length;
|
||||
},
|
||||
}
|
||||
|
||||
get unseenCount() {
|
||||
return this.notifications.filter(n => !n.acknowledged).length;
|
||||
},
|
||||
}
|
||||
|
||||
get countVisible() {
|
||||
return this.count > 1;
|
||||
},
|
||||
}
|
||||
|
||||
countUpdated() {
|
||||
this.emit('count-updated');
|
||||
},
|
||||
}
|
||||
|
||||
_createPolicy() {
|
||||
return new NotificationPolicy();
|
||||
},
|
||||
}
|
||||
|
||||
setTitle(newTitle) {
|
||||
this.title = newTitle;
|
||||
this.emit('title-changed');
|
||||
},
|
||||
}
|
||||
|
||||
createBanner(notification) {
|
||||
return new NotificationBanner(notification);
|
||||
},
|
||||
}
|
||||
|
||||
// Called to create a new icon actor.
|
||||
// Provides a sane default implementation, override if you need
|
||||
@ -754,11 +739,11 @@ var Source = new Lang.Class({
|
||||
createIcon(size) {
|
||||
return new St.Icon({ gicon: this.getIcon(),
|
||||
icon_size: size });
|
||||
},
|
||||
}
|
||||
|
||||
getIcon() {
|
||||
return new Gio.ThemedIcon({ name: this.iconName });
|
||||
},
|
||||
}
|
||||
|
||||
_onNotificationDestroy(notification) {
|
||||
let index = this.notifications.indexOf(notification);
|
||||
@ -770,7 +755,7 @@ var Source = new Lang.Class({
|
||||
this.destroy();
|
||||
|
||||
this.countUpdated();
|
||||
},
|
||||
}
|
||||
|
||||
pushNotification(notification) {
|
||||
if (this.notifications.indexOf(notification) >= 0)
|
||||
@ -785,7 +770,7 @@ var Source = new Lang.Class({
|
||||
this.emit('notification-added', notification);
|
||||
|
||||
this.countUpdated();
|
||||
},
|
||||
}
|
||||
|
||||
notify(notification) {
|
||||
notification.acknowledged = false;
|
||||
@ -796,7 +781,7 @@ var Source = new Lang.Class({
|
||||
} else {
|
||||
notification.playSound();
|
||||
}
|
||||
},
|
||||
}
|
||||
|
||||
destroy(reason) {
|
||||
this.policy.destroy();
|
||||
@ -808,15 +793,15 @@ var Source = new Lang.Class({
|
||||
notifications[i].destroy(reason);
|
||||
|
||||
this.emit('destroy', reason);
|
||||
},
|
||||
}
|
||||
|
||||
iconUpdated() {
|
||||
this.emit('icon-updated');
|
||||
},
|
||||
}
|
||||
|
||||
// To be overridden by subclasses
|
||||
open() {
|
||||
},
|
||||
}
|
||||
|
||||
destroyNonResidentNotifications() {
|
||||
for (let i = this.notifications.length - 1; i >= 0; i--)
|
||||
@ -825,13 +810,11 @@ var Source = new Lang.Class({
|
||||
|
||||
this.countUpdated();
|
||||
}
|
||||
});
|
||||
};
|
||||
Signals.addSignalMethods(Source.prototype);
|
||||
|
||||
var MessageTray = new Lang.Class({
|
||||
Name: 'MessageTray',
|
||||
|
||||
_init() {
|
||||
var MessageTray = class MessageTray {
|
||||
constructor() {
|
||||
this._presence = new GnomeSession.Presence((proxy, error) => {
|
||||
this._onStatusChanged(proxy.status);
|
||||
});
|
||||
@ -938,27 +921,27 @@ var MessageTray = new Lang.Class({
|
||||
this._sources = new Map();
|
||||
|
||||
this._sessionUpdated();
|
||||
},
|
||||
}
|
||||
|
||||
_sessionUpdated() {
|
||||
this._updateState();
|
||||
},
|
||||
}
|
||||
|
||||
_onDragBegin() {
|
||||
Shell.util_set_hidden_from_pick(this.actor, true);
|
||||
},
|
||||
}
|
||||
|
||||
_onDragEnd() {
|
||||
Shell.util_set_hidden_from_pick(this.actor, false);
|
||||
},
|
||||
}
|
||||
|
||||
get bannerAlignment() {
|
||||
return this._bannerBin.get_x_align();
|
||||
},
|
||||
}
|
||||
|
||||
set bannerAlignment(align) {
|
||||
this._bannerBin.set_x_align(align);
|
||||
},
|
||||
}
|
||||
|
||||
_onNotificationKeyRelease(actor, event) {
|
||||
if (event.get_key_symbol() == Clutter.KEY_Escape && event.get_state() == 0) {
|
||||
@ -967,27 +950,27 @@ var MessageTray = new Lang.Class({
|
||||
}
|
||||
|
||||
return Clutter.EVENT_PROPAGATE;
|
||||
},
|
||||
}
|
||||
|
||||
_expireNotification() {
|
||||
this._notificationExpired = true;
|
||||
this._updateState();
|
||||
},
|
||||
}
|
||||
|
||||
get queueCount() {
|
||||
return this._notificationQueue.length;
|
||||
},
|
||||
}
|
||||
|
||||
set bannerBlocked(v) {
|
||||
if (this._bannerBlocked == v)
|
||||
return;
|
||||
this._bannerBlocked = v;
|
||||
this._updateState();
|
||||
},
|
||||
}
|
||||
|
||||
contains(source) {
|
||||
return this._sources.has(source);
|
||||
},
|
||||
}
|
||||
|
||||
add(source) {
|
||||
if (this.contains(source)) {
|
||||
@ -1003,7 +986,7 @@ var MessageTray = new Lang.Class({
|
||||
});
|
||||
source.policy.connect('policy-changed', this._updateState.bind(this));
|
||||
this._onSourceEnableChanged(source.policy, source);
|
||||
},
|
||||
}
|
||||
|
||||
_addSource(source) {
|
||||
let obj = {
|
||||
@ -1018,7 +1001,7 @@ var MessageTray = new Lang.Class({
|
||||
obj.destroyId = source.connect('destroy', this._onSourceDestroy.bind(this));
|
||||
|
||||
this.emit('source-added', source);
|
||||
},
|
||||
}
|
||||
|
||||
_removeSource(source) {
|
||||
let obj = this._sources.get(source);
|
||||
@ -1028,11 +1011,11 @@ var MessageTray = new Lang.Class({
|
||||
source.disconnect(obj.destroyId);
|
||||
|
||||
this.emit('source-removed', source);
|
||||
},
|
||||
}
|
||||
|
||||
getSources() {
|
||||
return [...this._sources.keys()];
|
||||
},
|
||||
}
|
||||
|
||||
_onSourceEnableChanged(policy, source) {
|
||||
let wasEnabled = this.contains(source);
|
||||
@ -1044,11 +1027,11 @@ var MessageTray = new Lang.Class({
|
||||
else
|
||||
this._removeSource(source);
|
||||
}
|
||||
},
|
||||
}
|
||||
|
||||
_onSourceDestroy(source) {
|
||||
this._removeSource(source);
|
||||
},
|
||||
}
|
||||
|
||||
_onNotificationDestroy(notification) {
|
||||
if (this._notification == notification && (this._notificationState == State.SHOWN || this._notificationState == State.SHOWING)) {
|
||||
@ -1063,7 +1046,7 @@ var MessageTray = new Lang.Class({
|
||||
this._notificationQueue.splice(index, 1);
|
||||
this.emit('queue-changed');
|
||||
}
|
||||
},
|
||||
}
|
||||
|
||||
_onNotify(source, notification) {
|
||||
if (this._notification == notification) {
|
||||
@ -1089,7 +1072,7 @@ var MessageTray = new Lang.Class({
|
||||
}
|
||||
}
|
||||
this._updateState();
|
||||
},
|
||||
}
|
||||
|
||||
_resetNotificationLeftTimeout() {
|
||||
this._useLongerNotificationLeftTimeout = false;
|
||||
@ -1099,7 +1082,7 @@ var MessageTray = new Lang.Class({
|
||||
this._notificationLeftMouseX = -1;
|
||||
this._notificationLeftMouseY = -1;
|
||||
}
|
||||
},
|
||||
}
|
||||
|
||||
_onNotificationHoverChanged() {
|
||||
if (this._bannerBin.hover == this._notificationHovered)
|
||||
@ -1143,7 +1126,7 @@ var MessageTray = new Lang.Class({
|
||||
this._notificationLeftTimeoutId = Mainloop.timeout_add(timeout, this._onNotificationLeftTimeout.bind(this));
|
||||
GLib.Source.set_name_by_id(this._notificationLeftTimeoutId, '[gnome-shell] this._onNotificationLeftTimeout');
|
||||
}
|
||||
},
|
||||
}
|
||||
|
||||
_onStatusChanged(status) {
|
||||
if (status == GnomeSession.PresenceStatus.BUSY) {
|
||||
@ -1158,7 +1141,7 @@ var MessageTray = new Lang.Class({
|
||||
}
|
||||
|
||||
this._updateState();
|
||||
},
|
||||
}
|
||||
|
||||
_onNotificationLeftTimeout() {
|
||||
let [x, y, mods] = global.get_pointer();
|
||||
@ -1180,13 +1163,13 @@ var MessageTray = new Lang.Class({
|
||||
this._updateState();
|
||||
}
|
||||
return GLib.SOURCE_REMOVE;
|
||||
},
|
||||
}
|
||||
|
||||
_escapeTray() {
|
||||
this._pointerInNotification = false;
|
||||
this._updateNotificationTimeout(0);
|
||||
this._updateState();
|
||||
},
|
||||
}
|
||||
|
||||
// All of the logic for what happens when occurs here; the various
|
||||
// event handlers merely update variables such as
|
||||
@ -1249,7 +1232,7 @@ var MessageTray = new Lang.Class({
|
||||
// Clean transient variables that are used to communicate actions
|
||||
// to updateState()
|
||||
this._notificationExpired = false;
|
||||
},
|
||||
}
|
||||
|
||||
_tween(actor, statevar, value, params) {
|
||||
let onComplete = params.onComplete;
|
||||
@ -1266,24 +1249,24 @@ var MessageTray = new Lang.Class({
|
||||
|
||||
let valuing = (value == State.SHOWN) ? State.SHOWING : State.HIDING;
|
||||
this[statevar] = valuing;
|
||||
},
|
||||
}
|
||||
|
||||
_tweenComplete(statevar, value, onComplete, onCompleteScope, onCompleteParams) {
|
||||
this[statevar] = value;
|
||||
if (onComplete)
|
||||
onComplete.apply(onCompleteScope, onCompleteParams);
|
||||
this._updateState();
|
||||
},
|
||||
}
|
||||
|
||||
_clampOpacity() {
|
||||
this._bannerBin.opacity = Math.max(0, Math.min(this._bannerBin._opacity, 255));
|
||||
},
|
||||
}
|
||||
|
||||
_onIdleMonitorBecameActive() {
|
||||
this._userActiveWhileNotificationShown = true;
|
||||
this._updateNotificationTimeout(2000);
|
||||
this._updateState();
|
||||
},
|
||||
}
|
||||
|
||||
_showNotification() {
|
||||
this._notification = this._notificationQueue.shift();
|
||||
@ -1328,7 +1311,7 @@ var MessageTray = new Lang.Class({
|
||||
this._lastSeenMouseY = y;
|
||||
|
||||
this._resetNotificationLeftTimeout();
|
||||
},
|
||||
}
|
||||
|
||||
_updateShowingNotification() {
|
||||
this._notification.acknowledged = true;
|
||||
@ -1362,12 +1345,12 @@ var MessageTray = new Lang.Class({
|
||||
};
|
||||
|
||||
this._tween(this._bannerBin, '_notificationState', State.SHOWN, tweenParams);
|
||||
},
|
||||
}
|
||||
|
||||
_showNotificationCompleted() {
|
||||
if (this._notification.urgency != Urgency.CRITICAL)
|
||||
this._updateNotificationTimeout(NOTIFICATION_TIMEOUT * 1000);
|
||||
},
|
||||
}
|
||||
|
||||
_updateNotificationTimeout(timeout) {
|
||||
if (this._notificationTimeoutId) {
|
||||
@ -1380,7 +1363,7 @@ var MessageTray = new Lang.Class({
|
||||
this._notificationTimeout.bind(this));
|
||||
GLib.Source.set_name_by_id(this._notificationTimeoutId, '[gnome-shell] this._notificationTimeout');
|
||||
}
|
||||
},
|
||||
}
|
||||
|
||||
_notificationTimeout() {
|
||||
let [x, y, mods] = global.get_pointer();
|
||||
@ -1404,7 +1387,7 @@ var MessageTray = new Lang.Class({
|
||||
this._lastSeenMouseX = x;
|
||||
this._lastSeenMouseY = y;
|
||||
return GLib.SOURCE_REMOVE;
|
||||
},
|
||||
}
|
||||
|
||||
_hideNotification(animate) {
|
||||
this._notificationFocusGrabber.ungrabFocus();
|
||||
@ -1438,7 +1421,7 @@ var MessageTray = new Lang.Class({
|
||||
this._notificationState = State.HIDDEN;
|
||||
this._hideNotificationCompleted();
|
||||
}
|
||||
},
|
||||
}
|
||||
|
||||
_hideNotificationCompleted() {
|
||||
let notification = this._notification;
|
||||
@ -1453,14 +1436,14 @@ var MessageTray = new Lang.Class({
|
||||
this._banner.actor.destroy();
|
||||
this._banner = null;
|
||||
this.actor.hide();
|
||||
},
|
||||
}
|
||||
|
||||
_expandActiveNotification() {
|
||||
if (!this._banner)
|
||||
return;
|
||||
|
||||
this._expandBanner(false);
|
||||
},
|
||||
}
|
||||
|
||||
_expandBanner(autoExpanding) {
|
||||
// Don't animate changes in notifications that are auto-expanding.
|
||||
@ -1469,23 +1452,20 @@ var MessageTray = new Lang.Class({
|
||||
// Don't focus notifications that are auto-expanding.
|
||||
if (!autoExpanding)
|
||||
this._ensureBannerFocused();
|
||||
},
|
||||
}
|
||||
|
||||
_ensureBannerFocused() {
|
||||
this._notificationFocusGrabber.grabFocus();
|
||||
}
|
||||
});
|
||||
};
|
||||
Signals.addSignalMethods(MessageTray.prototype);
|
||||
|
||||
var SystemNotificationSource = new Lang.Class({
|
||||
Name: 'SystemNotificationSource',
|
||||
Extends: Source,
|
||||
|
||||
_init() {
|
||||
this.parent(_("System Information"), 'dialog-information-symbolic');
|
||||
},
|
||||
var SystemNotificationSource = class SystemNotificationSource extends Source {
|
||||
constructor() {
|
||||
super(_("System Information"), 'dialog-information-symbolic');
|
||||
}
|
||||
|
||||
open() {
|
||||
this.destroy();
|
||||
}
|
||||
});
|
||||
};
|
||||
|
Reference in New Issue
Block a user