[gnome-shell] ModalDialog: add 'default' pseudo-class to default button



commit 8970e17911f767f19d3948c1d5765c6f9cd77596
Author: Giovanni Campagna <gcampagna src gnome org>
Date:   Thu Jul 19 15:32:59 2012 +0200

    ModalDialog: add 'default' pseudo-class to default button
    
    Add 'default' parameter to setButtons, that controls the binding
    of Return (unless overridden) and applies the 'default' pseudo-class.
    Currently it has no effect, but it will start having after the
    login dialog redesign.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=619955

 js/gdm/loginDialog.js              |    3 ++-
 js/ui/extensionDownloader.js       |    3 ++-
 js/ui/keyringPrompt.js             |    3 ++-
 js/ui/modalDialog.js               |    6 ++++++
 js/ui/networkAgent.js              |    2 +-
 js/ui/polkitAuthenticationAgent.js |    3 ++-
 js/ui/shellMountOperation.js       |    3 ++-
 7 files changed, 17 insertions(+), 6 deletions(-)
---
diff --git a/js/gdm/loginDialog.js b/js/gdm/loginDialog.js
index 7fb8aee..33307dd 100644
--- a/js/gdm/loginDialog.js
+++ b/js/gdm/loginDialog.js
@@ -998,7 +998,8 @@ const LoginDialog = new Lang.Class({
                        { action: Lang.bind(this, function() {
                                      hold.release();
                                  }),
-                         label: C_("button", "Sign In") }];
+                         label: C_("button", "Sign In"),
+                         default: true }];
 
         this._promptEntryActivateCallbackId = this._promptEntry.clutter_text.connect('activate',
                                                                                      Lang.bind(this, function() {
diff --git a/js/ui/extensionDownloader.js b/js/ui/extensionDownloader.js
index 83f8a36..72e1177 100644
--- a/js/ui/extensionDownloader.js
+++ b/js/ui/extensionDownloader.js
@@ -197,7 +197,8 @@ const InstallExtensionDialog = new Lang.Class({
                            key:    Clutter.Escape
                          },
                          { label:  _("Install"),
-                           action: Lang.bind(this, this._onInstallButtonPressed)
+                           action: Lang.bind(this, this._onInstallButtonPressed),
+                           default: true
                          }]);
 
         let message = _("Download and install '%s' from extensions.gnome.org?").format(info.name);
diff --git a/js/ui/keyringPrompt.js b/js/ui/keyringPrompt.js
index 9116326..da26d2a 100644
--- a/js/ui/keyringPrompt.js
+++ b/js/ui/keyringPrompt.js
@@ -65,7 +65,8 @@ const KeyringDialog = new Lang.Class({
                          key:    Clutter.Escape
                        },
                        { label: '',
-                         action: Lang.bind(this, this._onContinueButton)
+                         action: Lang.bind(this, this._onContinueButton),
+                         default: true
                        }]
 
         this.setButtons(buttons);
diff --git a/js/ui/modalDialog.js b/js/ui/modalDialog.js
index e30b705..bdeee73 100644
--- a/js/ui/modalDialog.js
+++ b/js/ui/modalDialog.js
@@ -119,11 +119,17 @@ const ModalDialog = new Lang.Class({
             let label = buttonInfo['label'];
             let action = buttonInfo['action'];
             let key = buttonInfo['key'];
+            let isDefault = buttonInfo['default'];
+
+            if (isDefault && !key)
+                key = Clutter.KEY_Return;
 
             buttonInfo.button = new St.Button({ style_class: 'modal-dialog-button',
                                                 reactive:    true,
                                                 can_focus:   true,
                                                 label:       label });
+            if (isDefault)
+                buttonInfo.button.add_style_pseudo_class('default');
 
             let x_alignment;
             if (buttons.length == 1)
diff --git a/js/ui/networkAgent.js b/js/ui/networkAgent.js
index 0615a90..8435a09 100644
--- a/js/ui/networkAgent.js
+++ b/js/ui/networkAgent.js
@@ -147,7 +147,7 @@ const NetworkSecretDialog = new Lang.Class({
 
         this._okButton = { label:  _("Connect"),
                            action: Lang.bind(this, this._onOk),
-                           key:    Clutter.KEY_Return,
+                           default: true
                          };
 
         this.setButtons([{ label: _("Cancel"),
diff --git a/js/ui/polkitAuthenticationAgent.js b/js/ui/polkitAuthenticationAgent.js
index 152c11f..982b0f8 100644
--- a/js/ui/polkitAuthenticationAgent.js
+++ b/js/ui/polkitAuthenticationAgent.js
@@ -178,7 +178,8 @@ const AuthenticationDialog = new Lang.Class({
                            key:    Clutter.Escape
                          },
                          { label:  _("Authenticate"),
-                           action: Lang.bind(this, this._onAuthenticateButtonPressed)
+                           action: Lang.bind(this, this._onAuthenticateButtonPressed),
+                           default: true
                          }]);
 
         this._doneEmitted = false;
diff --git a/js/ui/shellMountOperation.js b/js/ui/shellMountOperation.js
index f524a13..a8f7064 100644
--- a/js/ui/shellMountOperation.js
+++ b/js/ui/shellMountOperation.js
@@ -398,7 +398,8 @@ const ShellMountPasswordDialog = new Lang.Class({
                          key:    Clutter.Escape
                        },
                        { label: _("Unlock"),
-                         action: Lang.bind(this, this._onUnlockButton)
+                         action: Lang.bind(this, this._onUnlockButton),
+                         default: true
                        }];
 
         this.setButtons(buttons);



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