Florian Müllner 66fca8f
From 5f81215e9771b14be1562d82f54db3fdb92521e3 Mon Sep 17 00:00:00 2001
22f01e4
From: Hans de Goede <hdegoede@redhat.com>
22f01e4
Date: Wed, 15 Aug 2018 14:26:19 +0200
22f01e4
Subject: [PATCH 1/2] endSessionDialog: Immediately add buttons to the dialog
22f01e4
22f01e4
Immediately add buttons to the dialog instead of first building an
22f01e4
array of button-info structs.
22f01e4
22f01e4
This is a preparation patch for adding support changing the "Reboot"
22f01e4
button into a "Boot Options" button when Alt is pressed.
22f01e4
---
Florian Müllner 66fca8f
 js/ui/endSessionDialog.js | 28 +++++++++++++++-------------
Florian Müllner 66fca8f
 1 file changed, 15 insertions(+), 13 deletions(-)
22f01e4
22f01e4
diff --git a/js/ui/endSessionDialog.js b/js/ui/endSessionDialog.js
Florian Müllner 66fca8f
index 0b475b6f9..301d8c9bf 100644
22f01e4
--- a/js/ui/endSessionDialog.js
22f01e4
+++ b/js/ui/endSessionDialog.js
Florian Müllner 66fca8f
@@ -440,25 +440,27 @@ class EndSessionDialog extends ModalDialog.ModalDialog {
Florian Müllner ccbb314
     }
22f01e4
 
22f01e4
     _updateButtons() {
22f01e4
-        let dialogContent = DialogContent[this._type];
22f01e4
-        let buttons = [{ action: this.cancel.bind(this),
22f01e4
+        this.clearButtons();
22f01e4
+
22f01e4
+        this.addButton({ action: this.cancel.bind(this),
Florian Müllner 108bb2b
                          label: _("Cancel"),
Florian Müllner 108bb2b
-                         key: Clutter.Escape }];
Florian Müllner 108bb2b
+                         key: Clutter.Escape });
22f01e4
 
22f01e4
+        let dialogContent = DialogContent[this._type];
22f01e4
         for (let i = 0; i < dialogContent.confirmButtons.length; i++) {
22f01e4
             let signal = dialogContent.confirmButtons[i].signal;
22f01e4
             let label = dialogContent.confirmButtons[i].label;
22f01e4
-            buttons.push({ action: () => {
Florian Müllner 66fca8f
-                               this.close(true);
Florian Müllner 66fca8f
-                               let signalId = this.connect('closed', () => {
Florian Müllner 66fca8f
-                                   this.disconnect(signalId);
Florian Müllner 66fca8f
-                                   this._confirm(signal);
Florian Müllner 66fca8f
-                               });
22f01e4
-                           },
22f01e4
-                           label: label });
Florian Müllner 66fca8f
+            let button = this.addButton({
Florian Müllner 66fca8f
+                action: () => {
Florian Müllner 66fca8f
+                    this.close(true);
Florian Müllner 66fca8f
+                    let signalId = this.connect('closed', () => {
Florian Müllner 66fca8f
+                        this.disconnect(signalId);
Florian Müllner 66fca8f
+                        this._confirm(signal);
Florian Müllner 66fca8f
+                    });
Florian Müllner 66fca8f
+                },
Florian Müllner 66fca8f
+                label
Florian Müllner 66fca8f
+            });
22f01e4
         }
22f01e4
-
22f01e4
-        this.setButtons(buttons);
Florian Müllner ccbb314
     }
22f01e4
 
22f01e4
     close(skipSignal) {
22f01e4
-- 
Florian Müllner 108bb2b
2.21.0
22f01e4