diff --git a/js/ui/endSessionDialog.js b/js/ui/endSessionDialog.js index f221d7e2c..c019e2aaa 100644 --- a/js/ui/endSessionDialog.js +++ b/js/ui/endSessionDialog.js @@ -66,16 +66,20 @@ const logoutDialogContent = { uninhibitedDescriptionWithUser: _("%s will be logged out automatically in %d seconds."), uninhibitedDescription: _("You will be logged out automatically in %d seconds."), endDescription: _("Logging out of the system."), - confirmButtonText: _("Log Out"), + confirmButtons: [{ signal: 'ConfirmedLogout', + label: _("Log Out") }], iconStyleClass: 'end-session-dialog-logout-icon' }; const shutdownDialogContent = { - subject: _("Shut Down"), - inhibitedDescription: _("Click Shut Down to quit these applications and shut down the system."), - uninhibitedDescription: _("The system will shut down automatically in %d seconds."), - endDescription: _("Shutting down the system."), - confirmButtonText: _("Shut Down"), + subject: _("Power Off"), + inhibitedDescription: _("Click Power Off to quit these applications and power off the system."), + uninhibitedDescription: _("The system will power off automatically in %d seconds."), + endDescription: _("Powering off the system."), + confirmButtons: [{ signal: 'ConfirmedReboot', + label: _("Restart") }, + { signal: 'ConfirmedShutdown', + label: _("Power Off") }], iconName: 'system-shutdown', iconStyleClass: 'end-session-dialog-shutdown-icon' }; @@ -85,7 +89,8 @@ const restartDialogContent = { inhibitedDescription: _("Click Restart to quit these applications and restart the system."), uninhibitedDescription: _("The system will restart automatically in %d seconds."), endDescription: _("Restarting the system."), - confirmButtonText: _("Restart"), + confirmButtons: [{ signal: 'ConfirmedReboot', + label: _("Restart") }], iconName: 'system-shutdown', iconStyleClass: 'end-session-dialog-shutdown-icon' }; @@ -406,18 +411,20 @@ EndSessionDialog.prototype = { return; let dialogContent = DialogContent[this._type]; - let confirmButtonText = _("Confirm"); + let buttons = [{ action: Lang.bind(this, this.cancel), + label: _("Cancel"), + key: Clutter.Escape }]; - if (dialogContent.confirmButtonText) - confirmButtonText = dialogContent.confirmButtonText; + for (let i = 0; i < dialogContent.confirmButtons.length; i++) { + let signal = dialogContent.confirmButtons[i].signal; + let label = dialogContent.confirmButtons[i].label; + buttons.push({ action: Lang.bind(this, function() { + this._confirm(signal); + }), + label: label }); + } - this.setButtons([{ label: _("Cancel"), - action: Lang.bind(this, this.cancel), - key: Clutter.Escape - }, - { label: confirmButtonText, - action: Lang.bind(this, this._confirm) - }]); + this.setButtons(buttons); }, close: function() { @@ -435,12 +442,12 @@ EndSessionDialog.prototype = { this.close(global.get_current_time()); }, - _confirm: function() { + _confirm: function(signal) { this._fadeOutDialog(); this._stopTimer(); DBus.session.emit_signal('/org/gnome/SessionManager/EndSessionDialog', 'org.gnome.SessionManager.EndSessionDialog', - 'Confirmed', '', []); + signal, '', []); }, _onOpened: function() { @@ -455,7 +462,11 @@ EndSessionDialog.prototype = { time: this._secondsLeft, transition: 'linear', onUpdate: Lang.bind(this, this._updateContent), - onComplete: Lang.bind(this, this._confirm), + onComplete: Lang.bind(this, function() { + let dialogContent = DialogContent[this._type]; + let button = dialogContent.confirmButtons[dialogContent.confirmButtons.length - 1]; + this._confirm(button.signal); + }), }); },