From 8a4b245812a37e8d82c39ef92cfa839c67665080 Mon Sep 17 00:00:00 2001 From: Christian Kellner Date: Wed, 26 Apr 2017 23:48:16 +0200 Subject: [PATCH] places-menu: make the icon query asynchronous Don't use the sync version of g_file_query_info because that might potentially block (especially when the connection is slow or drops). https://bugzilla.gnome.org/show_bug.cgi?id=781765 --- extensions/places-menu/placeDisplay.js | 41 +++++++++++++++----------- 1 file changed, 24 insertions(+), 17 deletions(-) diff --git a/extensions/places-menu/placeDisplay.js b/extensions/places-menu/placeDisplay.js index a9682c4c..37d59657 100644 --- a/extensions/places-menu/placeDisplay.js +++ b/extensions/places-menu/placeDisplay.js @@ -61,24 +61,31 @@ const PlaceInfo = new Lang.Class({ }, getIcon: function() { - try { - let info = this.file.query_info('standard::symbolic-icon', 0, null); - return info.get_symbolic_icon(); - } catch(e if e instanceof Gio.IOErrorEnum) { - // return a generic icon for this kind - switch (this.kind) { - case 'network': + this.file.query_info_async('standard::symbolic-icon', 0, 0, null, + Lang.bind(this, function(file, result) { + try { + let info = file.query_info_finish(result); + this.icon = info.get_symbolic_icon(); + this.emit('changed'); + } catch(e if e instanceof Gio.IOErrorEnum) { + return; + } + })); + + // return a generic icon for this kind for now, until we have the + // icon from the query info above + switch (this.kind) { + case 'network': + return new Gio.ThemedIcon({ name: 'folder-remote-symbolic' }); + case 'devices': + return new Gio.ThemedIcon({ name: 'drive-harddisk-symbolic' }); + case 'special': + case 'bookmarks': + default: + if (!this.file.is_native()) return new Gio.ThemedIcon({ name: 'folder-remote-symbolic' }); - case 'devices': - return new Gio.ThemedIcon({ name: 'drive-harddisk-symbolic' }); - case 'special': - case 'bookmarks': - default: - if (!this.file.is_native()) - return new Gio.ThemedIcon({ name: 'folder-remote-symbolic' }); - else - return new Gio.ThemedIcon({ name: 'folder-symbolic' }); - } + else + return new Gio.ThemedIcon({ name: 'folder-symbolic' }); } },