From 9d5be1660d8f74038ebed3d74fdbc809e43787ae Mon Sep 17 00:00:00 2001 From: Nippy Date: Fri, 9 Oct 2026 17:23:53 +0200 Subject: gnome fix --- .../blur-my-shell@aunetx/conveniences/settings.js | 180 ++------------------- 1 file changed, 15 insertions(+), 165 deletions(-) (limited to 'raveos-gnome-theme/theme-data/extensions/installed/blur-my-shell@aunetx/conveniences/settings.js') diff --git a/raveos-gnome-theme/theme-data/extensions/installed/blur-my-shell@aunetx/conveniences/settings.js b/raveos-gnome-theme/theme-data/extensions/installed/blur-my-shell@aunetx/conveniences/settings.js index 53f8497..337c8c2 100644 --- a/raveos-gnome-theme/theme-data/extensions/installed/blur-my-shell@aunetx/conveniences/settings.js +++ b/raveos-gnome-theme/theme-data/extensions/installed/blur-my-shell@aunetx/conveniences/settings.js @@ -1,4 +1,5 @@ import GLib from 'gi://GLib'; +import { pack_pipelines, unpack_pipelines } from './pipeline_settings.js'; const Signals = imports.signals; /// An enum non-extensively describing the type of gsettings key. @@ -122,171 +123,20 @@ export const Settings = class Settings { case Type.PIPELINES: Object.defineProperty(component, property_name, { get() { - let pips = component_settings.get_value(key.name).deep_unpack(); - Object.keys(pips).forEach(pipeline_id => { - let pipeline = pips[pipeline_id]; - - if (!('name' in pipeline)) { - this._warn('impossible to get pipelines, pipeline has not name, resetting'); - component[property_name + '_reset'](); - return component[property_name]; - } - let name = pipeline.name.deep_unpack(); - if (typeof name !== 'string') { - this._warn('impossible to get pipelines, pipeline name is not a string, resetting'); - component[property_name + '_reset'](); - return component[property_name]; - } - - if (!('effects' in pipeline)) { - this._warn('impossible to get pipelines, pipeline has not effects, resetting'); - component[property_name + '_reset'](); - return component[property_name]; - } - let effects = pipeline.effects.deep_unpack(); - if (!Array.isArray(effects)) { - this._warn('impossible to get pipelines, pipeline effects is not an array, resetting'); - component[property_name + '_reset'](); - return component[property_name]; - } - - effects = effects.map(effect => effect.deep_unpack()); - effects.forEach(effect => { - if (!('type' in effect)) { - this._warn('impossible to get pipelines, effect has not type, resetting'); - component[property_name + '_reset'](); - return component[property_name]; - } - let type = effect.type.deep_unpack(); - if (typeof type !== 'string') { - this._warn('impossible to get pipelines, effect type is not a string, resetting'); - component[property_name + '_reset'](); - return component[property_name]; - } - - if (!('id' in effect)) { - this._warn('impossible to get pipelines, effect has not id, resetting'); - component[property_name + '_reset'](); - return component[property_name]; - } - let id = effect.id.deep_unpack(); - if (typeof id !== 'string') { - this._warn('impossible to get pipelines, effect id is not a string, resetting'); - component[property_name + '_reset'](); - return component[property_name]; - } - - let params = {}; - if ('params' in effect) - params = effect.params.deep_unpack(); - if (!(params && typeof params === 'object' && params.constructor === Object)) { - this._warn('impossible to get pipelines, effect params is not an object, resetting'); - component[property_name + '_reset'](); - return component[property_name]; - } - Object.keys(params).forEach(param_key => { - params[param_key] = params[param_key].deep_unpack(); - }); - - effect.type = type; - effect.id = id; - effect.params = params; - }); - pipeline.name = name; - pipeline.effects = effects; - }); - return pips; + try { + return unpack_pipelines(component_settings.get_value(key.name)); + } catch (error) { + this._warn(`impossible to get pipelines, resetting: ${error.message}`); + component_settings.reset(key.name); + return unpack_pipelines(component_settings.get_value(key.name)); + } }, - set(pips) { - let pipelines = {}; - Object.keys(pips).forEach(pipeline_id => { - let pipeline = pips[pipeline_id]; - if (!(pipeline && typeof pipeline === 'object' && pipeline.constructor === Object)) { - this._warn('impossible to set pipelines, pipeline is not an object'); - return; - } - - if (!('name' in pipeline)) { - this._warn('impossible to set pipelines, pipeline has no name'); - return; - } - if (typeof pipeline.name !== 'string') { - this._warn('impossible to set pipelines, pipeline name is not a string'); - return; - } - - if (!('effects' in pipeline)) { - this._warn('impossible to set pipelines, pipeline has no effect'); - return; - } - if (!Array.isArray(pipeline.effects)) { - this._warn('impossible to set pipelines, effects is not an array'); - return; - } - - let gvariant_effects = []; - pipeline.effects.forEach(effect => { - if (!(effect instanceof Object)) { - this._warn('impossible to set pipelines, effect is not an object'); - return; - } - - if (!('type' in effect)) { - this._warn('impossible to set pipelines, effect has not type'); - return; - } - if (typeof effect.type !== 'string') { - this._warn('impossible to set pipelines, effect type is not a string'); - return; - } - - if (!('id' in effect)) { - this._warn('impossible to set pipelines, effect has not id'); - return; - } - if (typeof effect.id !== 'string') { - this._warn('impossible to set pipelines, effect id is not a string'); - return; - } - - let params = {}; - if ('params' in effect) { - params = effect.params; - } - let gvariant_params = {}; - Object.keys(params).forEach(param_key => { - let param = params[param_key]; - if (typeof param === 'boolean') - gvariant_params[param_key] = GLib.Variant.new_boolean(param); - else if (typeof param === 'number') { - if (Number.isInteger(param)) - gvariant_params[param_key] = GLib.Variant.new_int32(param); - else - gvariant_params[param_key] = GLib.Variant.new_double(param); - } else if (typeof param === 'string') - gvariant_params[param_key] = GLib.Variant.new_string(param); - else if (Array.isArray(param) && param.length == 4) - gvariant_params[param_key] = new GLib.Variant("(dddd)", param); - else - this._warn('impossible to set pipeline, effect parameter type is unknown'); - }); - - gvariant_effects.push( - new GLib.Variant("a{sv}", { - type: GLib.Variant.new_string(effect.type), - id: GLib.Variant.new_string(effect.id), - params: new GLib.Variant("a{sv}", gvariant_params) - }) - ); - }); - - pipelines[pipeline_id] = { - name: GLib.Variant.new_string(pipeline.name), - effects: new GLib.Variant("av", gvariant_effects) - }; - }); - let val = new GLib.Variant("a{sa{sv}}", pipelines); - component_settings.set_value(key.name, val); + set(pipelines) { + try { + component_settings.set_value(key.name, pack_pipelines(pipelines)); + } catch (error) { + this._warn(`impossible to set pipelines: ${error.message}`); + } } }); break; @@ -360,4 +210,4 @@ export const Settings = class Settings { } }; -Signals.addSignalMethods(Settings.prototype); \ No newline at end of file +Signals.addSignalMethods(Settings.prototype); -- cgit v1.3