[gnome-shell] endSessionDialog: make shutdown dialog work like latest mock ups



commit dba02f8f08c7c0499d0c7e4869e95b4c58ea4c90
Author: Ray Strode <rstrode redhat com>
Date:   Mon Mar 21 16:12:30 2011 -0400

    endSessionDialog: make shutdown dialog work like latest mock ups
    
    This commit adds a restart button to the shutdown dialog and changes
    the terminology from Shut Down to Power Off.  This brings things in
    line with the latest mockups here:
    
    http://live.gnome.org/GnomeShell/Design/Whiteboards/SystemStopRestart
    
    https://bugzilla.gnome.org/show_bug.cgi?id=641375

 js/ui/endSessionDialog.js |   55 +++++++++++++++++++++++++++------------------
 1 files changed, 33 insertions(+), 22 deletions(-)
---
diff --git a/js/ui/endSessionDialog.js b/js/ui/endSessionDialog.js
index f221d7e..c019e2a 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");
-
-        if (dialogContent.confirmButtonText)
-            confirmButtonText = dialogContent.confirmButtonText;
-
-        this.setButtons([{ label: _("Cancel"),
-                           action: Lang.bind(this, this.cancel),
-                           key:    Clutter.Escape
-                         },
-                         { label:  confirmButtonText,
-                           action: Lang.bind(this, this._confirm)
-                         }]);
+        let buttons = [{ action: Lang.bind(this, this.cancel),
+                         label:  _("Cancel"),
+                         key:    Clutter.Escape }];
+
+        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(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);
+                                       }),
                          });
     },
 



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]