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
This commit is contained in:
Giovanni Campagna 2011-11-20 16:32:59 +01:00
parent b356aa8e3b
commit 987099ea55
7 changed files with 41 additions and 67 deletions

View File

@ -750,12 +750,12 @@ function LoginDialog() {
return _loginDialog; return _loginDialog;
} }
LoginDialog.prototype = { const LoginDialog = new Lang.Class({
__proto__: ModalDialog.ModalDialog.prototype, Name: 'LoginDialog',
Extends: ModalDialog.ModalDialog,
_init: function() { _init: function() {
ModalDialog.ModalDialog.prototype._init.call(this, { shellReactive: true, this.parent({ shellReactive: true, styleClass: 'login-dialog' });
styleClass: 'login-dialog' });
this.connect('destroy', this.connect('destroy',
Lang.bind(this, this._onDestroy)); Lang.bind(this, this._onDestroy));
this.connect('opened', this.connect('opened',
@ -1399,8 +1399,8 @@ LoginDialog.prototype = {
}, },
close: function() { close: function() {
ModalDialog.ModalDialog.prototype.close.call(this); this.parent();
Main.ctrlAltTabManager.removeGroup(this._group); Main.ctrlAltTabManager.removeGroup(this._group);
} }
}; });

View File

@ -230,27 +230,19 @@ function _setLabelText(label, text) {
} }
} }
function EndSessionDialog() {
if (_endSessionDialog == null) {
this._init();
_endSessionDialog = this;
}
return _endSessionDialog;
}
function init() { function init() {
// This always returns the same singleton object // This always returns the same singleton object
// By instantiating it initially, we register the // By instantiating it initially, we register the
// bus object, etc. // bus object, etc.
let dialog = new EndSessionDialog(); _endSessionDialog = new EndSessionDialog();
} }
EndSessionDialog.prototype = { const EndSessionDialog = new Lang.Class({
__proto__: ModalDialog.ModalDialog.prototype, Name: 'EndSessionDialog',
Extends: ModalDialog.ModalDialog,
_init: function() { _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()); this._user = AccountsService.UserManager.get_default().get_user(GLib.get_user_name());
@ -441,7 +433,7 @@ EndSessionDialog.prototype = {
}, },
close: function() { close: function() {
ModalDialog.ModalDialog.prototype.close.call(this); this.parent();
this._dbusImpl.emit_signal('Closed', null); this._dbusImpl.emit_signal('Closed', null);
}, },
@ -543,4 +535,4 @@ EndSessionDialog.prototype = {
this.disconnect(signalId); this.disconnect(signalId);
})); }));
} }
}; });

View File

@ -502,15 +502,12 @@ function loadExtensions() {
_loadExtensionsIn(userExtensionsDir, ExtensionType.PER_USER); _loadExtensionsIn(userExtensionsDir, ExtensionType.PER_USER);
} }
function InstallExtensionDialog(uuid, version_tag, name) { const InstallExtensionDialog = new Lang.Class({
this._init(uuid, version_tag, name); Name: 'InstallExtensionDialog',
} Extends: ModalDialog.ModalDialog,
InstallExtensionDialog.prototype = {
__proto__: ModalDialog.ModalDialog.prototype,
_init: function(uuid, version_tag, name) { _init: function(uuid, version_tag, name) {
ModalDialog.ModalDialog.prototype._init.call(this, { styleClass: 'extension-dialog' }); this.parent({ styleClass: 'extension-dialog' });
this._uuid = uuid; this._uuid = uuid;
this._version_tag = version_tag; this._version_tag = version_tag;
@ -570,4 +567,4 @@ InstallExtensionDialog.prototype = {
this.close(global.get_current_time()); this.close(global.get_current_time());
} }
}; });

View File

@ -29,11 +29,9 @@ const State = {
FADED_OUT: 4 FADED_OUT: 4
}; };
function ModalDialog() { const ModalDialog = new Lang.Class({
this._init(); Name: 'ModalDialog',
}
ModalDialog.prototype = {
_init: function(params) { _init: function(params) {
params = Params.parse(params, { shellReactive: false, params = Params.parse(params, { shellReactive: false,
styleClass: null }); styleClass: null });
@ -303,5 +301,5 @@ ModalDialog.prototype = {
}) })
}); });
} }
}; });
Signals.addSignalMethods(ModalDialog.prototype); Signals.addSignalMethods(ModalDialog.prototype);

View File

