2012-05-20 16:30:14 +00:00
|
|
|
// -*- mode: js; js-indent-level: 4; indent-tabs-mode: nil -*-
|
2019-01-31 14:07:06 +00:00
|
|
|
/* exported UnlockDialog */
|
2012-05-20 16:30:14 +00:00
|
|
|
|
2019-10-07 18:28:40 +00:00
|
|
|
const { AccountsService, Atk, Clutter, Gdm, Gio, GLib,
|
|
|
|
GnomeDesktop, GObject, Meta, Shell, St } = imports.gi;
|
2012-05-20 16:30:14 +00:00
|
|
|
|
2013-07-16 11:31:22 +00:00
|
|
|
const Layout = imports.ui.layout;
|
2012-05-20 16:30:14 +00:00
|
|
|
const Main = imports.ui.main;
|
2019-10-07 19:19:30 +00:00
|
|
|
const MessageTray = imports.ui.messageTray;
|
|
|
|
const Signals = imports.signals;
|
2012-05-20 16:30:14 +00:00
|
|
|
|
2013-07-24 00:37:42 +00:00
|
|
|
const AuthPrompt = imports.gdm.authPrompt;
|
2012-05-20 16:30:14 +00:00
|
|
|
|
2012-08-16 19:24:53 +00:00
|
|
|
// The timeout before going back automatically to the lock screen (in seconds)
|
|
|
|
const IDLE_TIMEOUT = 2 * 60;
|
|
|
|
|
2019-10-07 22:18:55 +00:00
|
|
|
var SUMMARY_ICON_SIZE = 24;
|
2019-10-07 19:19:30 +00:00
|
|
|
|
2019-10-07 18:28:40 +00:00
|
|
|
var Clock = class {
|
|
|
|
constructor() {
|
|
|
|
this.actor = new St.BoxLayout({
|
|
|
|
style_class: 'screen-shield-clock',
|
|
|
|
vertical: true,
|
|
|
|
});
|
|
|
|
|
|
|
|
this._time = new St.Label({ style_class: 'screen-shield-clock-time' });
|
|
|
|
this._date = new St.Label({ style_class: 'screen-shield-clock-date' });
|
|
|
|
|
|
|
|
this.actor.add(this._time, { x_align: St.Align.MIDDLE });
|
|
|
|
this.actor.add(this._date, { x_align: St.Align.MIDDLE });
|
|
|
|
|
|
|
|
this._wallClock = new GnomeDesktop.WallClock({ time_only: true });
|
|
|
|
this._wallClock.connect('notify::clock', this._updateClock.bind(this));
|
|
|
|
|
|
|
|
this._updateClock();
|
|
|
|
}
|
|
|
|
|
|
|
|
_updateClock() {
|
|
|
|
this._time.text = this._wallClock.clock;
|
|
|
|
|
|
|
|
let date = new Date();
|
|
|
|
/* Translators: This is a time format for a date in
|
|
|
|
long format */
|
|
|
|
let dateFormat = Shell.util_translate_time_string(N_("%A, %B %d"));
|
|
|
|
this._date.text = date.toLocaleFormat(dateFormat);
|
|
|
|
}
|
|
|
|
|
|
|
|
destroy() {
|
|
|
|
this.actor.destroy();
|
|
|
|
this._wallClock.run_dispose();
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2019-10-07 19:19:30 +00:00
|
|
|
var NotificationsBox = class {
|
|
|
|
constructor() {
|
|
|
|
this.actor = new St.BoxLayout({ vertical: true,
|
|
|
|
name: 'screenShieldNotifications',
|
|
|
|
style_class: 'screen-shield-notifications-container' });
|
|
|
|
|
|
|
|
this._scrollView = new St.ScrollView({ x_fill: false, x_align: St.Align.START,
|
|
|
|
hscrollbar_policy: St.PolicyType.NEVER });
|
|
|
|
this._notificationBox = new St.BoxLayout({ vertical: true,
|
|
|
|
style_class: 'screen-shield-notifications-container' });
|
|
|
|
this._scrollView.add_actor(this._notificationBox);
|
|
|
|
|
|
|
|
this.actor.add(this._scrollView, { x_fill: true, x_align: St.Align.START });
|
|
|
|
|
|
|
|
this._sources = new Map();
|
|
|
|
Main.messageTray.getSources().forEach(source => {
|
|
|
|
this._sourceAdded(Main.messageTray, source, true);
|
|
|
|
});
|
|
|
|
this._updateVisibility();
|
|
|
|
|
|
|
|
this._sourceAddedId = Main.messageTray.connect('source-added', this._sourceAdded.bind(this));
|
|
|
|
}
|
|
|
|
|
|
|
|
destroy() {
|
|
|
|
if (this._sourceAddedId) {
|
|
|
|
Main.messageTray.disconnect(this._sourceAddedId);
|
|
|
|
this._sourceAddedId = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
let items = this._sources.entries();
|
|
|
|
for (let [source, obj] of items) {
|
|
|
|
this._removeSource(source, obj);
|
|
|
|
}
|
|
|
|
|
|
|
|
this.actor.destroy();
|
|
|
|
}
|
|
|
|
|
|
|
|
_updateVisibility() {
|
|
|
|
this._notificationBox.visible =
|
|
|
|
this._notificationBox.get_children().some(a => a.visible);
|
|
|
|
|
|
|
|
this.actor.visible = this._notificationBox.visible;
|
|
|
|
}
|
|
|
|
|
|
|
|
_makeNotificationSource(source, box) {
|
|
|
|
let sourceActor = new MessageTray.SourceActor(source, SUMMARY_ICON_SIZE);
|
|
|
|
box.add(sourceActor, { y_fill: true });
|
|
|
|
|
2019-10-07 22:18:55 +00:00
|
|
|
let title = new St.Label({
|
|
|
|
text: source.title,
|
|
|
|
style_class: 'screen-shield-notification-label',
|
|
|
|
x_expand: true,
|
|
|
|
y_align: Clutter.ActorAlign.START,
|
|
|
|
y_expand: true,
|
|
|
|
y_align: Clutter.ActorAlign.CENTER,
|
|
|
|
});
|
|
|
|
box.add_child(title);
|
2019-10-07 19:19:30 +00:00
|
|
|
|
|
|
|
let count = source.unseenCount;
|
2019-10-07 22:18:55 +00:00
|
|
|
let countLabel = new St.Label({
|
|
|
|
text: '%d'.format(count),
|
|
|
|
style_class: 'screen-shield-notification-count-text',
|
|
|
|
y_expand: true,
|
|
|
|
y_align: Clutter.ActorAlign.CENTER,
|
|
|
|
});
|
|
|
|
box.add_child(countLabel);
|
2019-10-07 19:19:30 +00:00
|
|
|
|
|
|
|
box.visible = count != 0;
|
|
|
|
return [title, countLabel];
|
|
|
|
}
|
|
|
|
|
|
|
|
_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,
|
|
|
|
child: sourceActor });
|
|
|
|
box.add(sourceBin);
|
|
|
|
|
|
|
|
let textBox = new St.BoxLayout({ vertical: true });
|
|
|
|
box.add(textBox, { y_fill: false, y_align: St.Align.START });
|
|
|
|
|
|
|
|
let title = new St.Label({ text: source.title,
|
|
|
|
style_class: 'screen-shield-notification-label' });
|
|
|
|
textBox.add(title);
|
|
|
|
|
|
|
|
let visible = false;
|
|
|
|
for (let i = 0; i < source.notifications.length; i++) {
|
|
|
|
let n = source.notifications[i];
|
|
|
|
|
|
|
|
if (n.acknowledged)
|
|
|
|
continue;
|
|
|
|
|
|
|
|
let body = '';
|
|
|
|
if (n.bannerBodyText) {
|
|
|
|
body = n.bannerBodyMarkup
|
|
|
|
? n.bannerBodyText
|
|
|
|
: GLib.markup_escape_text(n.bannerBodyText, -1);
|
|
|
|
}
|
|
|
|
|
|
|
|
let label = new St.Label({ style_class: 'screen-shield-notification-count-text' });
|
|
|
|
label.clutter_text.set_markup('<b>' + n.title + '</b> ' + body);
|
|
|
|
textBox.add(label);
|
|
|
|
|
|
|
|
visible = true;
|
|
|
|
}
|
|
|
|
|
|
|
|
box.visible = visible;
|
|
|
|
return [title, null];
|
|
|
|
}
|
|
|
|
|
|
|
|
_shouldShowDetails(source) {
|
|
|
|
return source.policy.detailsInLockScreen ||
|
|
|
|
source.narrowestPrivacyScope == MessageTray.PrivacyScope.SYSTEM;
|
|
|
|
}
|
|
|
|
|
|
|
|
_showSource(source, obj, box) {
|
|
|
|
if (obj.detailed) {
|
|
|
|
[obj.titleLabel, obj.countLabel] = this._makeNotificationDetailedSource(source, box);
|
|
|
|
} else {
|
|
|
|
[obj.titleLabel, obj.countLabel] = this._makeNotificationSource(source, box);
|
|
|
|
}
|
|
|
|
|
|
|
|
box.visible = obj.visible && (source.unseenCount > 0);
|
|
|
|
}
|
|
|
|
|
|
|
|
_sourceAdded(tray, source, initial) {
|
|
|
|
let obj = {
|
|
|
|
visible: source.policy.showInLockScreen,
|
|
|
|
detailed: this._shouldShowDetails(source),
|
|
|
|
sourceDestroyId: 0,
|
|
|
|
sourceCountChangedId: 0,
|
|
|
|
sourceTitleChangedId: 0,
|
|
|
|
sourceUpdatedId: 0,
|
|
|
|
sourceBox: null,
|
|
|
|
titleLabel: null,
|
|
|
|
countLabel: null,
|
|
|
|
};
|
|
|
|
|
|
|
|
obj.sourceBox = new St.BoxLayout({ style_class: 'screen-shield-notification-source',
|
|
|
|
x_expand: true });
|
|
|
|
this._showSource(source, obj, obj.sourceBox);
|
|
|
|
this._notificationBox.add(obj.sourceBox, { x_fill: false, x_align: St.Align.START });
|
|
|
|
|
|
|
|
obj.sourceCountChangedId = source.connect('count-updated', source => {
|
|
|
|
this._countChanged(source, obj);
|
|
|
|
});
|
|
|
|
obj.sourceTitleChangedId = source.connect('title-changed', source => {
|
|
|
|
this._titleChanged(source, obj);
|
|
|
|
});
|
|
|
|
obj.policyChangedId = source.policy.connect('policy-changed', (policy, key) => {
|
|
|
|
if (key == 'show-in-lock-screen')
|
|
|
|
this._visibleChanged(source, obj);
|
|
|
|
else
|
|
|
|
this._detailedChanged(source, obj);
|
|
|
|
});
|
|
|
|
obj.sourceDestroyId = source.connect('destroy', source => {
|
|
|
|
this._onSourceDestroy(source, obj);
|
|
|
|
});
|
|
|
|
|
|
|
|
this._sources.set(source, obj);
|
|
|
|
|
|
|
|
if (!initial) {
|
|
|
|
// block scrollbars while animating, if they're not needed now
|
|
|
|
let boxHeight = this._notificationBox.height;
|
|
|
|
if (this._scrollView.height >= boxHeight)
|
|
|
|
this._scrollView.vscrollbar_policy = St.PolicyType.NEVER;
|
|
|
|
|
|
|
|
let widget = obj.sourceBox;
|
|
|
|
let [, natHeight] = widget.get_preferred_height(-1);
|
|
|
|
widget.height = 0;
|
|
|
|
widget.ease({
|
|
|
|
height: natHeight,
|
|
|
|
mode: Clutter.AnimationMode.EASE_OUT_QUAD,
|
|
|
|
duration: 250,
|
|
|
|
onComplete: () => {
|
|
|
|
this._scrollView.vscrollbar_policy = St.PolicyType.AUTOMATIC;
|
|
|
|
widget.set_height(-1);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
this._updateVisibility();
|
|
|
|
if (obj.sourceBox.visible)
|
|
|
|
this.emit('wake-up-screen');
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
_titleChanged(source, obj) {
|
|
|
|
obj.titleLabel.text = source.title;
|
|
|
|
}
|
|
|
|
|
|
|
|
_countChanged(source, obj) {
|
|
|
|
// A change in the number of notifications may change whether we show
|
|
|
|
// details.
|
|
|
|
let newDetailed = this._shouldShowDetails(source);
|
|
|
|
let oldDetailed = obj.detailed;
|
|
|
|
|
|
|
|
obj.detailed = newDetailed;
|
|
|
|
|
|
|
|
if (obj.detailed || oldDetailed != newDetailed) {
|
|
|
|
// A new notification was pushed, or a previous notification was destroyed.
|
|
|
|
// Give up, and build the list again.
|
|
|
|
|
|
|
|
obj.sourceBox.destroy_all_children();
|
|
|
|
obj.titleLabel = obj.countLabel = null;
|
|
|
|
this._showSource(source, obj, obj.sourceBox);
|
|
|
|
} else {
|
|
|
|
let count = source.unseenCount;
|
2019-10-07 22:18:55 +00:00
|
|
|
obj.countLabel.text = '%d'.format(count);
|
2019-10-07 19:19:30 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
obj.sourceBox.visible = obj.visible && (source.unseenCount > 0);
|
|
|
|
|
|
|
|
this._updateVisibility();
|
|
|
|
if (obj.sourceBox.visible)
|
|
|
|
this.emit('wake-up-screen');
|
|
|
|
}
|
|
|
|
|
|
|
|
_visibleChanged(source, obj) {
|
|
|
|
if (obj.visible == source.policy.showInLockScreen)
|
|
|
|
return;
|
|
|
|
|
|
|
|
obj.visible = source.policy.showInLockScreen;
|
|
|
|
obj.sourceBox.visible = obj.visible && source.unseenCount > 0;
|
|
|
|
|
|
|
|
this._updateVisibility();
|
|
|
|
if (obj.sourceBox.visible)
|
|
|
|
this.emit('wake-up-screen');
|
|
|
|
}
|
|
|
|
|
|
|
|
_detailedChanged(source, obj) {
|
|
|
|
let newDetailed = this._shouldShowDetails(source);
|
|
|
|
if (obj.detailed == newDetailed)
|
|
|
|
return;
|
|
|
|
|
|
|
|
obj.detailed = newDetailed;
|
|
|
|
|
|
|
|
obj.sourceBox.destroy_all_children();
|
|
|
|
obj.titleLabel = obj.countLabel = null;
|
|
|
|
this._showSource(source, obj, obj.sourceBox);
|
|
|
|
}
|
|
|
|
|
|
|
|
_onSourceDestroy(source, obj) {
|
|
|
|
this._removeSource(source, obj);
|
|
|
|
this._updateVisibility();
|
|
|
|
}
|
|
|
|
|
|
|
|
_removeSource(source, obj) {
|
|
|
|
obj.sourceBox.destroy();
|
|
|
|
obj.sourceBox = obj.titleLabel = obj.countLabel = null;
|
|
|
|
|
|
|
|
source.disconnect(obj.sourceDestroyId);
|
|
|
|
source.disconnect(obj.sourceCountChangedId);
|
|
|
|
source.disconnect(obj.sourceTitleChangedId);
|
|
|
|
source.policy.disconnect(obj.policyChangedId);
|
|
|
|
|
|
|
|
this._sources.delete(source);
|
|
|
|
}
|
|
|
|
};
|
|
|
|
Signals.addSignalMethods(NotificationsBox.prototype);
|
|
|
|
|
2019-10-10 19:30:15 +00:00
|
|
|
var UnlockDialogLayout = GObject.registerClass(
|
|
|
|
class UnlockDialogLayout extends Clutter.LayoutManager {
|
2019-10-15 13:37:46 +00:00
|
|
|
_init(clockStack, notifications) {
|
2019-10-10 19:30:15 +00:00
|
|
|
super._init();
|
|
|
|
|
2019-10-15 13:37:46 +00:00
|
|
|
this._clockStack = clockStack;
|
2019-10-10 19:30:15 +00:00
|
|
|
this._notifications = notifications;
|
|
|
|
}
|
|
|
|
|
|
|
|
vfunc_get_preferred_width(container, forHeight) {
|
2019-10-15 13:37:46 +00:00
|
|
|
return this._clockStack.get_preferred_width(forHeight);
|
2019-10-10 19:30:15 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
vfunc_get_preferred_height(container, forWidth) {
|
2019-10-15 13:37:46 +00:00
|
|
|
return this._clockStack.get_preferred_height(forWidth);
|
2019-10-10 19:30:15 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
vfunc_allocate(container, box, flags) {
|
|
|
|
let [width, height] = box.get_size();
|
|
|
|
|
|
|
|
let tenthOfHeight = height / 10.0;
|
|
|
|
let thirdOfHeight = height / 3.0;
|
|
|
|
|
2019-10-15 13:37:46 +00:00
|
|
|
let [clockStackWidth, clockStackHeight] =
|
|
|
|
this._clockStack.get_preferred_size();
|
2019-10-10 19:30:15 +00:00
|
|
|
|
|
|
|
let [, , notificationsWidth, notificationsHeight] =
|
|
|
|
this._notifications.get_preferred_size();
|
|
|
|
|
2019-10-15 13:37:46 +00:00
|
|
|
let columnWidth = Math.max(clockStackWidth, notificationsWidth);
|
2019-10-10 19:30:15 +00:00
|
|
|
|
|
|
|
let columnX1 = Math.floor(width / 2.0 - columnWidth / 2.0);
|
|
|
|
let actorBox = new Clutter.ActorBox();
|
|
|
|
|
|
|
|
// Notifications
|
|
|
|
let maxNotificationsHeight = Math.min(
|
|
|
|
notificationsHeight,
|
2019-10-15 13:37:46 +00:00
|
|
|
height - tenthOfHeight - clockStackHeight);
|
2019-10-10 19:30:15 +00:00
|
|
|
|
|
|
|
actorBox.x1 = columnX1;
|
|
|
|
actorBox.y1 = height - maxNotificationsHeight;
|
|
|
|
actorBox.x2 = columnX1 + columnWidth;
|
|
|
|
actorBox.y2 = actorBox.y1 + maxNotificationsHeight;
|
|
|
|
|
|
|
|
this._notifications.allocate(actorBox, flags);
|
|
|
|
|
2019-10-15 13:37:46 +00:00
|
|
|
// Clock Stack
|
|
|
|
let clockStackY = Math.min(
|
2019-10-10 19:30:15 +00:00
|
|
|
thirdOfHeight,
|
2019-10-15 13:37:46 +00:00
|
|
|
height - clockStackHeight - maxNotificationsHeight);
|
2019-10-10 19:30:15 +00:00
|
|
|
|
|
|
|
actorBox.x1 = columnX1;
|
2019-10-15 13:37:46 +00:00
|
|
|
actorBox.y1 = clockStackY;
|
2019-10-10 19:30:15 +00:00
|
|
|
actorBox.x2 = columnX1 + columnWidth;
|
2019-10-15 13:37:46 +00:00
|
|
|
actorBox.y2 = clockStackY + clockStackHeight;
|
2019-10-10 19:30:15 +00:00
|
|
|
|
2019-10-15 13:37:46 +00:00
|
|
|
this._clockStack.allocate(actorBox, flags);
|
2019-10-10 19:30:15 +00:00
|
|
|
}
|
|
|
|
});
|
|
|
|
|
2019-09-20 11:17:40 +00:00
|
|
|
var UnlockDialog = GObject.registerClass({
|
|
|
|
Signals: { 'failed': {} },
|
|
|
|
}, class UnlockDialog extends St.Widget {
|
|
|
|
_init(parentActor) {
|
|
|
|
super._init({
|
|
|
|
accessible_role: Atk.Role.WINDOW,
|
|
|
|
style_class: 'login-dialog',
|
|
|
|
visible: false,
|
|
|
|
});
|
2013-07-16 11:31:22 +00:00
|
|
|
|
2019-09-20 11:17:40 +00:00
|
|
|
this.add_constraint(new Layout.MonitorConstraint({ primary: true }));
|
|
|
|
parentActor.add_child(this);
|
2012-05-20 16:30:14 +00:00
|
|
|
|
|
|
|
this._userManager = AccountsService.UserManager.get_default();
|
|
|
|
this._userName = GLib.get_user_name();
|
|
|
|
this._user = this._userManager.get_user(this._userName);
|
|
|
|
|
2019-10-15 13:37:46 +00:00
|
|
|
let clockStack = new Shell.Stack();
|
|
|
|
this.add_child(clockStack);
|
|
|
|
|
2019-10-10 19:30:15 +00:00
|
|
|
this._clock = new Clock();
|
2019-10-15 13:37:46 +00:00
|
|
|
clockStack.add_child(this._clock.actor);
|
|
|
|
|
|
|
|
this._activePage = this._clock.actor;
|
2019-10-10 19:30:15 +00:00
|
|
|
|
2019-10-15 13:37:46 +00:00
|
|
|
this._authBox = new St.BoxLayout({
|
2019-10-07 18:28:40 +00:00
|
|
|
x_align: Clutter.ActorAlign.CENTER,
|
|
|
|
y_align: Clutter.ActorAlign.CENTER,
|
|
|
|
x_expand: true,
|
|
|
|
y_expand: true,
|
|
|
|
vertical: true,
|
2019-10-15 13:37:46 +00:00
|
|
|
visible: false,
|
2019-10-07 18:28:40 +00:00
|
|
|
});
|
2019-10-15 13:37:46 +00:00
|
|
|
clockStack.add_child(this._authBox);
|
2012-05-20 16:30:14 +00:00
|
|
|
|
2013-07-22 15:07:35 +00:00
|
|
|
this._authPrompt = new AuthPrompt.AuthPrompt(new Gdm.Client(), AuthPrompt.AuthPromptMode.UNLOCK_ONLY);
|
2017-12-02 00:27:35 +00:00
|
|
|
this._authPrompt.connect('failed', this._fail.bind(this));
|
|
|
|
this._authPrompt.connect('cancelled', this._fail.bind(this));
|
|
|
|
this._authPrompt.connect('reset', this._onReset.bind(this));
|
2013-07-16 11:31:22 +00:00
|
|
|
this._authPrompt.setPasswordChar('\u25cf');
|
2012-08-07 14:49:22 +00:00
|
|
|
|
2019-10-15 13:37:46 +00:00
|
|
|
this._authBox.add_child(this._authPrompt.actor);
|
2012-05-20 16:30:14 +00:00
|
|
|
|
2012-10-24 15:53:19 +00:00
|
|
|
this.allowCancel = false;
|
2012-08-07 15:38:12 +00:00
|
|
|
|
2014-06-24 19:17:09 +00:00
|
|
|
let screenSaverSettings = new Gio.Settings({ schema_id: 'org.gnome.desktop.screensaver' });
|
2013-01-03 00:02:13 +00:00
|
|
|
if (screenSaverSettings.get_boolean('user-switch-enabled')) {
|
|
|
|
let otherUserLabel = new St.Label({ text: _("Log in as another user"),
|
|
|
|
style_class: 'login-dialog-not-listed-label' });
|
|
|
|
this._otherUserButton = new St.Button({ style_class: 'login-dialog-not-listed-button',
|
|
|
|
can_focus: true,
|
|
|
|
child: otherUserLabel,
|
|
|
|
reactive: true,
|
|
|
|
x_align: St.Align.START,
|
2013-12-11 20:36:49 +00:00
|
|
|
x_fill: false });
|
2017-12-02 00:27:35 +00:00
|
|
|
this._otherUserButton.connect('clicked', this._otherUserClicked.bind(this));
|
2019-10-15 13:37:46 +00:00
|
|
|
this._authBox.add_child(this._otherUserButton);
|
2013-01-03 00:02:13 +00:00
|
|
|
} else {
|
|
|
|
this._otherUserButton = null;
|
|
|
|
}
|
2012-05-26 15:04:25 +00:00
|
|
|
|
2019-10-07 19:19:30 +00:00
|
|
|
this._notificationsBox = new NotificationsBox();
|
|
|
|
this._wakeUpScreenId = this._notificationsBox.connect('wake-up-screen', this._wakeUpScreen.bind(this));
|
2019-10-10 19:30:15 +00:00
|
|
|
this.add_child(this._notificationsBox.actor);
|
2019-10-07 19:19:30 +00:00
|
|
|
|
2013-07-28 21:49:50 +00:00
|
|
|
this._authPrompt.reset();
|
2012-11-18 21:36:17 +00:00
|
|
|
this._updateSensitivity(true);
|
|
|
|
|
2019-09-20 11:17:40 +00:00
|
|
|
Main.ctrlAltTabManager.addGroup(this, _("Unlock Window"), 'dialog-password-symbolic');
|
2012-08-11 03:53:59 +00:00
|
|
|
|
2013-08-14 13:47:27 +00:00
|
|
|
this._idleMonitor = Meta.IdleMonitor.get_core();
|
2017-12-02 00:27:35 +00:00
|
|
|
this._idleWatchId = this._idleMonitor.add_idle_watch(IDLE_TIMEOUT * 1000, this._escape.bind(this));
|
2019-09-20 11:17:40 +00:00
|
|
|
|
2019-10-10 19:30:15 +00:00
|
|
|
this.layout_manager = new UnlockDialogLayout(
|
2019-10-15 13:37:46 +00:00
|
|
|
clockStack,
|
2019-10-10 19:30:15 +00:00
|
|
|
this._notificationsBox.actor);
|
|
|
|
|
2019-09-20 11:17:40 +00:00
|
|
|
this.connect('destroy', this._onDestroy.bind(this));
|
2017-10-31 01:19:44 +00:00
|
|
|
}
|
2012-05-20 16:30:14 +00:00
|
|
|
|
2019-10-15 13:37:46 +00:00
|
|
|
_showClock() {
|
|
|
|
if (this._activePage == this._clock.actor)
|
|
|
|
return;
|
|
|
|
|
|
|
|
this._activePage = this._clock.actor;
|
|
|
|
this._clock.actor.show();
|
|
|
|
|
|
|
|
this._authBox.ease({
|
|
|
|
opacity: 0,
|
|
|
|
duration: 300,
|
|
|
|
mode: Clutter.AnimationMode.EASE_OUT_QUAD,
|
|
|
|
onComplete: () => this._authBox.hide(),
|
|
|
|
});
|
|
|
|
|
|
|
|
this._clock.actor.ease({
|
|
|
|
opacity: 255,
|
|
|
|
duration: 300,
|
|
|
|
mode: Clutter.AnimationMode.EASE_OUT_QUAD,
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
_showAuth() {
|
|
|
|
if (this._activePage == this._authBox)
|
|
|
|
return;
|
|
|
|
|
|
|
|
this._activePage = this._authBox;
|
|
|
|
this._authBox.show();
|
|
|
|
|
|
|
|
this._clock.actor.ease({
|
|
|
|
opacity: 0,
|
|
|
|
duration: 300,
|
|
|
|
mode: Clutter.AnimationMode.EASE_OUT_QUAD,
|
|
|
|
onComplete: () => this._clock.actor.hide(),
|
|
|
|
});
|
|
|
|
|
|
|
|
this._authBox.ease({
|
|
|
|
opacity: 255,
|
|
|
|
duration: 300,
|
|
|
|
mode: Clutter.AnimationMode.EASE_OUT_QUAD,
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
vfunc_captured_event(event) {
|
|
|
|
if (event.type() != Clutter.EventType.KEY_PRESS)
|
|
|
|
return Clutter.EVENT_PROPAGATE;
|
|
|
|
|
|
|
|
if (this._activePage == this._authBox)
|
|
|
|
return Clutter.EVENT_PROPAGATE;
|
|
|
|
|
|
|
|
let symbol = event.get_key_symbol();
|
|
|
|
let unichar = event.get_key_unicode();
|
|
|
|
|
|
|
|
let isEnter = (symbol == Clutter.KEY_Return ||
|
|
|
|
symbol == Clutter.KEY_KP_Enter ||
|
|
|
|
symbol == Clutter.KEY_ISO_Enter);
|
|
|
|
let isEscape = (symbol == Clutter.KEY_Escape);
|
|
|
|
let isLiftChar = (GLib.unichar_isprint(unichar) &&
|
|
|
|
(this._activePage == this._clock.actor ||
|
|
|
|
!GLib.unichar_isgraph(unichar)));
|
|
|
|
|
|
|
|
if (!isEnter && !isEscape && !isLiftChar)
|
|
|
|
return Clutter.EVENT_PROPAGATE;
|
|
|
|
|
|
|
|
this._showAuth();
|
|
|
|
|
|
|
|
return Clutter.EVENT_PROPAGATE;
|
|
|
|
}
|
|
|
|
|
2017-10-31 00:03:21 +00:00
|
|
|
_updateSensitivity(sensitive) {
|
2013-07-16 11:31:22 +00:00
|
|
|
this._authPrompt.updateSensitivity(sensitive);
|
|
|
|
|
2013-01-03 00:02:13 +00:00
|
|
|
if (this._otherUserButton) {
|
|
|
|
this._otherUserButton.reactive = sensitive;
|
|
|
|
this._otherUserButton.can_focus = sensitive;
|
|
|
|
}
|
2017-10-31 01:19:44 +00:00
|
|
|
}
|
2012-11-01 15:19:17 +00:00
|
|
|
|
2017-10-31 00:03:21 +00:00
|
|
|
_fail() {
|
2019-10-15 13:37:46 +00:00
|
|
|
this._showClock();
|
2013-07-22 15:07:35 +00:00
|
|
|
this.emit('failed');
|
2017-10-31 01:19:44 +00:00
|
|
|
}
|
2012-10-03 21:15:41 +00:00
|
|
|
|
2017-10-31 00:03:21 +00:00
|
|
|
_onReset(authPrompt, beginRequest) {
|
2013-07-28 21:49:50 +00:00
|
|
|
let userName;
|
|
|
|
if (beginRequest == AuthPrompt.BeginRequestType.PROVIDE_USERNAME) {
|
|
|
|
this._authPrompt.setUser(this._user);
|
|
|
|
userName = this._userName;
|
|
|
|
} else {
|
|
|
|
userName = null;
|
|
|
|
}
|
|
|
|
|
|
|
|
this._authPrompt.begin({ userName: userName });
|
2017-10-31 01:19:44 +00:00
|
|
|
}
|
2013-07-28 21:49:50 +00:00
|
|
|
|
2017-10-31 00:03:21 +00:00
|
|
|
_escape() {
|
2013-07-28 20:06:04 +00:00
|
|
|
if (this.allowCancel)
|
2013-07-22 15:07:35 +00:00
|
|
|
this._authPrompt.cancel();
|
2017-10-31 01:19:44 +00:00
|
|
|
}
|
2012-08-03 17:26:30 +00:00
|
|
|
|
2019-02-04 11:30:53 +00:00
|
|
|
_otherUserClicked() {
|
2012-08-14 15:49:46 +00:00
|
|
|
Gdm.goto_login_session_sync(null);
|
2012-05-20 16:30:14 +00:00
|
|
|
|
2013-07-22 15:07:35 +00:00
|
|
|
this._authPrompt.cancel();
|
2017-10-31 01:19:44 +00:00
|
|
|
}
|
2012-05-20 16:30:14 +00:00
|
|
|
|
2019-10-07 19:19:30 +00:00
|
|
|
_wakeUpScreen() {
|
|
|
|
// FIXME
|
|
|
|
//this._onUserBecameActive();
|
|
|
|
this.emit('wake-up-screen');
|
|
|
|
}
|
|
|
|
|
2019-09-20 11:17:40 +00:00
|
|
|
_onDestroy() {
|
2013-07-22 15:07:35 +00:00
|
|
|
this.popModal();
|
2012-08-16 19:24:53 +00:00
|
|
|
|
2019-10-07 19:19:30 +00:00
|
|
|
if (this._notificationsBox) {
|
|
|
|
this._notificationsBox.disconnect(this._wakeUpScreenId);
|
|
|
|
this._notificationsBox.destroy();
|
|
|
|
this._notificationsBox = null;
|
|
|
|
}
|
|
|
|
|
2019-10-07 18:28:40 +00:00
|
|
|
this._clock.destroy();
|
|
|
|
this._clock = null;
|
|
|
|
|
2012-08-16 19:24:53 +00:00
|
|
|
if (this._idleWatchId) {
|
|
|
|
this._idleMonitor.remove_watch(this._idleWatchId);
|
|
|
|
this._idleWatchId = 0;
|
|
|
|
}
|
2017-10-31 01:19:44 +00:00
|
|
|
}
|
2012-05-20 16:30:14 +00:00
|
|
|
|
2017-10-31 00:03:21 +00:00
|
|
|
cancel() {
|
2013-07-22 15:07:35 +00:00
|
|
|
this._authPrompt.cancel();
|
2017-10-31 01:19:44 +00:00
|
|
|
}
|
2013-03-05 05:55:54 +00:00
|
|
|
|
2017-10-31 00:03:21 +00:00
|
|
|
addCharacter(unichar) {
|
2019-10-15 13:37:46 +00:00
|
|
|
this._showAuth();
|
2013-07-16 11:31:22 +00:00
|
|
|
this._authPrompt.addCharacter(unichar);
|
2017-10-31 01:19:44 +00:00
|
|
|
}
|
2013-07-18 12:58:58 +00:00
|
|
|
|
2017-10-31 00:03:21 +00:00
|
|
|
finish(onComplete) {
|
2013-07-22 15:07:35 +00:00
|
|
|
this._authPrompt.finish(onComplete);
|
2017-10-31 01:19:44 +00:00
|
|
|
}
|
2013-07-16 11:31:22 +00:00
|
|
|
|
2017-10-31 00:03:21 +00:00
|
|
|
open(timestamp) {
|
2019-09-20 11:17:40 +00:00
|
|
|
this.show();
|
2013-07-16 11:31:22 +00:00
|
|
|
|
|
|
|
if (this._isModal)
|
|
|
|
return true;
|
2013-07-18 12:58:58 +00:00
|
|
|
|
2019-09-20 11:17:40 +00:00
|
|
|
let modalParams = {
|
|
|
|
timestamp,
|
|
|
|
actionMode: Shell.ActionMode.UNLOCK_SCREEN,
|
|
|
|
};
|
|
|
|
if (!Main.pushModal(this, modalParams))
|
2013-07-16 11:31:22 +00:00
|
|
|
return false;
|
|
|
|
|
|
|
|
this._isModal = true;
|
|
|
|
|
|
|
|
return true;
|
2017-10-31 01:19:44 +00:00
|
|
|
}
|
2013-07-16 11:31:22 +00:00
|
|
|
|
2017-10-31 00:03:21 +00:00
|
|
|
popModal(timestamp) {
|
2013-07-16 11:31:22 +00:00
|
|
|
if (this._isModal) {
|
2019-09-20 11:17:40 +00:00
|
|
|
Main.popModal(this, timestamp);
|
2013-07-16 11:31:22 +00:00
|
|
|
this._isModal = false;
|
|
|
|
}
|
2013-07-18 12:58:58 +00:00
|
|
|
}
|
2019-09-20 11:17:40 +00:00
|
|
|
});
|