[gnome-shell/wip/gtk-notification: 12/22] messageTray: Split out addButton to allow consumers to pass a pre-made button



commit bf643eaeeeee35637fc9d08af46d4bdb038106a4
Author: Jasper St. Pierre <jstpierre mecheye net>
Date:   Sun Oct 13 23:08:16 2013 -0400

    messageTray: Split out addButton to allow consumers to pass a pre-made button

 js/ui/messageTray.js |   36 ++++++++++++++++++++----------------
 1 files changed, 20 insertions(+), 16 deletions(-)
---
diff --git a/js/ui/messageTray.js b/js/ui/messageTray.js
index c577032..4eab80c 100644
--- a/js/ui/messageTray.js
+++ b/js/ui/messageTray.js
@@ -836,17 +836,7 @@ const Notification = new Lang.Class({
         }
     },
 
-    // addButton:
-    // @id: the action ID
-    // @label: the label for the action's button
-    //
-    // Adds a button with the given @label to the notification. All
-    // action buttons will appear in a single row at the bottom of
-    // the notification.
-    //
-    // If the button is clicked, the notification will emit the
-    // %action-invoked signal with @id as a parameter
-    addButton: function(id, label) {
+    addButtonFull: function(id, button) {
         if (!this._buttonBox) {
             let box = new St.BoxLayout({ style_class: 'notification-actions' });
             this.setActionArea(box, { x_expand: false,
@@ -858,6 +848,24 @@ const Notification = new Lang.Class({
             global.focus_manager.add_group(this._buttonBox);
         }
 
+        this._buttonBox.add(button);
+        button.connect('clicked', Lang.bind(this, this._onActionInvoked, id));
+
+        this.updated();
+        return button;
+    },
+
+    // addButton:
+    // @id: the action ID
+    // @label: the label for the action's button
+    //
+    // Adds a button with the given @label to the notification. All
+    // action buttons will appear in a single row at the bottom of
+    // the notification.
+    //
+    // If the button is clicked, the notification will emit the
+    // %action-invoked signal with @id as a parameter
+    addButton: function(id, label) {
         let button = new St.Button({ can_focus: true });
 
         let iconName = strHasSuffix(id, '-symbolic') ? id : id + '-symbolic';
@@ -869,11 +877,7 @@ const Notification = new Lang.Class({
             button.label = label;
         }
 
-        this._buttonBox.add(button);
-        button.connect('clicked', Lang.bind(this, this._onActionInvoked, id));
-
-        this.updated();
-        return button;
+        return this.addButtonFull(id, button);
     },
 
     setUrgency: function(urgency) {


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