From 25be4d60b4f0fe0088cbbccf0c0bb9b6dc032c3e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Florian=20M=C3=BCllner?= Date: Sat, 6 Apr 2013 01:55:11 +0200 Subject: [PATCH] app-menu: Update icons on icon theme changes https://bugzilla.gnome.org/show_bug.cgi?id=697400 --- extensions/apps-menu/extension.js | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/extensions/apps-menu/extension.js b/extensions/apps-menu/extension.js index 3c1bc22b..05c930f6 100644 --- a/extensions/apps-menu/extension.js +++ b/extensions/apps-menu/extension.js @@ -55,12 +55,21 @@ const ApplicationMenuItem = new Lang.Class({ this._app = app; this._button = button; - let icon = this._app.create_icon_texture(APPLICATION_ICON_SIZE); - this.addActor(icon); + this._iconBin = new St.Bin(); + this.addActor(this._iconBin); let appLabel = new St.Label({ text: app.get_name() }); this.addActor(appLabel, { span: -1, expand: true }); this.actor.label_actor = appLabel; + + let textureCache = St.TextureCache.get_default(); + let iconThemeChangedId = textureCache.connect('icon-theme-changed', + Lang.bind(this, this._updateIcon)); + this.actor.connect('destroy', Lang.bind(this, + function() { + textureCache.disconnect(iconThemeChangedId); + })); + this._updateIcon(); }, activate: function(event) { @@ -78,6 +87,10 @@ const ApplicationMenuItem = new Lang.Class({ _getPreferredWidth: function(actor, forHeight, alloc) { alloc.min_size = alloc.natural_size = -1; + }, + + _updateIcon: function() { + this._iconBin.set_child(this._app.create_icon_texture(APPLICATION_ICON_SIZE)); } });