@ -32,15 +32,12 @@ const ModalDialog = imports.ui.modalDialog;
const PopupMenu = imports.ui.popupMenu; const PopupMenu = imports.ui.popupMenu;
const ShellEntry = imports.ui.shellEntry; const ShellEntry = imports.ui.shellEntry;
function NetworkSecretDialog() { const NetworkSecretDialog = new Lang.Class({
this._init.apply(this, arguments); Name: 'NetworkSecretDialog',
} Extends: ModalDialog.ModalDialog,
NetworkSecretDialog.prototype = {
__proto__: ModalDialog.ModalDialog.prototype,
_init: function(agent, requestId, connection, settingName, hints) { _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._agent = agent;
this._requestId = requestId; this._requestId = requestId;
@ -358,7 +355,7 @@ NetworkSecretDialog.prototype = {
return content; return content;
} }
}; });
function NetworkAgent() { function NetworkAgent() {
this._init.apply(this, arguments); this._init.apply(this, arguments);

View File

@ -36,15 +36,12 @@ const PolkitAgent = imports.gi.PolkitAgent;
const ModalDialog = imports.ui.modalDialog; const ModalDialog = imports.ui.modalDialog;
const ShellEntry = imports.ui.shellEntry; const ShellEntry = imports.ui.shellEntry;
function AuthenticationDialog(actionId, message, cookie, userNames) { const AuthenticationDialog = new Lang.Class({
this._init(actionId, message, cookie, userNames); Name: 'AuthenticationDialog',
} Extends: ModalDialog.ModalDialog,
AuthenticationDialog.prototype = {
__proto__: ModalDialog.ModalDialog.prototype,
_init: function(actionId, message, cookie, userNames) { _init: function(actionId, message, cookie, userNames) {
ModalDialog.ModalDialog.prototype._init.call(this, { styleClass: 'polkit-dialog' }); this.parent({ styleClass: 'polkit-dialog' });
this.actionId = actionId; this.actionId = actionId;
this.message = message; this.message = message;
@ -335,8 +332,7 @@ AuthenticationDialog.prototype = {
this.close(global.get_current_time()); this.close(global.get_current_time());
this._emitDone(false, true); this._emitDone(false, true);
}, },
});
};
Signals.addSignalMethods(AuthenticationDialog.prototype); Signals.addSignalMethods(AuthenticationDialog.prototype);
function AuthenticationAgent() { function AuthenticationAgent() {

View File

@ -192,15 +192,12 @@ ShellMountOperation.prototype = {
}, },
} }
function ShellMountQuestionDialog(icon) { const ShellMountQuestionDialog = new Lang.Class({
this._init(icon); Name: 'ShellMountQuestionDialog',
} Extends: ModalDialog.ModalDialog,
ShellMountQuestionDialog.prototype = {
__proto__: ModalDialog.ModalDialog.prototype,
_init: function(icon) { _init: function(icon) {
ModalDialog.ModalDialog.prototype._init.call(this, { styleClass: 'mount-question-dialog' }); this.parent({ styleClass: 'mount-question-dialog' });
let mainContentLayout = new St.BoxLayout(); let mainContentLayout = new St.BoxLayout();
this.contentLayout.add(mainContentLayout, { x_fill: true, this.contentLayout.add(mainContentLayout, { x_fill: true,
@ -236,7 +233,7 @@ ShellMountQuestionDialog.prototype = {
_setLabelsForMessage(this, message); _setLabelsForMessage(this, message);
_setButtonsForChoices(this, choices); _setButtonsForChoices(this, choices);
} }
} });
Signals.addSignalMethods(ShellMountQuestionDialog.prototype); Signals.addSignalMethods(ShellMountQuestionDialog.prototype);
const ShellMountPasswordSource = new Lang.Class({ const ShellMountPasswordSource = new Lang.Class({
@ -298,15 +295,12 @@ const ShellMountPasswordNotification = new Lang.Class({
} }
}); });
function ShellProcessesDialog(icon) { const ShellProcessesDialog = new Lang.Class({
this._init(icon); Name: 'ShellProcessesDialog',
} Extends: ModalDialog.ModalDialog,
ShellProcessesDialog.prototype = {
__proto__: ModalDialog.ModalDialog.prototype,
_init: function(icon) { _init: function(icon) {
ModalDialog.ModalDialog.prototype._init.call(this, { styleClass: 'show-processes-dialog' }); this.parent({ styleClass: 'show-processes-dialog' });
let mainContentLayout = new St.BoxLayout(); let mainContentLayout = new St.BoxLayout();
this.contentLayout.add(mainContentLayout, { x_fill: true, this.contentLayout.add(mainContentLayout, { x_fill: true,
@ -392,5 +386,5 @@ ShellProcessesDialog.prototype = {
_setLabelsForMessage(this, message); _setLabelsForMessage(this, message);
_setButtonsForChoices(this, choices); _setButtonsForChoices(this, choices);
} }
} });
Signals.addSignalMethods(ShellProcessesDialog.prototype); Signals.addSignalMethods(ShellProcessesDialog.prototype);