MessageTray: only create icon buttons if specifically requested

Action names sometimes unintentionally overlap with icon names, so
we should only create icon buttons if the message tray source requests
it.  For the notification daemon, this is done by setting the
'action-icons' hint on the notification.

The previous notification server capability used to advertise this
feature, "x-gnome-icon-buttons", has been removed in favour of the
new capability described in the notification spec, "action-icons".

https://bugzilla.gnome.org/show_bug.cgi?id=624584
This commit is contained in:
Jonathan Matthew 2010-10-30 16:29:21 +10:00
parent 31df386fed
commit 9585c823d5
2 changed files with 8 additions and 2 deletions

View File

@ -102,6 +102,7 @@ Notification.prototype = {
this.source = source; this.source = source;
this.urgent = false; this.urgent = false;
this.expanded = false; this.expanded = false;
this._useActionIcons = false;
this._customContent = false; this._customContent = false;
this._bannerBodyText = null; this._bannerBodyText = null;
this._titleFitsInBannerMode = true; this._titleFitsInBannerMode = true;
@ -346,7 +347,7 @@ Notification.prototype = {
let button = new St.Button(); let button = new St.Button();
if (Gtk.IconTheme.get_default().has_icon(id)) { if (this._useActionIcons && Gtk.IconTheme.get_default().has_icon(id)) {
button.add_style_class_name('notification-icon-button'); button.add_style_class_name('notification-icon-button');
button.child = St.TextureCache.get_default().load_icon_name(id, St.IconType.SYMBOLIC, BUTTON_ICON_SIZE); button.child = St.TextureCache.get_default().load_icon_name(id, St.IconType.SYMBOLIC, BUTTON_ICON_SIZE);
} else { } else {
@ -363,6 +364,10 @@ Notification.prototype = {
this.urgent = urgent; this.urgent = urgent;
}, },
setUseActionIcons: function(useIcons) {
this._useActionIcons = useIcons;
},
_styleChanged: function() { _styleChanged: function() {
this._spacing = this.actor.get_theme_node().get_length('spacing-columns'); this._spacing = this.actor.get_theme_node().get_length('spacing-columns');
}, },

View File

@ -294,6 +294,7 @@ NotificationDaemon.prototype = {
} }
if (actions.length) { if (actions.length) {
notification.setUseActionIcons(hints['action-icons'] == true);
for (let i = 0; i < actions.length - 1; i += 2) for (let i = 0; i < actions.length - 1; i += 2)
notification.addButton(actions[i], actions[i + 1]); notification.addButton(actions[i], actions[i + 1]);
} }
@ -317,6 +318,7 @@ NotificationDaemon.prototype = {
GetCapabilities: function() { GetCapabilities: function() {
return [ return [
'actions', 'actions',
'action-icons',
'body', 'body',
// 'body-hyperlinks', // 'body-hyperlinks',
// 'body-images', // 'body-images',
@ -325,7 +327,6 @@ NotificationDaemon.prototype = {
'icon-static', 'icon-static',
'persistence', 'persistence',
// 'sound', // 'sound',
'x-gnome-icon-buttons'
]; ];
}, },