From 856c32db919560a68b9aa3a7d2e21444ce9400aa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Florian=20M=C3=BCllner?= Date: Fri, 20 Sep 2019 13:17:40 +0200 Subject: [PATCH] unlockDialog: Use inheritance instead of composition The screen shield creates the unlock dialog based on the session mode. However since commit 0c0d76f7d6990 turned LoginDialog into an actor subclass (while UnlockDialog kept using the delegate pattern), it is no longer possible to handle both objects the same way without warnings. Allow this again by turning UnlockDialog into an actor subclass as well. https://gitlab.gnome.org/GNOME/gnome-shell/merge_requests/736 --- js/ui/unlockDialog.js | 46 ++++++++++++++++++++++++------------------- 1 file changed, 26 insertions(+), 20 deletions(-) diff --git a/js/ui/unlockDialog.js b/js/ui/unlockDialog.js index 08dbfdd06..5af1b4823 100644 --- a/js/ui/unlockDialog.js +++ b/js/ui/unlockDialog.js @@ -2,8 +2,7 @@ /* exported UnlockDialog */ const { AccountsService, Atk, Clutter, - Gdm, Gio, GLib, Meta, Shell, St } = imports.gi; -const Signals = imports.signals; + Gdm, Gio, GLib, GObject, Meta, Shell, St } = imports.gi; const Layout = imports.ui.layout; const Main = imports.ui.main; @@ -13,15 +12,19 @@ const AuthPrompt = imports.gdm.authPrompt; // The timeout before going back automatically to the lock screen (in seconds) const IDLE_TIMEOUT = 2 * 60; -var UnlockDialog = class { - constructor(parentActor) { - this.actor = new St.Widget({ accessible_role: Atk.Role.WINDOW, - style_class: 'login-dialog', - layout_manager: new Clutter.BoxLayout(), - visible: false }); +var UnlockDialog = GObject.registerClass({ + Signals: { 'failed': {} }, +}, class UnlockDialog extends St.Widget { + _init(parentActor) { + super._init({ + accessible_role: Atk.Role.WINDOW, + style_class: 'login-dialog', + layout_manager: new Clutter.BoxLayout(), + visible: false, + }); - this.actor.add_constraint(new Layout.MonitorConstraint({ primary: true })); - parentActor.add_child(this.actor); + this.add_constraint(new Layout.MonitorConstraint({ primary: true })); + parentActor.add_child(this); this._userManager = AccountsService.UserManager.get_default(); this._userName = GLib.get_user_name(); @@ -32,7 +35,7 @@ var UnlockDialog = class { y_align: Clutter.ActorAlign.CENTER, x_expand: true, y_expand: true }); - this.actor.add_child(this._promptBox); + this.add_child(this._promptBox); this._authPrompt = new AuthPrompt.AuthPrompt(new Gdm.Client(), AuthPrompt.AuthPromptMode.UNLOCK_ONLY); this._authPrompt.connect('failed', this._fail.bind(this)); @@ -64,10 +67,12 @@ var UnlockDialog = class { this._authPrompt.reset(); this._updateSensitivity(true); - Main.ctrlAltTabManager.addGroup(this.actor, _("Unlock Window"), 'dialog-password-symbolic'); + Main.ctrlAltTabManager.addGroup(this, _("Unlock Window"), 'dialog-password-symbolic'); this._idleMonitor = Meta.IdleMonitor.get_core(); this._idleWatchId = this._idleMonitor.add_idle_watch(IDLE_TIMEOUT * 1000, this._escape.bind(this)); + + this.connect('destroy', this._onDestroy.bind(this)); } _updateSensitivity(sensitive) { @@ -106,9 +111,8 @@ var UnlockDialog = class { this._authPrompt.cancel(); } - destroy() { + _onDestroy() { this.popModal(); - this.actor.destroy(); if (this._idleWatchId) { this._idleMonitor.remove_watch(this._idleWatchId); @@ -131,13 +135,16 @@ var UnlockDialog = class { } open(timestamp) { - this.actor.show(); + this.show(); if (this._isModal) return true; - if (!Main.pushModal(this.actor, { timestamp: timestamp, - actionMode: Shell.ActionMode.UNLOCK_SCREEN })) + let modalParams = { + timestamp, + actionMode: Shell.ActionMode.UNLOCK_SCREEN, + }; + if (!Main.pushModal(this, modalParams)) return false; this._isModal = true; @@ -147,9 +154,8 @@ var UnlockDialog = class { popModal(timestamp) { if (this._isModal) { - Main.popModal(this.actor, timestamp); + Main.popModal(this, timestamp); this._isModal = false; } } -}; -Signals.addSignalMethods(UnlockDialog.prototype); +});