diff --git a/blur.js b/blur.js index 95c7b77..b6111bf 100644 --- a/blur.js +++ b/blur.js @@ -20,6 +20,7 @@ var shellVersionMajor = parseInt(Config.PACKAGE_VERSION.split('.')[0]); var shellVersionMinor = parseInt(Config.PACKAGE_VERSION.split('.')[1]); var shellVersionPoint = parseInt(Config.PACKAGE_VERSION.split('.')[2]); +var blurField = shellVersionMajor >= 46 ? "radius" : "sigma"; // default BWP mild blur var BWP_BLUR_SIGMA = 2; var BWP_BLUR_BRIGHTNESS = 55; @@ -50,7 +51,7 @@ export function _updateBackgroundEffects_BWP(monitorIndex) { if (effect) { effect.set({ // GNOME defaults when login prompt is visible brightness: BLUR_BRIGHTNESS, - sigma: BLUR_SIGMA * themeContext.scale_factor, + [blurField]: BLUR_SIGMA * themeContext.scale_factor, }); } } @@ -59,7 +60,7 @@ export function _updateBackgroundEffects_BWP(monitorIndex) { if (effect) { effect.set({ // adjustable blur when clock is visible brightness: BWP_BLUR_BRIGHTNESS * 0.01, // we use 0-100 rather than 0-1, so divide by 100 - sigma: BWP_BLUR_SIGMA * themeContext.scale_factor, + [blurField]: BWP_BLUR_SIGMA * themeContext.scale_factor, }); } } @@ -91,7 +92,7 @@ export function _clampValue(value) { export default class Blur { constructor() { this.enabled = false; - log('Bing Wallpaper adjustable blur is '+supportedVersion()?'available':'not available'); + log('Bing Wallpaper adjustable blur is '+(supportedVersion()?'available':'not available')); } set_blur_strength(value) { diff --git a/extension.js b/extension.js index 493e2c8..8cffec1 100644 --- a/extension.js +++ b/extension.js @@ -220,15 +220,21 @@ class BingWallpaperIndicator extends Button { // listen for configuration changes _setConnections() { - this._settings.connect('changed::hide', () => { - this.visible = !this._settings.get_boolean('hide'); - }); + this.settings_connections = []; + + this.settings_connections.push( + this._settings.connect('changed::hide', () => { + this.visible = !this._settings.get_boolean('hide'); + }) + ); let settingConnections = [ {signal: 'changed::icon-name', call: this._setIcon}, {signal: 'changed::market', call: this._refresh}, {signal: 'changed::set-background', call: this._setBackground}, {signal: 'changed::override-lockscreen-blur', call: this._setBlur}, + {signal: 'changed::lockscreen-blur-strength', call: this._setBlur}, + {signal: 'changed::lockscreen-blur-brightness', call: this._setBlur}, {signal: 'changed::selected-image', call: this._setImage}, {signal: 'changed::delete-previous', call: this._cleanUpImages}, {signal: 'changed::notify', call: this._notifyCurrentImage}, @@ -244,11 +250,10 @@ class BingWallpaperIndicator extends Button { // _setShuffleToggleState settingConnections.forEach((e) => { - this._settings.connect(e.signal, e.call.bind(this)); + this.settings_connections.push( + this._settings.connect(e.signal, e.call.bind(this)) + ); }); - - this._settings.connect('changed::lockscreen-blur-strength', blur.set_blur_strength.bind(this, this._settings.get_int('lockscreen-blur-strength'))); - this._settings.connect('changed::lockscreen-blur-brightness', blur.set_blur_brightness.bind(this, this._settings.get_int('lockscreen-blur-brightness'))); // ensure we're in a sensible initial state this._setIcon(); @@ -282,10 +287,12 @@ class BingWallpaperIndicator extends Button { /*{key: 'random-mode-include-only-unhidden', toggle: this.toggleShuffleOnlyUnhidden},*/ {key: 'random-mode-include-only-uhd', toggle: this.toggleShuffleOnlyUHD}]; - toggles.forEach( (e) => { - this._settings.connect('changed::'+e.key, () => { - e.toggle.setToggleState(this._settings.get_boolean(e.key)); - }); + toggles.forEach( (e) => { + this.settings_connections.push( + this._settings.connect('changed::'+e.key, () => { + e.toggle.setToggleState(this._settings.get_boolean(e.key)); + }) + ); e.toggle.connect('toggled', (item, state) => { this._settings.set_boolean(e.key, state); }); @@ -302,6 +309,16 @@ class BingWallpaperIndicator extends Button { } } + _onDestroy() { + this._unsetConnections(); + } + + _unsetConnections() { + this.settings_connections.forEach((e) => { + this._settings.disconnect(e); + }); + } + _openPrefs() { this._extension.openPreferences(); }