[gnome-shell-extensions] places-menu: make the icon query asynchronous
- From: Christian Kellner <gicmo src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-shell-extensions] places-menu: make the icon query asynchronous
- Date: Thu, 27 Apr 2017 12:27:06 +0000 (UTC)
commit 8a4b245812a37e8d82c39ef92cfa839c67665080
Author: Christian Kellner <christian kellner me>
Date: Wed Apr 26 23:48:16 2017 +0200
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 files changed, 24 insertions(+), 17 deletions(-)
---
diff --git a/extensions/places-menu/placeDisplay.js b/extensions/places-menu/placeDisplay.js
index a9682c4..37d5965 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' });
}
},
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]