[gnome-shell] IconGrid: don't force the size of the icon



commit 26580f8f2c9cbb1a29be30a19002bc61b9319a21
Author: Giovanni Campagna <gcampagna src gnome org>
Date:   Tue Dec 20 19:11:07 2011 +0100

    IconGrid: don't force the size of the icon
    
    Forcing the icon size will distort it unnecessarily, and will
    in any case not work if showing an animation (which is a ClutterGroup).
    Instead, set the size on the bin, and make it align its child
    if needed.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=666606

 js/ui/iconGrid.js |   14 ++++++++++----
 1 files changed, 10 insertions(+), 4 deletions(-)
---
diff --git a/js/ui/iconGrid.js b/js/ui/iconGrid.js
index 1b9c905..b93f6c0 100644
--- a/js/ui/iconGrid.js
+++ b/js/ui/iconGrid.js
@@ -35,7 +35,8 @@ const BaseIcon = new Lang.Class({
         this.actor.set_child(box);
 
         this.iconSize = ICON_SIZE;
-        this._iconBin = new St.Bin();
+        this._iconBin = new St.Bin({ x_align: St.Align.MIDDLE,
+                                     y_align: St.Align.MIDDLE });
 
         box.add_actor(this._iconBin);
 
@@ -125,12 +126,12 @@ const BaseIcon = new Lang.Class({
         this.iconSize = size;
         this.icon = this.createIcon(this.iconSize);
 
+        this._iconBin.child = this.icon;
+
         // The icon returned by createIcon() might actually be smaller than
         // the requested icon size (for instance StTextureCache does this
         // for fallback icons), so set the size explicitly.
-        this.icon.set_size(this.iconSize, this.iconSize);
-
-        this._iconBin.child = this.icon;
+        this._iconBin.set_size(this.iconSize, this.iconSize);
     },
 
     _onStyleChanged: function() {
@@ -145,6 +146,11 @@ const BaseIcon = new Lang.Class({
             size = found ? len : ICON_SIZE;
         }
 
+        // don't create icons unnecessarily
+        if (size == this.iconSize &&
+            this._iconBin.child)
+            return;
+
         this._createIconTexture(size);
     }
 });



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