Bug 588050 - Cache information icon forever, only look up recent once

Extend ShellTextureCache by adding the concept of a policy, which
we expose to the public API for loading URIs.

This lets us have the shell tell the cache to keep the information
icon texture around forever.

Secondly, fix the caching of recent info; we shouldn't always be
loading the backup pixbuf.  Move recent info loading entirely
into ShellTextureCache.
This commit is contained in:
Colin Walters
2009-07-16 17:44:50 -04:00
parent 2c5d520395
commit 8d9fc28872
5 changed files with 271 additions and 61 deletions

View File

@ -24,19 +24,7 @@ DocInfo.prototype = {
},
createIcon : function(size) {
let icon = null;
let defaultPixbuf = this._recentInfo.get_icon(size);
if (this.uri.match("^file://")) {
icon = Shell.TextureCache.get_default().load_thumbnail(size, this.uri, this.mimeType,
defaultPixbuf);
}
if (!icon) {
icon = new Clutter.Texture({});
Shell.clutter_texture_set_from_pixbuf(icon, defaultPixbuf);
}
return icon;
return Shell.TextureCache.get_default().load_recent_thumbnail(size, this._recentInfo);
},
launch : function() {
@ -137,13 +125,13 @@ DocManager.prototype = {
let deleted = {};
for (var uri in this._items) {
if (!(uri in newItems))
deleted[uri] = 1;
deleted[uri] = this._items[uri];
}
/* If we'd cached any thumbnail references that no longer exist,
dump them here */
let texCache = Shell.TextureCache.get_default();
for (var uri in deleted) {
texCache.unref_thumbnail(this._iconSize, uri);
texCache.evict_recent_thumbnail(this._iconSize, this._items[uri]);
}
this._items = newItems;
},

View File

@ -58,7 +58,8 @@ DocDisplayItem.prototype = {
if (this._docInfo.mimeType == null || this._docInfo.mimeType.indexOf("image/") != 0)
return null;
return Shell.TextureCache.get_default().load_uri_sync(this._docInfo.uri, availableWidth, availableHeight);
return Shell.TextureCache.get_default().load_uri_sync(Shell.TextureCachePolicy.NONE,
this._docInfo.uri, availableWidth, availableHeight);
}
};

View File

@ -85,7 +85,8 @@ GenericDisplayItem.prototype = {
let global = Shell.Global.get();
let infoIconUri = "file://" + global.imagedir + "info.svg";
let infoIcon = Shell.TextureCache.get_default().load_uri_sync(infoIconUri,
let infoIcon = Shell.TextureCache.get_default().load_uri_sync(Shell.TextureCachePolicy.FOREVER,
infoIconUri,
INFORMATION_BUTTON_SIZE,
INFORMATION_BUTTON_SIZE);
this._informationButton = new Button.iconButton(this.actor, INFORMATION_BUTTON_SIZE, infoIcon);