settings_updater.js 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. import { Settings } from './settings.js';
  2. import { KEYS, DEPRECATED_KEYS } from './keys.js';
  3. const CURRENT_SETTINGS_VERSION = 2;
  4. export function update_from_old_settings(gsettings) {
  5. const preferences = new Settings(KEYS, gsettings);
  6. const deprecated_preferences = new Settings(DEPRECATED_KEYS, gsettings);
  7. const old_version = preferences.settings.get_int('settings-version');
  8. if (old_version < CURRENT_SETTINGS_VERSION) {
  9. // set artifacts hacks to be 1 at most, as it should be suitable now that most big bugs have
  10. // been resolved (and especially because hack levels to 2 now means disabling clipped
  11. // redraws entirely, which is very much not what we want for users that update)
  12. if (preferences.HACKS_LEVEL > 1)
  13. preferences.HACKS_LEVEL = 1;
  14. // enable dash-to-dock blurring, as most disabled it due to the lack of rounded corners; set
  15. // it to static blur by default too and with transparent background
  16. preferences.dash_to_dock.BLUR = true;
  17. preferences.dash_to_dock.STATIC_BLUR = true;
  18. preferences.dash_to_dock.STYLE_DASH_TO_DOCK = 0;
  19. // 'customize' has been removed: we merge the current used settings
  20. ['appfolder', 'panel', 'dash_to_dock', 'applications', 'window_list'].forEach(
  21. component_name => {
  22. const deprecated_component = deprecated_preferences[component_name];
  23. const new_component = preferences[component_name];
  24. if (!deprecated_component.CUSTOMIZE) {
  25. new_component.SIGMA = deprecated_preferences.SIGMA;
  26. new_component.BRIGHTNESS = deprecated_preferences.BRIGHTNESS;
  27. }
  28. });
  29. // remove old preferences in order not to clutter the gsettings
  30. deprecated_preferences.reset();
  31. }
  32. preferences.settings.set_int('settings-version', CURRENT_SETTINGS_VERSION);
  33. }