Consolidate creation of login and unlock dialog in the screenshield

The design calls for the curtain to appear in the gdm greeter too.
Implement this by having the screenshield manage the login dialog
(delegating its creation to SessionMode).

https://bugzilla.gnome.org/show_bug.cgi?id=619955
This commit is contained in:
Giovanni Campagna 2012-05-26 17:04:25 +02:00
parent c0652bcd8f
commit a28d639c3b
6 changed files with 93 additions and 37 deletions

View File

@ -34,7 +34,6 @@ dist_theme_DATA = \
theme/dash-placeholder.svg \ theme/dash-placeholder.svg \
theme/filter-selected-ltr.svg \ theme/filter-selected-ltr.svg \
theme/filter-selected-rtl.svg \ theme/filter-selected-rtl.svg \
theme/gdm.css \
theme/gnome-shell.css \ theme/gnome-shell.css \
theme/panel-button-border.svg \ theme/panel-button-border.svg \
theme/panel-button-highlight-narrow.svg \ theme/panel-button-highlight-narrow.svg \

View File

@ -646,8 +646,11 @@ const LoginDialog = new Lang.Class({
Name: 'LoginDialog', Name: 'LoginDialog',
Extends: ModalDialog.ModalDialog, Extends: ModalDialog.ModalDialog,
_init: function() { _init: function(parentActor) {
this.parent({ shellReactive: true, styleClass: 'login-dialog' }); this.parent({ shellReactive: true,
styleClass: 'login-dialog',
parentActor: parentActor
});
this.connect('destroy', this.connect('destroy',
Lang.bind(this, this._onDestroy)); Lang.bind(this, this._onDestroy));
this.connect('opened', this.connect('opened',
@ -858,7 +861,7 @@ const LoginDialog = new Lang.Class({
GdmUtil.fadeOutActor(this._promptFingerprintMessage); GdmUtil.fadeOutActor(this._promptFingerprintMessage);
} }
_onCancel: function() { cancel: function() {
this._userVerifier.cancel(); this._userVerifier.cancel();
}, },
@ -901,7 +904,7 @@ const LoginDialog = new Lang.Class({
_showPrompt: function() { _showPrompt: function() {
let hold = new Batch.Hold(); let hold = new Batch.Hold();
let buttons = [{ action: Lang.bind(this, this._onCancel), let buttons = [{ action: Lang.bind(this, this.cancel),
label: _("Cancel"), label: _("Cancel"),
key: Clutter.Escape }, key: Clutter.Escape },
{ action: Lang.bind(this, function() { { action: Lang.bind(this, function() {

View File

@ -36,6 +36,7 @@ const SessionMode = imports.ui.sessionMode;
const ShellDBus = imports.ui.shellDBus; const ShellDBus = imports.ui.shellDBus;
const ShellMountOperation = imports.ui.shellMountOperation; const ShellMountOperation = imports.ui.shellMountOperation;
const TelepathyClient = imports.ui.telepathyClient; const TelepathyClient = imports.ui.telepathyClient;
const UnlockDialog = imports.ui.unlockDialog;
const WindowManager = imports.ui.windowManager; const WindowManager = imports.ui.windowManager;
const Magnifier = imports.ui.magnifier; const Magnifier = imports.ui.magnifier;
const XdndHandler = imports.ui.xdndHandler; const XdndHandler = imports.ui.xdndHandler;
@ -94,14 +95,21 @@ function createUserSession() {
} }
function createGDMSession() { function createGDMSession() {
screenShield.showDialog();
}
function createGDMLoginDialog(parentActor) {
// We do this this here instead of at the top to prevent GDM // We do this this here instead of at the top to prevent GDM
// related code from getting loaded in normal user sessions // related code from getting loaded in normal user sessions
const LoginDialog = imports.gdm.loginDialog; const LoginDialog = imports.gdm.loginDialog;
let loginDialog = new LoginDialog.LoginDialog(); let loginDialog = new LoginDialog.LoginDialog(parentActor);
loginDialog.connect('loaded', function() { return [loginDialog, true];
loginDialog.open(); }
});
function createSessionUnlockDialog(parentActor) {
let dialog = new UnlockDialog.UnlockDialog(parentActor);
return [dialog, false];
} }
function createInitialSetupSession() { function createInitialSetupSession() {

View File

@ -9,7 +9,6 @@ const St = imports.gi.St;
const GnomeSession = imports.misc.gnomeSession; const GnomeSession = imports.misc.gnomeSession;
const Lightbox = imports.ui.lightbox; const Lightbox = imports.ui.lightbox;
const UnlockDialog = imports.ui.unlockDialog;
const Main = imports.ui.main; const Main = imports.ui.main;
const Tweener = imports.ui.tweener; const Tweener = imports.ui.tweener;
@ -97,7 +96,7 @@ const ScreenShield = new Lang.Class({
_onLockScreenKeyRelease: function(actor, event) { _onLockScreenKeyRelease: function(actor, event) {
if (event.get_key_symbol() == Clutter.KEY_Escape) { if (event.get_key_symbol() == Clutter.KEY_Escape) {
this._showUnlockDialog(); this._showUnlockDialog(true);
return true; return true;
} }
@ -124,7 +123,7 @@ const ScreenShield = new Lang.Class({
_onDragEnd: function(action, actor, eventX, eventY, modifiers) { _onDragEnd: function(action, actor, eventX, eventY, modifiers) {
if (this._lockScreenGroup.y < -(ARROW_DRAG_TRESHOLD * global.stage.height)) { if (this._lockScreenGroup.y < -(ARROW_DRAG_TRESHOLD * global.stage.height)) {
// Complete motion automatically // Complete motion automatically
this._showUnlockDialog(); this._showUnlockDialog(true);
} else { } else {
// restore the lock screen to its original place // restore the lock screen to its original place
// try to use the same speed as the normal animation // try to use the same speed as the normal animation
@ -146,7 +145,9 @@ const ScreenShield = new Lang.Class({
if (status == GnomeSession.PresenceStatus.IDLE) { if (status == GnomeSession.PresenceStatus.IDLE) {
if (this._dialog) { if (this._dialog) {
this._dialog.cancel(); this._dialog.cancel();
this._dialog = null; if (!this._keepDialog) {
this._dialog = null;
}
} }
if (!this._isModal) { if (!this._isModal) {
@ -169,32 +170,54 @@ const ScreenShield = new Lang.Class({
} }
}, },
_showUnlockDialog: function() { showDialog: function() {
if (this._dialog) this.lock();
return; this._showUnlockDialog(false);
},
// Tween the lock screen out of screen _showUnlockDialog: function(animate) {
// try to use the same speed regardless of original position if (animate) {
let h = global.stage.height; // Tween the lock screen out of screen
let time = CURTAIN_SLIDE_TIME * (h + this._lockScreenGroup.y) / h; // try to use the same speed regardless of original position
Tweener.removeTweens(this._lockScreenGroup); let h = global.stage.height;
Tweener.addTween(this._lockScreenGroup, let time = CURTAIN_SLIDE_TIME * (h + this._lockScreenGroup.y) / h;
{ y: -h, Tweener.removeTweens(this._lockScreenGroup);
time: time, Tweener.addTween(this._lockScreenGroup,
transition: 'linear', { y: -h,
onComplete: Lang.bind(this, this._hideLockScreen), time: time,
}); transition: 'linear',
onComplete: Lang.bind(this, this._hideLockScreen),
});
} else {
this._hideLockScreen();
}
this._dialog = new UnlockDialog.UnlockDialog(); if (!this._dialog) {
this._dialog.connect('failed', Lang.bind(this, this._onUnlockFailed)); [this._dialog, this._keepDialog] = Main.sessionMode.createUnlockDialog(this._lockDialogGroup);
this._dialog.connect('unlocked', Lang.bind(this, this._onUnlockSucceded)); if (!this._dialog) {
// This session mode has no locking capabilities
this.unlock();
return;
}
if (!this._dialog.open(global.get_current_time())) { this._dialog.connect('loaded', Lang.bind(this, function() {
log('Could not open unlock dialog: failed to acquire grab'); if (!this._dialog.open()) {
log('Could not open login dialog: failed to acquire grab');
this.unlock();
}
}));
// and then? best we can do is to autounlock, although that's potentially this._dialog.connect('failed', Lang.bind(this, this._onUnlockFailed));
// a security issue this._dialog.connect('unlocked', Lang.bind(this, this._onUnlockSucceded));
this._onUnlockSucceded(); }
if (this._keepDialog) {
// Notify the other components that even though we are showing the
// screenshield, we're not in a locked state
// (this happens for the gdm greeter)
this._isLocked = false;
this.emit('lock-status-changed', false);
} }
}, },
@ -227,6 +250,14 @@ const ScreenShield = new Lang.Class({
}, },
unlock: function() { unlock: function() {
if (this._keepDialog) {
// The dialog must be kept alive,
// so immediately go back to it
// This will also reset _isLocked
this._showUnlockDialog(false);
return;
}
if (this._dialog) { if (this._dialog) {
this._dialog.destroy(); this._dialog.destroy();
this._dialog = null; this._dialog = null;

View File

@ -39,6 +39,7 @@ const _modes = {
hasRunDialog: false, hasRunDialog: false,
hasWorkspaces: false, hasWorkspaces: false,
createSession: Main.createGDMSession, createSession: Main.createGDMSession,
createUnlockDialog: Main.createGDMLoginDialog,
extraStylesheet: null, extraStylesheet: null,
statusArea: { statusArea: {
order: [ order: [
@ -86,6 +87,7 @@ const _modes = {
hasRunDialog: true, hasRunDialog: true,
hasWorkspaces: true, hasWorkspaces: true,
createSession: Main.createUserSession, createSession: Main.createUserSession,
createUnlockDialog: Main.createSessionUnlockDialog,
extraStylesheet: null, extraStylesheet: null,
statusArea: { statusArea: {
order: [ order: [
@ -113,6 +115,8 @@ const SessionMode = new Lang.Class({
this._createSession = params.createSession; this._createSession = params.createSession;
delete params.createSession; delete params.createSession;
this._createUnlockDialog = params.createUnlockDialog;
delete params.createUnlockDialog;
Lang.copyProperties(params, this); Lang.copyProperties(params, this);
}, },
@ -120,5 +124,12 @@ const SessionMode = new Lang.Class({
createSession: function() { createSession: function() {
if (this._createSession) if (this._createSession)
this._createSession(); this._createSession();
} },
createUnlockDialog: function() {
if (this._createUnlockDialog)
return this._createUnlockDialog.apply(this, arguments);
else
return null;
},
}); });

View File

@ -7,7 +7,6 @@ const Gio = imports.gi.Gio;
const GLib = imports.gi.GLib; const GLib = imports.gi.GLib;
const Gtk = imports.gi.Gtk; const Gtk = imports.gi.Gtk;
const Lang = imports.lang; const Lang = imports.lang;
const Mainloop = imports.mainloop;
const Signals = imports.signals; const Signals = imports.signals;
const Shell = imports.gi.Shell; const Shell = imports.gi.Shell;
const St = imports.gi.St; const St = imports.gi.St;
@ -152,6 +151,11 @@ const UnlockDialog = new Lang.Class({
this._updateOkButton(false); this._updateOkButton(false);
this._reset(); this._reset();
GLib.idle_add(GLib.PRIORITY_DEFAULT, Lang.bind(this, function() {
this.emit('loaded');
return false;
}));
}, },
_updateOkButton: function(sensitive) { _updateOkButton: function(sensitive) {