messageTray: Record actions added to notifications

Both the screen shield and the notification section in the message
list create their own UI for notifications rather than using the
notification actor itself. Currently there is no clean way for such
representations to include notification actions - we will need this
as we will soon use a separate actor for banners as well, so keep
track of actions added via addAction().
This commit is contained in:
Florian Müllner 2015-02-19 13:45:31 +01:00
parent 71f59de797
commit a3c1c09cc1

View File

@ -495,6 +495,7 @@ const Notification = new Lang.Class({
this._soundName = null; this._soundName = null;
this._soundFile = null; this._soundFile = null;
this._soundPlayed = false; this._soundPlayed = false;
this.actions = [];
this.actor = new St.Button({ accessible_role: Atk.Role.NOTIFICATION }); this.actor = new St.Button({ accessible_role: Atk.Role.NOTIFICATION });
this.actor.add_style_class_name('notification-unexpanded'); this.actor.add_style_class_name('notification-unexpanded');
@ -594,6 +595,7 @@ const Notification = new Lang.Class({
this._actionArea.destroy(); this._actionArea.destroy();
this._actionArea = null; this._actionArea = null;
this._buttonBox = null; this._buttonBox = null;
this.actions = [];
} }
if (!this._scrollArea && !this._actionArea) if (!this._scrollArea && !this._actionArea)
this._table.remove_style_class_name('multi-line-notification'); this._table.remove_style_class_name('multi-line-notification');
@ -818,6 +820,7 @@ const Notification = new Lang.Class({
// action buttons will appear in a single row at the bottom of // action buttons will appear in a single row at the bottom of
// the notification. // the notification.
addAction: function(label, callback) { addAction: function(label, callback) {
this.actions.push({ label: label, callback: callback });
let button = new St.Button({ style_class: 'notification-button', let button = new St.Button({ style_class: 'notification-button',
label: label, label: label,
can_focus: true }); can_focus: true });