[MessageTray] fix notifications with short banners and action buttons
Previously the banner was only promoted to the body if it got truncated, but the banner was *always* hidden when expanding the notification. This meant a message with a short banner, plus notification buttons, would have no banner text visible when it was expanded. Fix that. https://bugzilla.gnome.org/show_bug.cgi?id=606755
This commit is contained in:
parent
d8af8f7305
commit
090335ad8b
@ -36,7 +36,7 @@ function _cleanMarkup(text) {
|
|||||||
// @source: the notification's Source
|
// @source: the notification's Source
|
||||||
// @title: the title
|
// @title: the title
|
||||||
// @banner: the banner text
|
// @banner: the banner text
|
||||||
// @overflow: whether or not to do banner overflow (see below)
|
// @bannerBody: whether or not to promote the banner to the body on overflow
|
||||||
//
|
//
|
||||||
// Creates a notification. In banner mode, it will show
|
// Creates a notification. In banner mode, it will show
|
||||||
// @source's icon, @title (in bold) and @banner, all on a single line
|
// @source's icon, @title (in bold) and @banner, all on a single line
|
||||||
@ -48,17 +48,18 @@ function _cleanMarkup(text) {
|
|||||||
// hiding the @banner) if the pointer is moved into it while it is
|
// hiding the @banner) if the pointer is moved into it while it is
|
||||||
// visible.
|
// visible.
|
||||||
//
|
//
|
||||||
// If @overflow is %true, and @banner is too long to fit in the
|
// If @bannerBody is %true, then @banner will also be used as the body
|
||||||
// single-line mode, then the notification will automatically call
|
// of the notification (as with addBody()) when the banner is expanded.
|
||||||
// addBody() to show the full text of @banner in expanded mode.
|
// In this case, if @banner is too long to fit in the single-line mode,
|
||||||
function Notification(source, title, banner, overflow) {
|
// the notification will be made expandable automatically.
|
||||||
this._init(source, title, banner, overflow);
|
function Notification(source, title, banner, bannerBody) {
|
||||||
|
this._init(source, title, banner, bannerBody);
|
||||||
}
|
}
|
||||||
|
|
||||||
Notification.prototype = {
|
Notification.prototype = {
|
||||||
_init: function(source, title, banner, overflow) {
|
_init: function(source, title, banner, bannerBody) {
|
||||||
this.source = source;
|
this.source = source;
|
||||||
this._overflow = overflow;
|
this._bannerBody = bannerBody;
|
||||||
|
|
||||||
this.actor = new St.Table({ name: 'notification' });
|
this.actor = new St.Table({ name: 'notification' });
|
||||||
this.update(title, banner, true);
|
this.update(title, banner, true);
|
||||||
@ -116,8 +117,10 @@ Notification.prototype = {
|
|||||||
this._titleLabel.clutter_text.set_markup('<b>' + title + '</b>');
|
this._titleLabel.clutter_text.set_markup('<b>' + title + '</b>');
|
||||||
this._bannerBox.add_actor(this._titleLabel);
|
this._bannerBox.add_actor(this._titleLabel);
|
||||||
|
|
||||||
if (this._overflow)
|
if (this._bannerBody)
|
||||||
this._overflowText = banner;
|
this._bannerBodyText = banner;
|
||||||
|
else
|
||||||
|
this._bannerBodyText = null;
|
||||||
|
|
||||||
this._bannerLabel = new St.Label();
|
this._bannerLabel = new St.Label();
|
||||||
banner = banner ? _cleanMarkup(banner.replace('\n', ' ')) : '';
|
banner = banner ? _cleanMarkup(banner.replace('\n', ' ')) : '';
|
||||||
@ -194,6 +197,11 @@ Notification.prototype = {
|
|||||||
this.addActor(body, props);
|
this.addActor(body, props);
|
||||||
},
|
},
|
||||||
|
|
||||||
|
_addBannerBody: function() {
|
||||||
|
this.addBody(this._bannerBodyText, { row: 1 });
|
||||||
|
this._bannerBodyText = null;
|
||||||
|
},
|
||||||
|
|
||||||
// addAction:
|
// addAction:
|
||||||
// @id: the action ID
|
// @id: the action ID
|
||||||
// @label: the label for the action's button
|
// @label: the label for the action's button
|
||||||
@ -206,6 +214,9 @@ Notification.prototype = {
|
|||||||
// %action-invoked signal with @id as a parameter
|
// %action-invoked signal with @id as a parameter
|
||||||
addAction: function(id, label) {
|
addAction: function(id, label) {
|
||||||
if (!this._actionBox) {
|
if (!this._actionBox) {
|
||||||
|
if (this._bannerBodyText)
|
||||||
|
this._addBannerBody();
|
||||||
|
|
||||||
let box = new St.BoxLayout({ name: 'notification-actions' });
|
let box = new St.BoxLayout({ name: 'notification-actions' });
|
||||||
this.addActor(box, { x_expand: false,
|
this.addActor(box, { x_expand: false,
|
||||||
x_fill: false,
|
x_fill: false,
|
||||||
@ -265,10 +276,8 @@ Notification.prototype = {
|
|||||||
overflow = true;
|
overflow = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (overflow && this._overflowText) {
|
if (overflow && this._bannerBodyText)
|
||||||
this.addBody(this._overflowText, { row: 1 });
|
this._addBannerBody();
|
||||||
this._overflowText = null;
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
|
|
||||||
popOut: function() {
|
popOut: function() {
|
||||||
|
Loading…
Reference in New Issue
Block a user