From 987099ea55156002939d8f3acad1ada2a684a657 Mon Sep 17 00:00:00 2001 From: Giovanni Campagna Date: Sun, 20 Nov 2011 16:32:59 +0100 Subject: [PATCH] Port ModalDialog to the class framework Similar to the previous commits, time to port shell modal dialogs to the class framework. https://bugzilla.gnome.org/show_bug.cgi?id=664436 --- js/gdm/loginDialog.js | 12 ++++++------ js/ui/endSessionDialog.js | 22 +++++++--------------- js/ui/extensionSystem.js | 13 +++++-------- js/ui/modalDialog.js | 8 +++----- js/ui/networkAgent.js | 13 +++++-------- js/ui/polkitAuthenticationAgent.js | 14 +++++--------- js/ui/shellMountOperation.js | 26 ++++++++++---------------- 7 files changed, 41 insertions(+), 67 deletions(-) diff --git a/js/gdm/loginDialog.js b/js/gdm/loginDialog.js index b3afa343a..810920617 100644 --- a/js/gdm/loginDialog.js +++ b/js/gdm/loginDialog.js @@ -750,12 +750,12 @@ function LoginDialog() { return _loginDialog; } -LoginDialog.prototype = { - __proto__: ModalDialog.ModalDialog.prototype, +const LoginDialog = new Lang.Class({ + Name: 'LoginDialog', + Extends: ModalDialog.ModalDialog, _init: function() { - ModalDialog.ModalDialog.prototype._init.call(this, { shellReactive: true, - styleClass: 'login-dialog' }); + this.parent({ shellReactive: true, styleClass: 'login-dialog' }); this.connect('destroy', Lang.bind(this, this._onDestroy)); this.connect('opened', @@ -1399,8 +1399,8 @@ LoginDialog.prototype = { }, close: function() { - ModalDialog.ModalDialog.prototype.close.call(this); + this.parent(); Main.ctrlAltTabManager.removeGroup(this._group); } -}; +}); diff --git a/js/ui/endSessionDialog.js b/js/ui/endSessionDialog.js index 4650097a3..947524a76 100644 --- a/js/ui/endSessionDialog.js +++ b/js/ui/endSessionDialog.js @@ -230,27 +230,19 @@ function _setLabelText(label, text) { } } -function EndSessionDialog() { - if (_endSessionDialog == null) { - this._init(); - _endSessionDialog = this; - } - - return _endSessionDialog; -} - function init() { // This always returns the same singleton object // By instantiating it initially, we register the // bus object, etc. - let dialog = new EndSessionDialog(); + _endSessionDialog = new EndSessionDialog(); } -EndSessionDialog.prototype = { - __proto__: ModalDialog.ModalDialog.prototype, +const EndSessionDialog = new Lang.Class({ + Name: 'EndSessionDialog', + Extends: ModalDialog.ModalDialog, _init: function() { - ModalDialog.ModalDialog.prototype._init.call(this, { styleClass: 'end-session-dialog' }); + this.parent({ styleClass: 'end-session-dialog' }); this._user = AccountsService.UserManager.get_default().get_user(GLib.get_user_name()); @@ -441,7 +433,7 @@ EndSessionDialog.prototype = { }, close: function() { - ModalDialog.ModalDialog.prototype.close.call(this); + this.parent(); this._dbusImpl.emit_signal('Closed', null); }, @@ -543,4 +535,4 @@ EndSessionDialog.prototype = { this.disconnect(signalId); })); } -}; +}); diff --git a/js/ui/extensionSystem.js b/js/ui/extensionSystem.js index a1fdbdefe..a0302fe02 100644 --- a/js/ui/extensionSystem.js +++ b/js/ui/extensionSystem.js @@ -502,15 +502,12 @@ function loadExtensions() { _loadExtensionsIn(userExtensionsDir, ExtensionType.PER_USER); } -function InstallExtensionDialog(uuid, version_tag, name) { - this._init(uuid, version_tag, name); -} - -InstallExtensionDialog.prototype = { - __proto__: ModalDialog.ModalDialog.prototype, +const InstallExtensionDialog = new Lang.Class({ + Name: 'InstallExtensionDialog', + Extends: ModalDialog.ModalDialog, _init: function(uuid, version_tag, name) { - ModalDialog.ModalDialog.prototype._init.call(this, { styleClass: 'extension-dialog' }); + this.parent({ styleClass: 'extension-dialog' }); this._uuid = uuid; this._version_tag = version_tag; @@ -570,4 +567,4 @@ InstallExtensionDialog.prototype = { this.close(global.get_current_time()); } -}; +}); diff --git a/js/ui/modalDialog.js b/js/ui/modalDialog.js index c2f3b3982..a6479595e 100644 --- a/js/ui/modalDialog.js +++ b/js/ui/modalDialog.js @@ -29,11 +29,9 @@ const State = { FADED_OUT: 4 }; -function ModalDialog() { - this._init(); -} +const ModalDialog = new Lang.Class({ + Name: 'ModalDialog', -ModalDialog.prototype = { _init: function(params) { params = Params.parse(params, { shellReactive: false, styleClass: null }); @@ -303,5 +301,5 @@ ModalDialog.prototype = { }) }); } -}; +}); Signals.addSignalMethods(ModalDialog.prototype); diff --git a/js/ui/networkAgent.js b/js/ui/networkAgent.js index dbb3ed762..276f1403c 100644 --- a/js/ui/networkAgent.js +++ b/js/ui/networkAgent.js @@ -32,15 +32,12 @@ const ModalDialog = imports.ui.modalDialog; const PopupMenu = imports.ui.popupMenu; const ShellEntry = imports.ui.shellEntry; -function NetworkSecretDialog() { - this._init.apply(this, arguments); -} - -NetworkSecretDialog.prototype = { - __proto__: ModalDialog.ModalDialog.prototype, +const NetworkSecretDialog = new Lang.Class({ + Name: 'NetworkSecretDialog', + Extends: ModalDialog.ModalDialog, _init: function(agent, requestId, connection, settingName, hints) { - ModalDialog.ModalDialog.prototype._init.call(this, { styleClass: 'polkit-dialog' }); + this.parent({ styleClass: 'polkit-dialog' }); this._agent = agent; this._requestId = requestId; @@ -358,7 +355,7 @@ NetworkSecretDialog.prototype = { return content; } -}; +}); function NetworkAgent() { this._init.apply(this, arguments); diff --git a/js/ui/polkitAuthenticationAgent.js b/js/ui/polkitAuthenticationAgent.js index 6f0103975..7fe03105b 100644 --- a/js/ui/polkitAuthenticationAgent.js +++ b/js/ui/polkitAuthenticationAgent.js @@ -36,15 +36,12 @@ const PolkitAgent = imports.gi.PolkitAgent; const ModalDialog = imports.ui.modalDialog; const ShellEntry = imports.ui.shellEntry; -function AuthenticationDialog(actionId, message, cookie, userNames) { - this._init(actionId, message, cookie, userNames); -} - -AuthenticationDialog.prototype = { - __proto__: ModalDialog.ModalDialog.prototype, +const AuthenticationDialog = new Lang.Class({ + Name: 'AuthenticationDialog', + Extends: ModalDialog.ModalDialog, _init: function(actionId, message, cookie, userNames) { - ModalDialog.ModalDialog.prototype._init.call(this, { styleClass: 'polkit-dialog' }); + this.parent({ styleClass: 'polkit-dialog' }); this.actionId = actionId; this.message = message; @@ -335,8 +332,7 @@ AuthenticationDialog.prototype = { this.close(global.get_current_time()); this._emitDone(false, true); }, - -}; +}); Signals.addSignalMethods(AuthenticationDialog.prototype); function AuthenticationAgent() { diff --git a/js/ui/shellMountOperation.js b/js/ui/shellMountOperation.js index 439be580b..ba5f45e41 100644 --- a/js/ui/shellMountOperation.js +++ b/js/ui/shellMountOperation.js @@ -192,15 +192,12 @@ ShellMountOperation.prototype = { }, } -function ShellMountQuestionDialog(icon) { - this._init(icon); -} - -ShellMountQuestionDialog.prototype = { - __proto__: ModalDialog.ModalDialog.prototype, +const ShellMountQuestionDialog = new Lang.Class({ + Name: 'ShellMountQuestionDialog', + Extends: ModalDialog.ModalDialog, _init: function(icon) { - ModalDialog.ModalDialog.prototype._init.call(this, { styleClass: 'mount-question-dialog' }); + this.parent({ styleClass: 'mount-question-dialog' }); let mainContentLayout = new St.BoxLayout(); this.contentLayout.add(mainContentLayout, { x_fill: true, @@ -236,7 +233,7 @@ ShellMountQuestionDialog.prototype = { _setLabelsForMessage(this, message); _setButtonsForChoices(this, choices); } -} +}); Signals.addSignalMethods(ShellMountQuestionDialog.prototype); const ShellMountPasswordSource = new Lang.Class({ @@ -298,15 +295,12 @@ const ShellMountPasswordNotification = new Lang.Class({ } }); -function ShellProcessesDialog(icon) { - this._init(icon); -} - -ShellProcessesDialog.prototype = { - __proto__: ModalDialog.ModalDialog.prototype, +const ShellProcessesDialog = new Lang.Class({ + Name: 'ShellProcessesDialog', + Extends: ModalDialog.ModalDialog, _init: function(icon) { - ModalDialog.ModalDialog.prototype._init.call(this, { styleClass: 'show-processes-dialog' }); + this.parent({ styleClass: 'show-processes-dialog' }); let mainContentLayout = new St.BoxLayout(); this.contentLayout.add(mainContentLayout, { x_fill: true, @@ -392,5 +386,5 @@ ShellProcessesDialog.prototype = { _setLabelsForMessage(this, message); _setButtonsForChoices(this, choices); } -} +}); Signals.addSignalMethods(ShellProcessesDialog.prototype);