[gnome-maps/wip/contacts: 9/17] utils: Handle all loadable icons
- From: Jonas Danielsson <jonasdn src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-maps/wip/contacts: 9/17] utils: Handle all loadable icons
- Date: Tue, 16 Dec 2014 09:52:56 +0000 (UTC)
commit c66c4b5b78ccc9ee00881ff459c408408a7a39bc
Author: Jonas Danielsson <jonas threetimestwo org>
Date: Tue Dec 16 03:33:27 2014 -0500
utils: Handle all loadable icons
src/utils.js | 26 ++++++++++----------------
1 files changed, 10 insertions(+), 16 deletions(-)
---
diff --git a/src/utils.js b/src/utils.js
index 79c857f..8f7ab11 100644
--- a/src/utils.js
+++ b/src/utils.js
@@ -261,37 +261,31 @@ function getAccuracyDescription(accuracy) {
}
function load_icon(icon, size, loadCompleteCallback) {
- if (icon instanceof Gio.FileIcon) {
- _load_file_icon(icon, loadCompleteCallback);
+ if (icon instanceof Gio.FileIcon || icon instanceof Gio.BytesIcon) {
+ _load_icon(icon, loadCompleteCallback);
} else if (icon instanceof Gio.ThemedIcon) {
_load_themed_icon(icon, size, loadCompleteCallback);
}
}
-function _load_file_icon(icon, loadCompleteCallback) {
- let pixbuf = _iconStore[icon.file.get_uri()];
+function _load_icon(icon, loadCompleteCallback) {
- if (pixbuf) { // check if the icon is cached
- loadCompleteCallback(pixbuf);
- return;
- }
-
- if (icon.file.has_uri_scheme ("http") || icon.file.has_uri_scheme ("https")) {
- _load_http_icon(icon, loadCompleteCallback);
- return;
+ if (icon.file) {
+ if (icon.file.has_uri_scheme ("http") || icon.file.has_uri_scheme ("https")) {
+ _load_http_icon(icon, loadCompleteCallback);
+ return;
+ }
}
icon.load_async(-1, null, function(icon, res) {
try {
let stream = icon.load_finish(res, null)[0];
+ let pixbuf = GdkPixbuf.Pixbuf.new_from_stream(stream, null);
- pixbuf =
- GdkPixbuf.Pixbuf.new_from_stream(stream, null);
-
- _iconStore[icon.file.get_uri()] = pixbuf;
loadCompleteCallback(pixbuf);
} catch(e) {
log("Failed to load pixbuf: " + e);
+ loadCompleteCallback(null);
}
});
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]