js: Use gjs-defined GObject accessors where possible

Nowadays gjs allows to omit get/set accessors for read-write properties,
and will define reasonable defaults in that case. In many cases we don't
need anything more than the default handling, let gjs handle those props.

Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/1611>
This commit is contained in:
Florian Müllner
2021-01-30 01:03:04 +01:00
parent a41e294e21
commit 0f1b566918
5 changed files with 68 additions and 371 deletions

View File

@ -35,16 +35,13 @@ var RadialShaderEffect = GObject.registerClass({
},
}, class RadialShaderEffect extends Shell.GLSLEffect {
_init(params) {
this._brightness = undefined;
this._sharpness = undefined;
super._init(params);
this._brightnessLocation = this.get_uniform_location('brightness');
this._sharpnessLocation = this.get_uniform_location('vignette_sharpness');
this.brightness = 1.0;
this.sharpness = 0.0;
this._setBrightnessUniform();
this._setSharpnessUniform();
}
vfunc_build_pipeline() {
@ -52,30 +49,14 @@ var RadialShaderEffect = GObject.registerClass({
VIGNETTE_DECLARATIONS, VIGNETTE_CODE, true);
}
get brightness() {
return this._brightness;
}
set brightness(v) {
if (this._brightness == v)
return;
this._brightness = v;
_setBrightnessUniform() {
this.set_uniform_float(this._brightnessLocation,
1, [this._brightness]);
this.notify('brightness');
1, [this.brightness]);
}
get sharpness() {
return this._sharpness;
}
set sharpness(v) {
if (this._sharpness == v)
return;
this._sharpness = v;
_setSharpnessUniform() {
this.set_uniform_float(this._sharpnessLocation,
1, [this._sharpness]);
this.notify('sharpness');
1, [this.sharpness]);
}
});