Show both summary and body of notifications, and support body-markup
Previously we were only showing the summary for notifications, but most notifications only make sense if you show both. https://bugzilla.gnome.org/show_bug.cgi?id=606331
This commit is contained in:
parent
4ab513ca77
commit
a424bbbabf
@ -17,6 +17,7 @@ dist_jsui_DATA = \
|
|||||||
lookingGlass.js \
|
lookingGlass.js \
|
||||||
main.js \
|
main.js \
|
||||||
messageTray.js \
|
messageTray.js \
|
||||||
|
notificationDaemon.js \
|
||||||
overview.js \
|
overview.js \
|
||||||
panel.js \
|
panel.js \
|
||||||
placeDisplay.js \
|
placeDisplay.js \
|
||||||
|
@ -44,7 +44,11 @@ NotificationBox.prototype = {
|
|||||||
|
|
||||||
setContent: function(notification) {
|
setContent: function(notification) {
|
||||||
this._iconBox.child = notification.icon;
|
this._iconBox.child = notification.icon;
|
||||||
this._text.text = notification.text;
|
|
||||||
|
// Support <b>, <i>, and <u>, escape anything else
|
||||||
|
// so it displays as raw markup.
|
||||||
|
let markup = notification.text.replace(/<(\/?[^biu]>|[^>\/][^>])/g, "<$1");
|
||||||
|
this._text.clutter_text.set_markup(markup);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -8,6 +8,7 @@ const Mainloop = imports.mainloop;
|
|||||||
|
|
||||||
const Main = imports.ui.main;
|
const Main = imports.ui.main;
|
||||||
const MessageTray = imports.ui.messageTray;
|
const MessageTray = imports.ui.messageTray;
|
||||||
|
const Params = imports.misc.params;
|
||||||
|
|
||||||
let nextNotificationId = 1;
|
let nextNotificationId = 1;
|
||||||
|
|
||||||
@ -42,6 +43,12 @@ const NotificationClosedReason = {
|
|||||||
UNDEFINED: 4
|
UNDEFINED: 4
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const Urgency = {
|
||||||
|
LOW: 0,
|
||||||
|
NORMAL: 1,
|
||||||
|
CRITICAL: 2
|
||||||
|
};
|
||||||
|
|
||||||
function NotificationDaemon() {
|
function NotificationDaemon() {
|
||||||
this._init();
|
this._init();
|
||||||
}
|
}
|
||||||
@ -92,7 +99,11 @@ NotificationDaemon.prototype = {
|
|||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
|
|
||||||
source.notify(summary);
|
summary = GLib.markup_escape_text(summary, -1);
|
||||||
|
if (body)
|
||||||
|
source.notify('<b>' + summary + '</b>: ' + body);
|
||||||
|
else
|
||||||
|
source.notify('<b>' + summary + '</b>');
|
||||||
return id;
|
return id;
|
||||||
},
|
},
|
||||||
|
|
||||||
@ -109,7 +120,7 @@ NotificationDaemon.prototype = {
|
|||||||
'body',
|
'body',
|
||||||
// 'body-hyperlinks',
|
// 'body-hyperlinks',
|
||||||
// 'body-images',
|
// 'body-images',
|
||||||
// 'body-markup',
|
'body-markup',
|
||||||
// 'icon-multi',
|
// 'icon-multi',
|
||||||
'icon-static'
|
'icon-static'
|
||||||
// 'sound',
|
// 'sound',
|
||||||
@ -145,8 +156,11 @@ Source.prototype = {
|
|||||||
_init: function(sourceId, icon, hints) {
|
_init: function(sourceId, icon, hints) {
|
||||||
MessageTray.Source.prototype._init.call(this, sourceId);
|
MessageTray.Source.prototype._init.call(this, sourceId);
|
||||||
|
|
||||||
|
hints = Params.parse(hints, { urgency: Urgency.NORMAL }, true);
|
||||||
|
|
||||||
this._icon = icon;
|
this._icon = icon;
|
||||||
this._iconData = hints.icon_data;
|
this._iconData = hints.icon_data;
|
||||||
|
this._urgency = hints.urgency;
|
||||||
},
|
},
|
||||||
|
|
||||||
createIcon: function(size) {
|
createIcon: function(size) {
|
||||||
@ -166,8 +180,17 @@ Source.prototype = {
|
|||||||
return textureCache.load_from_raw(data, data.length, hasAlpha,
|
return textureCache.load_from_raw(data, data.length, hasAlpha,
|
||||||
width, height, rowStride, size);
|
width, height, rowStride, size);
|
||||||
} else {
|
} else {
|
||||||
// FIXME: fallback icon?
|
let stockIcon;
|
||||||
return textureCache.load_icon_name('gtk-dialog-info', size);
|
switch (this._urgency) {
|
||||||
|
case Urgency.LOW:
|
||||||
|
case Urgency.NORMAL:
|
||||||
|
stockIcon = 'gtk-dialog-info';
|
||||||
|
break;
|
||||||
|
case Urgency.CRITICAL:
|
||||||
|
stockIcon = 'gtk-dialog-error';
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
return textureCache.load_icon_name(stockIcon, size);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
Loading…
Reference in New Issue
Block a user