windowAttentionHandler: Fix updating on title changes

We were supposed to be updating the notification's title when the
window title changes, but we didn't actually bother to re-format
the title and body, effectively leaving the notification unchanged.
This commit is contained in:
Jasper St. Pierre 2012-02-28 17:12:20 -05:00
parent 8d854d5f1a
commit f967fd21f8

View File

@ -14,6 +14,12 @@ const WindowAttentionHandler = new Lang.Class({
global.display.connect('window-demands-attention', Lang.bind(this, this._onWindowDemandsAttention));
},
_getTitleAndBanner: function(app, window) {
let title = app.get_name();
let banner = _("'%s' is ready").format(window.get_title());
return [title, banner]
},
_onWindowDemandsAttention : function(display, window) {
// We don't want to show the notification when the window is already focused,
// because this is rather pointless.
@ -30,16 +36,15 @@ const WindowAttentionHandler = new Lang.Class({
let source = new Source(app, window);
Main.messageTray.add(source);
let banner = _("'%s' is ready").format(window.title);
let title = app.get_name();
let [title, banner] = this._getTitleAndBanner(app, window);
let notification = new MessageTray.Notification(source, title, banner);
source.notify(notification);
source.signalIDs.push(window.connect('notify::title',
Lang.bind(this, function() {
notification.update(title, banner);
})));
source.signalIDs.push(window.connect('notify::title', Lang.bind(this, function() {
let [title, banner] = this._getTitleAndBanner(app, window);
notification.update(title, banner);
})));
}
});