background: Inherit Animation from GnomeDesktop.BGSlideShow

Animation background is just wrapping a native GnomeDesktop BGSlideShow
object, so instead of using composition we can now just inherit from the
native GObject, re-using native properties when possible, and avoiding
to keep an extra wrapper to the bg file.

https://gitlab.gnome.org/GNOME/gnome-shell/merge_requests/563
This commit is contained in:
Marco Trevisan (Treviño) 2019-05-29 01:21:51 +02:00 committed by Florian Müllner
parent 5944a1e74b
commit 348e4ac901

View File

@ -625,11 +625,11 @@ var BackgroundSource = class BackgroundSource {
} }
}; };
var Animation = class Animation { var Animation = GObject.registerClass(
constructor(params) { class Animation extends GnomeDesktop.BGSlideShow {
params = Params.parse(params, { file: null }); _init(params) {
super._init(params);
this.file = params.file;
this.keyFrameFiles = []; this.keyFrameFiles = [];
this.transitionProgress = 0.0; this.transitionProgress = 0.0;
this.transitionDuration = 0.0; this.transitionDuration = 0.0;
@ -637,9 +637,7 @@ var Animation = class Animation {
} }
load(callback) { load(callback) {
this._show = new GnomeDesktop.BGSlideShow({ file: this.file }); this.load_async(null, () => {
this._show.load_async(null, () => {
this.loaded = true; this.loaded = true;
if (callback) if (callback)
callback(); callback();
@ -649,13 +647,11 @@ var Animation = class Animation {
update(monitor) { update(monitor) {
this.keyFrameFiles = []; this.keyFrameFiles = [];
if (!this._show) if (this.get_num_slides() < 1)
return; return;
if (this._show.get_num_slides() < 1) let [progress, duration, isFixed_, filename1, filename2] =
return; this.get_current_slide(monitor.width, monitor.height);
let [progress, duration, isFixed_, filename1, filename2] = this._show.get_current_slide(monitor.width, monitor.height);
this.transitionDuration = duration; this.transitionDuration = duration;
this.transitionProgress = progress; this.transitionProgress = progress;
@ -666,8 +662,7 @@ var Animation = class Animation {
if (filename2) if (filename2)
this.keyFrameFiles.push(Gio.File.new_for_path(filename2)); this.keyFrameFiles.push(Gio.File.new_for_path(filename2));
} }
}; });
Signals.addSignalMethods(Animation.prototype);
var BackgroundManager = class BackgroundManager { var BackgroundManager = class BackgroundManager {
constructor(params) { constructor(params) {