messageTray: Provide a hook for customizing banners
While we want to encourage the use of regular notification banners, some of our built-in stuff does require more or less customized content ("more" being chat notifications, a.k.a. king of custom). Account for this use case by delegating banner creation to a method, so either Notification or Source subclasses can overwrite it.
This commit is contained in:
parent
87ae45a12f
commit
e8a023a78f
@ -1080,6 +1080,15 @@ const Notification = new Lang.Class({
|
|||||||
this.actor.add_style_class_name('notification-unexpanded');
|
this.actor.add_style_class_name('notification-unexpanded');
|
||||||
},
|
},
|
||||||
|
|
||||||
|
// Allow customizing the banner UI:
|
||||||
|
// the default implementation defers the creation to
|
||||||
|
// the source (which will create a NotificationBanner),
|
||||||
|
// so customization can be done by subclassing either
|
||||||
|
// Notification or Source
|
||||||
|
createBanner: function() {
|
||||||
|
return this.source.createBanner(this);
|
||||||
|
},
|
||||||
|
|
||||||
activate: function() {
|
activate: function() {
|
||||||
this.emit('activated');
|
this.emit('activated');
|
||||||
// We hide all types of notifications once the user clicks on them because the common
|
// We hide all types of notifications once the user clicks on them because the common
|
||||||
@ -1376,6 +1385,10 @@ const Source = new Lang.Class({
|
|||||||
this.emit('title-changed');
|
this.emit('title-changed');
|
||||||
},
|
},
|
||||||
|
|
||||||
|
createBanner: function(notification) {
|
||||||
|
return new NotificationBanner(notification);
|
||||||
|
},
|
||||||
|
|
||||||
// Called to create a new icon actor.
|
// Called to create a new icon actor.
|
||||||
// Provides a sane default implementation, override if you need
|
// Provides a sane default implementation, override if you need
|
||||||
// something more fancy.
|
// something more fancy.
|
||||||
@ -1876,7 +1889,7 @@ const MessageTray = new Lang.Class({
|
|||||||
this.idleMonitor.add_user_active_watch(Lang.bind(this, this._onIdleMonitorBecameActive));
|
this.idleMonitor.add_user_active_watch(Lang.bind(this, this._onIdleMonitorBecameActive));
|
||||||
}
|
}
|
||||||
|
|
||||||
this._banner = new NotificationBanner(this._notification);
|
this._banner = this._notification.createBanner();
|
||||||
this._bannerClickedId = this._banner.connect('done-displaying',
|
this._bannerClickedId = this._banner.connect('done-displaying',
|
||||||
Lang.bind(this, this._escapeTray));
|
Lang.bind(this, this._escapeTray));
|
||||||
this._bannerUnfocusedId = this._banner.connect('unfocused', Lang.bind(this, function() {
|
this._bannerUnfocusedId = this._banner.connect('unfocused', Lang.bind(this, function() {
|
||||||
|
Loading…
Reference in New Issue
Block a user