messageTray: Primarily use a GIcon to drive the source's icon

This is a bit of a cleanup since we ported notification icons/secondary
icons to be in the same situation.

https://bugzilla.gnome.org/show_bug.cgi?id=680426
This commit is contained in:
Jasper St. Pierre 2012-09-15 03:10:15 -03:00
parent 928ea3bb01
commit f5974f6793
3 changed files with 15 additions and 21 deletions

View File

@ -546,9 +546,8 @@ const AutorunTransientSource = new Lang.Class({
this.notify(this._notification); this.notify(this._notification);
}, },
createIcon: function(size) { getIcon: function() {
return new St.Icon({ gicon: this.mount.get_icon(), return this.mount.get_icon();
icon_size: size });
} }
}); });

View File

@ -509,24 +509,16 @@ const ChatSource = new Lang.Class({
this._notification.appendAliasChange(oldAlias, newAlias); this._notification.appendAliasChange(oldAlias, newAlias);
}, },
createIcon: function(size) { getIcon: function() {
this._iconBox = new St.Bin({ style_class: 'avatar-box' });
this._iconBox._size = size;
let textureCache = St.TextureCache.get_default();
let file = this._contact.get_avatar_file(); let file = this._contact.get_avatar_file();
if (file) { if (file) {
let uri = file.get_uri(); return new Gio.FileIcon({ file: file });
this._iconBox.child = textureCache.load_uri_async(uri, this._iconBox._size, this._iconBox._size);
} else { } else {
this._iconBox.child = new St.Icon({ icon_name: 'avatar-default', return new Gio.ThemedIcon({ name: 'avatar-default' });
icon_size: this._iconBox._size });
} }
return this._iconBox;
}, },
createSecondaryIcon: function() { getSecondaryIcon: function() {
let iconName; let iconName;
let presenceType = this._contact.get_presence_type(); let presenceType = this._contact.get_presence_type();
@ -732,7 +724,7 @@ const ChatSource = new Lang.Class({
title = GLib.markup_escape_text(this.title, -1); title = GLib.markup_escape_text(this.title, -1);
this._notification.update(this._notification.title, null, { customContent: true, secondaryGIcon: this.createSecondaryIcon() }); this._notification.update(this._notification.title, null, { customContent: true, secondaryGIcon: this.getSecondaryIcon() });
if (message) if (message)
msg += ' <i>(' + GLib.markup_escape_text(message, -1) + ')</i>'; msg += ' <i>(' + GLib.markup_escape_text(message, -1) + ')</i>';
@ -760,7 +752,7 @@ const ChatNotification = new Lang.Class({
Extends: MessageTray.Notification, Extends: MessageTray.Notification,
_init: function(source) { _init: function(source) {
this.parent(source, source.title, null, { customContent: true, secondaryGIcon: source.createSecondaryIcon() }); this.parent(source, source.title, null, { customContent: true, secondaryGIcon: source.getSecondaryIcon() });
this.setResident(true); this.setResident(true);
this._responseEntry = new St.Entry({ style_class: 'chat-response', this._responseEntry = new St.Entry({ style_class: 'chat-response',
@ -1070,9 +1062,8 @@ const ApproverSource = new Lang.Class({
this.parent(); this.parent();
}, },
createIcon: function(size) { getIcon: function() {
return new St.Icon({ gicon: this._gicon, return this._gicon;
icon_size: size });
} }
}); });

View File

@ -1122,10 +1122,14 @@ const Source = new Lang.Class({
// Provides a sane default implementation, override if you need // Provides a sane default implementation, override if you need
// something more fancy. // something more fancy.
createIcon: function(size) { createIcon: function(size) {
return new St.Icon({ icon_name: this.iconName, return new St.Icon({ gicon: this.getIcon(),
icon_size: size }); icon_size: size });
}, },
getIcon: function() {
return new Gio.ThemedIcon({ name: this.iconName });
},
_ensureMainIcon: function() { _ensureMainIcon: function() {
if (this._mainIcon) if (this._mainIcon)
return; return;