From d8fc37adc3107b55d87b1f1344417de5a51a94db Mon Sep 17 00:00:00 2001 From: Joan Torres Date: Wed, 7 Feb 2024 13:03:11 +0100 Subject: [PATCH] loginDialog: Add ConflictingSessionDialog This dialog will be used by the next commit when a session is being opened but there's already a conflicting session opened. Part-of: --- .../gnome-shell-sass/widgets/_login-lock.scss | 19 +++++ js/gdm/loginDialog.js | 71 +++++++++++++++++++ 2 files changed, 90 insertions(+) diff --git a/data/theme/gnome-shell-sass/widgets/_login-lock.scss b/data/theme/gnome-shell-sass/widgets/_login-lock.scss index 87ed1cad9..52441a5c1 100644 --- a/data/theme/gnome-shell-sass/widgets/_login-lock.scss +++ b/data/theme/gnome-shell-sass/widgets/_login-lock.scss @@ -45,6 +45,25 @@ $_gdm_dialog_width: 25em; spacing: $base_padding * 2; } +.conflicting-session-dialog-content { + spacing: 20px; + + .conflicting-session-dialog-title { + text-align: center; + @extend %title_2; + margin-bottom: 5px; + } + + .conflicting-session-dialog-desc { + text-align: center; + } + + .conflicting-session-dialog-desc-warning { + text-align: center; + color: $warning_color; + } +} + .login-dialog-logo-bin { margin: 3em 0; } diff --git a/js/gdm/loginDialog.js b/js/gdm/loginDialog.js index f97811299..09b68b42f 100644 --- a/js/gdm/loginDialog.js +++ b/js/gdm/loginDialog.js @@ -36,6 +36,7 @@ import * as GdmUtil from './util.js'; import * as Layout from '../ui/layout.js'; import * as LoginManager from '../misc/loginManager.js'; import * as Main from '../ui/main.js'; +import * as ModalDialog from '../ui/modalDialog.js'; import * as PopupMenu from '../ui/popupMenu.js'; import * as Realmd from './realmd.js'; import * as UserWidget from '../ui/userWidget.js'; @@ -406,6 +407,76 @@ const SessionMenuButton = GObject.registerClass({ } }); +export const ConflictingSessionDialog = GObject.registerClass({ + Signals: { + 'cancel': {}, + 'force-stop': {}, + }, +}, class ConflictingSessionDialog extends ModalDialog.ModalDialog { + _init(conflictingSession, greeterSession, userName) { + super._init(); + + let bannerText; + if (greeterSession.Remote && conflictingSession.Remote) + /* Translators: is running for */ + bannerText = _('Remote login is not possible because a remote session is already running for %s. To login remotely, you must log out from the remote session or force stop it.').format(userName); + else if (!greeterSession.Remote && conflictingSession.Remote) + /* Translators: is running for */ + bannerText = _('Login is not possible because a remote session is already running for %s. To login, you must log out from the remote session or force stop it.').format(userName); + else if (greeterSession.Remote && !conflictingSession.Remote) + /* Translators: is running for */ + bannerText = _('Remote login is not possible because a local session is already running for %s. To login remotely, you must log out from the local session or force stop it.').format(userName); + else + /* Translators: is running for */ + bannerText = _('Login is not possible because a session is already running for %s. To login, you must log out from the session or force stop it.').format(userName); + + let textLayout = new St.BoxLayout({ + style_class: 'conflicting-session-dialog-content', + vertical: true, + x_expand: true, + }); + + let title = new St.Label({ + text: _('Session Already Running'), + style_class: 'conflicting-session-dialog-title', + }); + + let banner = new St.Label({ + text: bannerText, + style_class: 'conflicting-session-dialog-desc', + }); + banner.clutter_text.ellipsize = Pango.EllipsizeMode.NONE; + banner.clutter_text.line_wrap = true; + + let warningBanner = new St.Label({ + text: _('Force stopping will quit any running apps and processes, and could result in data loss.'), + style_class: 'conflicting-session-dialog-desc-warning', + }); + warningBanner.clutter_text.ellipsize = Pango.EllipsizeMode.NONE; + warningBanner.clutter_text.line_wrap = true; + + textLayout.add_child(title); + textLayout.add_child(banner); + textLayout.add_child(warningBanner); + this.contentLayout.add_child(textLayout); + + this.addButton({ + label: _('Cancel'), + action: () => { + this.emit('cancel'); + }, + key: Clutter.KEY_Escape, + default: true, + }); + this.addButton({ + label: _('Force Stop'), + action: () => { + this.emit('force-stop'); + }, + }); + } +}); + export const LoginDialog = GObject.registerClass({ Signals: { 'failed': {},