background: Simplify animation code
https://bugzilla.gnome.org/show_bug.cgi?id=719803
This commit is contained in:
parent
adb49bdf0b
commit
887590730d
@ -409,27 +409,26 @@ const Background = new Lang.Class({
|
|||||||
this._fileWatches[filename] = signalId;
|
this._fileWatches[filename] = signalId;
|
||||||
},
|
},
|
||||||
|
|
||||||
_addImage: function(content, index, filename) {
|
_ensureImage: function(index) {
|
||||||
content.brightness = this._brightness;
|
if (this._images[index])
|
||||||
content.vignette_sharpness = this._vignetteSharpness;
|
return;
|
||||||
|
|
||||||
let actor = new Meta.BackgroundActor();
|
let actor = new Meta.BackgroundActor();
|
||||||
actor.content = content;
|
|
||||||
|
|
||||||
// The background pattern is the first actor in
|
// The background pattern is the first actor in
|
||||||
// the group, and all images should be above that.
|
// the group, and all images should be above that.
|
||||||
this.actor.insert_child_at_index(actor, index + 1);
|
this.actor.insert_child_at_index(actor, index + 1);
|
||||||
|
|
||||||
this._images[index] = actor;
|
this._images[index] = actor;
|
||||||
this._watchCacheFile(filename);
|
|
||||||
},
|
},
|
||||||
|
|
||||||
_updateImage: function(content, index, filename) {
|
_updateImage: function(index, content, filename) {
|
||||||
content.brightness = this._brightness;
|
content.brightness = this._brightness;
|
||||||
content.vignette_sharpness = this._vignetteSharpness;
|
content.vignette_sharpness = this._vignetteSharpness;
|
||||||
|
|
||||||
this._cache.removeImageContent(this._images[index].content);
|
let image = this._images[index];
|
||||||
this._images[index].content = content;
|
if (image.content)
|
||||||
|
this._cache.removeImageContent(content);
|
||||||
|
image.content = content;
|
||||||
this._watchCacheFile(filename);
|
this._watchCacheFile(filename);
|
||||||
},
|
},
|
||||||
|
|
||||||
@ -477,11 +476,8 @@ const Background = new Lang.Class({
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!this._images[i]) {
|
this._ensureImage(i);
|
||||||
this._addImage(content, i, files[i]);
|
this._updateImage(i, content, files[i]);
|
||||||
} else {
|
|
||||||
this._updateImage(content, i, files[i]);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (numPendingImages == 0) {
|
if (numPendingImages == 0) {
|
||||||
this._setLoaded();
|
this._setLoaded();
|
||||||
@ -543,8 +539,10 @@ const Background = new Lang.Class({
|
|||||||
filename: filename,
|
filename: filename,
|
||||||
cancellable: this._cancellable,
|
cancellable: this._cancellable,
|
||||||
onFinished: Lang.bind(this, function(content) {
|
onFinished: Lang.bind(this, function(content) {
|
||||||
if (content)
|
if (content) {
|
||||||
this._addImage(content, 0, filename);
|
this._ensureImage(0);
|
||||||
|
this._updateImage(0, content, filename);
|
||||||
|
}
|
||||||
this._setLoaded();
|
this._setLoaded();
|
||||||
})
|
})
|
||||||
});
|
});
|
||||||
|
Loading…
Reference in New Issue
Block a user