diff --git a/js/ui/components/telepathyClient.js b/js/ui/components/telepathyClient.js index 86a62bbbb..16c5f6712 100644 --- a/js/ui/components/telepathyClient.js +++ b/js/ui/components/telepathyClient.js @@ -1095,8 +1095,8 @@ const RoomInviteNotification = new Lang.Class({ * for example. */ this.addBody(_("%s is inviting you to join %s").format(inviter.get_alias(), channel.get_identifier())); - this.addButton('decline', _("Decline")); - this.addButton('accept', _("Accept")); + this.addAction('decline', _("Decline")); + this.addAction('accept', _("Accept")); this.connect('action-invoked', Lang.bind(this, function(self, action) { switch (action) { @@ -1136,9 +1136,9 @@ const AudioVideoNotification = new Lang.Class({ this.setUrgency(MessageTray.Urgency.CRITICAL); - this.addButton('reject', _("Decline")); + this.addAction('reject', _("Decline")); /* translators: this is a button label (verb), not a noun */ - this.addButton('answer', _("Answer")); + this.addAction('answer', _("Answer")); this.connect('action-invoked', Lang.bind(this, function(self, action) { switch (action) { @@ -1176,8 +1176,8 @@ const FileTransferNotification = new Lang.Class({ { customContent: true }); this.setResident(true); - this.addButton('decline', _("Decline")); - this.addButton('accept', _("Accept")); + this.addAction('decline', _("Decline")); + this.addAction('accept', _("Accept")); this.connect('action-invoked', Lang.bind(this, function(self, action) { switch (action) { @@ -1239,8 +1239,8 @@ const SubscriptionRequestNotification = new Lang.Class({ this.addActor(layout); - this.addButton('decline', _("Decline")); - this.addButton('accept', _("Accept")); + this.addAction('decline', _("Decline")); + this.addAction('accept', _("Accept")); this.connect('action-invoked', Lang.bind(this, function(self, action) { switch (action) { @@ -1358,7 +1358,7 @@ const AccountNotification = new Lang.Class({ this._account = account; - this.addButton('view', _("View account")); + this.addAction('view', _("View account")); this.connect('action-invoked', Lang.bind(this, function(self, action) { switch (action) { diff --git a/js/ui/messageTray.js b/js/ui/messageTray.js index 9a87106e4..9e6e5c0bb 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) { + addButton: 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; + }, + + // addAction: + // @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 + addAction: 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.addButton(id, button); }, setUrgency: function(urgency) { diff --git a/js/ui/notificationDaemon.js b/js/ui/notificationDaemon.js index 4c41dd1a5..55d98a967 100644 --- a/js/ui/notificationDaemon.js +++ b/js/ui/notificationDaemon.js @@ -422,7 +422,7 @@ const NotificationDaemon = new Lang.Class({ this._emitActionInvoked(ndata.id, "default"); })); else - notification.addButton(actions[i], actions[i + 1]); + notification.addAction(actions[i], actions[i + 1]); } } switch (hints.urgency) { diff --git a/js/ui/overview.js b/js/ui/overview.js index 69563a6c1..93c2ec2bb 100644 --- a/js/ui/overview.js +++ b/js/ui/overview.js @@ -79,7 +79,7 @@ const ShellInfo = new Lang.Class({ this._undoCallback = undoCallback; if (undoCallback) { - notification.addButton('system-undo', _("Undo")); + notification.addAction('system-undo', _("Undo")); notification.connect('action-invoked', Lang.bind(this, this._onUndoClicked)); } diff --git a/js/ui/status/bluetooth.js b/js/ui/status/bluetooth.js index 718a866a4..a302ac8fc 100644 --- a/js/ui/status/bluetooth.js +++ b/js/ui/status/bluetooth.js @@ -105,8 +105,8 @@ const AuthNotification = new Lang.Class({ this._devicePath = device_path; this.addBody(_("Device %s wants to pair with this computer").format(long_name)); - this.addButton('allow', _("Allow")); - this.addButton('deny', _("Deny")); + this.addAction('allow', _("Allow")); + this.addAction('deny', _("Deny")); this.connect('action-invoked', Lang.bind(this, function(self, action) { if (action == 'allow') @@ -133,9 +133,9 @@ const AuthServiceNotification = new Lang.Class({ this._devicePath = device_path; this.addBody(_("Device %s wants access to the service '%s'").format(long_name, uuid)); - this.addButton('always-grant', _("Always grant access")); - this.addButton('grant', _("Grant this time only")); - this.addButton('reject', _("Reject")); + this.addAction('always-grant', _("Always grant access")); + this.addAction('grant', _("Grant this time only")); + this.addAction('reject', _("Reject")); this.connect('action-invoked', Lang.bind(this, function(self, action) { switch (action) { @@ -172,8 +172,8 @@ const ConfirmNotification = new Lang.Class({ this.addBody(_("Please confirm whether the Passkey '%06d' matches the one on the device.").format(pin)); /* Translators: this is the verb, not the noun */ - this.addButton('matches', _("Matches")); - this.addButton('does-not-match', _("Does not match")); + this.addAction('matches', _("Matches")); + this.addAction('does-not-match', _("Does not match")); this.connect('action-invoked', Lang.bind(this, function(self, action) { if (action == 'matches') @@ -217,8 +217,8 @@ const PinNotification = new Lang.Class({ })); this.addActor(this._entry); - let okButton = this.addButton('ok', _("OK")); - this.addButton('cancel', _("Cancel")); + let okButton = this.addAction('ok', _("OK")); + this.addAction('cancel', _("Cancel")); okButton.reactive = this._canActivateOkButton(); this._entry.clutter_text.connect('text-changed', Lang.bind(this, function() {