Blob Blame History Raw
From bbbe73b2a0293165f9bc9cc63b647b35914a4a05 Mon Sep 17 00:00:00 2001
From: Hans de Goede <hdegoede@redhat.com>
Date: Wed, 15 Aug 2018 14:26:19 +0200
Subject: [PATCH 1/2] endSessionDialog: Immediately add buttons to the dialog

Immediately add buttons to the dialog instead of first building an
array of button-info structs.

This is a preparation patch for adding support changing the "Reboot"
button into a "Boot Options" button when Alt is pressed.
---
 js/ui/endSessionDialog.js | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/js/ui/endSessionDialog.js b/js/ui/endSessionDialog.js
index e1c6517f4..4ce797527 100644
--- a/js/ui/endSessionDialog.js
+++ b/js/ui/endSessionDialog.js
@@ -441,15 +441,17 @@ class EndSessionDialog extends ModalDialog.ModalDialog {
     }
 
     _updateButtons() {
-        let dialogContent = DialogContent[this._type];
-        let buttons = [{ action: this.cancel.bind(this),
+        this.clearButtons();
+
+        this.addButton({ action: this.cancel.bind(this),
                          label: _("Cancel"),
-                         key: Clutter.Escape }];
+                         key: Clutter.Escape });
 
+        let dialogContent = DialogContent[this._type];
         for (let i = 0; i < dialogContent.confirmButtons.length; i++) {
             let signal = dialogContent.confirmButtons[i].signal;
             let label = dialogContent.confirmButtons[i].label;
-            buttons.push({
+            let button = this.addButton({
                 action: () => {
                     this.close(true);
                     let signalId = this.connect('closed', () => {
@@ -460,8 +462,6 @@ class EndSessionDialog extends ModalDialog.ModalDialog {
                 label: label,
             });
         }
-
-        this.setButtons(buttons);
     }
 
     close(skipSignal) {
-- 
2.23.0