[gnome-shell] messageTray: Primarily use a GIcon to drive the source's icon



commit f5974f67930fe916b0abf6e5e4ef626b65580a5b
Author: Jasper St. Pierre <jstpierre mecheye net>
Date:   Sat Sep 15 03:10:15 2012 -0300

    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

 js/ui/components/autorunManager.js  |    5 ++---
 js/ui/components/telepathyClient.js |   25 ++++++++-----------------
 js/ui/messageTray.js                |    6 +++++-
 3 files changed, 15 insertions(+), 21 deletions(-)
---
diff --git a/js/ui/components/autorunManager.js b/js/ui/components/autorunManager.js
index 83ca894..bf94759 100644
--- a/js/ui/components/autorunManager.js
+++ b/js/ui/components/autorunManager.js
@@ -546,9 +546,8 @@ const AutorunTransientSource = new Lang.Class({
         this.notify(this._notification);
     },
 
-    createIcon: function(size) {
-        return new St.Icon({ gicon: this.mount.get_icon(),
-                             icon_size: size });
+    getIcon: function() {
+        return this.mount.get_icon();
     }
 });
 
diff --git a/js/ui/components/telepathyClient.js b/js/ui/components/telepathyClient.js
index 26e19ed..062c930 100644
--- a/js/ui/components/telepathyClient.js
+++ b/js/ui/components/telepathyClient.js
@@ -509,24 +509,16 @@ const ChatSource = new Lang.Class({
         this._notification.appendAliasChange(oldAlias, newAlias);
     },
 
-    createIcon: function(size) {
-        this._iconBox = new St.Bin({ style_class: 'avatar-box' });
-        this._iconBox._size = size;
-        let textureCache = St.TextureCache.get_default();
+    getIcon: function() {
         let file = this._contact.get_avatar_file();
-
         if (file) {
-            let uri = file.get_uri();
-            this._iconBox.child = textureCache.load_uri_async(uri, this._iconBox._size, this._iconBox._size);
+            return new Gio.FileIcon({ file: file });
         } else {
-            this._iconBox.child = new St.Icon({ icon_name: 'avatar-default',
-                                                icon_size: this._iconBox._size });
+            return new Gio.ThemedIcon({ name: 'avatar-default' });
         }
-
-        return this._iconBox;
     },
 
-    createSecondaryIcon: function() {
+    getSecondaryIcon: function() {
         let iconName;
         let presenceType = this._contact.get_presence_type();
 
@@ -732,7 +724,7 @@ const ChatSource = new Lang.Class({
 
         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)
             msg += ' <i>(' + GLib.markup_escape_text(message, -1) + ')</i>';
@@ -760,7 +752,7 @@ const ChatNotification = new Lang.Class({
     Extends: MessageTray.Notification,
 
     _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._responseEntry = new St.Entry({ style_class: 'chat-response',
@@ -1070,9 +1062,8 @@ const ApproverSource = new Lang.Class({
         this.parent();
     },
 
-    createIcon: function(size) {
-        return new St.Icon({ gicon: this._gicon,
-                             icon_size: size });
+    getIcon: function() {
+        return this._gicon;
     }
 });
 
diff --git a/js/ui/messageTray.js b/js/ui/messageTray.js
index c41b492..cd5fd26 100644
--- a/js/ui/messageTray.js
+++ b/js/ui/messageTray.js
@@ -1122,10 +1122,14 @@ const Source = new Lang.Class({
     // Provides a sane default implementation, override if you need
     // something more fancy.
     createIcon: function(size) {
-        return new St.Icon({ icon_name: this.iconName,
+        return new St.Icon({ gicon: this.getIcon(),
                              icon_size: size });
     },
 
+    getIcon: function() {
+        return new Gio.ThemedIcon({ name: this.iconName });
+    },
+
     _ensureMainIcon: function() {
         if (this._mainIcon)
             return;



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]