From ae3d1423e59c8ed1d7bef6e266d415a5f78fc12b Mon Sep 17 00:00:00 2001 From: Colin Walters Date: Sun, 28 Feb 2010 15:51:28 -0500 Subject: [PATCH] [panel] Handle async load of icons correctly Fading the application icon required the texture to have already been loaded, which was normally the case since we create icons for apps in the well and browser; but when finding an app not from there, the cogl-texture for the icon might not be available. Fix this by watching for the texture and fading when it appears. https://bugzilla.gnome.org/show_bug.cgi?id=611288 --- js/ui/panel.js | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/js/ui/panel.js b/js/ui/panel.js index d9e40ce26..da56cb174 100644 --- a/js/ui/panel.js +++ b/js/ui/panel.js @@ -152,12 +152,13 @@ AppPanelMenu.prototype = { this._activeSequence = null; this._startupSequences = {}; - this.actor = new St.Bin({ name: 'appMenu', }); + this.actor = new St.Bin({ name: 'appMenu' }); this._container = new Shell.GenericContainer(); this.actor.set_child(this._container); this._container.connect('get-preferred-width', Lang.bind(this, this._getPreferredWidth)); this._container.connect('get-preferred-height', Lang.bind(this, this._getPreferredHeight)); this._container.connect('allocate', Lang.bind(this, this._allocate)); + this._sourceIcon = null; this._iconBox = new Shell.Slicer({ name: 'appMenuIcon' }); this._container.add_actor(this._iconBox); this._label = new TextShadower(); @@ -263,9 +264,21 @@ AppPanelMenu.prototype = { } else { icon = null; } - + if (icon != null) { - let faded = Shell.fade_app_icon(icon); /* TODO consider caching */ + if (this._sourceIcon != null) + this._sourceIcon.destroy(); + this._sourceIcon = icon; + let faded = Shell.fade_app_icon(icon); + // Because loading the texture is async, we may not have it yet. + // If we don't, just create an empty one for now. + if (faded == null) + faded = new Clutter.Texture({ width: AppDisplay.APPICON_SIZE, + height: AppDisplay.APPICON_SIZE }); + this._sourceIcon.connect('notify::cogl-texture', Lang.bind(this, function () { + faded = Shell.fade_app_icon(icon); + this._iconBox.set_child(faded); + })); this._iconBox.set_child(faded); this._iconBox.show(); }