Fully show long titles when a notification is expanded
We used to keep long titles ellipsized when a notification was expanded, which was a bug. We now show them fully by line wrapping them. Based on the original patch from Steven Van Bael. https://bugzilla.gnome.org/show_bug.cgi?id=623970
This commit is contained in:
parent
f8dc3b88f8
commit
a25f7df626
@ -96,6 +96,7 @@ Notification.prototype = {
|
|||||||
this.urgent = false;
|
this.urgent = false;
|
||||||
this._customContent = false;
|
this._customContent = false;
|
||||||
this._bannerBodyText = null;
|
this._bannerBodyText = null;
|
||||||
|
this._titleFitsInBannerMode = true;
|
||||||
this._spacing = 0;
|
this._spacing = 0;
|
||||||
|
|
||||||
this._hasFocus = false;
|
this._hasFocus = false;
|
||||||
@ -197,7 +198,8 @@ Notification.prototype = {
|
|||||||
col: 0,
|
col: 0,
|
||||||
x_expand: false,
|
x_expand: false,
|
||||||
y_expand: false,
|
y_expand: false,
|
||||||
y_fill: false });
|
y_fill: false,
|
||||||
|
y_align: St.Align.START });
|
||||||
|
|
||||||
title = title ? _cleanMarkup(title.replace(/\n/g, ' ')) : '';
|
title = title ? _cleanMarkup(title.replace(/\n/g, ' ')) : '';
|
||||||
this._titleLabel.clutter_text.set_markup('<b>' + title + '</b>');
|
this._titleLabel.clutter_text.set_markup('<b>' + title + '</b>');
|
||||||
@ -377,6 +379,7 @@ Notification.prototype = {
|
|||||||
titleBox.x2 = Math.min(titleNatW, availWidth);
|
titleBox.x2 = Math.min(titleNatW, availWidth);
|
||||||
titleBox.y2 = titleNatH;
|
titleBox.y2 = titleNatH;
|
||||||
this._titleLabel.allocate(titleBox, flags);
|
this._titleLabel.allocate(titleBox, flags);
|
||||||
|
this._titleFitsInBannerMode = (titleNatW <= availWidth);
|
||||||
|
|
||||||
let bannerFits = true;
|
let bannerFits = true;
|
||||||
if (titleBox.x2 + this._spacing > availWidth) {
|
if (titleBox.x2 + this._spacing > availWidth) {
|
||||||
@ -405,21 +408,43 @@ Notification.prototype = {
|
|||||||
},
|
},
|
||||||
|
|
||||||
popOut: function(animate) {
|
popOut: function(animate) {
|
||||||
if (this.actor.row_count <= 1)
|
// The banner is never shown when the title did not fit, so this
|
||||||
return false;
|
// can be an if-else statement.
|
||||||
|
if (!this._titleFitsInBannerMode) {
|
||||||
|
// Remove ellipsization from the title label and make it wrap so that
|
||||||
|
// we show the full title when the notification is expanded.
|
||||||
|
this._titleLabel.clutter_text.line_wrap = true;
|
||||||
|
this._titleLabel.clutter_text.line_wrap_mode = Pango.WrapMode.WORD_CHAR;
|
||||||
|
this._titleLabel.clutter_text.ellipsize = Pango.EllipsizeMode.NONE;
|
||||||
|
return true;
|
||||||
|
} else if (this.actor.row_count > 1) {
|
||||||
|
// We always hide the banner if the notification has additional content.
|
||||||
|
//
|
||||||
|
// We don't need to wrap the banner that doesn't fit the way we wrap the
|
||||||
|
// title that doesn't fit because we won't have a notification with
|
||||||
|
// row_count=1 that has a banner that doesn't fully fit. We'll either add
|
||||||
|
// that banner to the content of the notification in _bannerBoxAllocate()
|
||||||
|
// or the notification will have custom content.
|
||||||
|
if (animate)
|
||||||
|
Tweener.addTween(this._bannerLabel,
|
||||||
|
{ opacity: 0,
|
||||||
|
time: ANIMATION_TIME,
|
||||||
|
transition: 'easeOutQuad' });
|
||||||
|
else
|
||||||
|
this._bannerLabel.opacity = 0;
|
||||||
|
|
||||||
if (animate)
|
return true;
|
||||||
Tweener.addTween(this._bannerLabel,
|
}
|
||||||
{ opacity: 0,
|
|
||||||
time: ANIMATION_TIME,
|
|
||||||
transition: 'easeOutQuad' });
|
|
||||||
else
|
|
||||||
this._bannerLabel.opacity = 0;
|
|
||||||
|
|
||||||
return true;
|
return false;
|
||||||
},
|
},
|
||||||
|
|
||||||
popInCompleted: function() {
|
popInCompleted: function() {
|
||||||
|
// Make sure we don't line wrap the title, and ellipsize it instead.
|
||||||
|
this._titleLabel.clutter_text.line_wrap = false;
|
||||||
|
this._titleLabel.clutter_text.ellipsize = Pango.EllipsizeMode.END;
|
||||||
|
// Restore banner opacity in case the notification is shown in the
|
||||||
|
// banner mode again on update.
|
||||||
this._bannerLabel.opacity = 255;
|
this._bannerLabel.opacity = 255;
|
||||||
},
|
},
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user